//脚本挂载移动的物体上
public class Player : MonoBehaviour {
public float Speed = 4;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float h = Input.GetAxis("Horizontal");
transform.Translate(Vector3.right * h * Speed * Time.deltaTime, Space.World);
float v = Input.GetAxis("Vertical");
transform.Translate(Vector3.forward * v * Speed * Time.deltaTime, Space.World);
}
private void OnTriggerEnter(Collider other)
{
switch (other.tag) {
case "Sphere":
other.GetComponent<pet>().enabled = true;
// Destroy(gameObject);
break;
default:
break;
}
}
}
//Tag 换成Sphere
//脚本挂载跟随的物体上
//打开脚本是跟随移动 关闭是触发移动
// public