The first steps I took when I started to build the game mechanics is to start simple. I therefore focused on basic triggers. I also used a first person character controller as I wanted to make sure that my game worked as an FPS before I tried to add VR features.
I used trigger boxes to activate events within the game. The first event I wanted to create was a respawn sequence. I decided to use a similar approach from past projects for this.
I made sure once the player enters the trigger their transform equaled to the transform of the respawn location. This code was simply player.transform.position = respawn.transform.position.
I set the respawn position as a trigger box within the baby crib (Small cube trigger) so that the starting point was always in the crib. However this posed an issue on how the player was going to get out of the crib.
I therefore created another script and trigger at the end of the crib which when the player enters and presses a key or button the transform of the player will translate on the y axis allowing them to jump out of the crib. Once the player leaves the trigger box the transform will default back to zero and the player will stop rising. I used a boolean to detect whether the player has entered the trigger or not.
For the majority of the scripts as well as the climbing script I used a combination of booleans and coroutines. When the player enters a trigger the trigger will activate a boolean. Inside the coroutine there will be functions that will activate such as lights turning on and off or animations playing. Some functions can be called after a certain period of time using waitforseconds. Then I'll start the coroutine if the both the boolean equals true and the button or key is pressed.







No comments:
Post a Comment