void Start()
    {
        anim          = this.GetComponent <Animator>();
        rb            = this.GetComponent <Rigidbody>();
        magicRb       = magic.GetComponent <Rigidbody>();
        player        = this.gameObject;
        startPosition = player.transform.position;

        GenerateEnviroment.RunDummy();

        if (PlayerPrefs.HasKey("highscore")) ////
        {
            highScore.text = "High Score: " + PlayerPrefs.GetInt("highscore");
        }
        else
        {
            highScore.text = "High Score: 0";
        }


        isDead    = false;
        livesLeft = PlayerPrefs.GetInt("lives");

        for (int i = 0; i < icons.Length; i++)
        {
            if (i >= livesLeft)
            {
                icons[i].texture = deadIcon;
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other is BoxCollider && GenerateEnviroment.lastPlatform.tag != "platformTSection")
        {
            GenerateEnviroment.RunDummy();
        }

        if (other is SphereCollider)
        {
            canTurn = true;
        }
    }
    void Update()
    {
        if (PlayerController.isDead)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Space) && anim.GetBool("isMagic") == false)
        {
            anim.SetBool("isJumping", true);
            rb.AddForce(Vector3.up * 200);
        }
        else if (Input.GetKeyDown(KeyCode.E) && anim.GetBool("isJumping") == false)
        {
            anim.SetBool("isMagic", true);
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow) && canTurn)
        {
            this.transform.Rotate(Vector3.up * 90);
            GenerateEnviroment.dummyTraveller.transform.forward = -this.transform.forward;
            GenerateEnviroment.RunDummy();

            if (GenerateEnviroment.lastPlatform.tag != "platformTSection")
            {
                GenerateEnviroment.RunDummy();
            }

            this.transform.position = new Vector3(startPosition.x, this.transform.position.y, startPosition.z);
        }
        else if (Input.GetKeyDown(KeyCode.LeftArrow) && canTurn)
        {
            this.transform.Rotate(Vector3.up * -90);
            GenerateEnviroment.dummyTraveller.transform.forward = -this.transform.forward;
            GenerateEnviroment.RunDummy();

            if (GenerateEnviroment.lastPlatform.tag != "platformTSection")
            {
                GenerateEnviroment.RunDummy();
            }

            this.transform.position = new Vector3(startPosition.x, this.transform.position.y, startPosition.z);
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            this.transform.Translate(-0.5f, 0, 0);
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            this.transform.Translate(0.5f, 0, 0);
        }
    }