I’m working on a FPS, and I want to use rigidbody to launch my bullet. Here is my script so far
using UnityEngine;
using System.Collections;
public class PlayerGunController : MonoBehaviour
{
public GameObject bullet;
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
print("Pulled trigger");
bullet.rigidbody.AddForce(Vector3.forward * 10);
}
}
}
I did a little reading about Rigidbody in the script reference, then gave it a go. Doesn’t work. The bullet gameobject is a sphere with a rigidbody attached to it. useGravity is off and isKinematic is on, no other settings were changed.
I click the button and see the message printed, but the sphere doesn’t move. Any help?