{
player = GameObject.FindGameObjectWithTag("Player").transform;
lastpos = player.position;
direction = (lastpos - transform.position).normalized;
Destroy(gameObject, 4f);
}
获取最后一个姿势,并拍摄该方向,碰撞不工作这种方法。
void Update()
{
transform.Translate(direction * (30f * Time.deltaTime));
}
``` this dosent work with collisions so i need to use rigidbody forces, any help please? idk how to do that
听起来你想在子弹上放一个刚体和一个碰撞器(mesh,球体,胶囊,你的喜好)。要移动子弹,你可以做
public float thrust = 1.0f;
void Start() {
Rigidbody rb = GetComponent<Rigidbody>();
}
void FixedUpdate() {
rb.AddForce(transform.forward * thrust);
//alternate rb.velocity = new Vector3(1.0f,1.0f,1.0f);
}
void OnCollisionEnter(collision other) {
//do something when the bullet hits another collider
}