Camera switch

Hi all,

I’m relatively new to unity and am using javascript. I have wrote some code to switch cameras on the click of a button, (namely from a third person controller to a first person zoom camera), however I don’t know how to assign a camera object to a variable.

Here’s some info. My third person camera will be called Camera1, my first person camera will be called Camera2. I have declared these two variables at the top as Camera variables, it’s just applying the objects directly to the variable that I am having trouble with.

Any help will be greatly appreciated.

You can drag objects from the hierarchy or prefabs from the project view onto variables that are exposed in the inspector to assign them. Is that what you’re looking for?

Thank you! :slight_smile: I’m learning unity as part of my degree so expect to see me posting on here very often :smile:

Sorry but they dont appear in the inspector at all. I have looked into this and changed them to public variables but they still do not appear! :frowning:

You mean the variables don’t appear in the inspector? If so, perhaps you could post your code so we can take a look.