2D top down, turn off rotation

When I try to set rotation speed to 0 or when I comment out:

var currentRotationSpeed = rotationSpeed * Mathf.Clamp01((Mathf.Sqrt(slowdown) - 0.3f) / 0.7f); RotateTowards(velocity2D, currentRotationSpeed * deltaTime);

The pathfinding just stops working, the character moves in some weird direction at the wrong speed. I need the same behaviour as when you freeze Z rotation on a rigidbody 2D, i.e it should NOT rotate.

Any idea how to fix this?

Hi

I think you should be able to set the rotation speed to zero and also disable the option ‘slow when not facing target’ to get the behavior you want.

Where can I find ‘slow when not facing target’ ? Not on AI Path or Seeker.

Ah. Right. It exists in the beta, however in the non beta version I think it might be hardcoded to true.

There is a line in the AIPath script that looks like

velocity2D = MovementUtilities.ClampVelocity(velocity2D, speed, slowdown, true, movementPlane.ToPlane(rotationIn2D ? tr.up : tr.forward));

change the ‘true’ parameter to ‘false’.

Perfect, thanks a bunch.
Something to consider for beta might be a simple checkbox called “Turn off rotation”, or something simple, so that this is a bit more clear :slight_smile: