Hi, I have some code to make colnodes.
self.colNode[x] = self.zombie[x].attachNewNode(CollisionNode("z"+str(x)))
self.colNode[x].node().addSolid(CollisionTube(self.zombie[x].getX(), self.zombie[x].getY(), self.zombie[x].getZ()+10, self.zombie[x].getX(), self.zombie[x].getY(), self.zombie[x].getZ()-10, 10))
But they are not spawning in the right place! Quite a bit off from the zombies, actually. I’m pretty sure I’m doing it right, what’s going on?
You’re reparenting the collision nodes to your zombie, which means they are in the zombie’s coordinate system. So, in zombie-space, the position of your collision nodes should really be (0, 0, 0), which means they won’t be translated relative to the parent zombie.
Instead, you’re setting them to the same position as the parent, so this translation gets doubly applied. Just remove the setPos line and it should work.
Hi, Thanks for the reply.
I tried removing the setPos line, and the collision Tubes are way off from the zombies. Does anyone know what’s happening? I think it has something to do with placing the tubes, can someone tell me how to correctly place them?
Well, you’re adding the zombie pos again to the tube vertices. Don’t do that; just create a tube at 0,0,0 with something like CollisionTube(0,0,0, 0,0,1).
Looks like you are passing absolute coordinates (using the position of zombie) to CollisionTube. You should only have to give coordinates relative to the zombie. Basically the same problem problem as doing a setPos. Both problems should be corrected.