ignore collision between dynamic objects.

Hi,

Once more a little problem to solve. If my player hits an enemy he should ignore the collision in certain circumstances only.

Things I tried:

A:
Replace dynamic object with a non dynamic object. Won’t work as it would ruin enemies behaviour.

B:
Slightly move dynamic object away. Works but if enemy turns during collision, he turns not right as the dynamic object is moved so the center.

Example:

def NoPhysics(cont):
        own = cont.owner
        own_pos_x = own.position[0]+5.0
        own.position[0] = own_pos_x

        own['reset_physics_count'] += 1
        for child in own.children:
            
            pos_x = child.position[0]-5.0
            child.position[0] = pos_x




def ResetPhysics(cont):
    own = cont.owner
    s_delay_physics = cont.sensors['s_delay_physics']

    phys_count = 5.0 * own['reset_physics_count']
    
    if s_delay_physics.positive:
        
        own['reset_physics'] = False

        own_pos_x = own.position[0]-phys_count
        own.position[0] = own_pos_x

        
        for child in own.children:
            
           
            pos_x = child.position[0]+phys_count
            child.position[0] = pos_x

        own['reset_physics_count'] = 0
        


Do you have any better idea to ignore collision? Thanks in advance

i can guess only to use suspend dynamics , the object become static until you not re-enable dynamics.
this mean that you can move througt other obj, but other obj dynamic continue to get the collision…

or you can parent the obj to a empty noCollision (compound,ghost) this make the obj really ghost …

You could put the collision box on a different layer and add/remove it in different situations.

You could replace the player’s mesh with a non-collision enabled mesh and recalculate the physics. That might work. You could also try doing the object’s physics yourself - then you can selectively ignore collisions. Otherwise, I believe Kupoman’s Cucumber branch from last year’s GSOC had collision groups implemented - maybe they’ll be merged soon, or maybe you or someone else can make a build with it enabled.

Hey thanks all for your nice ideas. This seems to be quite difficult to get good results.

@MarcoIT
suspending dynamics won’t work for the reason you mentioned.

or you can parent the obj to a empty noCollision (compound,ghost) this make the obj really ghost

The problem here is that if set to noCollision that the object will loose its motion and would not anymore detect ground.

@redbaron5

You could put the collision box on a different layer and add/remove it in different situations.

Is that possible? I thought not.

@SolarLune

You could replace the player’s mesh with a non-collision enabled mesh and recalculate the physics.

This really might work. I will try that out.

You could also try doing the object’s physics yourself - then you can selectively ignore collisions.

I think that’s hard to achieve.

It’s possible. I have a cube with collision on it on a second layer that I add to the enemy when the player is a certain distance away, then remove it when the player leaves that distance. You could just only add the collision cube if the conditions you need are met.

Not sure if this is the most efficient way, but it works.

Thanks again Redbaron5 for further explanation. Aha, you mean add object from a hidden layer and remove afterwards. This I have already tried but not with really great results.

For now, the most simplest solution would be to change the enemies collision object from dynamic to nocollision and try doing the object’s physics myself.