UserObject of the PhysicsCollisionObject

how exactly is the UserObject of the PhysicsCollisionObject defined?

:?

if my PhysicsCollisionObject happens to be a physicsControl,

is my UserObject simply the spatial that has called addControl() to add it?

:frowning:

i am having some trouble understanding how collision() is used.

for example, if my player node is involved in a physics collision and i call

[java]

event.getObjectA()

[/java]

my return will be the characterControl assigned to my player, correct?

and if i call

[java]

event.getObjectA().getUserObject()

[/java]

then my return should be the player node which i have added my characterControl onto, correct?

and i am guessing here, but if i instead call

[java]

event.getNodeA()

[/java]

then my return would be the player node again, correct?

if this is all correct, then how would i compare these returns to the objects i am looking for so i can assign to persistent fields and perform actions on them.

i have tried

[java]

if ( event.getNodeA().getName().equals("player") ) {

final Node node = event.getNodeA();

/** … do something with the node … */

}

[/java]

taken from the tutorial on Physics Listeners, but it isnt working for me. none of my approaches seem to be working.

8O

i am pretty lost

No, you never know what A or B is. Apart from that, yes, when you use physics controls they automatically set the user object to the spatial they are attached to so you can reach it from the physics side. getNode() just returns a Spatial directly as long as its a Spatial, so you dont have to cast it.

what would be some example ways i could check to see if the objects involved in the collision are a specific spatial or PhysicsCollisionObject?

i have had no success with getName() or instanceof.

:frowning:

basically i want to check if a node was hit by a bombcontrol bullet, then remove that node from the rootnode and the control from the physicsspace as if it was destroyed.

(as if the bricks in the wall from TestWalkingChar.java were destroyed by the bullet instead of knocked over.)

i may even do a check in the future to see if the collision object implements a “destroyable” interface.