Panda3d Collisions made simple

ok I update the package(s) - MMichaud I suggest you (and of course the other ppl) to download again the whole stuff cos I found some other inconsistencies to be up-to-date.

Also check out the Logic panel in Blender ( F4).
This is where you set some of your objects to act as collision geometry.
@Astelix: nice job. A lot easier way to learn collisions than RR sample.
How about adding the line


or other billboard effect to the jumping minigame?

if youre rferring to the windmill minigame I guess I can’t apply that to the avatar - dunno if happened to you playing to fall your avatar off a certain heights but if you do you’ll see I need the avatar to stay stick parallel to the ground so I guess using billboard I shouldn’t get the same effect.

Minor changes applied:
addeed a step0, a very easy and minimal introductory snippet for real noobs with whatsoever knowledge of collisions - just to break the ice.
Alsp lighted down AMAP the package file sizes, really squeezing bytes for those fellas with bandwidth shortage. the intermediate package is still no less than 5MB but really can’t go down more.

I dont think I am explaining my troubles correctly. I’m not a n00b when it comes to programming. I have know Python for 3 years now and know Java pretty extensively too. I’m only new to the 3D scene. I dont know how to edit the model files so that they are collision-able.

“heartCollider = heartModel.find(”**/collider_heart")"

where is it looking for “/collider_heart"? How do I give my models a "/collider_heart” (obviously without the “heart”)?

no fear that when you said “newbie” I got indeed you’re just a panda3D newbie, not a newbie in everything :wink:
Anyhow, not getting what you’re asking for reveals you haven’t read or got the infos I provided in the models.blend file in the beginners package that cite:

so now I’m asking you: did you opened the models.blend file and read that? And if yes, what it is not clear to you there, so that I try to make it clear the better?

I did not open models.blend. How did you make the sphere in Blender?

Other than that last question I think I understand everything now. That was really the last piece of the puzzle. Thank you so much for you help I really appreciate it.

can’t help you out here fella, by lack of time - here you’re on you own - I assumed Blender knowledge in this tutorial so you gotta check the blender documentation on Blender’s website I guess. Keep up

Well I know how to make spheres, I’m not a moron. But how do you specify a certain object to being for collision purposes?

why do you assume I’m offending ppl like that? I’m here trying to help you not to making you see as a moron, but you are doing no effort to look otherwise. If you inquire me with:

what do you think I understand off that sentence?
Then you said:

I already pointed you above. Can’t see how to be more clear than that. The last suggestion I can do above this topic is to read again more carefully the beginner and to look again inside the models.blend file with the same care and you’ll certainly succeed.
good luck

Did you by any chance mean how to make a COLLISION sphere? Because what you wrote was a bit confusing.

You should have, the text in the Text Editor view explained what you wanted.

  1. select your object (the sphere)
  2. go to the Logic Panel (from Buttons Window):

If you want to set your object to be exported as a panda collision object, youll need to Add Property ,change the Types to String ,write ‘Collide’ as the name and on the left window from the Name window, add the parameters. I think you can change their order but write them separeted with spaces (no commas). ‘Sphere’ parameter tells the chicken exporter to export it as a sphere collision geometry, dont remember what ‘descend’ does , but the chicken manual found in the chicken archive explains that:

…okay, maybe it doesnt?..

The html doc can be found in bpydata/chicken/doc.html

Haha! I found more resources! Great stuff. Should keep me busy for a while…

I think you should show more respect here. Otherwise you won’t get any questions answered.

I apologize for sounding disrespectful. I highly revere this dude, he has helped me more than I can say. I think I’m good for now. Thank you again for your help, you’re a saint.

:laughing: haha that’s what my woman say every time she made something that needs to be forgiven, but that’s not your case MMichaud and you never sounded disrespectful to me. Just a little lazy to read manuals and comments, a very used habit by coders, especially young ones (like I was) - that’s what I tried to point you out so far.
keep up dude :wink:

I have a question:
How come you don’t set any INTO or FROM flags in tutorial?

Is it because all objects are automatically assumed to be INTO, unless they are added to CollisionTraverser?

Also I have a question, why is it that I get “name base is not defined” error if I do my imports like this:

import snipstuff
import direct.directbase.DirectStart

but it works if I do them the other way?

import direct.directbase.DirectStart
import snipstuff

EDIT: I think I figured this one out… DirectStart initializes a whole bunch of global variables (including base), and snipstuff accesses base - so it has to be imported after DirectStart.

Also, in the traverseTask function, why do you need a for loop, it never runs more than one iteration:

def traverseTask(task=None):
  # as soon as a collison is detected, the collision queue handler will contain all the objects taking part in the collison
  for i in range(collisionHandler.getNumEntries()):
    # we'll turn on the lights, to visually show this happy event
    snipstuff.dlight.setColor((.5, .5, .5, 1))
    snipstuff.info_message("Smiley is now touching Frowney!")
    if task: return task.cont

  # If there are no collisions the collision queue will be empty so the program flow arrives here and we'll shut down the lights and clear the text message
  snipstuff.dlight.setColor((.0, .1, .0, 1))
  if task: return task.cont

Can’t we just replace it with this?:

def traverseTask(task=None):
  if collisionHandler.getNumEntries() > 0:
    snipstuff.dlight.setColor((.5, .5, .5, 1))
    snipstuff.info_message("Smiley is now touching Frowney!")
    snipstuff.dlight.setColor((.0, .1, .0, 1))

  if task: return task.cont

yo, cool down you submerged me with questions! :wink:
one thing at a time:

It is all wrote - citing line 50:

# ...and then we add it to the panda collision routines telling also that this is handled by the collision handler defined above. Afte issued this command the smiley become a true FROM collider object.
base.cTrav.addCollider(smileyCollider, collisionHandler)

and this is line 53:

#** This is the frowney model that will intereact with the smiley - it is shaped and settled exactly as smiley so there isn't much to say here, other than this time we won't add this object to the main traverser because we wanna assign to him just a INTO role.

I find not hard to admit my English is not awesome but: is it so bad or rather you guys really do not read what I wrote there? :wink:

About the second post yes you figured that alone correctly.

The third answer is obviously yes, but it is true just for that situation and that solution is off the logic of that routine. However you found indeed a piece of code screwed I must fix even if works right now, because may confuse ppl. To see a better CollisionHandlerQueue sample jump to

Thanks for responses!

I guess the words “true FROM collider” confused me. I guess something like this would’ve been more clear:

# ...and then we add it to the panda collision routines telling also that this is handled by the collision handler defined above. After this command the smiley becomes a FROM collider object.


#** This is the frowney model that will intereact with the smiley - it is shaped and settled exactly as smiley so there isn't much to say here, other than this time we won't add this object to the main traverser. This makes him an INTO object.

It’s just I was expecting you to set some kind of BIT masks here (like in some panda sample tutorials). But now I am more clear - all objects are INTO objects by default, and if you adding them as colliders, they also become FROM objects.


you’re welcome

suggestion taken and snippet fixed - keep pointing kinda discrepancies if you’ll find others (I bet you will :wink:)

you’ll find bitmasks in following steps - go ahead, you passed the novice levels bigtime :wink: