Question by
cmcmains · Mar 20, 2017 at 11:34 PM ·
gameobjectrigidbodyinstantiatevector3quaternion
Having trouble with Instantiate
I'm trying to shoot a bullet out of an empty attached to a gun. I'm using instantiate but it keeps telling me that I'm using it wrong and that it can't convert Vector3 to Quaternion in my instantiate line. What am I doing wrong?
public GameObject barrelEnd;
public GameObject bullet;
void Update ()
{
if (Input.GetMouseButtonDown (0))
{
barrelEnd.transform.rotation = Quaternion.Euler (barrelEnd.transform.rotation.x, barrelEnd.transform.rotation.y, barrelEnd.transform.rotation.z);
GameObject.Instantiate (bullet, barrelEnd.transform.position, barrelEnd.transform.forward);
}
}
Comment
barrelEnd.tranform.forward is a Vector3, you need to feed the instantiate a Quaternation, like barrelEnd.transform.rotation