Objects targeting objects on layer 2, Hmm...

(tldr at bottom)

New to Blender and of course Blender Game Engine. Really I’m new to everything in game programming, 2d, and 3d modeling period. But over the last few weeks I’ve been messing around with all of it and for some reason I’m finding it pretty interesting. And from the looks of it this web site, there seems to be a lot of really helpful people who are willing to give advice and other ideas to help you get your project just right.

Anywho… I made up what I’m calling a learning curve game that has a player cube, moves using wasd. Nothing else. When you press the space bar an enemy block comes out. It will chase after the player cube. Nothing happens when it reaches the player. I haven’t set anything yet. So far so Good.

Also when you press the ‘t’ key a supply ball comes out and chases after the player. When it reaches the player it disappears. If the enemy were to hit the supply ball nothing happens. I haven’t set anything to happen yet. Still good…

What I want is for the enemy to change targets from the player to the supply ball. Which it does, but the enemy appears to chase after the supply ball that is on the second layer. Not the one you summoned in. If the player hits the supply ball and it disappears, the enemy will chase after the player again. Summon in another supply ball, and once the again the enemy goes directly for the supply ball on the second layer. Not the newly summoned one.

The player cube is on layer 1. Both the enemy and supply ball are on layer 2. When you start the game you only see the player until you summon in the others. I use empties on layer 1 to create the objects enemy, and supply. Since the enemy chases after the supply ball on layer 2, I’m guessing there has to be a way to hide layer 2 objects till you create them or perhaps there is some other method I’ve yet to discover, that is better to summon in objects?

I tried using logic bricks and a simple python script I made (which I’m sure could be cleaned up or simplified). I get the same result.

So after looking on google, YouTube, this site and others I can’t seem to find the answer. Either I’m not looking for it correctly or this is fixed by some other means like hiding a layer, or maybe objects need to be in a group? Or some other option that I haven’t learned yet.

Any thoughts or points in the right direction would be greatly appreciated!

Thanks,

-Nihil

tldr:
I use empties on layer 1 to create an object from layer 2. New object from layer 2 now on layer 1 targets the layer 2’s object. Is there a way to hide layer 2 objects till called?

Attachments

cube_with_chasing_enemy_and_supply.blend (628 KB)