Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

c# - Blend-Tree animations goes the opposite way

I'm trying to create a simple Blend-tree Animation that the player will be able to Run + Strafe + Walk Backwards. Now when I press play and walk straight all seem to be good (other than animation speed but that all right) but when I'm trying to go 180* it's doing his animation but still trying to go to the straightway as before.

Here is my code

public class AnimatorController : MonoBehaviour
{
    Player player;
    Animator anim;
    public float speed;
    // Start is called before the first frame update
    void Start()
    {
        player = GetComponent<Player>();
        anim = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        var x = player.moveVector.x;
        var y = player.moveVector.y;


        ChenRedo(x, y);
    }

    private void ChenRedo(float x,float y)
    {
        anim.SetFloat("VelX", x);
        anim.SetFloat("VelY", y);

        player.transform.position += (Vector3.forward * speed) * y * Time.deltaTime;
        player.transform.position += (Vector3.right * speed )* x * Time.deltaTime;

    }

Unity Blend Tree:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...