Skip to content

A Unity controller that allows seamless switching between First-Person, Third-Person, and Real-Time Strategy camera modes implemented using Cinemachine. Ideal for games requiring multiple perspectives or hybrid gameplay styles.

License

Notifications You must be signed in to change notification settings

bentoBAUX/Multimode-Camera-Controller-in-Unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multimode Camera Controller in Unity

Showcase video

This project demonstrates a versatile camera controller for Unity that enables seamless switching between First-Person, Third-Person, and Real-Time Strategy (RTS) perspectives. Ideal for games with hybrid gameplay styles, this setup provides a flexible and customizable foundation for multi-perspective experiences.

Table of Contents

Getting Started

Clone or download the project files and open it in Unity. This project is set up with Unity’s Input System, so make sure it’s installed and configured in your Unity project. Alternatively, the release is available for download, should you wish to test out the project.

Controls

  • Sprint: Hold "Shift" on your keyboard.

  • Switch between First-Person and Third-Person: Press 'C' on your keyboard.

  • Switch to RTS Mode: Press 'V' on your keyboard to switch from either FPS or TPS to RTS mode. Each mode is designed with unique functionality:

  • First-Person View: Offers an immersive player perspective, common in FPS games.

  • Third-Person View: Provides a full view of the player character, suitable for platformers and adventure games.

  • RTS View: A top-down, bird’s-eye view, ideal for strategy and management games.

How It Works

This camera controller leverages Unity's Cinemachine package and the Unity Input System for flexible and reliable camera switching.

The setup includes:

  • A singleton InputHandler to manage keybinds and input checks.
  • Camera switching logic in CameraManager that adjusts the priorities of different CinemachineVirtualCamera components to control which camera is currently active. By modifying the priority, only the desired camera view is shown at any time, providing smooth transitions.
  • Different Cinemachine cameras for different views:
    • Third-Person View: CinemachineFreeLook
    • First-Person View: CinemachineVirtualCamera $\rightarrow$ Body: "Hard Lock To Target"
    • RTS View: CinemachineVirtualCamera $\rightarrow$ Body: "Do Nothing" (PS: I added some code to make sure that the player is in view when RTS is activated)

Requirements

This project was made in Unity 2022.3.13f1 URP.

  • Cinemachine
  • Unity Input System package.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A Unity controller that allows seamless switching between First-Person, Third-Person, and Real-Time Strategy camera modes implemented using Cinemachine. Ideal for games requiring multiple perspectives or hybrid gameplay styles.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published