collisions (again...)

So what method should I use to load an egg file as collision solid?

You should modify the egg data to contain a tag first.

does chicken have that somewhere?

Sure. The Chicken manual describes exactly how to do it.
It’s as simple as adding a Property in the ‘Logic’ panel.

Done. Now what?

You just load it using loader.loadModel, and there will be collision geometry (depending on the flags you’ve used in Blender).

so now if i want collisions with my character and wall, i would write

wall = loader.loadModel('wall')
wall.reparentTo(render)
wall.setScale(2)
wall.setPos(32,12,0)
wall.setHpr(45,0,0)

# collision box for the wall
collisionbox = loader.loadModel('collision')
collisionbox.reparentTo(wall) #same position, size, rotation, but becomes visible
collisionbox.hide()

# and for my moving character
player = Actor("player")
player.reparentTo(render)

# collision sphere for the character
collisionsphere = loader.loadModel("collisionsphere")
collisionsphere.reparentTo(player) # move with it
collisionsphere.hide()

# initialize traverser
traverser = CollisionTraverser()

# initialize pusher
pusher = CollisionHandlerPusher()

# add the collisionsphere to the traverser and pusher

traverser.addCollider(collisionsphere,pusher)
pusher.addCollider(collisionsphere,player)

:question:

wall = loader.loadModel('wall')
wall.reparentTo(render)
wall.setScale(2)
wall.setPos(32,12,0)
wall.setHpr(45,0,0)

# collision box for the wall
collisionbox = loader.loadModel('collision')
collisionbox.reparentTo(wall) #same position, size, rotation, but becomes visible
collisionbox.hide()

# and for my moving character
player = Actor("player")
player.reparentTo(render)

# collision sphere for the character
collisionsphere = loader.loadModel("collisionsphere")
collisionsphere.reparentTo(player) # move with it
collisionsphere.hide()

# initialize traverser
traverser = CollisionTraverser()

# initialize pusher
pusher = CollisionHandlerPusher()

# add the collisionsphere to the traverser and pusher

traverser.addCollider(collisionsphere,pusher)
pusher.addCollider(collisionsphere,player)

Blender settings:

Never used blender, but after you setup the tags, I don’t belive you need another collision around the player. Unless you have a need to.

Also I know it can be hard to follow, but keep re-reading collision section in the manual and follow this tuts to help get it to work.

panda3d.org/manual/index.php/Pusher_Example

Have you read the Chicken manual? The tag name must be “Collide” and the value something like “polyset keep descend” (depending on what kind of behavior you want exactly). Read up on the egg syntax documentation for the possible flags of the Collide tag.

Sorry mistaken when making the picture. its a String type and “Collide” and “Polyset. Keep, Descend” as it should be.

I get an error from a .cxx file so probably something wrong with my code and not the model?

Im using pre-made collision geometry so that isnt helping

Nono, it should say “polyset keep descend”, without dot or comma.

Did it say like that in the docs? Sorry, didnt learn in school.

Still a cxx error with this code

wall = loader.loadModel('wall')
wall.reparentTo(render)
wall.setScale(2)
wall.setPos(32,12,0)
wall.setHpr(45,0,0)

# collision box for the wall
collisionbox = loader.loadModel('collision')
collisionbox.reparentTo(wall) #same position, size, rotation, but becomes visible
collisionbox.hide()

# and for my moving character
player = Actor("player")
player.reparentTo(render)

# collision sphere for the character
collisionsphere = loader.loadModel("collisionsphere")
collisionsphere.reparentTo(player) # move with it
collisionsphere.hide()

# initialize traverser
traverser = CollisionTraverser()

# initialize pusher
pusher = CollisionHandlerPusher()

# add the collisionsphere to the traverser and pusher

traverser.addCollider(collisionsphere,pusher)
pusher.addCollider(collisionsphere,player)

What’s the error?

Anon I remade time ago ball-in-maze official demo providing blender source as well, maybe you could find something of your interest into. Click here for the whole thread and to download the sources.

Thanks, but it uses a single file for both collision geometry and normal geometry…

That’s what you’re doing right? If not, you should remove the “keep” tag.

Anyways, the error means that you added an empty collider. “frowneyCollision” is probably not a valid node.

May Chicken version 81 be the problem?

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *

# initialize traverser
base.cTrav = CollisionTraverser()

# initialize pusher
pusher = CollisionHandlerPusher()

#########

# load a model. reparent it to the camera so we can move it.
smiley = loader.loadModel('smiley')
smiley.reparentTo(camera)
smiley.setPos(0, 25.5,0.5)

# create a collision solid for this model
smileyCollision = loader.loadModel("collisionsphere")

#########

# load a model
frowney = loader.loadModel('frowney')
frowney.reparentTo(render)
frowney.setPos(5, 25,0)
# create a collsion solid for this model
frowneyCollision = loader.loadModel("collisionsphere")
frowneyCollision.show()

#########
# ADD THE COLLISION NODE TO THE TRAVERSER AND PUSHER

base.cTrav.addCollider(frowneyCollision,pusher)
pusher.addCollider(frowneyCollision,frowney, base.drive.node())

#########

# have the one ball moving to help show what is happening
frowney.posInterval(5,Point3(5,25,0),startPos=Point3(-5,25,0),fluid=1).loop()

# run the world. move around with the mouse to see how the moving ball changes 
# course to avoid the one attached to the camera.

run()

Seeing that i get an error with my code, i tried with the Pusher example, but changed collision geometry to pre-made one in Blender
Its almost the same code tho

PS. astelix, how did you get egg to Blender? I wanted to improve some models, but converters dont work for me.
Even the maze model has alot of unnecessary vertices: