- Home /
Load a level at a specific point
Hi,
I have what I consider a pretty simple question, but I am not sure if it would work. l want the player to touch a collider and send him to a specific point in a level. I just don't know where or how to code that.
Here is some generic code to show:
function OnTriggerEnter(other:Collider)
{
if (other.gameObject.tag == "Level")
{
Application.LoadLevel("Level1-1");
}
}
I am just wondering if I can use vector3 to specify where I want to send the player, and if so, where do I insert this into the code?
Thanks in advance!
So you want a script where OnTriggerEnter it goes to a point on the terrain.
yes, that's right.
FYI, I've tried using transform.position, but it did not work. I thought this this made sense:
if (other.gameObject.tag=="Level") { Application.LoadLevel("Level1-1"); transform.position = Vector3(111.2593, 0.1513774, 94.3337); } }
Answer by PAEvenson · Jan 04, 2013 at 09:28 PM
you can have a script and in OnLevelWasLoaded put your teleport code...
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnLevelWasLoaded.html
how would this load the character to a specific point on the map? I know that I could create an empty gameObject and call it spawnPoint1 and then reference it later, but that seems inefficient. I just want the player to collide with an object and be sent to a specific point in a specific level. Thanks for the link BTW.
Your answer
Follow this Question
Related Questions
Curious about "Vortex" force (HELP) 2 Answers
Vector3.Scale and rotated colliders 1 Answer
physics.OverlapSphere colliders 1 Answer