Tower Defense Example

47
48
0
1

How it works

The "Path Tracer" object is spawned in by the "Enemy Spawner" object. This is because the "Path Tracer" object will follow the exact path, mapping which direction it goes. It is done like this so that none of the Enemy objects need to have Ray Casts, improving performance.

After the path is mapped out by the "Path Tracer", the Enemy objects can now follow the path via a List without the need for Ray Casts.


Objects to Copy:

Copy the code inside the "Path Tracer" object. Make sure the sprite for the "Path Tracer" is the same size as the "Path" to avoid any possible errors. Make sure to input the size of the path (in pixels)

Copy the code inside the "Enemy Slow" (or "Enemy Fast") object. This is needed because the movement code is custom to work with the map that is created from the "Path Tracer" object.


Other Features

By press 1 or 2 you can alternate between which movement for the enemy you would like to use. 1 is tile based, meaning that the enemy pauses after each space. 2 is not tile based, meaning it is a smooth transition between all paths.

2 Enemy types. This is to show you that with the same code you can vary speed however you want. Simply change the Ease for the X, Y and it will work.


Notes

The "Path" cannot ever touch more than 2 other "Path" objects.

Editor