Can Panda3d grab boolean values created from blender's "Logic Editor"? (Answered, Solved)

Hello once again panda community, I ask not of a problem, but rather a question, while I was doing research on panda’s collision, I found a few articles online that said Blender 3d can do it through it’s logic editor.

What I experienced and observed was that blender at least with string values can be set up in blender’s logic editor and passed through to panda3d (though, I still do not know how to do that from panda’s end).

I was wondering if the same can be said with boolean values, what I want to do is embed boolean values into my models, so that using panda’s collision engine, when the player collides into said object with a boolean value, I can use code to grab it and see if it returns True when the two meet.

Much thanks to anyone who is willing to help.

Yes, you definitely can. They will be exported as string tags with the respective strings “True” and “False”. You can easily check this when colliding using getNetTag. Or, if you are using collision events, you can configure it to send different events depending on the value of a tag.

You can also find all nodes with a specific property value using something like this:

for path in model.findAllMatches("**/=tagname=True"):
   print(path)

Thanks, I’ll get to researching, but just in case I don’t find anything, how would be this implemented in blender? I read in a article yesterday where someone used the logic editor and gave the “Game Property” as it is called in blender, the name “Collide” and the string value of “Polyset keep descend” to create a wall.

if I read correctly and assume right, I would create a game property named "Collide, then give it the string value of “Polyset True False”, “Polyset True, False”, or “Polyset True and False”, right?

So after a day’s worth of research and observing examples in panda’s documentation, it seems I may have a problem, it seems that standard collision handlers have 3 states, one, if two met just once, two, if two continue to meet, and three, if two are no longer met.

So my issue is, how would this translate to my boolean idea? rdb said it would be exported with both values, but what I was looking for was a boolean to return true as long as the two objects are collided with each other, it seems I may have to use standard handlers for my needs, hmmm.

Sorry, I’m a little confused by what you were expecting to see. I thought you wanted to assign custom properties to a model in Blender and read those out in Panda3D in a collision event, but your other posts seem to ask for something else.

If you want to know whether two objects collide or not, you can use a queue or event handler. For example, you could use the event handler to set a property in a dictionary based on the value of a tag, which you can easily read out in the event. You would have the “in” event set the property to True and the “out” event set the property to False. Then it sounds like you end up with something similar to what you want.

If you create a game property in Blender called “test” then you can read it out in Panda3D on collision using entry.getIntoNodePath().getNetTag("test")

My question is this: what is the purpose of your boolean values? (And perhaps describe to us a hypothetical example of it in action.) If we understand what you’re trying to achieve, we might be better able to suggest a solution. :slight_smile:

Sorry, I was not being clear enough, I asking for a vary simple way for panda to say if something collided with something else and thought I can implement a simple true or false system without really thinking, I had the strange idea that the model with a boolean value would be false at all times until it was collided with.

My apologies for the confusion.

Edit: I like the event handler idea, and try it out today, thank you.

I was confused, the idea was I thought when the boolean value was implemented into the model, it would remain false at all times until it was collided with and until the collision continues it would return true, but I never thought (yet, then) about the what objects would collide for it to return true, or the type of collision.

apologies for the confusion.

Aah, I see. (And don’t worry about the confusion.) Thank you for explaining! :slight_smile:

rdb’s suggestion of an “event” handler is a good one, I think. Indeed, having Panda say “this collided with that”, or “this stopped colliding with that” is a big part of what that type of handler does, I believe!

I you haven’t found it already, I believe that the manual gives some detail and example code on using Panda’s collision system, starting with this page, and continuing on for several pages. (There’s even an example of using an “event” handler.)

so, yeah I was looking at that and learning the event handler, but ran into a problem along the way, and I,m wondering if you (or anyone) can answer this, I,m trying to implement the .find feature and I keep getting a error:

/collsioninerror/Main.py", line 163, in init
base.cTrav.addCollider(scenebounds, collisionHandler)
AssertionError: !collider.is_empty() && collider.node()->is_collision_node() at line 104 of panda/src/collide/collisionTraverser.cxx

I did some quick searching on the internet for help and found a thread on these vary forums that had a similar problem here: collisions in egg files but when I tired the solutions I still got a error, so I assume that it is my misunderstanding in the syntax then.

I have included my script for evaluation here: colasrterror.zip (373.6 KB)

Hmm… If I’m reading this correctly, and I’m not much mistaken, I see two problems.

Looking at “scenetest.egg”, I see an object named “Plane”, which has a tag named “solidness”, with the value “Polyset keep descend”.

I’m guessing thus that in Blender the object in question is named “Plane”, and that in the logic panel you have a property named “solidness”, with the value “Polyset keep descend”.

In your code, you’re searching for an object named “solidness”, which is expected to be a collision object.

The first problem, then, is that you’re searching for the object by the wrong name–it’s name is “Plane”, not “solidness”. (If you wanted to search for it by the name of a tag, such as the “solidness” tag, that can be done–but see the next point.)

The second problem is that, if you want the object to be exported as a collision object, then the tag’s name is incorrect. If I’m not much mistaken, a collision object is indicated by a tag with the name “Collision”, with an appropriate value (in your case “Polyset keep descend”). That is, in Blender’s logic panel, you would have a property named “Collision”, with the value “Polyset keep descend”.

(I’m not sure of the capitalisation–if it doesn’t work with capitals, try it in all-lowercase.)

oh, okay, then I’ll try you suggestion right away, thank you vary much.

Edit: so your suggestion worked with a bit of tweaking, thanks.

I managed to get the collision accepting events and almost achieved the type of collision I asked for with event handling but I ran into a issue.

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/EventManager.py”, line 47, in eventLoopTask
self.doEvents()
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/EventManager.py”, line 41, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/EventManager.py”, line 98, in processEvent
messenger.send(eventName, paramList)
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/Messenger.py”, line 333, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/Messenger.py”, line 418, in __dispatch
result = method ((extraArgs + sentArgs))
TypeError: touch() takes 3 positional arguments but 4 were given
Traceback (most recent call last):
File “/Users/mac/Desktop/alfincol/Main.py”, line 403, in
app.run()
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/ShowBase.py”, line 3047, in run
self.taskMgr.run()
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/task/Task.py”, line 531, in run
self.step()
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/task/Task.py”, line 485, in step
self.mgr.poll()
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/EventManager.py”, line 47, in eventLoopTask
self.doEvents()
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/EventManager.py”, line 41, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/EventManager.py”, line 98, in processEvent
messenger.send(eventName, paramList)
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/Messenger.py”, line 333, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/direct/showbase/Messenger.py”, line 418, in __dispatch
result = method (
(extraArgs + sentArgs))
TypeError: touch() takes 3 positional arguments but 4 were given

So thin ice close too! Okay, what I did was try to replicate the keys input code from the roaming ralph demo which seems to use the same premise of accepting a event, but in it’s case it would be listening to a key press while my case it would be listening to a collision.

It did not seem to go well, so I tested it on the original code but changed the accept condition to my collision, but a no go, I have included a updated demo featuring the issue starting on line 164, what I did was tie it up to some on screen text which was supposed to return True when you move into the cube. here is the demo here: alfincol.zip (453.9 KB)

P.S. sorry for being a little pestering, and a big thanks to those who are helping, and have a good day.

Don’t worry about it, I don’t think that you’re pestering. :slight_smile:

As to the error, simply put, the events generated by an “event” collision-handler send through one more parameter than key-events do. Specifically, they send a “Collision Entry”, which describes the collision–which objects were involved, and so on.

So, your “touch” method is expecting three parameters: the “self” parameter, something called “tou”, and something called “value”.

The event handler is sending the “self” parameter, the “collision entry”, and presumably the two parameters that you added to the “accept” method: “t1” and either “True” or “False”. In total, we thus have four parameters being sent.

Okay, thanks you have been really helpful, the thing I is should be researching how this works, but to be honest, the roaming ralph demo has a lot of advanced concepts that go into the code, some that I still cannot even figure out yet, I guess the key events is one of them.

Perhaps there is way to modify the key event to accept 4 parameters? I’ll try that first before tackling a different method, anyways thanks for the insight.

Edit: okay i got it to work, I have added “col” into define list of “touch” then took out “value” after the equal and replaced it with “col” to make it work.

Here to confirm that this question has been answered and solved, here is a demo proving that jncoldemo.zip (639.0 KB)

As you can see it is way too wonky using a simple boolean style for collision, I’ll research a different method, and to those who helped, thank you, I now have a better grasp on panda’s collision system, have a good day people.

I’m glad that you got it working. :slight_smile:

As to it being wonky, once again the question is that of what you’re trying to achieve. Looking briefly at the code, it looks like you’re attempting basic collision detection, as well as jumping and falling.

For basic collision detection–just keeping the player out of walls, etc., and excluding very fast objects–you might find that Panda’s “CollisionHandlerPusher” class does what you want. (For more information, look at the manual section to which I linked above, I believe.)

Jumping and falling can be a little more complicated, I think, depending on how fast things may fall. I do encourage you to research methods of implementing it! :slight_smile:

Yeah, you have it right, I was attempting to make a 3d platformer, I thought I can keep things simple, but it didn’t turn out so well, the pusher handler as it was described, reminds of how Mario 64’s collisions worked described in a youtube video.

So that is where I was heading next, I tried it yesterday though, and couldn’t get it to work, but I need to find actual examples of where the pusher is used so I can get a clue of how it really works.

The manual has a simple example here, I believe. :slight_smile:

I haven’t played Mario 64, nor do I recall seeing much of it, so I’m not in a position to comment on the comparison, I’m afraid. ^^;

it’s okay, and thanks, I will look at this example you have given me.