Strafing (move without facing target)

Hey guys, this seems like a problem that would come up a lot but I couldn’t find any info on it.

I’ve set up a basic enemy in an FPS game with AIPath as the driving script. It works quite well, finds its way to the target etc. but I want to have it aim at the player while it follows its path.

In game terms, I want to allow the AI to move from cover to cover while shooting at the player.

By default the character must be facing in the direction it’s moving. I’m pretty sure this is a part of AIPath, but I’d prefer not to have to write my own pathing script. Is there a simple toggle or a separate script I’ve overlooked or would I have to write a new one from scratch?

Thanks.

You can modify the RotateTowards function in the AIPath script so instead of doing whatever it does there. Make it do something like
transform.LookAt (target.position);
or something more fancy if you want it to look better.

The best way to do this would be to create a new script which inherits from AIPath and then override the function.
public class MyAIPath : MonoBehaviour { protected override void RotateTowards (Vector3 dir) { transform.lookAt (target.position); } }