Spawning AI problem

Hello everyone, hope yall doing well. Im in a pickle right now and wondering if anyone could help. I made a Finite state Machine based AI that follows you around and shoots you, by using a cone object that uses a “property” and ray targeting system that sends messages to the actual AI. It works pretty well when there is only one of them and if its on the same layer as what its searching for. When I try to make a spawner for a “horde” mode or an instant action type team death match only 2 of them work. My guess is since they are all the same object the messages conflict with eachother, saying player (or friendly AI) found then instantly saying lost because one of the other AI objects doesn’t see it. I hope that makes sense, if it doesnt I will elaborate. I remeber someone saying making an instance in python for the spawner. How would I go about doing that? Thank you for everyone sticking around reading this, any help would be amazing.

This is the one that works (what its supposed to do)
BASIC FPS AI (FSM).zip (381.8 KB)

This is the one I want to fix
FSM TDM.zip (467.2 KB)

My WinZip is constantly telling me it’s expired soon after I install it, so I can’t open those files and I’m not going to bother reinstalling it any more.

Can you just post the blend?

Sure 1 sec

Here it is
This one is the one that works
BASIC FPS AI (FSM).blend (2.3 MB)

This one I need help on
FSM TDM.blend (3.0 MB)

The file that’s supposed to work doesn’t. It doesn’t react to the keyboard.

I’m not sure what you’re trying to spawn either.

I don’t know if I can help you. This looks a little too complex for me to follow the logic without studying it for a while.

It could be because I am using UPBGE instead of blender game engine. Basically how the ai works is by states. 1st state it idles until the “eyes” cone sees the player, then it sends a message to the ai cube telling it to switch to the 2nd state which it will track the player. There is a timer that will be set to zero as long as the “eyes” see the player. Once the player hides behind a wall or something for 3 seconds the ai cube will switch to state 3, the pathfinding state. It will go to the player using pathfinding until the “eyes” lock onto the player once again switching it back to 2nd state. I have a death state (5) but havent set up the guns yet. But that is how it works, the player should have full functionality wasd, shift, and space to jump

Here is a video I made showing gameplay VIDEO IS LOUD WHEN SHOOTING

Where does it spawn? What does it spawn?

If you reduce a copy of the file down to just the necessary logic for the spawning, you might find it easier to figure out what’s going wrong.

check the console for errors, you blend spews a lot

here is the ones that comes the most

 Error: Nand(AI Cube), Python script error
Traceback (most recent call last):
  File "Pathfinding", line 11, in <module>
ValueError: actuator.object = value: SCA_SteeringActuator, requested name "" did not match any KX_GameObject in this scene

Error: And.001(eyes), Python script error
Traceback (most recent call last):
  File "TrackToNearest.py", line 30, in <module>
NameError: name 'obj' is not defined

This is the problem I am having. So for the second blend I made 2 different teams of ai to battle against eachother. There is only really 2 ai objects (one of each, on a separate layer) but they have multiple spawn points, spawning about 4 each im pretty sure. So what I think the problem truly is, when one of the ai’s “eyes” ray sensor sees a player it sends a message back to the ai object saying to track and shoot it. But since the other ai are in a different area and don’t see a player it sends a message to the ai object to not track the player because it doesn’t see it. The ai also has a near sensor that when activated is supposed to send the ai object to state 3 to pathfind the player. But since the player isn’t in some of the other ai’s near sensor bounds it tells them not to find the player. I hope that all makes sense

it is not very likely you are going to get it to work using messages, it is not the best tool for this.

It works if all of them are separate objects, but not if its they are the same but uses a spawner. Im wondering if anyone knows how to make a spawner like an empty that will add the same object “ai cube” but make them all be separate while being added

it has nothing to do with the spawners, the problem is messages is one to many and not one to one.

if the eyes on you baddies is parented to main bode you can do this instead of messages.

#if eyes sees enemy do this
# states : 0 = not seen , 1 = seen etc...
own.parent["state"] = 1

Sorry I’ve been away, thank you for that that actually helps alot! What about the “skeleton” armature used for tracking to the player aswell, since its not the parent how would I do that one?

About the ‘obj’ syntax error I read about a similar issue in this

https://www.google.com/url?sa=t&source=web&rct=j&url=https://blenderartists.org/t/referenced-before-assignment/586733&ved=2ahUKEwiq4ZGIgrjrAhVRHzQIHaERAekQFjAAegQIAhAB&usg=AOvVaw0qIHhdhdZZTZcBDe_kQwsT

Since its in an if statement it does that, so they recommended taking it out of the if statement before hand but I looked and it already is to my knowledge, what am I doing wrong?

armature is for playing animation, the tracking should be on the physics body not the armature.

here is an example blend (it is a very simple one)
parent-cildren-action-demo-279.blend (541.2 KB)

press spacebar to toggle seeing something.