• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

What is the best substitute for paths?

RedP

Member
Hi, I'm doing Tower Defense, and I've been using paths until now because they are easy to configure, but I wanted enemies on the path to have unique speeds, and could be thrown out of the path, so I want to use hspd and vspd, and I haven't found a way to do this with paths. So I'm wondering what is the best way to program these routes that enemies take without paths, any ideas?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Keep using paths to plan the route(s) but move the enemy yourself. You can find the next path point to go to (check the path functions in the manual), then use the other movement functions to move to it, so you can set your own speed and type of movement. Essentially:

  • ON create get the next path point to go to and store the X/Y in variables, and set a "point counter" variable to 1, since your instance will be moving to point 1 on the path
  • Move the instance using any method you want, and check the distance to the next path point (point 2)
  • When the instance is close to the next path point (2), get the point x/y and set the move to variables to that and set the pointer counter to the next point (3)
  • Rinse and repeat...

Obviously, you'll need to add in checking for when the path ends, but that's easy enough to do by comparing the path point counter variable with the number of points on the path. :)
 

3dgeminis

Member
You can use other objects to change the direction, one that represents up, down, right, and left.
When an enemy collides with these objects, the enemy object changes direction according to the object with which it collides.
Of course this would be useful if the roads are straight.
 
Top