Situation:
I have a player object which can enter a Portal, and be immediately teleported to a new location. Currently, this happens instantly. The Portal object, in it’s OnTriggerEnter() function, calls the Player’s Teleport() function to immediately send the player to the target location.
Problem:
What I would like to implement, is the following sequence of events when the player enters a Portal:
- The player controls stop responding and the player’s avatar stops moving.
- The screen fades to black.
- The player’s avatar is teleported to the new location.
- The screen fades up from black.
Because this sequence of events relies on controlling numerous entities, I’m not sure how best to go about it, and was hoping someone might be able to propose some elegant solutions. I don’t need code, rather I need help with organising my code.
For example, the most ‘brute force’ (and messy) method I can think of would simply be to have a BeginTeleport() / EndTeleport() function on the Player, which in turn calls a Camera.FadeToBlack(), Player.TeleportToLocation(), Camera.FadeFromBlack() sequence of functions with callbacks to delay each step until the previous has been completed. This seems to me like it’d be bad practice, as I’d end up with this sequenced event split up across many different objects and scripts. Plus it confuses me just typing it ><
Perhaps I could have a ‘helper’ object of some kind, which I simply call ActivateTeleport() on, and IT worries about moving the player, fading the camera, and handling the delays? Or is there another solution?
Any help at all would be welcome, as I’m very new to Unity and I’m still getting used to how things work. Thankyou!