Spectating

Now that we have made the respawn mechanic with a timer, we need to set up a spectating mechanic to avoid players looking at their own invisible body whilst keeping tensions high if other players are being chased.
Prerequisite:
A list of all player’s child from which the camera should look at and a variable on the current dead player that is just a bool on whether the player is spectating or not.
Implementation:
Since we are using “Cinemachine” and “Cinemachine Virtual Camera”, setting this up is not too complicated. All we have to do is set bool of isSpectating to true and set the camera to follow the other player’s game object or child of said game object.
Once the respawn timer is up, we set the bool back to false and make the camera look at the now not so dead player.
Subscribe to my newsletter
Read articles from mian mohammad shah directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
