CollisionEvent - manipulate attributes of the fromModel


I have a simple scnene with colliding cubes. I use the CollisionHandlerEvent() to handle occuring collisions. In the method that handles an collision I want to manipulate attributes of the colliding model(mesh), like the size or the position. I’m not able to navigate to the object starting from the entry that is passed to the method, that handles the collision-event. I find the ModelRoot, but I cannot manipulate the model while ModelRoot() doesnt have methods like setPos() or setScale().

Thx for every answer

I must be totally blind. An example showing solving this problem can be found in the manual in the Collision section. Sorry for the post. For everyone who is interested in, the code:

def handleCollision(self, entry):

Now I got a new problem. Maybe someone could help.
I need the collision detection for a logic game with blocks(about 100). The blocks should fall down and stop falling when hitting another block (like tetris).
My problem is that the performance is very bad. I use CollisionRay as fromObjects, the geometry of the blocks as intoObjects an a CollisionHandlerFloor().
That is not much information and there might be several reasons for bad performance, but maybe anyone have some idea. Maybe the performance of 100 rays colliding with block or spheres is slow and I have to find another solution.

Yeah, 100 rays sounds pretty excessive. In general, you should keep the number of “from” objects low, less than 32 if possible.

PStats can be a useful tool to visualize performance bottlenecks. If PStats shows you that most of your time is spent in collisions, you know where to optimize. Of course, you’ve guessed that already, but it’s nice to have some positive confirmation before you waste time optimizing the wrong part of your code.


That is bad news. I was hoping I did something extremly wrong. Maybe i have to use a grid-system and calculate the events manually without using collisions. Maybe another solution is to enable collision detection and physics only on the necessary blocks in each game-situation.

Could you remove the ray for blocks that are stopped? Maybe try editing your block objects to only have collision geometry on the top (assuming they are just falling down and stacking Tetris style)

There will be situations, when many blocks(nearly all) have to fall down. In this situation the performance will be as bad as now.

It does sound like doing it by hand may be the most robust solution, since this is such a specialized case; but if you want to use Panda collisions to do it I’d recommend using spheres instead of rays and polygons. If you’re making a Tetris-like game, each box is basically a single point anyway, and there’s no reason to model it precisely. Using an arrangement of spheres, one sphere to each cell of the block, should be perfectly adequate for collisions, and should result in a reasonable handful of spheres as “from” objects.