Search Unity

Issue with blend and animation orientation on top view 3D shooter

Discussion in 'Animation' started by Aherys, Jun 5, 2019.

  1. Aherys

    Aherys

    Joined:
    Mar 12, 2018
    Posts:
    13
    Hello guys,

    Got an issue ! I use a blend tree, with 5 blend (iddle, run top, back, left and right).
    My charactere can move on X and Z axis and the modele is oriented by the mouse (like every classical 2D top view 3D shooter).

    The issue is easy, i use two paramaters for my blend tree, SpeedX and SpeedY (who is in reality "SpeedZ").
    But, i want SpeedX and SpeedY as a vector oriented by model of the charactere, so annimation depend of where the body face, and not the world coordinate.

    Actually i've got this :
    Code (CSharp):
    1.         Vector3 movementSpeedForAnimation = new Vector3(InputCatcher.AxisX, 0.0f, InputCatcher.AxisY);
    2.         //movementSpeedForAnimation = transform.TransformDirection(movementSpeedForAnimation);
    3.  
    4.         animator.SetFloat("SpeedX", movementSpeedForAnimation.x);
    5.         animator.SetFloat("SpeedY", movementSpeedForAnimation.z);
    as you can see, i try to use the transform direction, but not working and got weird result.
    can you provide me some help on this point ? Thanks !