tower defense targetting
Started by gamearium, Jun 27 2012 04:57 AM
9 replies to this topic
#1
Posted 27 June 2012 - 04:57 AM
how do i get my towers to target the enemy closest to the exit? please and thank you
#2
Posted 27 June 2012 - 05:03 AM
If following a path, I got the code in my tower defense tutorial. in my tools page
#3
Posted 27 June 2012 - 05:32 AM
its not a set path, its mp_grid and the path can change. i dont think i can use instance_furthest_along.
#4
Posted 27 June 2012 - 06:32 AM
can i get the tower to target the object with the least distance to the exit?
#5
Posted 27 June 2012 - 06:38 AM
its not a set path, its mp_grid and the path can change. i dont think i can use instance_furthest_along.
mp_grid returns a path, you did not use path_start with it?
You can mod instance_furthest_along to do a point_distance from x,y to exit.x and exit.y instead of looking at the path_position. But that is not truly if it's closest to be done as it may walk close to the exit while still be a long way from getting there. Like when you tile your turrets to make the kreepers zig zag like the original TD game
#6
Posted 27 June 2012 - 07:16 AM
yes, path_start, but when a new tower is laid a new path starts.
#7
Posted 27 June 2012 - 02:39 PM
do a path_get_length to get the pixel length after a new path
m_PLen = path_get_length(newpath);
now you can implement a path_point_distance like this
//123 - ((0->1) *123) = 123 - (0->123) = 123->0
return m_PLen -(path_position*m_PLen);
m_PLen = path_get_length(newpath);
now you can implement a path_point_distance like this
//123 - ((0->1) *123) = 123 - (0->123) = 123->0
return m_PLen -(path_position*m_PLen);
#8
Posted 27 June 2012 - 09:45 PM
or just do this
target = instance_furthest(exit.x,exit.y,enemy)
target = instance_furthest(exit.x,exit.y,enemy)
#9
Posted 29 June 2012 - 04:23 AM
i have been using path_get _length, but you lost me with that equation. is that to tell the tower to shoot at the shortest length?
#10
Posted 29 June 2012 - 04:28 AM
the length left.... the equation can be used as a replacement of the original path_position equation in my script.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











