- Home /
how can i make my character to be on another scene?
I cant figure this out. For example, I enter to a portal, how will I make my character to be on the next scene?
Tagged 'unityanswers'. Seriously? That's probably the one thing less useful than a 'scripting' tag...
You could at least tag the question with the language you want your answers in. If you don't I'll just answer in C# (because it's my preference) and if you don't like it well too bad.
Yeah, I've been deleting a lot of those kinds of tags lately trying to get rid of them.
Answer by syclamoth · Jan 25, 2012 at 07:04 AM
Make your portal a trigger. Then, on the portal gameObject, put a script that goes like this:
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
DontDestroyOnLoad(other.gameObject);
Application.LoadLevel("Next Level");
}
}
Of course, your character will remain in the same spot as the portal, so you might need something like this on the character script, as well:
void OnLevelWasLoaded(int thisLevel)
{
transform.position = GameObject.FindWithTag("SpawnPoint").transform.position;
}
This will teleport the player to an object tagged 'SpawnPoint' as soon as the level is loaded.
if you can't tell by looking at it or reading the comment @syclamoth posted at the top then throw it in a boo script.
Edit: Damn... you beat me typing lol
I should learn boo, just so I can answer every question in it and annoy everybody.