Double contact problem

I have a little problem with the OnContact method of ContactEvent :



the event seems to be triggered twice for each time an object touch an other one… the first time, the velocity of my object is negative so it’ s still falling and the second time, it’s positive so it’ s going up after having touch the other object…



Could someone tell me if that’s a normal behavior or there’s something I did’nt do right?



thanks

Ken

I think this is normal behavior (at least the same thing happens for me). The object collides triggering the onContact method. It then takes an update cycle to reverse velocities at which point the onContact method is called again. Then finally the object “bounces off” and the onContact isn’t called anymore. So basically it takes two update cycles to reverse velocities and stop being in contact with whatever the object collided with.

first of all, i forgot to say to ya on the other threads, welcome to jme and jme physics :slight_smile:



Secondly, this is natural behaviour because of the step size. What happens is that on each update call, the object moves forward say 10 units. In those 10 units, it has become submerged into another object, a collision has occured (it has a positive velocity still, its going in). In the next update, the physics simulation is sayin “hold on here a minute! we got a collision here, do some complicated maths and physics and lets get that object outta here”…hehe



the secon update, the velocity is negative, but the object is still emerged into the object because the velocity was reversed and acceleration wasn’t that great. So on dis-emerging (new term yes!) it only moved 0.1 unit.



Hope that explains it to you.



DP

To clarify: when two PhysicsObjects are in contact with each other, their ContactActions onContact method will get called every update of the physics logic. Not just the first time they come in contact.

Thanks a lot to everybody that helped me…



Fast answer and great hints…



I would like to tell you that I am very impressed by jme and jme physics… I started a week ago using it and I’ve already done the conversion from my old tennis game done with j3d standard and jme…



the api is very intuitive, the tutorials are great, the forums are full of info and the performance of the api speed and estetics is very impressive…



I’m asking myself why I did not switch before to jme.



So thanks a lot to per, Dark Prophet and shochu for their help…



I will try also to help others with the little exeprience i’ve got in 3d…



Ken