|
Hello fellow uniteres! I have a third person game where the camera is free to rotate around when the player is not moving. And when the player is moving the players Y axis lines with the cameras Y axis, but when doing so the player "snaps" to the cameras Y axis. I want to make this smooth and therefor considering using Quaternion.Slerp, but the problem using Quaternion.Slerp is that it is "Slerping" all axis X, Y, Z, but as said I only want to "Slerp" the Y axis. Is this possible(It most likely, but I do not know how to) I have tried Mathf.Clamp, but that causes "shaky" movements and slow fall through the floor. The current code I use for the rotation right now is this(small sample only): So can you please tell me a way to restricting "Slerping" to the Y axis only. I will be greatfull!
(comments are locked)
|
|
yourRotationQuaternion = Quaternion.Slerp(to, from, time); yourRotationQuaternion = Quaternion.Euler(new Vector3(0f, yourRotationQuaternion.eulerAngles.y, 0f)); done like dinner Thank you. tried messing with it, but importunately the player only turns/rotates 0.8 degrees each direction and nothing more and then the player is kinda "clamped" there and can not rotate further.
Jun 08 '11 at 10:14 PM
OrangeLightning
You corrected Anxo, but you made the same mistake.
Jun 09 '11 at 01:50 AM
Peter G
Ah- yes. I've edited my post to clarify. Just more proof that we need intellisense here too :)
Jun 09 '11 at 02:29 AM
testure
(comments are locked)
|
|
transform.rotation.y = Quaternion.Slerp(bla bla bla).y; yeah, but Y is not what you're thinking it is- he's talking about restricting to the Y euler angle, this would give you the Y quaternion component, which is not the same thing: http://unity3d.com/support/documentation/ScriptReference/Quaternion.html
Jun 08 '11 at 10:45 PM
testure
oh I guess I tried to answer the title without reading the question.
Jun 09 '11 at 11:52 AM
Anxowtf
(comments are locked)
|
|
After the Quaternion.Slerp statment transform.localEulerAngles = Vector3(0, transform.localEulerAngles.y, 0);
(comments are locked)
|

Can you post your current Slerp code?
I do not have any Slerp specific code since I could not for the life of me restrict it to the Y axis only so I sticked to the code in the updated post.