예제 #1
0
    // Update is called once per frame
    void Update()
    {
        Vector3 dir = Vector3.zero;

        if (!dash.IsDashing())
        {
            dir = ghost.GetNextDir().vec;
            if (dir != Vector3.zero)
            {
                rb.MovePosition(transform.position + dir * Time.deltaTime * speed);
                Mesh.transform.rotation = Quaternion.LookRotation(-dir.normalized, Vector3.up);
            }
        }
    }
예제 #2
0
 // Update is called once per frame
 private void Update()
 {
     if (doCool)
     {
         cool += Time.deltaTime;
         if (cool >= cooldown)
         {
             doCool = false;
             cool   = 0f;
         }
     }
     else
     {
         if (doDash)
         {
             if (dashTmr < dashTime)
             {
                 dashTmr += Time.deltaTime;
                 //Debug.Log(rb.velocity);
                 if (!afterDash)
                 {
                     rb.AddForce(currentDir * dashSpeed * dashMultiplier, ForceMode.Impulse);
                     afterDash = true;
                     doCool    = true;
                 }
             }
             else
             {
                 Stop();
             }
         }
         else
         {
             if (Input.GetKeyDown(KeyCode.Z))
             {
                 Dash(ghost.GetNextDir());
             }
         }
     }
 }