• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - IDE Physics collision doesn't seem to reflect shape I've set.

K

kylecruffin

Guest
Collision-Error.gif
This boxing glove ship is meant to bounce away and take damage on collision with the ball. However, it seems to bounce away before it even gets close.
glove coll.png jack coll.png
Here are the physics colliders I've set. I don't understand why these seem to behave as though they're colliding before these should overlap.

Here's what the boxing glove has in the "collision with ball" event:
Code:
if(physics_test_overlap(phy_position_x,phy_position_y,phy_rotation,obj_exploder))
{
    action_set_relative(0);
    charging = false;
    var length = sqrt(power(other.x-x, 2) + power(other.y-y, 2));
    var xNormalized = (other.x-x)/length;
    var yNormalized = (other.y-y)/length;
    physics_apply_impulse(x, y, -xNormalized * 250, -yNormalized * 250);

    {
        action_set_relative(1);
        action_set_health(-10);
        action_set_relative(0);
    }
    var __b__;
    __b__ = action_if_variable(image_speed, 1, 0);
    if !__b__
    {
    {
    action_sprite_set(Player, 0, 1);
    action_set_alarm(invincibleTime, 0);
    __b__ = action_if_health(1, 1);
    if __b__
    {
    {
    dead = true;
    }
    }
    }
    }
    action_set_relative(0);
}
Excuse the messiness, this was converted fairly hastily from GMS1 and I haven't gotten around to cleaning up all of the variables named __b__ and such. Regardless, none of that should be relevant, since the collision itself is the issue. I suspect physics_test_overlap is redundant since it's in the collision event, but I was hoping it would fix this issue. It doesn't seem to.

I've checked the masks, and that doesn't seem to be the issue either. This is in a physics room, and both objects have a fixture, as evidenced by the physics collision shapes.

Any ideas on what might be going wrong? I'm very stuck.
 

Attachments

Jezla

Member
There is no need to check for overlap if you have a collision event defined, still less checking for overlap within the collision event. To get the behavior you want, all you should need in the collision event is code to apply the damage and the impulse.
 
K

kylecruffin

Guest
There is no need to check for overlap if you have a collision event defined, still less checking for overlap within the collision event. To get the behavior you want, all you should need in the collision event is code to apply the damage and the impulse.
I suspected as much. However, without that check for overlap, I still have the same problem as shown in the GIF.
 

Jezla

Member
Ok, have you tried turning the physics debug drawing on to make sure your fixtures do match how they are defined in the object editor? I've experience incidents where I defined a fixture in the editor, but when the instance was actually created in the room, the fixture was misaligned. You haven't scaled down your sprites at all, have you?

If none of these are the case, you'll need to post more code. How is your physics world defined (update speed, pixels/meter)? What do those action_set scripts do? How is the moving object controlled?
 
Top