Overriding RotateTowards() stops movement in aiPath

Hi

I’m trying to override the RotateTowards function in aiPath with a simple look at when the target is close. While it does cause the transform to look at the player it also stops the transform from moving completely (I’m using a rigidbody). I’ve read a post by Aron that this should be enough: Strafing (move without facing target) but unfortunately it isn’t and I’m a little stuck. I did mess with CalculateVelocity a bit and got the transform moving again but in all sorts of skeewompus directions.

Does anyone have any sample scripts where they’ve actually gotten a transform to move along a path without looking forward?

Thanks

Hi

There is one line in the AIPath script which looks something like

float dot = Vector3.Dot (dir.normalized,forward);

This will slow down movement when the character is not facing the direction it is moving in. You probably want to set that ‘dot’ variable to 1 to prevent this behaviour.

Awesome - thanks Aron. I also had to change the return for CalculateVelocity from: return forwardsp; to return dirsp; otherwise the transform just charged forward.

1 Like