Best spatial query or raycast to use for a simple combat system

  • workspace:GetPartsInParts()
  • workspace:Raycast()
  • workspace:GetPartsBoundInBox()
  • workspace:GetPartsBoundInRadius
  • workspace:Blockcast()
  • workspace:Shapecast()
  • workspace:Spherecast()
0 voters
1 Like

GetPartsInPart is much more performant and is usually enough for most combat systems

1 Like

i usually use Raycast, GetPartBoundInRadius, and GetPartsBoundInBox.

1 Like

I’ve always used workspace:GetPartsBoundInBox and its worked perfectly fine without much lag at all, and it was the easiest to use imo.

I actually use the following in given situations:

  1. workspace:GetPartsBoundInBox() is what I use for the majority of my skills.

  2. workspace:GetPartsInPart() is used when I need more accurate hitDetection for non-cube-like hitboxes, like that of a sphere. I could probably swap this out with workspace:GetPartsBoundInRadius().

  3. workspace:Raycast() for Projectiles (if they aren’t too big to the point of needing millions of raycasts lol) until it detects a hit, then I use :GetPartBoundsInBox to get enemies at the HitPosition.

Additionally, when a player spawns, I create a PlayerHitbox and set it’s collisionGroup to “Target”, which is a collisionGroup that only interacts with collisionGroups “Hitbox” and “Projectile” to help with performance a bit.