-
What do I want to achieve?
I’m currently trying to do spatial queries for cylindrical and cone shapes, but don’t know how. I don’t want to create instances and use GetPartsInPart because I feel like it’s more performance costly. I especially want it so that the cylinder CAN ROTATE IN ALL VECTORS and not just locked relative to a world axis. -
What is the issue?
I don’t know how. -
What solutions have I tried so far?
I haven’t really scripted anything, but I have a weird idea I could try, if only I knew the math for it. For cylinder, I would start by getting spherical query (distance from N) and then just eliminating anything above or below a certain Y coordinate. This works but only for world aligned poles, not cylinders that can rotate with a flying player’s body (it’s not supposed to be world orientation locked).
just use workspace:Shapecast()
https://create.roblox.com/docs/reference/engine/classes/WorldRoot#Shapecast
Sounds like you need shapecasts as previously mentioned.
(Correct :Shapecast() article: Introducing generalized shapecasts)
You should provide more information so we can help you. All cylinders can rotate on all axes normally. To change the direction of the shapecast you can use the direction argument which supports rotation in 3 dimensions since it is a 3 dimensional vector.
wait oh crap i just realized i didn’t mean shapecast, i meant shape queries (get EVERYTHING INSIDE A VOLUME)
not possible unless perhaps use Region3 which is deprecated
so should i use region3 or what? or try some convoluted asf method relying entirely on the mathematical/geometry of player positions and such?
just use workspace:GetPartsInParts() most combat games and systems who use overlapping functions use this and no it dont cost more peformance
oh true lol i could just do that
i was worrying about it first because idk how to create a part that only the server has and isn’t replicated to the client, so i don’t waste unnecessary replication data on an invisible part the server needs
I myself use the “PartCache” module to cache hitbox parts so that I don’t need to instance one every time. I think it would be worth looking into if you do end up going with physical parts.
Additionally, you can create a collision group so that the hitbox ONLY detects parts that you need.
1- I create a collisionGroup named ‘Target’. I set a custom playerHitbox with said collisionGroup instead of relying solely on their limbs.
2- I create a collisionGroup named ‘Hitbox’. This will only detect instances with the ‘Target’ collisionGroup.
3- For Projectiles, I have a third collisionGroup that detects both ‘Target’ and ‘Default’ (‘Default’ incase I want something to happen when it hit’s a non-player object).
This should save some processing by ignoring parts that don’t need to be checked.