track to nearest property single and all axis
bge/upbge:
track_to_closest.blend (941.9 KB)
Interesting, almost ready for a tower defense game
Thanks for sharing
this does not work with goran’s gravity script.the center of gravity gets offs as a npc follows me.
No idea why you reply to @mataii but… This is also not related to my resource.
The script is simple enough, it tracks or rather points to… the closest object nothing more nothing less. the error is somewhere else.
maybe, i say maybe, the trackto brick is causing the issue (i bet not) but you can simply convert the brick into python code as well remove everything below line 20 and replace it with
own.alignAxisToVect(closest_ai.worldPosition.copy(), 1,1.0)
Where 1 = y axis ( 0 = x, 2 = z) the axis that points to the closest ai(object), and 0.00-1.0 is the turn speed
Also remove line 10 and the edit object (trackto) brick on the object (not needed anymore if you use the code above)
To let an npc follow the player, don’t use this script in full length, use the line above and give it a velocity on the y axis (so it tracks to and move to the player)
i tried to get it to work but it did not work.i did what you told me.i also tried other things but
that did not work either.