Work in progress - I think it should all be working as listed, might have missed something. Also at the end shows how to install Jasons superb flow addon pack and utilises the wait loop from it.
To start with open Tools>Bolt>Editor Preferences and set Transition Reveal to always, it will make it easier to follow.
First of all make a new bolt flow macro and call it ReachEdgeSU, this will be a super unit of the old Reach edge flow graph from in the Enemy state machine. Well be using this in a few places hence the SuperUnit.
Now open the Enemy State machine and go into the Alive state. you can replace the contents of the Reach edge transition with this.
Edit the Enemy-Alive state machine to look like this, just put in the New state called EdgeCheck, go into it and delete its contents, it will just be an empty state.
Make sure you reconnect the transitions correctly, I didnt find a way to reconnect them so I simply made new ones then went inside the old ones and copied the contents then Ctrl-V pasted it inside the new transition and deleted the old one.
Put this in the safe to chase transition
Select the Enemy prefab and add a variable of type float called DontChase and set it to 0, if you set it higher the enemies wont chase the layer for that many seconds.
This goes in the ReachedEdge transition.
and modify the Player near to look like this. This prevents it from branching if the enemy is in the DontChase mode.
Chase state, Damage State and the Player Away transition I havent modified.
Now go into the Patrol State and add 2 more transitions between Walk left and Walk right so it looks like this.
You can also modify both the Reach Edge transitions to use the SuperUnit like we did earlier.
The Collide with Enemy transitions are also very simple due to the SuperUnit that was made in the main tutorial and they look like this.
Finally edit the EnemyWalk macro and add group into the graph. Late on well swap out this wait for Jasons wait as this wait is what will cause the error messages due to how wait works.
Test it out at this stage, it should all be working.
The enemies should no longer chase you off the edge and will turn around if they collide with each other. Due to the random timer that is set when they get in range of you but are too near the edge their behaviour is less predictable.
Now go back to the root of the Enemy State machine and add a new Empty state called Exit level, again go into it and delete the contents, this state does nothing. Make a transition between it called ExitLevel Triggered.
Exit level triggered again is a simple transition from an event
And thats the enemy state machine done. now we need the hudloader to control it.
The reason for it is to switch states so that when the level exits no state machines are running, although due to how the Wait command works it will cause some errors on loading levels (but no crashes) . We can fix those later using Jasons Wait routines.
And heres the hudloader, note to get fallback on a get variable select the node then in the graph inspector tick fallback, this is a good practice failsafe incase something isnt loaded when the variable gets interogated.
You can adjust the delay before loading the level, I set it to 2 seconds for the player death animation to have time later. The game should now load to the menu on Death.
Create an empty gameobject and call it SpawnPoint ,place where the player spawns and add a flow graph to it as shown below then save it as a refab and add to each scene.
Select the player prefab and add a variable of type bool called Invulnerable.
Now modify the spike flow graph to look like this so on hitting the spikes were set to not invulnerable and respawned on the spawnpoint.
Now we need to modify the player health state machine so that your not invulnerable after landing on the spikes, well also add in the animation state for player death.
Modify the Invulnerable state so it sets the bool as show below
And add this into the nolonger invulnerable transition
the player death transition you can robably workout for yourself by now it looks like this.
Then the player Death animation state is a copy of the enemy death with the Transform Detach children node added in, so you could turn everything after that into a super unit and share it.
The transform detach detaches the camera that is attached to the player otherwise instead of the player sinning the whole screen will spin - try it.
Adding in Jasons Wait routine to fix the errors. Simply replace the normal wait with this one.
Assets-Import package-Custom package and select the file, then Tools > Bolt > Update Unit Options. Then after goto Tools > Ludiq > Generate Custom Inspectors. After it'll be in the fuzzy finder under Control and Wait. If it isnt regenerate docs, inspectors and unit options again.
And thats it , at least thats all Ive done so far, unless I missed something !
Customer support service by UserEcho