예제 #1
0
 public void SideDodge(bool right)
 {
     if (right)
     {
         RigidbodyRef.AddForce(transform.right * dodgeForce, ForceMode.Impulse);
     }
     else
     {
         RigidbodyRef.AddForce(-transform.right * dodgeForce, ForceMode.Impulse);
     }
 }
예제 #2
0
    void FixedUpdate()
    {
        if (DamageableRef.IsAlive)
        {
            //Hover force
            RaycastHit hit;
            for (int i = 0; i < hoverPoints.Length; i++)
            {
                GameObject hoverPoint = hoverPoints[i];
                if (Physics.Raycast(hoverPoint.transform.position, -Vector3.up, out hit, hoverHeight))
                {
                    float hoverDistance = hit.distance / hoverHeight;
                    RigidbodyRef.AddForceAtPosition(Vector3.up * hoverForce * (1.0f - hoverDistance), hoverPoint.transform.position);
                }
                else
                {
                    if (transform.position.y > hoverPoint.transform.position.y)
                    {
                        RigidbodyRef.AddForceAtPosition(hoverPoint.transform.up * hoverForce, hoverPoint.transform.position);
                    }
                    else
                    {
                        RigidbodyRef.AddForceAtPosition(hoverPoint.transform.up * -hoverForce, hoverPoint.transform.position);
                    }
                }
            }

            if (Mathf.Abs(currentThrust) > 0)
            {
                RigidbodyRef.AddForce(transform.forward * currentThrust * thrustModifier * Time.deltaTime);
            }

            if (Mathf.Abs(currentSideThurst) > 0)
            {
                RigidbodyRef.AddForce(transform.right * currentSideThurst * Time.deltaTime);
            }

            if (currentTurn != 0)
            {
                RigidbodyRef.AddRelativeTorque(Vector3.up * currentTurn * turnStrength * Time.deltaTime);
            }
        }
    }