Exemple #1
0
    private void ApplyHover(HoverInput hoverInput)
    {
        var        ray = new Ray(CachedTransform.position, -CachedTransform.up);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, hoverHeight))
        {
            var force = _defaultForce + ((hoverHeight - hit.distance) / hoverHeight * correctiveForce);
            CachedRigidbody.AddForce(Vector3.up * force, ForceMode.Force);
        }

        CachedRigidbody.AddRelativeForce(0f, 0f, hoverInput.vertical * speed, ForceMode.Acceleration);

        if (strafe)
        {
            CachedRigidbody.AddRelativeForce(hoverInput.horizontal * speed, 0f, 0f, ForceMode.Acceleration);
        }
        else
        {
            CachedRigidbody.AddRelativeTorque(0f, hoverInput.horizontal * turnSensitivity, 0f, ForceMode.Acceleration);
        }

        if (hoverInput.jump)
        {
            CachedRigidbody.AddForce(Vector3.up * jumpStrength, ForceMode.Acceleration);
        }
    }
Exemple #2
0
 public void SetInput(HoverInput inp)
 {
     _input = inp;
 }