- Home /
Contour gravity
all I need is this: (I think)
Send a raycast down and find the surface normal, and set our rotation to that normal.
Could you provide me a script maybe explaining normals and raycasting to set our rotation to that normal?
That way I can use that to learn normals in alot of ways.
Thanks.
Answer by efge · Jan 18, 2011 at 10:43 PM
Lots of examples can be found in the reference: Physics.Raycast
The normal of the surface the ray hit: RaycastHit.normal
To rotate an object (e.g. when instantiating) you can use this normal as the forward-vector for Quaternion.LookRotation.
Thank you. I knew how to use raycasts to alter your position, but I wasn't too sure about the rotation part. and I wasn't sure where to look. But thank you.
Your answer
Follow this Question
Related Questions
Raycast hits and then doesn't fire again? 2D Game Raycasting Problem 1 Answer
Using Raycast Normal to match surface rotation to instantiated gameobject? EXAMPLE GIF Included 0 Answers
How to handler rotation of a Gameobject while aligning it with normals 1 Answer
How to steer a hovercraft that aligns itself to a surface normal? 0 Answers
How do I align my player transform to waypoints and without restricting Z Axis rotation? 2 Answers