コード例 #1
0
 public void SetActiveStatus(bool isActive)
 {
     this.isActive = isActive;
     if (isActive)
     {
         gravity.EnableGravity();
     }
     else
     {
         gravity.DisableGravity();
     }
 }
コード例 #2
0
    private void Update()
    {
        var x    = Input.GetAxis(horrizontalCtrl);
        var xRaw = Input.GetAxisRaw(horrizontalCtrl);

        var y    = Input.GetAxis(verticalCtrl);
        var yRaw = Input.GetAxisRaw(verticalCtrl);

        if (canFly)
        {
            grav.DisableGravity();
            Fly(x, y);
            return;
        }
        else
        {
            grav.EnableGravity();
        }

        if (coll.onGround && !isDashing)
        {
            Walk(x, y);
        }



        //canDash =  Time.time - lastTimeStamp > dashCoolDown;

        //if(Input.GetButtonDown(dashButton) && !isDashing && canDash)
        if (Input.GetButtonDown(dashButton) && !isDashing && coll.onGround)
        {
            if (Mathf.Abs(x) >= 0.1 || Mathf.Abs(y) >= 0.1)
            {
                Normalize(x, y, out float xNor, out float yNor);
                //lastTimeStamp = Time.time;
                //Debug.Log("x is " + xNor + "y is" + yNor);
                //listener.Listen();
                Dash(xNor, yNor);
            }
        }

        // if (isDashing && coll.onWall)
        // {
        //     rb.velocity = Vector2.zero;
        //     //canDash = false;
        //     //lastTimeStamp = Time.time;
        //     canWalk = false;

        //     //added enumerator terminator---
        //     StopCoroutine(DashWait());

        //     //grav.gravityScale = 3;
        //     isDashing = false;
        //     canDashGravChange = true;
        //     canWalk = true;
        //     //lastTimeStamp = 0;
        //     grav.enableGravity();

        //     // string nextKey = listener.Request();

        //     // if (nextKey == dashButton)
        //     // {
        //     //     Debug.Log("Followup");
        //     //     if (Mathf.Abs(x) >= 0.1 || Mathf.Abs(y) >= 0.1)
        //     //     {
        //     //         Normalize(x, y, out float xNor, out float yNor);
        //     //         lastTimeStamp = Time.time;
        //     //         listener.Listen();
        //     //         Dash(xNor, yNor);

        //     //     }
        //     // }
        //     // else
        //     // {
        //     //     Debug.Log("No Followup: " + nextKey);
        //     // }
        //     //------------------------------
        // }
        // else
        // {
        //     canWalk = true;
        //     canDashGravChange = false;
        // }
    }