Adding components to prefab instead of player
I have been trying to do my due diligence searching for an answer on how to switch camera's when the player enters a new room (prefab), but all of the answers I have found involve attaching a script to the player and keeping track of the previous camera to turn off.
What I am really looking for is the ability to attach things like the camera and light sources and other properties to the rooms and have the rooms react to to the player (or another AI) being present in them or not.
I am using a simple example, roll-a-ball, only I created four different prefab rooms, with openings in the center of 1 to 4 of the walls. Theses rooms are then placed together and the player navigates through them.
Each room has it's own collider and camera. Is there a good way to switch to the room's camera when the player hits the collider?
Perhaps it is an easy question and I am just overlooking something. Perhaps my approach is completely counterintuitive or backwards and there is a good reason I shouldn't be "placing the power in the hands of the room instead of the player".
Either Way, I would definitely appreciate some feedback, thanks.
(I am not sure if it matters, but I am trying to write the code in C#)
Your answer
Follow this Question
Related Questions
Assign main camera to a prefab with a canvas 0 Answers
Making the player the camera's axis of rotation. 0 Answers
Make character face movement direction 0 Answers
Enable Lerp Rotation with Keypress? 0 Answers