Initiating random camera on start?
Hey everyone.I am kinda beginner in C# programming and i need a script that would activate one of 5 cameras when my scene starts. I dont know how to write it so any help is appreciated. Thanks in advance!
Answer by tormentoarmagedoom · Feb 18, 2020 at 03:57 PM
Hello.
FIrst, Camera is a component, but i supose you have 1 object for each camera, so each of these objects have its own camera component.
So, you only need to activate or deactivate the objects. (Be sure to have only 1 camera object activated at any time)
https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html
To select one of the cameras, first you need to have all cameras in a GameObject[] variavle (GameObjects array). And select one of them using random.RAnge as a index.
https://docs.unity3d.com/ScriptReference/Random.Range.html
Take your time, read, investigate, watch youtubes, tutorials, manuals... dont try to go fast, try to understand and practice step by step.
Good luck"!
Your answer
Follow this Question
Related Questions
Adding components to prefab instead of player 0 Answers
Create a random Mountain 1 Answer
Randomly Spawn Outside The Camera Field of View 1 Answer
There is no 'Animation' attached to the "Camera" game object, but a script is trying to access it. 0 Answers
Error while linking ThirdControlCamera to gameobject 0 Answers