#Broad Phase Query
1 messages · Page 1 of 1 (latest)
that's a spatial query not a filter
and while yeah you can filter within the query, i don't think that's what you were asking - actually, i'm not sure what you're asking
can you elaborate what you mean by detection system
I'm not entirely sure what your asking
GetPartBoundsInRadius makes use of the same logic the physics solver uses, including however broad phase is handled, so its reasonably performant most of the time.
I don't know enough to say if GetPartBoundsInRadius is strictly good or bad for your situation, it depends.
If the performance is good, it might be a fine solution.
Keep in mind I don't know what your doing, so even an O(n^2) search of everything might be faster, it depends.
That's actually what I'm asking, I'm using a magnitude check for my hit detection and was wondering whether I could use a spacial query to act as a filter
I'm using the spacial query to filter out the positions needed for my magnitude hitbox checks
Whats the total number of magnitude checks you'd have to do if you didn't use a spatial query?
Around 80
tbh you can almost certainly get away with just doing the magnitude checks
it will probably be faster anyway
spatial query is almost always faster than checking against an array of instances
it depends how big the array is
and how often
i'd consider spatial query to be more optimal at this scale
it scales better
I'm doing them every 0.04 seconds for around 0.1-0.3 seconds depending on my active frames
Yeah I was hoping it would work as a filter so I can get better performance
yeah computers are fast as fuck I would just leave it with magnitude checks
you can always optimize it later if it becomes a problem
Which one scales better though?
also, consider doing a squared distance check instead of magnitude
spatial query but I disagree with pyro on where the line is of one being better than the other
You think it'll be fine per m1 because assuming we have 20 players (and 80 entities overall) that's around 1600 checks assuming they all m1 per second
*though asterisk because if you have of thousands of parts around that don't need to be queried, they will still be taken into account by the spatial query which can heavily hinder performance. You can get around that with world models but it does make stuff more complicated
sqrt is most expensive part of it
yeah
also, consider doing a squared distance check instead of magnitude
yeah thats fine
especially if you do your own distance check that doesn't use square root
and compares squared distances
will be fast as fuck
So you think it'd be better to do a squared distance check over a spatial query?
For your situation, absolutely
@near fjord Go with whichever one you will have an easier time implementing. If it ends up being too slow, try implementing the other one
Thanks guys
I'll stick with the query for now but I'll look into squared checks if performance becomes an issue
I know that I got my answer but I just forgot to mention that I use a whitelist for the spacial query. I wonder if that changes your view on things.
The spatial query (same with raycasts and everything else like that) will query every object in the world model and then filter those resulting matches based on your whitelist
So performance is actually technically worse when using a whitelist/blacklist 😭
-# though not a reason to avoid using the whitelist, because if you do, you'd probably end up doing the same thing but in luau
If you want to actually limit what a spatial query/raycast queries against, place the parts you want to query inside a world model and use its query methods
https://create.roblox.com/docs/reference/engine/classes/WorldModel
Gotcha that changes things for me
Ok tysm
Will placing characters into a world model have any effects on behavior?
first i'm hearing about this, always thought model and worldmodel were the same
the more you know
ikmoveto looks interesting i wonder why plugin only
They will stop simulating physics
and won't collide with anything in the workspace or other world models
If you wanted to use them, you'd have to add a part to the world model for each target and then query those.
Every frame, update those parts to match the position of the target in the workspace
When you do the query, map the matched parts to their corresponding targets
** You are now Level 29! **
sounds like a lot more work than just doing a squared broad check 😅