Transition between scenes
When a player moves to another scene, he searches for the position. But before that, one frame is visible the old position. How to fix it? Thanks!
Comment
Answer by Enyph-Games · Oct 18, 2016 at 02:37 PM
You should save your position before loading the next scene
Vector3 newPosition;
void WhenYouLoadYourNextScene() { newPosition = transform.position; SceneManager.LoadScene(nextLevel); }
void OnSceneLoaded() { transform.position = newPosition; }
Answer by OZBEND · Oct 18, 2016 at 03:40 PM
@eurocrem Something like this?
void WhenYouLoadYourNextScene() {
newPos = transform.position;
SceneManager.LoadScene("floor_1");
}
void OnSceneLoaded() {
transform.position = newPos; }
public void OnTriggerEnter2D(Collider2D col)
{
if (col.GetComponent<BoxCollider2D>().tag == "basementEnterTrigger_2")
SceneManager.LoadScene("room_7");
if (col.GetComponent<BoxCollider2D>().tag == "basementEnterTrigger_2")
gameObject.transform.position = GameObject.Find("InRoomPos_7").transform.position;
This dosn't works.
There is a corridor with several doors: 1, 2, 3. When I go to the door number 2 and then go out, then the player is looking for the door position number 2. But for a second, I see the old position.