Hello Panda3d community, I,m starting my next project and I decided to built it off my prevous code, so I decided to make some optimizations to it, all was going well within the last couple of days.
However, yesterday I ran into a issue, within my code when I paired two accepts with the same conditions but different functions together, here is a example below.
So basically I have two different functions where you enter a collision sphere, one flags a variable as True while the other is a list of effects that occur when made contact, I know they work because the one on the bottom works.
So I swap them to test, and yes only the bottom registers, so what do you think is it? I think is may be panda3d thinking the top line is redundant code and ignoring it, I may have some validation to this as I have second set accept lines in another branch just above this set.
Is the conditions are different by just a bit, and both work fine as a set, so what do you think it is? does anyone have any solutions? I thank anyone who is willing to help.
Yes, a second call to accept() for a particular event name will override the first one. Could you make a function that calls both base.touch() and base.tap(), and add that function in the accept() handler ?
I can, but I would have to rewrite a lot of code because the functions differ way too much, as one is used to help a moving object act, while the other plays out a generalized effect, I guess I don’t have a choice huh?
Anyway, thanks rdb, your quick response solved my issue.
I’m not sure if this will help, but you can accept the same event multiple times if you use different DirectObject instances. The reason that base.accept works is that ShowBase inherits from DirectObject, but you can actually have any class inherit from DirectObject or create any custom instance of it.
If the two accept calls are meant for two logically distinct things (as you seem to describe), then it might make sense to have two separate DirectObject instances to handle each type of event, which would allow you to accept the same event twice.
how would I do that? and is there a way to link it back to the showcase?
Edit: well, I just went with your original idea rdb, and fused the two functions into one, it was actually more straightforward then I described, so thanks, the issue is solved (still).