Lianna (on Mastodon) on Nostr: #Gamedev question: If I want to manually program a collision system for a lot of ...
#Gamedev question:
If I want to manually program a collision system for a lot of units, think like in an #RTS, and the only info I have is a list of units containing each their X and Y coordinates as well as their collision box diameter, how would I go about doing that?
Do I iterate through every single unit every frame to check whether the destination they'd move to this frame overlaps with ANY of the other units, meaning iterating through n² units per frame?
That's an exponential effort!
Published at
2025-04-04 12:07:36Event JSON
{
"id": "50720c7081ccba5690f46860ba90031d2995307769360fc0445f63e30f89d080",
"pubkey": "80c22a3f9bbdf0c245d57179851410b48497764fca16fbdb8463e446b585ce5a",
"created_at": 1743768456,
"kind": 1,
"tags": [
[
"t",
"gamedev"
],
[
"t",
"rts"
],
[
"proxy",
"https://mastodon.gamedev.place/users/lianna/statuses/114279609541624086",
"activitypub"
]
],
"content": "#Gamedev question:\n\nIf I want to manually program a collision system for a lot of units, think like in an #RTS, and the only info I have is a list of units containing each their X and Y coordinates as well as their collision box diameter, how would I go about doing that?\n\nDo I iterate through every single unit every frame to check whether the destination they'd move to this frame overlaps with ANY of the other units, meaning iterating through n² units per frame?\n\nThat's an exponential effort!",
"sig": "cc835236cdb9e1da2ce8c93295d5a0bedc208f14ba4b2e2b5a9c60f53cb04d6c476d14f55e936c75026301fdf0ef9fdc35c9e2b0d29c2eb2f33cd1b98ac75375"
}