Where should I insert code to get the RVO controller’s direction ?? I would like to write some code so my units always look in the direction there moving
I assume somewhere around here:
`…
rvoAgent.DesiredVelocity = desiredVelocity + force*wallAvoidForce;
tr.position = rvoAgent.InterpolatedPosition + Vector3.up*height*0.5f + center;
// Insert something like: Look at last position + 180º??
lastPosition = tr.position;
` public static void TurnAB(int UnitTurnSpeed, Transform Player ){
Vector3 velocity = Player.GetComponent().velocity;
if(velocity.magnitude < .01 ){//Low Pass Check: Is this low enough? Can I drop It a lot lower??
return;
}
Quaternion LookRotation = Quaternion.LookRotation(velocity);
Quaternion rotation = Quaternion.Slerp(Player.rotation, LookRotation , Time.deltaTime * UnitTurnSpeed);
Player.rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0);
}`
(For any other people out there trying to do the same thing) FYI:
Quaternion LookRotation is a little faster then LookAt due to not needing a comparison to transform.position~