void FixedUpdate()
    {
        if (isActive)
        {
            Ray        ray = new Ray(transform.position, -transform.up);
            RaycastHit hit;

            transform.localEulerAngles = new Vector3(stickV, transform.localEulerAngles.y, -stickH);

            dynamics.AddRelativeTorque(Vector3.up * hoverForce * 0.000005f * yaw);

            if (Physics.Raycast(ray, out hit, hoverHeight) && hit.collider.CompareTag("Floor"))
            {
                float   proportionalHeight = (hoverHeight - hit.distance) / hoverHeight;
                Vector3 appliedHoverForce  = Vector3.up * proportionalHeight * hoverForce;
                dynamics.AddRelativeForce(appliedHoverForce, ForceMode.Acceleration);
            }

            if (healthIndicator)
            {
                healthIndicator.SetHealth(dmgCtrl.health);
            }

            if (dmgCtrl.health < 0 && !isSelfDestroying)
            {
                isActive = false;
                Destroy(gameObject, 5f);
                dynamics.isKinematic = false;
                dynamics.useGravity  = true;
                dynamics.AddExplosionForce(100f, dmgCtrl.hitPos, 0.5f);
                isSelfDestroying = true;
            }
        }
    }
Exemple #2
0
 //@todo Figure out how to do weapon swaps with different max round capacity
 public void SetHealth(float healthPoint)
 {
     m_healthIndicator.SetHealth(healthPoint / 100f);
 }