I need help with scene switching

Hey guys! Me and a couple friends are working on a game where you are able to switch between 2 different game scenes for a short period of time. We want you to be able to press “Q” and switch into a different, and after 10 seconds return back to the original scene using a coroutine. Also, if it’s possible, is there any way that if the different scenes are built the game with the same coordinates, that you could put the player in the exact coordinates they left off in the other scene when they switch back. Here is my code.
///
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class WARP : MonoBehaviour
{
// Start is called before the first frame update

// Update is called once per frame
void Update()
{

if (Input.GetKey(KeyCode.Q))

{
StartCoroutine(Mindshift());
SceneManager.LoadScene(“GameScene2”);
IEnumerator Mindshift()
{
yield return new WaitForSeconds(10);
SceneManager.LoadScene(“GameScene”);
}

}
}
///

Hopefully someone understands this, the script isn’t throwing any error but still doesn’t work when I press “Q”. Have a good one y’all.

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

When you post code, please use code tags: Using code tags properly

Can you please illustrate what specifically doesn’t work? Is it that there is no effect at all or something else?

Yeah, nothing happens at all

Only one place to start with that! To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

Will do, Thanks for the suggestion.

Use GetKeyDown(), GetKey() fires repeatedly. Though not sure in this case if it’s switching scenes…
Are both scenes in the Build settings?
To remember position, use a static Vector3 to store the player position, and update it right before switching to the next scene. Will take some fiddling to reload it etc.