Trasport scene

Hi guys I have a problem:
How do I do to it makes to transport my character from a scene to the other without unity cancels me the preceding scene?
Example: my character is found inside a tavern and you/he/she must go to the outside crossing a door for go to the second scene?

Please help me

the good news is. The script works. The bad news is. I don’t you’re going to like what it does to the asteroid.
The asteroid is tumbling and turning. so when you do a transform.forward this directions is always changing. So i see that asteroid flying off the sides of screen.

ok, I found the real problem. the issue is that this script is per asteroid. so every time a new asteroid is spawned. the speed resets to -5, even though is was changed -20.
i almost have a fix for you.

here are you’re updated files to fix the speed issue

asteroid move script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mover : MonoBehaviour
{
    public static float asteroidSpeed;
    public float speed;
    private Rigidbody rb;


    void Start()
    {
        if(asteroidSpeed == 0)
        {
            asteroidSpeed = speed;
        }

        rb = GetComponent<Rigidbody>();
       
        rb.velocity = transform.forward * asteroidSpeed;
    }
   
}

Done_GameController script

using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;

public class Done_GameController : MonoBehaviour
{
    public GameObject[] hazards;
    public Vector3 spawnValues;
    public int hazardCount;
    public float spawnWait;
    public float startWait;
    public float waveWait;
   
    public GUIText scoreText;
    public GUIText restartText;
    public GUIText gameOverText;
   
    private bool gameOver;
    private bool restart;
    private int score;
   
    void Start ()
    {
        gameOver = false;
        restart = false;
        restartText.text = "";
        gameOverText.text = "";
        score = 0;
        UpdateScore ();
        StartCoroutine (SpawnWaves ());
        StartCoroutine("MyEvent");
    }
   
    void Update ()
    {
        if (restart)
        {
            if (Input.GetKeyDown (KeyCode.R))
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
        }
    }
   
    IEnumerator SpawnWaves ()
    {
        yield return new WaitForSeconds (startWait);
        while (true)
        {
            for (int i = 0; i < hazardCount; i++)
            {
                GameObject hazard = hazards [Random.Range (0, hazards.Length)];
                Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
                Quaternion spawnRotation = Quaternion.identity;
                Instantiate (hazard, spawnPosition, spawnRotation);
                yield return new WaitForSeconds (spawnWait);
            }
            yield return new WaitForSeconds (waveWait);
           
            if (gameOver)
            {
                restartText.text = "Press 'R' for Restart";
                restart = true;
                break;
            }
        }
    }
   
    public void AddScore (int newScoreValue)
    {
        score += newScoreValue;
        UpdateScore ();
    }
   
    void UpdateScore ()
    {
        scoreText.text = "Score: " + score;
    }
   
    public void GameOver ()
    {
        gameOverText.text = "Game Over!";
        gameOver = true;
    }

    private IEnumerator MyEvent()
    {
        while (true)
        {
            yield return new WaitForSeconds(7.5f);
            Mover.asteroidSpeed = Mover.asteroidSpeed + -2;
            Debug.Log("Asteroid speed increase");
        }
    }
}

Woah, this OP must have been changed or something lol :slight_smile:

ohh, crap. i posted to the wrong forum question.

2 Likes