Hi Unity Community, im a newb, so that’s, that:P
What im trying to achieve is a camera switch when my player collides with a trigger.
So ive set up my scene with 2 cameras, Camera01, and Camera02.
My “character” is just a cylinder with 3rd person controller attached to it, but with no 3rd person camera.
And the i have a box wich is a trigger, and i need help with the code, i cant figure it out, and yes i have googled alot, so now im turning to you guys/girls.
The code attached to my trigger atm is:
var camera01 : GameObject;
var camera02 : GameObject;
function OnTriggerEnter () {
{
Camera01.enabled(true);
Camera02.enabled(false);
}
}
function OnTriggerExit () {
Camera01.enabled(false);
Camera02.enabled(true);
}
}
}
and that doesnt work obviously.
I really hope you can help, thnx. /P
Alright, so this code works, but after my character enters the trigger, i cant control him anymore, nothing happends, any clues?
var camera01 : Camera;
var camera02 : Camera;
function OnTriggerEnter (other : Collider) {
camera01.enabled = false;
camera02.enabled = true;
}
function OnTriggerExit (other : Collider) {
camera01.enabled = true;
camera02.enabled = false;
}
Im gonna keep trying, i you have any ideas please write:)
best regard / P
So, you don’t have a camera attached in the 3rd person controller script? If not try setting one then when you enter the trigger have it change to the other camera.
So inside of the 3rd person script
var Cam :Camera; (not sure what the right feild is for camera)
var Cam1 : Camera;
var Cam2 : Camera;
function OnTriggerEnter() {
Cam = Cam1;
}
function OnTriggerExit (){
Cam = Cam2;
}
If this is the exact code you’re using, you’ve placed your camera.enabled statements outside of your OnTriggerEnter() function. There are too many brackets.
Makes sense, allthough when i alter the code it wont work at all, do you have any code examples?
Best regards / P