Trying to make a hovering board to move props easily and I'll use four tracers (one at every corner)
Could you be more specific? You can't simply find a rational 3D angle between 4 points.
Dont know how to specify it more than saying its literally a flat board hovering. I know it has been done a lot in E2
Are you looking for a way to get the normal of a theoretical plane that results from the HitPos of the 4 tracers perhaps? We need more info on what exactly you want
Like what exactly are you trying to find the angle between? You can't just find a simple angle when there's more than two points involved.
Yeah I guess that's it. I really can't explain it better. Lets say I have a 1x1 plate that tries to never touch the ground when hovering over a rough terrain and slopes.
I suppose you could average all the HitNormals together instead.
local average = vector_origin
local targetAngle = angle_zero
local traces = {} -- put all your trace HitPos in here
for i = 1, #traces do
average.x = average.x + traces[i].x
average.y = average.y + traces[i].y
average.z = average.z + traces[i].z
end
average.x = average.x / #traces
average.y = average.y / #traces
average.z = average.z / #traces
targetAngle = average:Angle()
May need to do something else to it, but I'm not sure. Untested.
Do you want your angle to point perpendicular to the plane between the 4 points?
function planeAngle(vec1,vec2,vec3) --three hitpos vectors from traces
local a = vec2-vec1
local b = vec3-vec1
return a:Cross(b):Angle() --if it faces the wrong direction, then just use the negative of this
end
A plane has 3 points. If you use 4 you could potentially get wonky results, since there would be 4 potential planes resulting from each triangle of points. Imagine one corner being FAR below the other 3. Do we raise the opposite corner by the same amount? It all goes downhill at that point.
Are you just trying to keep each corner of your 1x1 a certain distance off of the ground? Because you wouldn't need to make a plane anyway in that case, you could make it a lot simpler and just PhysObj/ApplyForceOffset at each corner depending on their traces.
That was the original plan but I wanted to make my own "physics" as I want it to be unmovable except by players pushing it, also be it untippable and support anything.
Ok I gave up and managed to make it look really stable using this method. The other ones just didn't work out at all. But I will give some coins to the good people that suffered through my question!
Sorry, you need to Log In to post a reply to this thread.