- Home /
Align plane to normal but keep Y-axis intact
So, I'm in a bit of a pinch cause I can't seem to find a definite solution to my problem, and I don't really have the math know-how to crack it, it seems. I'm spawning little footstep planes where the player walks, and I want to align these with the slopes of terrains. However, what I cannot for the life of me do, is keep the Y-axis, the property that makes the footsteps actually face the direction the player walked, intact.
Here's what I'm using so far to align the mesh.
Quaternion newRot = Quaternion.FromToRotation(Vector3.up, rcHit.normal);
transform.rotation = newRot;
Any ideas how to make them keep their direction if viewed from top-down, but still align to the terrain?
Answer by KubaPrusak · May 28, 2015 at 08:01 PM
To keep the footsteps in the correct direction, when you instantiate them make them face in the transform.forward direction of the player. I presume that the character controller that comes w/ unity has information about the current slope of terrain (since the script figures out whever you can go up the maximum slope you set), you could google around to see if such a thing exists.
Your answer
Follow this Question
Related Questions
Quaternions- how to leave out Y rotations... 1 Answer
Rotating an object to equal normals of object below 1 Answer
how can I align player with slope normals(no rigidbody) 0 Answers
Rotating with a preferred driection. 0 Answers
why am I getting a flipped-out effect from my transform.rotate 2 Answers