GameMaker (SOLVED) Disable collision for the same types

G

gavriil08

Guest
I have more soldiers, I want them to collide with enemies, but not between them.

I read I could do this using the built in physics and assign them to the same negative group. But this drops my FPS a lot, so I want to know if I could achieve this just by using regular functions.
 
How are you doing collisions? Do you have an collision event setup for Soldier->Soldier already? Or do you have a parent object that handles collision?

As long as you are not using the solid flag, just put a check at the top of your collision event for Soldier -> Soldier.

Code:
if ( other.object_index == objSoldier && object_index == objSoldier )
{
    return; // Ignore soldier -> soldier collisions
}

// Rest of collision code goes here.
 
G

gavriil08

Guest
I did not have any collision events, they just have collision masks. I tried with collision events also, but they still collide..
 
G

gavriil08

Guest
Seems like the collision event is never triggered...
 
G

gavriil08

Guest
I made sure the solid box is not checked already, the thing is for general-soldier the collision event is triggered, but not when the object are of similar type.
 
G

gavriil08

Guest
I figured it out the problem! Yay!!

The problem was that I was using mp_potential_step, and this has a parameter checkall which I set to true. That was preventing the objects from colliding with each other.
 
Top