Panda3d Collisions made simple

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:

Well I’m on step5 of beginner and absolutely love it.
I can actually write collision from scratch now and understand how it works (more or LESS!)

Another minor point: Took me a while to figure out what “ASA” means. I assume it’s “as soon as”?
Maybe global find-and-replace of ASA with explicit wording will be nicer :wink:

Also I have a bone to pick with you over something completely silly! In the tutorial you say that you “slim” the code by pointing both accept calls to the same function:

def collideEventIn(entry):
  colliderNode = entry.getIntoNode()
  if colliderNode.getName() == 'smileycnode':
  elif colliderNode.getName() == 'frowneycnode':
#... and this when they leave each other alone.
def collideEventOut(entry):
  colliderNode = entry.getIntoNode()
  if colliderNode.getName() == 'smileycnode':
  elif colliderNode.getName() == 'frowneycnode':

However, when I did it myself, I pointed it to different functions and I had less lines of code :slight_smile:

def heartCollisionEnter(event):
def heartCollisionLeave(event):
def brokenHeartCollisionEnter(event):
def brokenHeartCollisionLeave(event):

(Ignore the actual parameters).
But I think you should keep it pointing to the same function - because I actually didn’t know that you could do that. Maybe just remove the claim that it’s “to slim the code”.

Then again, this is really stupid thing, and I probably just need to sleeps more…

Thanks again for the tutorial.
Can’t believe this is not sticky!

that was put on purpose to keep your brain awake and working :slight_smile:

no that is neither silly nor stupid - seems you’re not the only one in need of more rest: you indeed catch another glitch and now it is fixed - I suggest you to download again the beginner package and see how looks now for you.

well I appreciate your endorsement but I guess as long as we keep finding these inconsistencies is better avoid it :wink:

keep up dude

Just as a suggestion: Maybe you should put some note in the documentation that says that models.blend has info about setting up the models so that they can be collision-able. I think that will help to point other super noobs in the right direction.

I think that’s all in the tutorials. He says you should go dig around in models.blend file to understand how to setup your models correctly.

At least I figured it out :slight_smile:
I guess you just can’t rush and have to read everything.