Hi,
So, this is what I've ended up with, and it works pretty well...
The global event 'Fire' is activated when the Titan is in range of the player.
1. Spawn Laser, spawns a pooled Prefab of the Laser which has the Draw Line action, and two child objects for the Start & End of the Draw Line.
2. Main Raycast spits out the raycast, and sets the position (every frame) of the End object in the laser/Draw Line prefab. It also stores any hit objects and has a Game Object Tag Switch, one for the player and one for other enemies. If nothing is Hit after a Wait of 3, it goes to FINISHED which sends an event to stop firing lasers/De-spawn the pooled Laser/Draw Line prefab and start the Titan hunting again.
If the player is hit by the raycast, it goes to the hitPlayer event which zips through the Subtract Player Health state which simply sends a global event to the player spaceship to reduce health by 1 (int), and then on to
Aux Raycast. I did not want to use a global variable for Health because I've worked really hard at completely stripping my game of global variables.
3. Aux Raycast is a copy of
Main Raycast, but with no Tag Switch for the player spaceship and is mainly used to continue driving the Draw Line laser prefab. It has a Wait of 0.3 then FINISHED.
4. Clear Hit Object sets the hit object variable stored in
Main Raycast to Null, so it doesn't instantly send the hitPlayer event.
The result is pretty much perfect. If the player is hit by the laser, it takes 1 off Health, and an additional 1 off Health for every Wait 0.3 the player is in the path of the laser. It's cool, because there are loads of other enemies doing different things, and sometimes it's not a case of simply flying out of the path of the lasers, so things get quite hectic and exciting!
I'll mark the thread as SOLVED. I've done plenty of game testing and it seems really solid.
Thanks.