tatelax
1
Hello,
I am developing an AI system. Currently, I am doing this:
transform.position = Vector3.MoveTowards(transform.position, player.position, moveSpeed * Time.deltaTime);
Works great, until the player goes at a higher point then the enemy…
How can I make it so that the enemy does not fly upwards towards the player?
THANKS
flamy
2
If you take a look at this function you may get something to proceed further!?!?!
http://unity3d.com/support/documentation/ScriptReference/Terrain.SampleHeight.html
system
3
You could also use Mathf.Clamp or a static ‘1’ on the Y axis , in the above example,
var newPos = “move towards”.
newPos.y = 1;
transform.position = newPos;