Issuing a command to an object

Discussion in 'Programming' started by gadgetkk, Jan 15, 2020 at 3:35 AM.

  1. gadgetkk

    gadgetkk Member

    Joined:
    Wednesday
    Posts:
    1
    Hi everyone,

    I have tried searching for this information here and using the google, but have not been able to find an answer/help.

    I would like to get some direction on how to code giving 'units' commands in the game.

    For example:
    - select a unit and tell it to move to clicked location.
    - select a unit to assign a structure to it (think assigning grunts to build or mine something).

    Any tips on how to get started are appreciated.
     
  2. CloseRange

    CloseRange Member

    Joined:
    Jul 2, 2016
    Posts:
    987
    Sounds like you are looking to make a rts game... You should google "how to make an rts game in game maker"
    But in short any command you want has to be hand coded.
    Want to make all selected units move to where the mouse was clicked?
    Code:
    with(obj_unit) {
         if(selected) {
              moving = true;
              target_x = mouse_x;
              target_y = mouse_y;
         }
    }
    then in the step event if they should be moving, then have them move to target_x/y

    there is no generic way to just say "do x command" at least not in game maker. You still have to make all the logic yourself,
    I won't go into anymore detail as that's why Youtuber's make videos
     
  3. ctl-f

    ctl-f Member

    Joined:
    Jan 2, 2020
    Posts:
    2
    Well it would be a lot easier to help you if you gave some more details, for example, what kind of game are you trying to make? Is it grid based or full-directional movement, etc.
    One thing to keep in mind is that for any given problem there can be many different solutions each one having its pros and cons. I'd be willing to help you and I'm sure that others would
    be willing as well but we simply need more information that this.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice