Collision solids on instances

Hi to all; I’ve been travelling a lot these past few weeks hence my absence.

I have a few models that I load and then instance later on; the models have collision solids within them that are meant to be used as INTO collision objects. I’m using procedurally generated terrains and then to fill up the terrains I instance the loaded models onto the newly generated terrain.

For the collision FROM object as I am at the testing phase of my project I simply use ralph and wrap a collision sphere around him like so:

ralph = Actor("samples/Roaming-Ralph/models/ralph",
anp = ralph.attachNewNode(ActorNode('actor'))
cs = CollisionSphere(ralph.getBounds().getCenter(), ralph.getBounds().getRadius())
cnodePath = anp.attachNewNode(CollisionNode('cnode'))
pusher.addCollider(cnodePath, anp)
travz.addCollider(cnodePath, pusher)

That should be all it takes for collisions to occur right? But no collisions are occurring. The screenshot below shows: a->the collision sphere around ralph and b->the collision sphere around the instanced model. So it appears that all the collision solids are being properly loaded and parented to their respective nodepaths; but nonetheless no collisions are occurring. What am I doing wrong?

Thanks in advance.

Well, firstly, the second argument to pusher.addCollider is the node that will be pushed when a collision happens. In your case, you are passing a node that is attached to the ralph model. This means that when a collision happens, the child node of ralph will get moved around, but not ralph itself. Perhaps you should try to pass in “ralph” itself, or perhaps a node that is a parent of the ralph model. I can’t say I’m too familiar with PhysicsCollisionHandler though.

Secondly, does your terrain have collision geometry?

Hi rdb;

Performing your suggestion regarding the collision issue and passing ralph as the second argument yields this error:

Assertion failed: target.node()->is_of_type(ActorNode::get_class_type()) at line
 212 of c:\buildslave\release_sdk_win32\build\panda3d\panda\src\physics\physicsC
Assertion failed: validate_target(target) at line 117 of c:\buildslave\release_s
Traceback (most recent call last):
  File "", line 684, in <module>
    pusher.addCollider(cnodePath, ralph)
AssertionError: target.node()->is_of_type(ActorNode::get_class_type()) at line 2
12 of c:\buildslave\release_sdk_win32\build\panda3d\panda\src\physics\physicsCol

Next; even though the node is attached to ralph shouldn’t a collision occur on it? But none occurs. Changing to “CollisionHandlerPusher” still gives the same result; no collision occurs:

ralph = Actor("samples/Roaming-Ralph/models/ralph",
cs = CollisionSphere(ralph.getBounds().getCenter(), ralph.getBounds().getRadius())
cnodePath = ralph.attachNewNode(CollisionNode('cnode'))
pusher.addCollider(cnodePath, ralph)
travz.addCollider(cnodePath, pusher)

As you can see from the above image the collision solids parented to ralph and the instance of the boulder model intersect. Could the error be connected to instancing? To instance the boulder model this is what I do:

#load the model:

#... instance it later on when necessary:

#note->the boulder was added to a list that will be referenced whenever the player enters a biome that it [the boulder] belongs to; so the above obtains the model
#from the list using its index therein.

As for the terrain no it does not have collision geometry; I am using the GeoMipMap method to generate procedural terrains so I just use the “getElevation()” method to position the various models/actors at their respective heights within the terrain given their x and y coordinates.

Sometimes I’m such an idiot :blush: …turns out I forgot to do this:


Right after I created the traverser. Adding that line solved everything.