Very simple push collision help

I’ve got this being set on my collision geometry:

colGeo = CollisionNode('world')
colGeo.addSolid(colBlock)
colGeo.setCollideMask(1)

Then, over by my player controls:

    def setupCollision(self):
        self.cnode = base.camera.attachNewNode(CollisionNode('cnode'))
        ct = CollisionTube(0,0,0,0,0,-1,1)
        self.cnode.node().addSolid(ct)
        self.traverser = CollisionTraverser('playerCollision')
        self.traverser.showCollisions(render)
        self.pusher = CollisionHandlerPusher()
        self.pusher.addCollider(self.cnode, base.camera)
        self.traverser.addCollider(self.cnode, self.pusher)

Then, in my task update loop:

self.traverser.traverse(render)

Now, because I have the line:

self.traverser.showCollisions(render)

I can see the collisions, it’s just not stopping me.

:collide(error): Invalid attempt to detect collision from CollisionTube!

This means that a CollisionTube object was added to a
CollisionTraverser as if it were a colliding object.  However,
no implementation for this kind of object has yet been defined
to collide with other objects.

What am I missing?

Thanks!
ZM

Just what the warning says: you cannot add a CollisionTube to a CollisionHandler. You can only add a CollisionSphere, or a CollisionRay/Line/Segment.

David

Thanks David,

I just assumed I had done something wrong in my set up. Will there be better support for collision tubes in the future? It does match my player a lot better then a sphere or spheres.

Not likely, due to the mathematical difficulty involved with efficiently intersecting tubes with many other geometrical shapes.

You could use multiple spheres on top of each other to approximate the shape.

Alright, I’m working with spheres now. While I’m working on building the engine, I have a first person controller that lets me fly around the world, using “space” to increase the Z vector, and Q to decrease the z vector. When I’m facing a wall/floor and am moving toward it the collision works just fine. However, if I use the Q/Space option to move up and down I seem to be able to fly right through the world.

Is there a way to test to see if I’m just moving too fast and need to look here:

panda3d.org/manual/index.php … ng_Objects

Or if my problem is something else entirely? I don’t think I’m moving too quickly:

 if (self.keyMap["forward"] != 0):
            base.camera.setPos(base.camera, (0,0.2,0))

The reason I don’t think I’m moving too quickly is that if I set that from 0.2 to 0.1, I still go right through (but I’m not sure what constitutes fast moving in Panda).

Thanks!
ZM

Try changing the setHorizontal setting on the CollisionHandlerPusher; it controls whether it should also work on the vertical axis.

That helped some, it seems to be a problem more if I change my collision sphere’s size to be less then 1. I’m trying to find a good balance.

Edit: I think I will have to use a collision polygon, as my world is a cube world and I get weird collision issues with a sphere…I’m hoping the cube fixes it.

Alright, collision poly suffers from the same lack of implementation as the collision tube. Back to spheres.

I’m parenting my collision spheres to base.camera, is there a way that I can easily prevent the spheres from rotating? I basically want to do a (0,0,0,1) and (0,0,-1,1), so that it looks like this:

  O
  O

However, since I’m using a first person style controller, when I rotate, it ends up looking like:

  O
 O

or

  O
   O

(please excuse the ascii representation :wink: )

I’ve been trying a couple of things, but it seems like I recall a built in Panda function to freeze the rotation, but I’m not finding it.

I think what I’m looking for is a way to only inherit the position from the base.camera node, and not the rotation. Is that possible?

You can run a task to reset the rotation every frame, or you can parent to a different node that doesn’t inherit a rotation.

David

Please pardon the stupidity, but is there a “clear rotation” function that I can be using each frame? It’s easy enough to throw into my task manager that I think that’s the route I want to go.

EDIT: Never mind! I got what you’re saying! :slight_smile: