- Home /
Character Mouse Look on Spine
I Have a Character that i want to apply the mouse look script to his spine to make him look up and down(bending over, leaning back) if i add an empty gameObject and place all cord,rotation to zero and place the spine inside i can achieve this but then the animation wont play above the spine with AddMixingTransform, How do i get the spine to act like the empty gameObject zeroed out retaining the animations yet allowing the mouse to look up and down. Do I rotate his spine some how with script? I have searched all over and cant seem to find what to do. I would much appreciate any help and advise on this please.
I had a similar problem. $$anonymous$$y animations also didn't play but the reason for that was that I destroyed the Bone-Hirarchy by adding the empty Gameobject. $$anonymous$$aybe it's a similar Problem. What I did was adding the $$anonymous$$ouseLook-Script directly to the spine-Bone and then changing the script a little bit because i had some weird rotation problems.
The Script I ended up using was this: https://dl.dropboxusercontent.com/u/83937500/$$anonymous$$ouseLookBones.cs
If you're trying to use it watch out. There are parts of networking + Recoil in the script. Just comment out what is blocking and maybe change if your model acts differently. Btw. In the Inspecter you have to choose $$anonymous$$ouseX.
Report back if you try it.
$$anonymous$$any thx ExTheSea I will certainly give this a try and report back once i have again cheers for the reply
I have managed to give this a quick test and although not fully working it allows me to move the spine now and retain the animation which currently didn't work but i'm getting what appears to be a rotation issue as the character flicks back and forth once i start to lean forward.I am a bit of a noob and will probably have to do some more reading on this. I currently have Root>Spine>Hip on the character and each has a rotation on the x axis. root = 90d, Spine = 270d and the hip which is the one i want to rotate is 90d so i guess its to do with the 90d on this bone as to why its trying to re-position. Thanks for sharing this i guess i now have to try understand how go about correcting this but i guess im a step closer....cheers
If it helps here is my question from the time where i had this problem. http://answers.unity3d.com/questions/334526/animation-interfears-player-movement.html
I can't quite remember what i finally did to solve my problem. It might have even been inside blender, not unity.
Answer by 03gramat · Oct 08, 2013 at 02:10 PM
In case you have not resolved this issue, or for anyone else that has a similar problem to you (or me)
Although I made my model in 3DS max, I expect this to work similarly for you. I attached an adaptation of the mouselook script to the 2nd of my 3 spine segments (it seemed to work best for the way the back bending looked). I changed it to JS from c# but it is pretty easy to convert. My solution was base on the fact that the update needs to be changed to a Late one and also the angle of rotation needs to be on the Z axis because of the orientation of the spine:
var sensitivityZ = 15F;
var minimumZ = -60F;
var maximumZ = 60F;
var rotationZ = 0F;
function LateUpdate ()
{
rotationZ += Input.GetAxis("Mouse Y") * sensitivityZ;
rotationZ = Mathf.Clamp (rotationZ, minimumZ, maximumZ);
transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y,rotationZ);
}
function Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
wow thank you so much! I have been looking for something like this forever, it work exactly like I want it except a small litle thing. I added the script to my main torso bone that controls the whole upper body and when I press play it rotates the whole torso 90 degrees to the right. why? : s I have tried to rotate the torso before going to to playmode 90 degrees at the other direction in hope that it would then rotate the character to the normal position at play but it still goes to the same direction as earlier. It seems like it only want to face 90 degrees on the Y axis all the time.
EDIT: I fixed it by changing the rotations on my bone to 0 in all directions, Thank you so much for the script! :D
How to make my characters torso move in the x-axis rather than the z-axis?
Thanks 03gramat, that is also something i have been looking for, for an extremely long time
How do you use Y axis ins$$anonymous$$d of Z? I changed everything from ...Z to Y but it does not change the axis ffs
Answer by Ectoo · Aug 30, 2016 at 02:01 PM
To get the Z axis you need to edit Input.GetAxis ("Mouse Y" ); to Input.GetAxis("Mouse X");
unity .GetAxis runs off x & y not y & z, The link down below can help.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
CharacterController "breaks" collision, goes haywire 2 Answers
CharacterController doesn't rotate on my script... 1 Answer
How to make Main Camera shake correctly when getting attacked? 1 Answer
Bone movement by scripting using given angle as input. 1 Answer