- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
- 纳金币
- 53488
- 精华
- 316
|
using UnityEngine;
using System.Collections;
public class switchAni : MonoBehaviour {
GameObject ani1;
GameObject ani2;
// Use this for initialization
void Start () {
ani1 = GameObject.Find ("Run");
ani2 = GameObject.Find ("AttackA");
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.Alpha1))
{
ani1.renderer.enabled = false;
ani2.renderer.enabled = true;
ani1.animation.Stop ();
ani2.animation.Play ();
}
else if (Input.GetKey (KeyCode.Alpha2))
{
ani1.renderer.enabled = true;
ani2.renderer.enabled = false;
ani1.animation.Play ();
ani2.animation.Stop ();
}
}
}
这是我参照这里写的:
http://answers.unity3d.com/questions/8632/how-to-change-my-character-during-the-game.html
可是为什么没反应? |
|