Hiding System

The Hiding System allows you to hide to any location by simply animating the Virtual Camera. When you are being chased by an enemy, you can hide, but don't get spotted where you are hiding.

Adding Hiding Places

  1. Add a Virtual Camera by selecting Game Object -> Cinemachine -> Virtual Camera to the object that represents the hiding place.

  2. In the Virtual Camera component settings, set Body and Aim to Do nothing.

  3. Move the camera to the potential hide starting position, where the player camera will move when you interact with the hiding place.

  1. Animate the Virtual Camera and create two animations. One will be a Hide animation and the other Unhide animation.

  2. Modify the Animator so that you will be able to hide from any state and unhide by transitioning from hide state.

Make sure that the transition duration between the Hide and Unhide states is zero.

  1. Create a new bool parameter and name it IsHiding. Set it so that the transition to the Hide state only occurs when IsHiding is true, and to the Unhide state when IsHiding is false.

  2. Add a Hiding Interact component to the object you want to interact with when you want to hide.

You can define whether you want to use the Interact or Trigger hiding style. If you set the Hiding Style to Interact, you will hide when you press E on the interactable object. If you set it to Trigger, you will hide when you move through a Collider that is marked as Is Trigger with this component added to it.

  1. Define the hiding and unhiding position of the player. The Hiding Position represents the location where the player object will be teleported after hiding. The Unhide Position represents where the player will be teleported to after unhiding.

Both the Hide and Unhide positions must be placed where the player foot will be. The Unhide position can be debugged by enabling the Draw Gizmos option. The red dot represents where the player camera is located. After unhide, the Main Camera will move to the player controller camera position.

  1. Assign references to the Virtual Camera and Animator and adjust the Blend Settings.

  2. Adjust the Animation Settings using the corresponding Animator State and Parameter names.

You can see how the Hiding System works and how it is set up in the Elevator scene and on the bottom floor.

Last updated