- Home /
Rotate a vector3 to a surface normal?
Hello,
I am trying to stop my character controller from hopping down slopes and I was told that i should rotate my movement vector to the normal of the ramp to stop this. However, I am not sure how to do this and I require some help. I am fairly new to unity and would greatly appreciate any help :P
Answer by Konomira · Dec 20, 2017 at 11:54 PM
You can match the rotation of the slope, assuming the slope is a rectangle, like so:
private void OnCollisionStay(Collision collision)
{
transform.rotation = collision.collider.transform.rotation;
}
Your answer
Follow this Question
Related Questions
3D Character Controller slowing down the higher the slope angle (both up and down) 1 Answer
character wont rotate and is stuck to the one position. 0 Answers
Rotation with Character Controller & Rotation using vector3 1 Answer
Character Controller Movement - Different speeds on different axis 1 Answer
Rotate plane by normal, how to calculate new position? 1 Answer