Hi, I’m using a cube at the end of my gun as a spawn placement for a Bullet Prefab. When firing I spawn a bullet instead of raycasting. All of the collision code is on the Bullet, using the code below though bullets bounce off of objects and instead of firing in a straight line they tend to curve. Is a RigidBody the best way to imitate Bullets or is there another method?
public class Bullet : MonoBehaviour {
public Rigidbody rb;
public Transform Parent;
void Start() {
rb = GetComponent<Rigidbody> ();
Parent = gameObject.transform.parent;
StartCoroutine ("Delete");
}
void Update() {
rb.AddForce (transform.forward * 1000);
}
IEnumerator Delete() {
yield return new WaitForSeconds(5);
Destroy (gameObject);
}
}