Collision issues

Blitz3D Forums/Blitz3D Programming/Collision issues

RifRaf(Posted 2004) [#1]
Ok, I have an object, when it collides with a wall I want to reverse its velocity.. thats fine, but during a power slide.. when the object collides facing away from the wall but still sliding backwards into it.. reversing the velocity sends it into the wall..

So my question is.. how can I determine if the object is facing the wall\triange it collided with or facing away from it so i can properly adjust velocities.


Bot Builder(Posted 2004) [#2]
hmm. I'm not gonna post a code example-to tired. this really is a bit complex.. Hmm. I would either find out the normal of the triangle you collided with or average the triangle's vertexs' normals. Then, do a crossproduct on the direction normal and the triangles normal. This'll tell you how much the car is pointed at the triangle. This would be good anyway, because you could use it to only slightly add a reversal force near 0. Hopefully someone else will iron out the errors in my idea/ help with the details. If not, I can do it tommorow


Ross C(Posted 2004) [#3]
You could do a fat linepick from the front of the object and the back. Not very techincal i suppose and you'd probably be best doing bot builders idea :)


(tu) sinu(Posted 2004) [#4]
try this


If CountCollisions(car)>0

nx = CollisionNX#(car)
ny = CollisionNY#(car)
nz = CollisionNZ#(car)

Else

nx = 0
ny = 0
nz = 0

EndIf


TFormVector nx,ny,nz,0,car

tCarmNX = TFormedX()
tCarNY = TFormedY()
tCarNZ = TFormedZ()



then check the tCarNZ value, if it's below 0 ie -value then the back of the car collided.

ps it maybe at +value depending on the car orientation in the modelling app.