- Home /
move camera when it collides with a trigger
Hello, ive been trying to move a cameras position when the character collides with a plain that i have set as a trigger.
What ive got doesnt work at all. Ive tried to set up two cameras so that why when i collide with the trigger it will disable one camera and turn on the other. I also tried to set a transform and move the camera to an empty game object(which i dont even know if thats possible).
To explain even more, if you have ever played LITTLE BIG PLANET you can tell that they have camera pathes or some kind of system to move the camera to different places. This is what i would like to do in my 2.5d side scroller.
would some one please explain to me how i could get this to work because this is a big part of my game.
Thanks for the help and consideration.
Answer by AngryOldMan · Mar 14, 2011 at 02:28 AM
if you want static cameras that change when you exit their viewing area (which you will have to match with a trigger area!) its just a case of parenting the camera to each game object then setting it by default as off. Then add a script to the game object for OnCollider Stay like:-
GetComponent ("camera")
{
camera.enabled = true
}
warning not tested for errors! if your trying something that involves the camera moving then you need to script something to parent camera to player in certain trigger areas similar to this http://answers.unity3d.com/questions/44919/super-meat-boy-styled-camera/44956#44956 (take a look at answer's comments too)