using UnityEngine;
public class Player : MonoBehaviour{
private Rigidbody rd;
public int force = 5;
// Use this for initialization
void Start(){
rd = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update(){
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
rd.AddForce( new Vector3(h,0,v) * force );
}
void OnCollisionEnter(Collision collision){
//collision.collider//获取碰撞到的游戏物体身上Collider组件
//string name = collision.collider.name;//获取碰撞到物体的名字
//print(name);//print可以把一个字符串输出显示到控制台
if (collision.collider.tag == "PickUp"){
Destroy(collision.collider.gameObject);
}
}
}