开发者

Finding the angle of a fleeing dodo

开发者 https://www.devze.com 2022-12-22 03:20 出处:网络
I want my critter AI to run directly away from the player when the player kicks it, and I don\'t know the math nor the syntax to calculate that angle. They are two characters moving independently thro

I want my critter AI to run directly away from the player when the player kicks it, and I don't know the math nor the syntax to calculate that angle. They are two characters moving independently through worldspace.

Here is what I got so far:

waypoint = (fleeWP.transform.position);

transform.LookAt(Vector3(waypoint.x, transform.position.y, waypoint.z));      
transform.Translate (Vector3.forward * speed * Time.deltaTime);

This currently makes the critter move towards the waypoint, rather than away. I might be开发者_StackOverflow中文版 attacking this all wrong. Please chastise me.


Just invert the translation:

transform.Translate (Vector3.forward * speed * Time.deltaTime * -1);
0

精彩评论

暂无评论...
验证码 换一张
取 消