Wiki

Case Status
Log In

Wiki

 
Home ยป Samples»M2H Jump Game»M2H Jump Game, Platform Spawne…
Index
Navigation
Community Wiki

M2H Jump Game, Platform Spawner Fsm

Create new platforms randomly positioned as we move up.

This is the most "complex" fsm in this example. So don't spend too much time on this if you don't fully grasp how it works, on a real game, the platforms will likely be hardcoded and even use some frameworks to help generating levels.

Platforms needs to be created in advance so that they already exists when the camera moves up as the player jump higher and higher, so we have a collider that when touched by the player triggers "SPAWN NEW PLATFORM" event. This is done in the "watch for player trigger" state. This state is the corner stone of this fsm. When the player hits that trigger ( this fsm own gameObject collider), we set the new height up to where we want platforms. This setting is exposed in the inspector via the variable "next platform height check". We then compute a random position ( with hard coded bounds, but that's fine for now), we move to the "Instantiate a new platform" which effectively create a place a new platform prefab ( you can select the prefab, it's also exposed in the fsm inspector under "platform prefab".

Once a Platform is created, we check if we need to create a new platform still, this is done by comparing the newly created platform with the height check, if we are still under, we need to spawn a new platform, until we reach the desired height. Note the "Move the spawner to the next height check" state that move up the trigger as we create new platforms, this way we will only go through these steps when we need to , not every time the user is jumping.

Tags:

Last modified on 5/9/2012 3:31 AM by User.

  • RSS Feed