Hello I’m trying to get a ball shooting in the direction that the camera is looking towards. I now got the sphere to spawn facing the direction the camera is facing but when i use bullet.rigidbody.AddForce(Vector3.forward * 1000);
it will simply shoot the sphere in the world’s Z axis direction.
complete code
public class Player : MonoBehaviour
{
GameObject bullet;
public float power;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.J))
{
Fire_Bullet();
}
}
void Fire_Bullet()
{
Debug.Log("test");
bullet = (GameObject)Instantiate(Resources.Load("Bullet"), transform.position, transform.rotation);
bullet.rigidbody.AddForce(Vector3.forward * 1000);
}
}