I have a question about an object collision with itself. Is there anyway that my character in my game, of which I have defined a collision sphere, will not recognize itself as a collision?
This gives me a lot of trouble because my AI character moves around the world and sometimes goes crazy because it collides with itself. I can simply tell it to do nothing when it collides with itself, but then when it “steps out of the world” it only collides with itself and I can’t tell it to cme back (because I told it to do nothing).
Any way to turn it off?
Does the model contain multiple collision nodes?
If so, make sure that the into and from masks are set in a way that they can’t collide with each other.
Yes, I have two nodes, but I don’t know how to make them not know each other. I have tried looking in the into and form masks methods but I really don’t understand the API’s explanation of this. Do you have a simple example of this? I’d really appreciate it, thanks for all the help!
Well, they collide if the from mask matches its into mask.
For example, if the from mask is BitMask32.bit(0), meaning the first bit:
And if the into mask happens to be BitMask32(3), meaning 3 in binary:
One 1 bit matches (the first one), so they collide.
So, you need to make sure that there are no 1 bits matching, then they will not collide.
What are the bitmasks set to, of your collision nodes, and what exactly should and shouldn’t be colliding with the object? For most simple cases, because your player only collides with other things and not the other way around, you’ll want to set the Into mask of the player to BitMask32.allOff(), (which is the same as BitMask32(0) but NOT the same as BitMask32.bit(0)).
(PS. I simplified the example to 8bits instead of 32bits)
You really helped, thank you. Now I was able to solve the issues I had and no longer my AI character goes crazy because it collides with itself. Thanks again!