void Start()
    {
        //Anim will ne null if no animator
        anim = this.GetComponent <Animator>();
        rb   = this.GetComponent <Rigidbody>();
        mRb  = magic.GetComponent <Rigidbody>();
        sfx  = GameObject.FindWithTag("gamedata").GetComponentsInChildren <AudioSource>();

        player        = this.gameObject;
        startPosition = player.transform.position;
        GenerateWorld1.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;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (PlayerController.isDead)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.Space) && anim.GetBool("isMagic") == false)
        {
            anim.SetBool("isJumping", true);
            rb.AddForce(Vector3.up * 200);
            sfx[3].Play();
        }
        else if (Input.GetKeyDown(KeyCode.M) && anim.GetBool("isJumping") == false)
        {
            anim.SetBool("isMagic", true);
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow) && canTurn)
        {
            this.transform.Rotate(Vector3.up * 90);
            GenerateWorld1.dummyTraveller.transform.forward = -this.transform.forward;
            GenerateWorld1.RunDummy();

            if (GenerateWorld1.lastPlatform.tag != "platformTSection")
            {
                GenerateWorld1.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);
            GenerateWorld1.dummyTraveller.transform.forward = -this.transform.forward;
            GenerateWorld1.RunDummy();

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

            this.transform.position = new Vector3(startPosition.x,
                                                  this.transform.position.
                                                  y, startPosition.z);
        }
        //for displacement to left
        else if (Input.GetKeyDown(KeyCode.A))
        {
            this.transform.Translate(-0.5f, 0, 0);
        }
        //for displacement to right
        else if (Input.GetKeyDown(KeyCode.D))
        {
            this.transform.Translate(0.5f, 0, 0);
        }
    }
 private void OnTriggerEnter(Collider other)
 {
     if (other is BoxCollider && GenerateWorld1.lastPlatform.tag != "platformTSection")
     {
         GenerateWorld1.RunDummy();
     }
     if (other is SphereCollider)
     {
         canTurn = true;
     }
 }