Skip to content

Instantly share code, notes, and snippets.

@nirinchev
Created February 9, 2022 15:22
Show Gist options
  • Save nirinchev/1d4e3467a50fed16bacd8f2655f02715 to your computer and use it in GitHub Desktop.
Save nirinchev/1d4e3467a50fed16bacd8f2655f02715 to your computer and use it in GitHub Desktop.
IQueryable<Powerup> PowerupsAroundLocation(Vector3 location, float radius)
{
// Note that this query returns a cube around the location, not a sphere.
var powerups = realm.All<Powerup>().Filter(
"Position.x > $0 AND Position.x < $1 AND Position.y > $2 AND Position.y < $3 AND Position.z > $4 AND Position.z < $5",
location.x - radius, location.x + radius,
location.y - radius, location.y + radius,
location.z - radius, location.z + radius);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment