Panda3d Collisions made simple

you don’t say what file you modified in but anyway never mind, pick the step1.py from the advanced folder, and just modify like this

def avatarwalk(dt, vel): 
  return

that function at line 217 and the shake is gone. About how to animate your character, that is a matter outside this tutorial I’m afraid - check the panda3D manual for this but keep in mind that you’ll have to play with the function above, the other called avatarjump and if not enough open the snipstuff.py file in the same folder, study it and modify it as you need.

my other question is, i saw in one of the file where you have a rotating ball avatar around, it had this thing were it said something like this: if iv > 42:

i tried: if avatar.getZ > 42
but it failed, nothing happened :frowning:
i have tried checking some python manuals but no help :-\

You need parentheses, otherwise you are comparing the actual function to 42 instead of what the function returns.

if avatar.getZ() > 42:

I also had them, but still they didnt work.

mojy1234, you should try to help me out to help you: which file in which folder and which line are you talking about? And also: what are you trying to achieve with that?
Being obvious like this we both go faster to the point.

I’m talking about:

folder: collisions-intermidiate
file: step3.py
line: 210
line’s text: if iv > 42:
what i changed it to: if avatar.getZ > 5:
problem: it wont do it.

edit: im also trying to edit the collisions-intermidiate snipstuff.py line: 164 and 165
im trying to make it rotate right and left, not move left. I try: def right(self, avatar): return avatar.setH(avatar, 2) but it would’nt work i get the error: **** End of process output ****
Traceback (most recent call last):
File “snipstuff.py”, line 13, in
base.setFrameRateMeter(True)
NameError: name ‘base’ is not defined

**** End of process output ****

It’s getZ(), not getZ.

Also note that the error message:

NameError: name 'base' is not defined

means this error has nothing to do with getZ or getZ() or any of that other code you’re asking about. You’ve got something else wrong with your code; somewhere there’s a reference to base where it doesn’t belong.

David

and my piece of advice is: roll back to the original snipstuff.py and start again - that ‘base’ error is something that make me guess as well you broke something important. Don’t be afraid (or lazy) to start again things, it is the best way to learn IMHO.

OK. I have the collisions working now with my own key system (forget snipstuff.py… :stuck_out_tongue:)

My problems:
I tried making a flying actor but failed…
Link for the code: dpaste.com/hold/273238/

It wont:
Fly, Play animation, and when i click space all the other keys get messed up, they dont play their anims… Any idea?
And how do you place the camera in Scene editor? I need to place the camera but it wont let me in the scene editor

Hey, thanks for the great tutorial! It’s very well put together and the blend file included was very very helpful.

in the intermediate script you’re only looking for “wall_collide” and the only object that is named that in the blender file is the wall cube. So how is it that the character also can’t walk through the diving boards and the house, especially since there’s nothing in the code or the blender file I can find that marks them as impassible.

Thanks!

Great work on the tutorials… I’m beginning with collision detection in Panda3D and I’m sure this will help a lot! Thanks!

Your great tutorial collection about collisions in panda3d is a big step forward to learning panda…thanks…and again thanks…and again…!

thank you

Just discovered this tutorial. Very helpful, thanks. I did discover a bug, however. When I run step7.py in the beginner’s tutorial, I get the following backtrace:

DirectStart: Starting the game.
Known pipe types:
osxGraphicsPipe
(all display modules loaded.)
Traceback (most recent call last):
File “/Developer/Panda3D/lib/direct/showbase/EventManager.py”, line 61, in eventLoopTask
self.doEvents()
File “/Developer/Panda3D/lib/direct/showbase/EventManager.py”, line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File “/Developer/Panda3D/lib/direct/showbase/EventManager.py”, line 124, in processEvent
messenger.send(eventName)
File “/Developer/Panda3D/lib/direct/showbase/Messenger.py”, line 325, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File “/Developer/Panda3D/lib/direct/showbase/Messenger.py”, line 410, in __dispatch
method ((extraArgs + sentArgs))
File “/Users/maria/python/panda/collision_examples/collisions-beginner/snipstuff.py”, line 40, in toggle_collisions
base.cTrav.showCollisions(base.render)
AttributeError: ‘int’ object has no attribute ‘showCollisions’
:task(error): Exception occurred in PythonTask eventManager
Traceback (most recent call last):
File “step7.py”, line 64, in
run()
File “/Developer/Panda3D/lib/direct/showbase/ShowBase.py”, line 2531, in run
self.taskMgr.run()
File “/Developer/Panda3D/lib/direct/task/Task.py”, line 496, in run
self.step()
File “/Developer/Panda3D/lib/direct/task/Task.py”, line 454, in step
self.mgr.poll()
File “/Developer/Panda3D/lib/direct/showbase/EventManager.py”, line 61, in eventLoopTask
self.doEvents()
File “/Developer/Panda3D/lib/direct/showbase/EventManager.py”, line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File “/Developer/Panda3D/lib/direct/showbase/EventManager.py”, line 124, in processEvent
messenger.send(eventName)
File “/Developer/Panda3D/lib/direct/showbase/Messenger.py”, line 325, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File “/Developer/Panda3D/lib/direct/showbase/Messenger.py”, line 410, in __dispatch
method (
(extraArgs + sentArgs))
File “/Users/maria/python/panda/collision_examples/collisions-beginner/snipstuff.py”, line 40, in toggle_collisions
base.cTrav.showCollisions(base.render)
AttributeError: ‘int’ object has no attribute ‘showCollisions’

Oops, forgot to say what I did to cause the crash. I hit the c button, which is suppose to toggle collisions. I think this is because there aren’t suppose to be collisions in this tutorial, which I didn’t realize when I clicked it, since I always look at the game first before reading the code, so I can try to figure out what it is doing, and what I expect to be in the code. So, it’s no big deal, but I think the c should just do nothing, not crash.