Unity Animator BlendTree1

Source: Internet
Author: User

Good to curse Ah, finally solved

Problem

I use Blendtree to let the character run, turn left, turn right, jump the function, but the character other animations play normal, as long as the steering is not moving in situ

Cause: The animation will not move when it is finished, set the Loop property on the line.

Using Blendtree

1 animations If you are only moving in situ, you can add motion curves to the animation (curves, in the animation window) and then add motion codes to the characters

In the Onanimatormove function
    void Onanimatormove ()    {        Animator Animator = getcomponent<animator> ();        if (animator)        {            Vector3 newposition = transform.position;            Newposition.z + = animator. GetFloat ("Run") * TIME.DELTATIME;            Transform.position = newposition;        }    }

2 Create controller controllers, add animations to controllers, add Blendtree, add variables to controller if you want to control animated motion by condition condition control character movement

Add code

public class Blendtree1:monobehaviour {    Animator animator1;    public float speed1 = 0.08f;//with this for initializationvoid Start () {        Animator1 = getcomponent<animator> ();} Update is called once per framevoid update () {        if (Animator1)        {            Animatorstateinfo statinfo = Animator1. Getcurrentanimatorstateinfo (0);            if (Statinfo.isname ("Base layer.run"))            {                if (Input.getkey (KEYCODE.A))                {                    Animator1. Setbool ("Jump", True);                }            }            else            {                Animator1. Setbool ("Jump", false);            }            float horizontal = Input.getaxis ("horizontal");            Animator1. SetFloat ("Speed", horizontal, speed1, time.deltatime);}}        

  

 

Unity Animator BlendTree1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.