Panda3d Collisions made simple

I don’t think so, because someone who wants to programm with Panda will at first look into the manual. And there you find a link, directly after the “Getting Started” tutorial.

Seems like a good idea. I wonder if there is a problem if we’ll add some links to snippets without asking the authors?
Ive seen something similar on other engine wikis. Categorizing the snippets like that will make others find it easier.

@astelix:
Hm, I think there is a bit misunderstanding here.
I’m familiar with the floor and pusher collision handlers and thats what I use for my characters and npcs.
But they don’t seem like an option for my camera system.
I have tried them both for cameras.


How the camera controls work is like this: the camera is parented to an empty node, which is in turn parented to a ‘target’ node. I move the camera along y, and when I rotate the empty node (its parent), the camera will ‘orbit’ around it. So y here is the distance between the camera and empty/target.
With the custom event handler I change the y value only. There really isn’t a need of telling the camera to lookAt() the target (empty) node each frame.

If I’ll use a pusher, not only the y value will change, so I’ll need a task to tell the camera to look at the target. I can do that, sure.
But like I said I have tried using a pusher before. Some of the problems I can remember now were, like I have a limit for a camera distance, but the pusher could move it too far away. Or the pusher could get the camera stuck on a wall between the camera and target. In these cases I would still end up using an event handler…

What I ment by switching to collision ray was I could check if there isn’t a collision happening between the ray and ground to zoom the camera instead (ray is below ground), so the camera wouldn’t never ‘stop’ under ground.But then I would still be using a sphere for the walls.

Like I said, the manual talks about this situation and mentions setFluidPos() method, but I’m changing the rotation here, not position, and there doesn’t seem to be a setFluidHpr(), which I understand. I cant think of any other use of it unless you have a child that is inheriting its parent’s rotation (like here).

Sorry for the long post

sorry Fero63 but I’m unable to find that link - could you point me the manual page link where to find it out?

your explanation clears very well how your cam works but I don’t see the pusher thing so off nonetheless provide you keep a couple of precautions:
the major problem is that the pusher collisions could end in harsh and abrupt movements, something to avoid for camera movements that need to be smooth but that is achievable using a dummy with collision sphere (w\ attached pusher collider for walls and ray for floor) in place of the cam - the cam will follow that dummy using well calibrated position lerps. For the stuck problem I guess you’ll solve it using a big enough collision sphere size to not get stuck in the smallest corners of your map. Anyhow I’m starting to think to try by myself that ideas and if they works I’ll make a snippet out of it, cos the issue is quite interesting.

Its in the table of contents, “G: User Contributed Tutorials and Examples”, which send you to panda3d.org/manual/index.php/U … d_Examples
It is pretty outdated and not many seem to be using it these days.

About getting stuck on walls, I ment something like this:

And thats just a wide wall, it can literally get stuck on other shapes.

cool

I was asking the page that point to the page you (and Fero63 before) cite.

after a good sleep and a better mumbling, the best solution I found adopted by big companies is to keep the walls not collidable w/ the cam and make them transparent between the cam and the dummy - in some RPGs I saw the ceilings/roofs disappear as well if the cam is above them - that is the overall best for me - to sum up: just collide with the floor and make all stuff interposing the cam transparent or disappear - you may use advanced step1 to know what in between the cam frustum and the dummy

panda3d.org/manual/index.php/Main_Page , G

About applying transparency, I’ve seen that too, but I don’t want to use it for my outdoor scenes. I’ve also seen games that zoom closer to target like I do.
I can’t explain why I don’t want to use that method, it just doesn’t look nice to me, “there is not to be discussion regarding tastes” I guess.

I never put your issue in that way - writing a game one should put above all to reach the best gameplay possible, tastes are irrelevant here, I think: you got in mind a camera movement and so you gotta find the best way to show to the player your game with that but without piss him off with camera shakes or sudden movements or annoying zoomings - I’m seeing that kind of quirks in very recent games as well so I know this is a very hard issue to manage and that above was best suggestion I can give to you. I’m looking forward in what you’ll came out with anyhow, if you’ll be willing to show us.

What I ment was: you think adding transparency to walls is less hassle for the player than zooming the camera closer to the character. And think the opposite. That was what I ment by ‘taste’.
I’ll let you know if I find a solution.

You go to the top of this page. Under “Documentation” you will find a button “Manual”. Click it a you will be forwarded to the Manual’s main page. There you will find the link I mentioned as point I.G. :wink:

Very good samples for Panda3d newbies and not so newbies, thank astelix, Why dont you add a simple camera collition sample??? it will be very helpful for everybody.

Thanks for this great Tutorial, and for the working examples.

I think the Panda Manual is not the best in this Section.

sorry guys for the late reply - I was off-duty for a while
thank you for your nice feedbacks

It is on my schedule indeed to make one - more later than sooner (gotta finish another project first) but I mean to make one. BTW - any suggestions on how to shape it and what to put into?

Thanks A million! This made Collisons so easy!!! at first i looked at roaming ralph and ball in maze… and i was like Wha??? but this just made it SO simple!!!

I had a little question, Can you make a sample for Characters?

I know there is a Roaming Ralph, But that is SUPER hard, Your’s is Super Easier! I tried editing a bit of your code to make it a character but it wont Exactly work… i get loads of errors… Can you make a Sample with a Character like ralph in it? Thank you! :wink:

you’re welcome mojy1234
provided that my limited spare time won’t happen that just tomorrow, I’m going to make a fat panda roaming around an uneven terrain with camera collision. Hope that will be enough for you.

I’ll add my thanks to this thread. Have got my chars moving on uneven terrain now.

Quick question, is there a simple way to implement flying chars? I had just adjusted Z pos previously, but as I’m now looking to integrate CollisionHandlerFloor (or Gravity) they obviously start drifting back down :slight_smile:

I was able to remove the char nodes from the traverser when tehy go into flying mode which semed to work , but have not been able to add them back in when they stop flying. Not sure that’s the best way anyway. Any tips?

Thank You So Much!

Tell me When its Posted :wink:

Thanks alot for spending time trying to help people like me :slight_smile:

Is the Character sample done yet…? :question:

I’m sorry mojy1234 but still ain’t not time - why don’t you try by yourself? it would be a good chance for you to practice what in this tutorial: btw it is all there: if you change the ball character with another one, also animated, it should work. Just try it, and if you get some trouble post it here so I’ll try to help you out.

My problems are,

I edited the file so that the ball wont rotate, and then i replaced the ball with my character model, but the problem is when i move it, the character shakes a little. That means it goes rotates forward a bit then rotates back a little (though i removed the rotate ball feature) and i dont know how to make it so that when the character is running loop an animation and when it is not running loop another animation. Is it the self.enabled thing?