I’m trying to instantiate an object, a bullet, so it comes from the back of the object. In other words, Im trying to change its degrees by 180, but it’s quaternion so it’s more complicated. Anyway here’s my code:
Instantiate(bullet, transform.position, transform.rotation);
//transform.rotation needs to be translated by 180 degrees
here’s the final working code:
var rot : Vector3 = transform.rotation.eulerAngles;
rot = new Vector3(rot.x, rot.y, rot.z + 180);
Instantiate(bullet, transform.position, Quaternion.Euler(rot));
You can use Quaternion.eulerAngles to get a Vector3 representation of the Quaternion and then convert the Vector3 back to a Quaternion using Quaternion.Euler.