Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

a sort of pathfinding script(More explanation inside)

I need a script that if u get a certain amount of squares close u can call an event and if you are within maybe the amount needed for the event for more than one it calls another event than the one that would be called if you were in  the range of one.
 
This needs no script. It can be done with events placed on the squares that they'd get the message. Just select "Below Player" and "Player Touch" in the event menu, and give it no graphic. Set your message, and you're done!

-Shadow Lord
 
That can be done with variables. Creat one that defines the player's X coordinates in the map, and another one that defines the player's Y coordinates in the map. After that, make an event that calls both those variables and then insert conditions that will tell you "If the player's coordinates are (X , Y) + 1 / - 1 / etc, call Event 001."

For example:

Imagine Event 001 is at (3,4) and Event 002 is at (6, 4).

@>Conditional Branch: Variable [0001: Player X] < = 4
    @>Conditional Branch: Variable [0002: Player Y] = = 3
          @>Set Move Route: Event 001 (Wait, Repeat)
          :                      : $> Move towards Player

          @>
      :  Else
          @>
      :  Branch End
    @>
:  Else
    @>Conditional Branch: Variable [0001: Player X] > = 5
          @>Conditional Branch: Variable [0002: Player Y] = = 3
              @>Set Move Route: Event 002 (Wait, Repeat)
                :                      : $> Move towards Player

              @>
                :  Else
              @>
                :  Branch End
              @>

Of course, you would have to do this for ALL the coordinates in the map, but, it wouldn't make the game laggy, neither would it make it all confusing. This was just an example, of course in every condition, you need to put the Event's Coordinates that are closer to your player. Meybe the best way to do it is aply a general condition for all the X, a Y condition that says: when Y = diferent from the value (so, you'd have to put an unexisting value in the map for the Y) and below it, all the coordinates for X. It's hard, and alot of trouble, but it would make everything more organized.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top