コード例 #1
0
ファイル: Dash.cs プロジェクト: mgrazier/FlappyClone
    public IEnumerator UseDash()
    {
        float   dashTime   = .25f;
        float   startVelX  = rb.velocity.x;
        Vector3 oldGravity = Physics.gravity;

        Physics.gravity = Vector3.zero;
        rb.velocity     = Vector3.zero;
        fc.SetDashing(true);

        if (rb.isKinematic)
        {
            rb.isKinematic = false;
        }
        while (fc.GetDashing())
        {
            rb.AddForce(new Vector3(500f, 0, 0));
            yield return(new WaitForSeconds(dashTime));

            rb.velocity = new Vector3(startVelX, 0, 0);
            fc.SetDashing(false);
        }

        Physics.gravity = oldGravity;
        yield return(null);
    }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (fc.GetDashing())
     {
         mainCamera.transform.position = new Vector3(playerCharacter.transform.position.x + 3, 0f, -10f);
     }
     else
     {
         mainCamera.transform.position = new Vector3(playerCharacter.transform.position.x + 3, 0f, -10f);
     }
 }
コード例 #3
0
ファイル: Flap.cs プロジェクト: mgrazier/FlappyClone
 public void UseFlap()
 {
     if (rb.isKinematic)
     {
         rb.isKinematic = false;
     }
     if (fc.GetDashing() == false)
     {
         rb.velocity = new Vector3(fc.startVelX, 5f, 0f);
     }
 }