Collision not at the right position

Hi,

I have a problem : my collision solid are not at the right position, they shift their position the more they are distant from the center.

See the picture :
http://img594.imageshack.us/img594/6408/screenshot2010102701143.png

The sphere should be at the same place as the plants.

Here is my code :

self.forest = render.attachNewNode("Forest Root")
self.nbFood = randint(self.minNbFood, self.maxNbFood)
for i in range(self.nbFood):
    t = loader.loadModel("models/shrubbery")
    t.reparentTo(self.forest)
    t.setScale(0.1)
    t.setPos(
            (randint(0, self.floorSize-1) - (self.floorSize / 2)) * self.flagSize, 
            (randint(0, self.floorSize-1) - (self.floorSize / 2)) * self.flagSize, 
            0)
    tColl = CollisionSphere(
            t.getX(), 
            t.getY(), 
            t.getZ()), 
            10)
    tCollNodePath = t.attachNewNode(CollisionNode('tCollNodePath'))
    tCollNodePath.node().addSolid(tColl)
    tCollNodePath.show()

Hopping someone can help me.

Thank you.

Hi, no time to offer a solution (very sorry!) however it looks as though your bush/shrub model is off-center, there is a programatic way to find the center using getBounds, or you can simply center it in your modeling tool before exporting it.

~powerpup118

The X/Y/Z values you provide to CollisionSphere are relative to its parent, not an absolute position. So you might want to give it a bit of Z to raise it up relative to “t”, but X and Y should be 0.

Thank you, it works with the collision position set to 0. :wink: