碰撞体与触发器-开门

打开unity5.2,添加plane,添加资源包,加入第三人称人物,导入有打开动画的门,添加一个球体,作为触发器

/**
 * 
 * 碰撞体与触发器
 * 
 * */
using UnityEngine;
using System.Collections;

public class Demo1 : MonoBehaviour {
    public GameObject obj01;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
    
    }
    /// <summary>
    /// 第三人称人物,触发进入函数
    /// </summary>
    /// <param name="e"></param>
    void OnTriggerEnter(Collider e)
    {
        if (e.name == "Sphere")//进入名为“sphere”的区域,播放动画
        {
            obj01.GetComponent<Animation>().Play("OPendoor1");    
        }
    }
}

 

相关文章:

  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2021-08-01
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案