• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Target specific object used in if statement

G

Guest User 1

Guest
I have some collision code:
Code:
if( x + 16 >= obj_platform.x - 16
 && x - 16 <= obj_platform.x + 16
 && y + 16 >= obj_platform.y - 8
 && y - 16 <= obj_platform.y + 8 ) {
    y = obj_platform.y - 24 ;
    vel_y *= -1 ;
    vel_y -= 1 ;
    obj_platform.vel_y -= vel_y ;
};
How do I have that last line affect ONLY the instance that would trigger the if statement? Will "other" work?
 

jo-thijs

Member
Code:
with obj_platform
    if other.x + 16 >= x - 16
    && other.x - 16 <= x + 16
    && other.y + 16 >= y - 8
    && other.y - 16 <= y + 8 {
        other.y = y - 24 ;
        other.vel_y = -other.vel_y;
        other.vel_y -= 1;
        vel_y -= other.vel_y ;
    }
 
G

Guest User 1

Guest
Code:
with obj_platform
    if other.x + 16 >= x - 16
    && other.x - 16 <= x + 16
    && other.y + 16 >= y - 8
    && other.y - 16 <= y + 8 {
        other.y = y - 24 ;
        other.vel_y = -other.vel_y;
        other.vel_y -= 1;
        vel_y -= other.vel_y ;
    }
Thanks... again :)
 
Top