Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setup Ignore Collisions between Body and Motor Colliders?
#4
(30-04-2024, 11:55 AM)spikebor Wrote: Yes, I mean Obi "layer" is this mask filtering system.
So dynamically setting filter and mask? I still not wrap my head around this fully.

It depends on how many characters you need to simulate simultaneously. You'll only ever need to dynamically change the filtering system at runtime if you have more than 16 characters on screen, since that's the maximum amount of categories you can have. Otherwise you can just give a different category to each character (doesn't matter which one), and set its mask to "everything except its own category".

If you really must have more than 16 characters simultaneously (which is probably too many if they all have to be simulated) you can just group them by proximity using a regular grid, for example. Assuming each character has a maximum size/radius of X meters:

- Take the position of the character, divide it by X and take its integer part. This gives you coordinates of a cell the character is in. Characters in cells not adjacent to it are guaranteed to be more than X meters apart, so you know a character can only ever collide with characters in its same cell or cells adjacent to it.

- Whenever a character moves to a new cell (that is, its integer coordinates change), take the categories of all characters found in adjacent cells and assign the first free one to it.

This method allows you to have up to 16 characters per cell neighborhood and is fairly straightforward to implement.
Reply


Messages In This Thread
RE: Setup Ignore Collisions between Body and Motor Colliders? - by josemendez - 30-04-2024, 12:40 PM