Misplaced CollisionPolygon??

Hi, and thanks for your attention.

I really can’t figure out why my collision triangle is misplaced.

I am trying to place it with one vertex at the same coordinates as the model (a building) - but it appears outside the building; at a distance that I think is proportional to the buildings distance to (0,0,0).

I am even assigning a variable (named position) to the position to be sure to keep track of it.

The funny thing is that if I # the loadModel then the Triangle is placed where I want it to.

Here is the code:

self.building = loader.loadModelCopy(“models/BuildingCluster3/BuildingCluster3”)
southernTriangle=CollisionPolygon(position , position+Vec3(0,0,10) , position+Vec3(10,0,0))

southColl.show() #TBD when done

The model is from alice.org/pandagallery/City/BuildingCluster3.zip

I note that you are attaching the polygon to the node self.building. But you have already done self.building.setPos(position)! Remember that a node always inherits its transform from the parent, so that means your collision polygon is inheriting a transform that adds position to its x, y, z–which is also set to position. So the resulting net position of the first vertex of your polygon will be 2 * position.

If you want to put the polygon at the building’s origin, just define it like this:

southernTriangle=CollisionPolygon(Point3(0, 0, 0), Point3(0,0,10) , Point3(10,0,0))


Ahh now I get it! Thanks a million drwr.
I wasn’t aware (ermm, forgot to think :blush:) of the inheritance of the transformation.

Now, in my game I want more than just one building at (0,0,0).
In fact I want 16 buildings, spread out in a well-defined pattern.
But I am pretty sure I can make the transformation of the coordinates myself, now that you have helped me.