function Update()
{
if(Input.GetMouseButton(0))
{
var forward = transform.TransformDirection(Vector3.forward);
var hitInfo : RaycastHit;
if (Physics.Raycast (transform.position, forward, hitInfo, 1000))
{hitInfo.rigidbody.AddForce (forward * 50);
}
}
This isn't good because it just tells the rigidbody to go the opposite direction where ever the bullet hit it. I want the rigidbody to react as if a bullet rigidbody hit it. How can i do this? Thanks!
Try AddForceAtPosition instead of AddForce and place the hit position in its argument. Now you are adding force at the pivot, no matter where the bullet hits.