i’m trying to get the position of an object in the world (the game). because of the way the classes are arranged in the code, i don’t see any way to pass the nodepath of the object to the other class which needs it. here comes the question:
is it possible to get the position of an object at any time in the gameloop from anywhere? in other words, can one query the scenegraph at any point in the game to obtain the position or nodepath or whatever of an object as long as you know it’s name?
i know this can be fixed if the code was organized in such a way that these objects were global variables but at the moment they aren’t
i was referring to what cyan said, that it would be made easier by setting appropriate tags beforehand so they can then be used when searching for the position of those objects…
Adding the tags to the scene requires adding them to the egg file. This process is specific to whatever modeling package you are using to fabricate your eggs; I am aware of a script in Maya to do this, but my knowledge of other modeling tools is limited.
If you are using maya to construct your eggs, I believe that a search of the Pipeline forum for “maya tag” may yield results. If it doesn’t, let us know and I’ll see if I can dig up some .mel script to do what you desire.
Another option is to insert the tag directly into the egg file itself; look into the egg syntax document to see the proper format and position for that.
just realized that making the tag in 3dsmax wouldn’t work anyway because there are two entities which are loaded from the same model but what i want is that they are both aware of where the other is positioned in the world
ie. 2 submarines (loaded with the same model). both should have some way of knowing where the other sub is in the world.
as i said, i’ll try the setTag thing…but if anyone else has any other ideas don’t hesitate!
what i’ve done is created a torpedo with the torpedo class and i want it to go towards one of the players so it needs the player’s position in every step of the game.
targetPlayer = render.find("**/")
i’ve done just prior to creating the torpedo from the submarine, that replacing modelname with the name of the submarine model, and then when i create the torpedo i pass targetPlayer to the torpedo class
in torpedo before i do any movement i try to do
self.torp.lookAt(target)
where target is the argument passed on and is equal to targetPlayer (ie. it should look at the targetPlayer who’s nodepath was hopefully passed on in the beginning
when i run it however, there are error msgs.
“NodePath”, line 5005, in __overloaded_lookAt_ptrNodePath_ptrConstNodePath
AssertionError: _error_type == ET_ok && other._error_type == ET_ok at line 645 of panda/src/pgraph/nodePath.cxx