Yep this is correct, using more rays will get a better average of the surface. A minimum of three rays is needed to form a mathematically flat plane which represents the surface.
Example project which uses three rays in this manner:
Features:
Reliably orients with the ground including when entity is on top of two (or more) different surfaces
This allows for a smooth transition from surface to surface which also makes it less “bumpy”.
A common method is to use the surface normal at one point which doesn’t account for cases such as when half of your entity’s body is on a ramp and the other half isn’t where you now want to orient sort-of “halfway” between both surfaces. This works around this by raycasting at 3 …
For the rotation bit you can use also this CFrame technique:
Rather than trying to convert this up vector into an angle which is also complicated it’s better to leave it I would rather use @EgoMoose advanced CFrame technique to leave it in terms of vectors.
We can obtain a CFrame rotation to align the current persons “UpVector” to the new surface upvector. Here is an example script and video.
The advantage of this method is that it will allow you to rotate along the new upVector without having to specify a right vector as a CFrame.fromMatrix solution.
…
1 Like