English 中文(简体)
Finding the angle of a fleeing dodo
原标题:

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 attacking this all wrong. Please chastise me.

问题回答

Just invert the translation:

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




相关问题
Finding the angle of a fleeing dodo

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 ...

XNA 2D vector angles - what s the correct way to calculate?

what is in XNA in 2D the standard way vector angles work ? 0 degrees points right, 90 points up, 180 left, 270 down ? What are the standard implementations of float VectortoAngle(Vector2 vec) ...

Flipping an angle using radians

Hello all you math whizzes out there! I am struggling with a math problem I am hoping you can help me with. I have calculated an angle of direction using radians. Within OpenGL ES I move my guy by ...

Finding Signed Angle Between Vectors

How would you find the signed angle theta from vector a to b? And yes, I know that theta = arccos((a.b)/(|a||b|)). However, this does not contain a sign (i.e. it doesn t distinguish between a ...

Get the slope from one point and an angle in degrees

In javascript, I am trying to draw a line that is at an angle that is user defined. Basically, I have a point (x,y) and an angle to create the next point at. The length of the line need to be 10px. ...

热门标签