Hello everyone, I have quick question, about panda3d nodes, you see I have my nodes attached to list variables to keep track of them, I use separate lists for the actor nodes and their collision nodes, so here comes my question.
Let’s say I had a 4 item list each for my actor nodes and collision nodes, which the collision nodes were reparented to the actor node of item that is the same index number as it’s item index number.
Now, let’s say if I were to remove the actor and it’s collision node at the same time in item 3 of their respective lists, then immediately delete item 3 of those lists since they were converted to None when those nodes are removed.
Would it effect the now item 3 collision node (item 4 before) since it was first reparented to actor of item 4 (now item 3 as well)? I know it is a beginner question, but I want to be safe rather than sorry, I thank anyone who is willing to answer this.
If I’m understanding you correctly, I think that it should be fine. As long as nothing continues to rely on the index of a given object in either list, and in particular as long as nothing relies on the index of a given object in either list remaining the same as it was when added, the place of each object in each list should have no real effect on their behaviour. The scene graph isn’t really aware of your lists, to the best of my knowledge.
Of course, when you come to remove objects you might want to take care that you have the correct indices for each object. Whether this is an issue may depend on just how you’ve implemented this system.
If I may ask, have you considered creating a new “game-object” class to contain both your collision-objects and your Actors? That should allow you to more-easily and more-reliably associate collision-nodes and actors, and to clean them up when a given game-object is to be destroyed, without as much worry about list indices.
No, I have not considered the class idea, I will say that my actors and their collisions while from separate lists are created (or extended) together at the same time to synchronize the index numbers, they are also destroyed together at the same time to keep said synchronization.
Anyway thanks, I,m going to test this idea, and come back later.
I get that; I just think that it’s an approach in which it’s somewhat easy to accidentally end up with things out of sync–or at least, easier than with classes.
That said, go with what works for you, and what makes sense to you! I offer the “class” approach in case it’s useful to you, and don’t by any means say that it’s the only good way.
okay, sorry I toke so long, I had to redo some code to even begin to test this, but I did, and everything seems to work, so you are right, Thaumaturge, also thanks, and about the class, I might look into it if things don’t turn out well here, so thanks for that too.
Oh and I marked your post as the solution as it basically answered my question.
I’m glad that you seem to have things sorted out, then.