Hi all,
I am working on my first game in Unity and at the start I have a camera moving around the starting area which I want to trigger the main level to begin once it gets to a specific point.
The code I am using is…
function OnTriggerEnter (Collision : Collider)
{
if(Collision.gameObject.tag == "MainCamera")
{
Application.LoadLevel("level2");
}
}
I have attached this script to an EmptyGameObject with a Trigger Collider, I have animated the MainCamera to enter this trigger box at the end of its cycle.
The main camera is tagged as ‘MainCamera’ to match the tag in the script.
When I do this nothing happens, however if I use a FirstPersonController instead, it works fine, as soon as I walk into the trigger collider the next level loads.
I do not want a FirstPersonController active though, as it is an intro camera pan where I want no interaction from the player.
I have also tried using other GameObjects to trigger the next level, but these do not activate the trigger either, it only seems to be the FirstPersonController that will trigger the next level to load when it hits the collider.
Can anyone offer any advice on this please?
Many thanks in advance.