Check if Character Controller is moving forward

I’ve got a simple character and it has to move with a Character Controller, but I’m trying to set the animations based on the direction it is moving.

I have a blend tree for going from idel to walk with a simple script:

horizontalVelocity = new Vector3(characterController.velocity.x, 0, characterController.velocity.z);

float horizontalSpeed = horizontalVelocity.magnitude;

if (horizontalSpeed > 0)
{
   animator.SetFloat("IdleWalk", horizontalSpeed);
}

So now I need to check which direction the player is moving, really I just need to know when the player is straffing, or moving backwards (or forwards)

Any tips?

Maybe use the input from the keyboard/controller?

if(Input.GetAxis("Forward"))
{
   // MoveCharacter() - This is your code that you pasted
   movingDirection = forward
}

Oh that might work. And its simple so I shouldn’t be able to mess it up haha. If I want to use it for strafing, how should I use the input? Should I do 2 separate lines of code, one for right and one for left, or is there a way I can I do right and -right?

Eh, it depends, can’t really tell if I don’t see your input code.

Just do 2 lines, for now, it’s fine.