# Unwanted physics reaction

Hey,

I’m building a game about a whale that’s sliding on the floe.

To do it, I have (basically) a sphere RigidBodyControl (which modelize my whale) that can slide along a platform which is another RigidBodyControl (kinematic). Here are some screenshots so you can visualize it pretty well: http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/the-sliding-whale/

The gameplay is based on the fact that the player can roll/pitch the platform to make the whale slide around (just like in Labyrinth).

My problem is that when my whale is around platform extremities, a quick roll/pitch is making my whale jump (the larger is the roll/pitch, the higher the whale jumps).

So you’re gonna tell me that’s it’s pretty normal (and I know it) but I just don’t want this effect to happen. I’d like my whale to stick the platform except when I allow her to jump.

So far, I thought about some ways to proceed (swap to CharacterControl, force the physics to stay at same level, …) but none seems to be useful. The best would be a “BodyControl” which is a mix between CharacterControl and RigidBodyControl cause I need some aspects of both those BodyControl. One one hand, I need my whale to behave like a character (stand up straight, stick to ground, etc) and on the other hand, I need it to behave like a free body on ice (slide according to the platform roll/pitch, applyImpulse, etc).

So maybe you guys could see a new way to approach this problem ?

How about you listen to collision events of whale and platform and if theres none for like 1 or 2 ticks then you apply a force in the platform direction to the whale. Another approach is to do a ray check from whale to platform and check the distance, then apply a force as needed.

How about you listen to collision events of whale and platform and if theres none for like 1 or 2 ticks then you apply a force in the platform direction to the whale. Another approach is to do a ray check from whale to platform and check the distance, then apply a force as needed.

Wouldn't it be too greedy in calculation ? I'm looking for something really "light" cause my game is already having fps issues so everywhere I can optimize calculations, I do it. But I'm gonna have a try.

Thx for the idea. I'm still open to any other ones.

Not really, what do you imagine the code would look like if it was in bullet already? ^^

Not really, what do you imagine the code would look like if it was in bullet already?

Point.

One more question. I know how to check collisions, but how do I check the lack of collision ? I mean, I usually use the Collisions method to do such stuff but here, how can I use it as I'm trying to catch no event ?

Edit: Unless I stack events and I delay the action by one frame... but it's weird to proceed so.

Thats what you have to do yeah catch events and then apply the next tick or not, not really weird if you think in terms of an update loop, remember to use the tick listeners or the PhysicsSpace.enqueue() to apply the forces in the right moment, its not necessarily every frame that the physics is really stepped.