Always rotates 0 when setting values

So i want the weapon to rotate to the to the x and y of the rotbot, which is a different object that rotates to point at the second hand (its a vr game but that doesn’t matter) and then rotate the z to the rotation of the hand holding the object. Take pavlov for example if you know how that works. heres code that should do that

HeldObject.GetComponent<CanInteractWithThis().RotBot.transform.LookAt(HeldObject.GetComponent<CanInteractWithThis>().HandHold.transform);
                HeldObject.transform.rotation = Quaternion.Euler(HeldObject.GetComponent<CanInteractWithThis>().RotBot.transform.rotation.x, HeldObject.GetComponent<CanInteractWithThis>().RotBot.transform.rotation.y, this.transform.rotation.z);

this is stopping my development please help. If you have questions about anything that i didn’t specify please ask. Thanks

@SPOTNINJADUD7890, First, before we can get to anything else, we have to fix a problem in the code you have posted. in all cases you refer to transform.rotation, you need to realize that the rotation member is a Quaternion. The x, y and z properties of the Quaternion are not angles. They have no meaning to your code. Search the internet for what a Quaternion is to understand what these values are, but I can assure you that you have absolutely no use for them whatsoever.


What you require are the eulerAngles property from the rotation. As in:

RotBot.transform.rotation.eulerAngles.x

That is the angle, in degrees, of the x axis from the RotBot’s rotation. The x you retrieved (and, thus, the y and z) are not related to an angle in the slightest.