- Home /
Question by
The_Thinker · Dec 04, 2014 at 12:32 AM ·
cameraapplication.loadlevel
Application.loadlevel
I want to load a scene when my camera is at a certain position. How would i do that
Comment
Answer by theLucre · Dec 04, 2014 at 12:35 AM
Add a script to your MainCamera that is something like:
public Bounds TeleportBounds;
void Update() {
if( TeleportBounds.Contains( transform.position ) ) {
Application.LoadLevel( "YourScene" );
}
}
You can set the Bounds box values in the editor when you attach this script to the Camera.
Add this function to the script and see if editing the Bounds values on the component will draw an area reflecting the geometry in your scene. Be sure the Gizmos setting is checked in your Scene panel:
void OnDrawGizmos()
{
Gizmos.DrawWireCube(TeleportBounds.center, TeleportBounds.size);
}