So I’ve been stuck on this problem for a long time, and I’m in need of some help…
I have a slightly rotated box, and a ball. I want to detect whether the ball is on the box, or falling in the air. I’ve tried using a GhostControl and a Ray directly below the ball to check for collision with the box, but apparently there is no support for a rotated box (when I am at the top of the box, this method works as desired, but at the bottom end of the rotated box, it thinks I’m colliding with the box even in the air). I can’t just check for zero Y movement, since the ball might be rolling up or down the small slope of the box. The physics engine knows when I am contacting and rolling on the box… how do I extract that information? I basically just want to know when the ball can “jump”!
Any help would be appreciated… thanks.
Probably not the best method but it’s what I settled on for some of my stuff…
To determine if my physics objects are “on the ground” so they can “jump” … I use a physicsCollisionListener to keep track of when there is a collision between the floor (in your case, rotated box object) and the object (your sphere) and then zero a count… then using a physicsTickListener, I check how many ‘ticks’ have passed since the last collision… if it is more than 3 or 4 ticks I class the object as “in the air”.
I ended up doing this since I found my objects would very slightly bounce along the surface which triggers the collisionListener heaps, so checking across several ticks helps smooth out this bounce and gives me a pretty good indication of when an object is in the air.
Interesting idea… Guess I’ll have to go with that since I can’t really find any other solution. I was hoping for an “instant check” method, since I also want to detect when the ball is about to roll off the floor (so I could stop it before it goes over). Maybe just record known “on floor” locations, and them when the ball is “in air”, teleport it to the last known floor location and set its velocity to zero… shrug