- Home /
hit.normal rotation problem, help please really confused
im casting a ray from character to wall i want to match the rotation of the character to the normal of the raycast hit.
this works fine on some normals using fromtorotation but on other normals it flips the character upside down, on its side etc,
im guessing that the faces hits normal isnt using the same up vector or something as the character but not sure how i could go about fixing it
thanks beforehand for any help
Answer by Baste · Jan 22, 2016 at 04:16 PM
You want your character to bounce out with the same angle as it's coming in?
The method Quaternion.Lookrotation has a second argument named upwards, with the default value of Vector3.up. Using that should give the correct results:
if(Physics.Raycast(..., out hit, ...)) {
Quaternion wantedRotation = Quaternion.LookRotation(hit.normal);
character.rotation = wantedRotation;
basically yE , i want to get the forward direction of the normal and apply that to the character. ive given in the vector3.up to lookrotation and it will work on some walls but not others still puts the character upside down or sideways tc
Your answer
Follow this Question
Related Questions
Using Raycast Normal to match surface rotation to instantiated gameobject? EXAMPLE GIF Included 0 Answers
How to get Raycast surface normal to align particle system? 1 Answer
Rotate Player to Match Surface Normal While Still Maintaining Y Rotation 0 Answers
Rotating with a preferred driection. 0 Answers
Get X normal of collider below object regardless of rotation 1 Answer