Hi
I have an issue trying to get my object to turn to the target and reach the target. The problem is, some times a target chosen is at such a position that my object just can't turn to reach it and thus keeps rotating endless orbiting around the object and i don't know how to correct for this.
Here is a visual of the issue:
hhttps://i.imgur.com/bFi9QNn.gif
Where i need it to do is some how figure out that it needs to slow down its forward velocity but turn at the same speed, but the turning is based on the change in velocity so i am confused how to fix it.
The rotation of the mesh visual just rotates to face the same direction as the velocity.
How can i improve on this steering behaviour so its more precise?
This is my current code:
_acceleration = _acceleration.normalized * MaxAcceleration; // constant acceleration
_velocity += _acceleration * Time.deltaTime;
// limit to max velocity
float speed = _velocity.magnitude;
Vector3 dir = _velocity / speed;
speed = Mathf.Clamp(speed, _minSpeed, _maxSpeed);
_velocity = dir * speed;
transform.position += _velocity * Time.deltaTime;
transform.forward = _velocity.normalized;