• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

another dilema

fxokz

Member
In my game there is a certain type of block that is activated when shot. When it is activated the player can now collide with it instead of passing through it. The problem is if the player is already colliding with it and then shoots the block the player becomes stuck.. My original idea was to make it so that if the player shoots it and is colliding with it, the player teleports a few pixels away until it is no longer colliding. But i dont know if that solution is a good idea. How would you go about solving this issue?
 
M

Maximus

Guest
You could just wait for the player to move out of the way before turning it solid (or whatever flag you use).

eg in the block's step put
Code:
if activated && !place_meeting(x, y, obj_player)
{
    solid = true;
    activated = false; // so you stop checking once its set
}
Edit: something like this might work for moving the player out of the way:
Code:
if (activated)
{
    var player_inst = instance_place(x, y, obj_player) // like place_meeting but returns an instance id
    if (player_inst == noone) // no collision, all g
    {
        solid = true;
        activated = false; // so you stop checking once its set
    }
    else // move the player out of the way
    {
        with (player_inst)
        {
            hsp += sign (x - other.x);
            vsp--; 
        }
    }
}
 
Last edited by a moderator:

fxokz

Member
You could just wait for the player to move out of the way before turning it solid (or whatever flag you use).

eg in the block's step put
Code:
if activated && !place_meeting(x, y, obj_player)
{
    solid = true;
    activated = false; // so you stop checking once its set
}
Edit: something like this might work for moving the player out of the way:
Code:
if (activated)
{
    var player_inst = instance_place(x, y, obj_player) // like place_meeting but returns an instance id
    if (player_inst == noone) // no collision, all g
    {
        solid = true;
        activated = false; // so you stop checking once its set
    }
    else // move the player out of the way
    {
        with (player_inst)
        {
            hsp += sign (x - other.x);
            vsp--;
        }
    }
}
you are actually the best.
 
Top