- Home /
How can I make a certain bone rotate with the camera?
I am making a first person game that uses the full body and I want to rotate it realistically, so how do I rotate the Spine with the camera? Actually, scratch that. How can I rotate 4 bones with each bone moving 1/4 the speed of the camera? That way it looks a little more realistic with the full body turning. Thank you!
I would do that in LateUpdate. Transform changes made here will be updated after the animation has played(for each frame). You'll have to experiment wil how much each bone rotates relative to the camera. Would be helpful if you put up some code showing what you're currently doing.
This link is useful when dealing with animations: http://docs.unity3d.com/Documentation/ScriptReference/AnimationState.html
Answer by vinod.kapoor · Aug 28, 2012 at 10:25 AM
var vecttoq : Quaternion;
var parent : Transform;
function Start(){ var parentRotInv : Quaternion= Quaternion.Inverse(parent.rotation);
vecttoq = parentRotInv*transform.rotation;
}
function Update(){
transform.rotation=Camera.main.transform.rotation*vecttoq;
}
assign the parent as the main/parent object at parent. attach this script to the spine or whichever part you wish to rotate with camera
Okay so how do I rotate two bones half the speed of the camera? It looks more realistic.
Also, I tested it out and it works great! Can I get your email so we can talk a little bit further? Or we can do it right here if you like.
First, the issue. I have objects parented to different bones. When I run an animation, they stick to the bones perfectly and all is good. When I use this, the objects are still connected to the bones, but they shift at a different rate than the bones. Do you know why this is?
And next, how can I edit this so it only rotates on the Y axis with the camera?
Answer by vinod.kapoor · Aug 29, 2012 at 05:11 AM
if the objects are the children of the the bones as u said, there movement should be proportional to the bones, however if they are up in the hierarchy they will move according to the main gameObject.
Then I have a glitch. This afternoon can I make a video and give it to you?
Okay. It is seen here.
Your answer
Follow this Question
Related Questions
Importing a armature from blender to unity ruins the models rotations -1 Answers
blender to unity animations 1 Answer
Can Unity import a Blender deformed bone rig (segments)? 1 Answer
Remove bone from animator/rig 0 Answers
Can't move mesh limbs? 1 Answer