- Home /
Best way to dynamically assign a camera?
I want to change the camera dynamically at runtime, to see the view from the a player, an enemy, etc. when I fire an event like clicking a UI button. I can think of a few ways to do it; I'd like some advice on the pros and cons:
Add a Camera GameObject to my player and enemy prefabs, set it inactive, and when the event fires enable the child camera GameObject on the appropriate parent object
Add a Camera component directly onto my player and enemy prefab or one of their existing children, e.g. a head. Disable it by default, enable it when the event fires.
Or, add the camera GO or camera component to an existing GO dynamically, so the prefabs don't have a camera to begin with and one just gets moved (added or removed) between players and enemies.
Two questions:
is there any benefit to having a Camera object instead of adding a Camera component to an existing object, other than the ability to position the Camera object independently of the other children?
Is there any benefit or liability to adding the child Camera or Camera component to the prefab, initially disabled, and enabling it on the desired instance, instead of adding a Camera child or Camera component dynamically?
Your answer
Follow this Question
Related Questions
Dynamic Camera Help 1 Answer
Dynamic terrain loading on one scene 0 Answers
Displaying streaming video as a dynamic texture. 0 Answers
2.5d Side Scroller Dynamic Camera Zoom 1 Answer
game grid generating whle in camera view ? 3d game scene) android 3 Answers