Newbie how to add collision event on SimpleRagDoll?

I am trying to add collision event (a sound) betwen ragdolls but i don't find the target in this string :

final SyntheticButton collisionEventHandler = TARGET.getCollisionEventHandler();

I tried to do the same as lesson 6… but harg! :?

I don't know where i have to declare the collisionEventHandler and the MyCollisionAction()

Please tell me how to do that.

You can get a global collision handler  if you do physicsSpace.getCollisionEventHandler()

–> all objects create an event.



Or you can get a object specifig collisionHandler if you do yourObject.getCollisionEventHandler()

–> only collisions with this object create an event.


thank Core-Dump

so i tried this

in the simpleInitGame

final SyntheticButton collisionEventHandler = getPhysicsSpace().getCollisionEventHandler();
input.addAction( new MyCollisionAction(), collisionEventHandler, false );


then

private class MyCollisionAction extends InputAction {
        public void performAction( InputActionEvent evt ) {
            System.out.println("bing");
        }


but for one collision i got 10 "bing".
I don't know why.

You will get an event once per update cycle as long as two objects intersect.



If a Sphere rolls down a floor, it generates collision events all the time.



If you want to play a sound when two objects collide you need to set some kind of timeout time between the sounds.

ok i have now information about collision

ContactInfo info = (ContactInfo) evt.getTriggerData();

how can i modify  the info.getGeometry1() first object position ?

I don't find the path to it.

take a look at tutorial.com.jmetest.physicstut.Lesson6.java in jmephysics project.

i think you want to do something similar:



            DynamicPhysicsNode sphere;
            if ( contactInfo.getNode1() instanceof DynamicPhysicsNode ) {
                sphere = (DynamicPhysicsNode) contactInfo.getNode1();
            }
            // put the sphere back up
            sphere.clearDynamics();
            sphere.getLocalTranslation().set( 0, 5, 0 );

Now i act on the object but i need to know the position.x to hit it with another object

i tried :

sphere.getPosition().x;

without success.

getLocalPosition either

did you try sphere.getLocalTranslation().x like in the code part in my earlier post?

yes of course and it's ok but it is not what i want.

i'm working on this :

http://www.vimeo.com/993580

sometimes tube are sticked and i need to hit them to unstick.

so i have an invisible object for it and i need the position of the sticked tube to hit it

i'm not sure if i understand you correctly.

What kind of physics material did you set on your tubes?

For example sponge material can stick into each other and will push each other slowly out of each other or stay stuck together.

But iron or concrete materials shouldn't be able to stay sticked into each other, they would push each other out of themselves very fast.

i use Iron matrial and FrictionCallback but i don't understand why i have this "stick problem".

Here is the all project :

http://www.santelli.name/chandelier.zip

if you want to try it;

i only have this problem to solve to finish it, it's really frustrating

Denis