im having problems with my game, i want to have a pistol orbit around my charecter and the position is allready done by a joint. however the joint doesn't rotate the object so i try to do that by code, but the problem is that i need to set an offset becouse the gun is 90degrees rotated around the y axes but than a weird thing happens.
i made a video to damonstrate this: https://youtu.be/HxNj6keyQ5U
i don't know how to fix this and i tryed everything.
thanks for your awnsers! (if i get any xD)
here's the code:
{
EulerRotation = new Vector3(Player.transform.rotation.eulerAngles.x, Player.transform.rotation.eulerAngles.y - 90, Player.transform.rotation.eulerAngles.z);
transform.rotation = Quaternion.Euler(EulerRotation);
}
if you are using Standard First Person Controller, It contains two parts: Main Object, Main Camera.
by a script, rotation on Y-axis is attached to Main Prefab, and rotation on the Z axis is attached to the Main camera. so when you use
Player.transform.rotation.eulerAngles.zin fact you are using Z axis on Main Object and so it will never change.