Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        ground = Physics2D.IsTouchingLayers(co, matchground);

        rg.velocity = new Vector2(speed * Time.deltaTime, rg.velocity.y);

        if (transform.position.x > speeddistance)
        {
            speeddistance = speeddistance + 300;

            speed = speed + speedplus;

            point.setdistancex(0.5f);
            point.setdistancex2(0.5f);
        }



        if (ground == true)     //if we're on the floor
        {
            //if (Input.GetMouseButtonDown(0))          //Input.GetKeyDown(KeyCode.Space))

            if (Input.GetMouseButtonDown(0) && Input.mousePosition.x < Screen.width / 2)


            {
                jumps();

                dblJump = true;

                jumpsound.Play();
            }
        }


        if (!ground && dblJump && Input.GetMouseButtonDown(0) && Input.mousePosition.x < Screen.width / 2)    // Input.GetMouseButtonDown(0))//Input.GetKeyDown(KeyCode.Space))
        {
            jumps();


            dblJump = false;
            doublejump.Play();
        }



        myanimator.SetBool("ground", ground);

        myanimator.SetBool("dblJump", dblJump);


        myanimator.SetBool("type", Input.GetMouseButtonDown(0));
    }