I tried lots of things but I still can’t get this simple thing right.
I just want to make the bullet shot from the gun to face away from the gun barrel but I can’t understand eulers and no solution I found on the internet works, even most of them being for top-down shooters.
The bullet just shoots with the same rotation no matter where I aim it.
queasypoliteamericantoad
My Shoot function:
public void Shoot(Vector3 playerpos)
{
Quaternion bulletRotation = Quaternion.Euler(0, 0, this.transform.rotation.x - 90);
GameObject bullet = GameObject.Instantiate(thisWeapon.projectile, bulletSpawn.position, bulletRotation); // TO-DO: fix bullet rotation
Rigidbody bBody = bullet.GetComponent<Rigidbody>();
bBody.AddForce(bulletSpawn.right * thisWeapon.projectileSpeed * Time.fixedDeltaTime, ForceMode.Impulse);
bullets.Add(bullet);
++global_vars.global_bulletCount;
return;
}
The script is placed on the gun and the bullet is spawned on a child object of the gun (bulletSpawn), the bullet shoots perfectly, only issue is the bullet rotation.
I hope this is enough information, I’m probably committing a simple error, thank you in advance.