本文整理汇总了C#中Animator类的典型用法代码示例。如果您正苦于以下问题:C#Animator类的具体用法?C#Animator怎么用?C#Animator使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:OnStateEnter
//OnStateEnteriscalledwhenatransitionstartsandthestatemachinestartstoevaluatethisstate
publicoverridevoidOnStateEnter(Animatoranimator,AnimatorStateInfostateInfo,intlayerIndex)
{
if(animator.gameObject.GetComponent
().indexPos==0){
if(animator.GetInteger("attack")==1){
GameObjectEarthBend=(GameObject)Instantiate(Resources.Load("EarthBend",typeof(GameObject)),GameObject.Find("skillSpawn(1)").transform.position,GameObject.Find("skillSpawn(1)").transform.rotation);
EarthBend.GetComponent().velocity=EarthBend.transform.TransformDirection(Vector3.forward*15);
EarthBend.transform.FindChild("source").gameObject.tag="Enemy1Attack";
}
}
if(animator.gameObject.GetComponent().indexPos==1){
if(animator.GetInteger("attack")==1){
GameObjectEarthBend=(GameObject)Instantiate(Resources.Load("EarthBend",typeof(GameObject)),GameObject.Find("skillSpawn(2)").transform.position,GameObject.Find("skillSpawn(2)").transform.rotation);
EarthBend.GetComponent().velocity=EarthBend.transform.TransformDirection(Vector3.forward*15);
EarthBend.transform.FindChild("source").gameObject.tag="Enemy2Attack";
}
}
if(animator.gameObject.GetComponent().indexPos==2){
if(animator.GetInteger("attack")==1){
GameObjectEarthBend=(GameObject)Instantiate(Resources.Load("EarthBend",typeof(GameObject)),GameObject.Find("skillSpawn(3)").transform.position,GameObject.Find("skillSpawn(3)").transform.rotation);
EarthBend.GetComponent().velocity=EarthBend.transform.TransformDirection(Vector3.forward*15);
EarthBend.transform.FindChild("source").gameObject.tag="Enemy3Attack";
}
}
}
原文链接:http://www.jxszl.com/biancheng/C/556537.html