Blend Tree animation problems at rotation

I have a Blend tree animation with two floats ( VelocityX, VelocityZ) that have idle, run , run right, run left ,
I use a pad to move it at world space

  • When VelocityX is -1 it run left, +1 it run right
  • When VelocityZ is -1 it run back, +1 it run foward

It is working fine but the problem comes when I rotate the character in his Y axis, If I rotate the character 90 degrees on the Y axis, This system ‘breaks’ since blend tree is calculating VelocityX and VelocityZ from world space and not local space, So character is doing ‘run foward’ animation to go top but hi should do ‘run right’ animation since from character prespective he is moving to the right

How I can implement that local rotation into my blend system?

Any help or guide will be apreciated

Set up all the velocity +1-1 running left right etc etc on an empty game object, parent the character to the empty game object, then the character can be rotated whatever degree you want, without worrying about messing up the turning ‘controller’.