/// <summary> /// Applies an impulse to the player from a point in world space. Fall-off of the impulse /// is linear relative to distance from the source. /// <summary> /// <param name="sourcePosition"> World space position of the explosion. </param> /// <param name="power"> Power of the explosion in units of velocity * distance. </param> public void RocketJump(Vector3 sourcePosition, float power) { var ds = _playerMover.Position - sourcePosition; if (ds.y > _minRocketJumpDeltaY && ds.sqrMagnitude < _maxRocketJumpDistance * _maxRocketJumpDistance) { var scaledPower = power / ds.magnitude; if (scaledPower > _maxRocketJumpPower) { scaledPower = _maxRocketJumpPower; } _playerMover.ApplyImpulse(ds.normalized * scaledPower); } }