Steering actuator is pathfinds towards an object in another layer

This question has been answered before, but the link has been taken down. I was wondering if anyone had any information about it? I have basically the same question. I have an object that has a steering actuator that gets spawned in to the game layer, it uses pathfinding to look for another object. The other object also gets spawned in from another layer. The pathfinding object will only go for the object on the inactive layer, has anyone else had this issue?

Heres the link:

you can not reference to an added object using logic bricks.

the original object is never added to the current layers, it stays there, hidden.
the added objects are copies with other names on the run (so that you can add many)
you have to use python.

addedObj = scene.addObject ( 'originalObj' , 'spawnerObj' ,  time=0.0 )
1 Like
import bge

cont = bge.logic.getCurrentController()

radar = cont.sensors['Radar']

if radar.positive and 'Target' not in own:
    ray = own.rayCast(radar.hitObject.worldPosition,own.worldPosition,0,"", 0,0,0)
    if ray[0]==radar.hitObject:
        forget = 120
        own['Target'] = ( ray[0], forget )

if 'Target' in own:
    cont.actautors['Steering'].target = own['Target'][0]
    if own['Target'][1]>=1:
        #forget enemy you have not seen in a while
        del own['Target']

with this it will go after the player it sees - so it even works for mulitplayer co-op

Hello m1440! use python for assign full controls you steering actuator targets or navmeshes or agent speeds

import bge
from bge import logic as gl
cont = gl.getCurrentController()
scene = gl.getCurrentCsene()

o = cont.owner
speed = o[‘speed’]

steering = cont.actuators[‘Steering’]

if speed>0.000:
steering.velocity = speed # assign for steering personal speed

for i in scene.objects:
if ‘ground’ in i:
steering.navmesh = i # assign navmesh, if steering empty navmesh

if 'player' in i: = i # assign target for steering if steering target empty

if you use raycast method or sensors rays in python- radars you get objects detected sensors and assigns for you actuators, this is objects always work right in scripts and not errors situation if you use simple logic bricks and spawn game objects stand another layers
if ray.positive:
obj = ray.hitObject = obj
more information reading in API for bge or upbge - good luck :подмигивать: