Hi! What is the python codes for getting the sensor’s ( “name” ) from the Logic Block? I wants python to detect the change of the name of the sensor from the Logic Block. Can it be done?
try this…i did this a while ago (so can’t remember the details) but it might help you…or at least set you on the right course.
cont = GameLogic.getCurrentController()
own = cont.getOwner()
name = own.getName()
Thanks! I’ll give it a try
Sorry mate, I’ve written a total of 3 python scripts and they were pretty simple. I replied to your post because no-one else had and I thought this might give what you needed.
I would take a look at the .blend but I can’t seem to get it now. says it’s been removed.
Sorry man! I been having problems loading up files. So this is the link - http://www.bestsharing.com/files/27RGNf267824/CharaPathnode.blend.html
Thanks again for your help. I trying to find a way to make this scrip more user friendly and easy to make a Path Node.
So you want to be able to put as many sequentially named nodes in as you like and have the red box visit each one without having to hard code each name?
YES! Peoples will be parent to the boxs to make them look like walk around . Or do you suggest another way for doing it?
at work now but i’ll see if i can work something out over lunch. i’ve only got a few weeks python experience myself but you should be able to get what you want.
No problem… take you time… its cool man. Your own work is more important. Thanks for the help!
sorry, no lunch today : (
No. Its ok… some other time than… Take care of yourself man. Can’t work on a empty stomach. Ha Ha! Chees.
I have loked at your .blend and changed it to ease management of nodes. Download it at http://www.bestsharing.com/f/y9grD1Y267966
Now you have only 1 collision sensor on cube object, node objects don’t need any property, they just need to be named ‘Node*’, where * is number of node. There should be no gap in numbering and cube object has property nodeCount, where node count has to be stored.
You can add new node by just giving it correct name and increasing nodeCount. Reordering of nodes is done by renaming them. Deleting by dropping node, decreasing nodeCount and renumbering remaining nodes.
THANKS ashsid! Wa! The codes are shot and simple to use. Can you explain what these codes mean? under the #Process part.
What must I add to make the box to go to eash node and stop there for a while before moving to the next point?
You can add stopping at each node by timer that will delay aiming for next node.
short explanation of code:
# collision sensor sens = cont.getSensor('Node') # index of node where are you heading to (-1 mean no node is choosen) nodeIdx = -1 # if some collision occured if sens.isPositive(): # find 'Node' object in currently colliding objects for obj in sens.getHitObjectList(): # is this object 'Node' name = obj.getName() if name[0:6] == 'OBNode': # get index of node from its name nodeIdx = int(name[6:]) break # if node is found if nodeIdx >= 0: # aim for next node own.dnode = nodeIdx % own.nodeCount + 1 # set next node name to go to it pursue.setObject('Node' + str(own.dnode))
Where do I add it? In the codes or in the data block?
try this file http://www.bestsharing.com/files/CzNoNO269671/CharaPathnode.blend.html
It’s quick hack, wait property defines time, how long will cube stay on each node.
What does getHitObjectList really mean? I know its return the name of the object that the box have touched but why a list? whats the different between getHitObjectList and getHitObject?
I also trying to make the box only stop at a specific node name. So I wanted to try adding an ‘and’ operator here
if own.timer < own.wait and name = “Node3”:
I know its wrong as it did not work… so how should I add the 2nd condition?