zoukankan      html  css  js  c++  java
  • Animation Parameter

    Animation Parameter

      Animation Parameters are variables that are defined within the animation system but can also be accessed and assigned values from scripts. 

      Animation Parameters 是Animator Controller中的用户自定义变量,script可以获取和设置其值,其值也可以作为transition转换的条件。配置界面如下:

      

      有四种类型的Parameter可选:

      

      Parameter可以作为transition的判定条件:

       

      script访问parameter的示例如下: 

     1 using UnityEngine;
     2 using System.Collections;
     3 
     4 
     5 public class AvatarCtrl : MonoBehaviour {
     6 
     7     protected Animator animator;
     8 
     9     public float DirectionDampTime = .25f;
    10 
    11     void Start () 
    12     {
    13         animator = GetComponent<Animator>();
    14     }
    15 
    16     void Update () 
    17     {
    18         if(animator)
    19         {
    20             //get the current state
    21             AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
    22 
    23             //if we're in "Run" mode, respond to input for jump, and set the Jump parameter accordingly. 
    24             if(stateInfo.nameHash == Animator.StringToHash("Base Layer.RunBT"))
    25             {
    26                 if(Input.GetButton("Fire1")) 
    27                     animator.SetBool("Jump", true );
    28             }
    29             else
    30             {
    31                 animator.SetBool("Jump", false);                
    32             }
    33 
    34             float h = Input.GetAxis("Horizontal");
    35             float v = Input.GetAxis("Vertical");
    36 
    37             //set event parameters based on user input
    38             animator.SetFloat("Speed", h*h+v*v);
    39             animator.SetFloat("Direction", h, DirectionDampTime, Time.deltaTime);
    40         }        
    41     }             
    42 }
    View Code

      综上所述,Animation Parameter是一个script可写,transition可读的控制变量。

    参考:file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/Manual/AnimationParameters.html

      

  • 相关阅读:
    int (*p)[10] 与*p[10]的区别
    运算顺序
    关于linux开机进入grub问题的解决方法
    对于特殊字符串的处理方法
    学习进度条
    阅读《实例化需求》4-6章有感
    学习进度条
    阅读《实例化需求》1-3章有感
    问题账户需求分析
    2016年秋季个人阅读计划
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3764825.html
Copyright © 2011-2022 走看看