Check out the blend. I got things to work, but no the way I wanted. I am trying to get the cube’s Y axis to match the average of the 2 rays hitNormal along the Z. I added a rayD for making the cube stay a distance above the ground. But that doesn’t work either. Suggestions?
I think that’s because of the length of your rays to get the average. When you go up 2 on the z axis the rays are no longer hitting anything so the average wont be right causing the object to freak out a little.
I do not think your method will ever work as you expect.
A) you destroy the normal vectors. a vector consists of all components. If you separate a term you get a projection = anther vector.
B) a normal vector has always the length of 1.0
C) the normal of the ground is not necessarily the best choice to align the “hovering” object. But this depends what you really want and what you define as “down”
Imagine a wavy ground
[ATTACH=CONFIG]237925[/ATTACH]
If your rays hit both the inclining faces your vehicle will suddenly turn to the moon. A small step later it turns the opposite. (I would not want to sit in such a vehicle.
As I do not really know what you are aiming for. Here is my wild guess:
[ATTACH=CONFIG]237924[/ATTACH]
detect along the rays (local Z). When they hit assume the ground is average between the two hitpoints.