I'm making a 2D soccer game, and the players are made of 2 objects: Head and feet.
I managed to, using groups, stop the feet and head from colliding with each other. But after adding a second player, I realized that the feet should actually ONLY collide with the ball and nothing else. How can this be achieved?
Objects should collide only with one category
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Objects should collide only with one category
You don't need separate bodies, you can set the category and mask PER fixture. Also, you can solve this without using "groups". You need at least 3 categories "head", "feet" and "ball", correspondingly: 0x1, 0x2 and 0x4. The trick would be setting the collision masks correctly. The masks should be: 0x0, 0x4, 0x2 when the ball is on the ground in short the "head" category is ignored altogether. Set the first mask to 0x1 if you want the player "heads" to collide with each other.
Not sure if it's a good idea to use collision masks in this way, but it's hard to say without seeing the rest of the code.
Not sure if it's a good idea to use collision masks in this way, but it's hard to say without seeing the rest of the code.
Re: Objects should collide only with one category
I'm not really familiar with collisions mask, how would I do that?ivan wrote: ↑Mon Nov 04, 2019 4:38 pm You don't need separate bodies, you can set the category and mask PER fixture. Also, you can solve this without using "groups". You need at least 3 categories "head", "feet" and "ball", correspondingly: 0x1, 0x2 and 0x4. The trick would be setting the collision masks correctly. The masks should be: 0x0, 0x4, 0x2 when the ball is on the ground in short the "head" category is ignored altogether. Set the first mask to 0x1 if you want the player "heads" to collide with each other.
Not sure if it's a good idea to use collision masks in this way, but it's hard to say without seeing the rest of the code.
Who is online
Users browsing this forum: Google [Bot] and 7 guests