How can I tell when my vehicle crashes?

with the physics vehicle control, how can i tell if it’s sideways or upside down to force a crash?

Thanks.

you could check the dot product of UNIT_Y and carRotation.mult(UNIT_Y)

Not sure what function I need to call for that one.

@normen said: you could check the dot product of UNIT_Y and carRotation.mult(UNIT_Y)

Just a note: the dot produce in this case will simply be the y value of the rotated UNIT_Y anyway. So no need to do the dot product… just check the y component of carRotation.mult(UNIT_Y). 1 = straight up and down, 0 = 90 degrees on its side, -1 = exactly upside down.

@pspeed said: Just a note: the dot produce in this case will simply be the y value of the rotated UNIT_Y anyway. So no need to do the dot product... just check the y component of carRotation.mult(UNIT_Y). 1 = straight up and down, 0 = 90 degrees on its side, -1 = exactly upside down.

True. Though thats only if up is UNIT_Y, so mine is basically the universal way, no matter what direction up is. I guess in a car game with a looping it would be bad to actually use UNIT_Y :wink:

@drarem:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

@normen said: True. Though thats only if up is UNIT_Y, so mine is basically the universal way, no matter what direction up is. I guess in a car game with a looping it would be bad to actually use UNIT_Y ;)

True… but even then “upside down” is a bit of an ambiguous statement. :slight_smile: I think you’d have to get contact points involved.

Thanks, it seems like it will work for me.

1 Like