- Home /
Bone doesn't rotate through script
Hello people, I'm working on a script moving the arm of my character in the direction where the camera's looking. Can't figure out why it's not working...
Here's the script, in the Player Control script, where cam is the camera GO, armControl is the bone i'd like to move, armRot is just a float.
void LateUpdate()
{
armRot = cam.transform.rotation.x;
armControl.Rotate(armRot, 0, 0);
}
Thank you!!
Answer by Destolos · Aug 15, 2017 at 01:12 PM
Transform.Rotate rotates the object at the given degree (https://docs.unity3d.com/ScriptReference/Transform.Rotate.html). But you want to set the rotation. I don't know, if it works, but you need something like that:
armControl.rotation = cam.tranform.rotation;
Trying that too but didn't work. I finally went with
armControl.transform.localRotation = Quaternion.AngleAxis(rotY-70, new Vector3(1, 0, 0));
Which gave me access correctly without defor$$anonymous$$g. And follows rotY which is directly the mouse input.
Thank you very much though
If I remember well, it told me rotation is not a variable, so I can't just tweak it.
Your answer
Follow this Question
Related Questions
Rotate a bone with mouse input while animation is playing 0 Answers
How to stop animation bones from rotating around wrong axes via script 0 Answers
How to bind two gameobjects together? 2 Answers
Armature moves further then the root bone 1 Answer
Armature bone unable to rotate while animation playing 1 Answer