Trigger problem while switching to another scene

Hey guys !

I started a 2D project, and made different “rooms” each in one scene. To switch from one scene to another, the player enters a box collider (set with a trigger) that loads the next scene and doesn’t destroy the player game object (that contains a character controller).

I use an “OnTriggerEnter” function for the box collider, and I use an “Awake” function for the next scene to place the player, that wasn’t destroyed while switching scene, in front of the door he just opened (changing the transform.position).
My problem is that if the player was at the position (25, 5) when leaving the previous scene, and if there is a trigger in the next scene that is also at (25, 5), it will trigger it. And I really don’t want that as the player is supposed to be appearing in front of the door, and not taking damage or loading another scene…

I tried to enable the trigger only in a Start function (trying to move the player before triggering anything), but it didn’t work either.

I can’t find a way to get through this, have you guys any idea ?

Try this solution:

Use this function in some script attached to the player gameobject:

function OnLevelWasLoaded (level : int) {
if (level == 1) // the corresponding level
transform.position= Vector3(x,y,z); // Put here the corresponding coords (outside any Trigger of course) :slight_smile:

}

Thanks for the reply ! I tried it but it doesn’t work either, my player collides with the same box collider. The funny thing is that I tried printing the current position of the player when a collision occured, and it shows the good transform.position, even if my box collider is far away from it…

I also tried to use the Move function instead of directly changing the transform.position, but that was useless as my player collided with walls and even though I was still colliding with the same box collider (that is giving me so much trouble… )

I think I’m gonna put a player for each scene, but it’s a shame I can’t figure out what’s going on.

Why not have all your rooms in a single scene and enable/disable as required.

I never thought of that, I’m kinda new to Unity so as I was going to make a really big level (I make some sort of dungeon crawler), I thought separating it into scenes was the best choice.
Is this solution still effective enough with big levels ? Doesn’t it affect the game speed ?