I don’t know about using python any more. I can’t get any code to work and I can’t get adequate help. I just want to move forward with my project, not stop to learn a new language. I’ve wasted three days getting drawn further and further away from my intended goal following the advice I’ve been getting.
So I’m ignoring all that and going back to square one with the logic bricks.
Here’s what I’ve got:
My enemy set-up is an object (“Enemy”) with camera (“Camera”) parented.
There is another object (“Enemy.001”) on another layer with it’s own parented camera (“Camera.001”) used for spawning new enemies through an empty (“Enemy Spawner”).
I have keyboard keys set up through another empty (“Game Data”) to switch camera views, with one of the keys set to the camera on “Enemy”. I want to use this same key on “Camera.001” after it’s spawned.
Using logic bricks, I currently have this set-up:
- Player hits enemy with a cannonball.
- Enemy keeps count of cannonball hits through a collision sensor.
- After 3 hits, enemy dies, sending a message to “Game Data” to spawn a new enemy (“Enemy.001”).
- “Game Data” sends a message to “Enemy Spawner” to spawn the new enemy.
This is where I start having trouble. Because “Enemy.001” has “Camera.001” parented to it and not “Camera”, the logic breaks down and the key for the enemy camera no longer works.
I don’t know enough about logic bricks to know how to get some order to them so that I can get the keyboard key for the enemy camera to Set Camera for “Camera.001” instead of “Camera” immediately after “Enemy.001” is spawned.
Now that I have all that python ‘advice’ shoved out of the way, I can think a little more clearly again.
I know that a boolean property could be used to keep track of whether the original enemy is alive or dead, and use that property to control whether the keyboard key Sets Camera for “Camera” or for “Camera.001”.
I put a property called “new enemy” on “Game Data” and pass it a message from “Enemy” when “Enemy” dies, and I’ve changed “Game Data” to check the property when the keyboard key is hit to switch to the enemy camera. The keyboard sensor points to “Camera” if it’s FALSE and “Camera.001” if it’s TRUE.
By my reasoning, this should work, but it doesn’t. “Camera.001” is no longer attached to “Enemy.001” when it spawns.
So I’m back to where I originally was.