コード例 #1
0
    public void Dodge(float velocity, float duration)
    {
        _dodgeVelocity   = velocity;
        _dodgeDuration   = duration;
        _dodgeTime       = Time.time;
        gameObject.layer = LayerManager.DodgeLayer;
        _isDodging       = true;
        float  portion       = Mathf.Sign(velocity) * .5f;
        ushort leftStrength  = Convert.ToUInt16((.5f - portion) * 3000);
        ushort rightStrength = Convert.ToUInt16((.5f + portion) * 3000);

        JoystickUtil.RumbleJoystick(leftStrength, rightStrength, 200);
    }
コード例 #2
0
    protected virtual void DamageRumbleEffect(float distance, float hitDirection, ushort rumbleStrength = 10000)
    {
        float maxDistance = 1.9f;
        float portion;

        if (distance * hitDirection > maxDistance)
        {
            portion = hitDirection * .5f;
        }
        else
        {
            portion = distance / maxDistance * .5f;
        }
        ushort leftStrength  = Convert.ToUInt16((.5f - portion) * rumbleStrength);
        ushort rightStrength = Convert.ToUInt16((.5f + portion) * rumbleStrength);

        JoystickUtil.RumbleJoystick(leftStrength, rightStrength, 200);
    }