So I was wondering if it would be possible to add a python script to the original object that makes it so each instance of the group is an Individual Instance this way it doesn’t interfere with the other instances wandering around the level?
But if there is no way of doing this I was also thinking about just having a room separate from the play area where the Forklifts are stored and just teleport them via empties and triggers to the location I need them similar to how it works in the GoldSRC engine:
Didn’t really find anything useful while reading around the forum so I’m using the GoldSRC Method of just having the forklifts stored in a far away room and then teleported in with a trigger
import bge
import mathutils
### Get Current Scene ###
scene = bge.logic.getCurrentScene()
### Get Current Object ###
cont = bge.logic.getCurrentController()
own = cont.owner
### Get Perpendicular Lines ###
ObjPosY = scene.objects['G_ForkLift_Arrow(+Y)']
### Get Diagonal Lines ###
ObjPosD = scene.objects['G_ForkLift_Arrow(+D)']
ObjNegD = scene.objects['G_ForkLift_Arrow(-D)']
### Get Main Sensors ###
Active = own.sensors['Active']
Active = ObjPosD.sensors['Active']
Active = ObjNegD.sensors['Active']
### Get Perpendicular Sensors ###
PosY = ObjPosY.sensors['PosY']
### Get Diagonal Sensors ###
PosD = ObjPosD.sensors['PosD']
NegD = ObjNegD.sensors['NegD']
### Logic Perpendicular Lines ###
if (Active.positive) and (PosY.positive) and not (PosD.positive) and not (NegD.positive):
own.localOrientation = (0,0,-180)
### Logic Diagonal Lines ###
elif (Active.positive) and (PosD.positive) and not (PosY.positive) and not (NegD.positive):
own.localOrientation = (0,0,-45)
elif (Active.positive) and (NegD.positive) and not (PosY.positive) and not (PosD.positive):
own.localOrientation = (0,0,45)
### Logic Misc Lines ###
if (Active.positive) and (NegD.positive) and (PosY.positive) and (PosD.positive):
own.localOrientation = (0,0,180)
elif (Active.positive) and (NegD.positive) and (PosY.positive) and not (PosD.positive):
own.localOrientation = (0,0,90)
elif (Active.positive) and (PosD.positive) and (PosY.positive) and not (NegD.positive):
own.localOrientation = (0,0,-90)
### Logics move forwards ###
if (Active.positive) and (PosD.positive) and (NegD.positive) and not (PosY.positive):
own.localOrientation = (0,0,0)
I’m trying to make a simple ai that just wonders around the level. The multiple actives where a work around that didn’t work. You only need the first active the other two con be removed
python scripts works for a single object if connected to multiple objects. But they all do stuff? Yes because it grabs data from 1 object and uses that data for all objects connected to it.
How to fix?
Simple, use functions.
def AI_wander():
#your script here
Now in the objects python brick…
click on the script and change it to module
now enter the scriptname and follow with a . and your function name like this: scriptname.AI_wander
Make sure your python file/script name ends with .py in the text editor.
Ah, you just have to call the sensors related to your object instead of directly.
change this part:
### Get Diagonal Lines ###
FRay = scene.objects['NPC_Roach_FRay']
LRay = scene.objects['NPC_Roach_LRay']
RRay = scene.objects['NPC_Roach_RRay']
### Get Main Sensors ###
Active = own.sensors['Active']
### Get Sensors ###
Front = FRay.sensors['FRay']
Left = LRay.sensors['LRay']
Right = RRay.sensors['RRay']
into this:
### Get Main Sensors ###
Active = own.sensors['Active']
### Get Sensors ###
Front = cont.sensors['FRay']
Left = cont.sensors['LRay']
Right = cont.sensors['RRay']