- Home /
Mesh rotation issue ( using FromToRotation )
Hey there people. Well i'm still not that good when it comes to scripting but i'm so determined to make a sonic game. And as hard as it seemed to be, I was able after so much work and messed up scripts to make the basic movements. These, use rigidbody.Velocity. I basically made a direction vector3 whith its components each using a CurrentSpeed float. That is to have some more control over the movement on all axis.
That put together, gives me a movement in all directions but of course without rotation. And to accomplish that, I simply rotated the mesh to face the movement direction vector. That basically works like sharm on flat surfaces. But sonic is suposed to run on slopes. And thats where shows the problem.
Somehow, after or while running on slopes the mesh stars rotating in a weird way. Sometimes it flips around and such. Most of the time, ( if not always ) after running on a slope and going back on flat surface, when moving forwrad the mesh flips by 180 degress on the x and z axis
mesh.transform.rotation = Quaternion.FromToRotation (transform.forward, direction*RotSpeed) * transform.rotation;
the direction code isn't something special. As I said, it uses 3 variables. the X and Z current speed vars simply keep increasing as long as you press the movement buttons.
I hope what I said was clear and I'm looking forward to your answers. ^^
Your answer
Follow this Question
Related Questions
Need explanation for this code 0 Answers
Rotate a sphere by its vertices... 1 Answer
Rotation, my script shouldn't work but does. 0 Answers
Can I use Quaternions to get from one point to another? 1 Answer
Problem with FromToRotation 1 Answer