Legacy GM Collision

S

Stac

Guest
How to make smooth enemy collision with speed == 20 and friction == 4?
 

GMWolf

aka fel666
your code should be independent of you speed and friction.
What do you mean by enemy collision? do you mean the player colliding with the enemy? the enemy colliding with walls?
 
S

Stac

Guest
your code should be independent of you speed and friction.
What do you mean by enemy collision? do you mean the player colliding with the enemy? the enemy colliding with walls?
I mean enemy colliding with wall.

UPD: my code doesn't work right, because enemy can pass first couple of pixels of wall.
 

GMWolf

aka fel666
I mean enemy colliding with wall.

UPD: my code doesn't work right, because enemy can pass first couple of pixels of wall.
what you want to do is on collision with the wall, use the move_outside_all function to move the object out of the wall.
I recommend you read the manual entry (linked above) about it.
 
S

Stac

Guest
what you want to do is on collision with the wall, use the move_outside_all function to move the object out of the wall.
I recommend you read the manual entry (linked above) about it.
By the way, how can I detect how many pixels of enemy is in wall? For "push" it from wall on N pixels.
 
S

Sanil

Guest
I don't know what code you are using right now but I am pretty sure it is something like
Code:
if place_meeting(x,y,wall)
{
     hsp = 0;
     vsp = 0;
//Other things
}
but I highly suggest that you watch this Shaun Spalding video to do it better.....
hope it helps:):)
 

GMWolf

aka fel666
By the way, how can I detect how many pixels of enemy is in wall? For "push" it from wall on N pixels.
it doesnt matter, simply set the value to -1 and it will do move by just the right amount.

But if you want a more robust system, I have a tutorial on how to implement such collisions with a player object.
You should be able to adapt it to enemy objects without much trouble.
 
S

Stac

Guest
it doesnt matter, simply set the value to -1 and it will do move by just the right amount.

But if you want a more robust system, I have a tutorial on how to implement such collisions with a player object.
You should be able to adapt it to enemy objects without much trouble.
Thanks for tutorial, but my enemies using potential_step. I'm just want to know how to fix that:


Code:
if (enemyBody.fallen == true || enemyBody.killed == true) && enemyBody.limiter == true {
    direction = enemyBody.direction;
    if v == false speed = 20; else if v == true speed = 0;
    friction = 4;
    enemyBody.limiter = false;
}

if (enemyBody.fallen == true) {
    seen = 0;

    if place_meeting(x, y, object6) {
        speed = 0;
        move_outside_all(180, 1);
        v = true;
        with (enemyBody) {
            
            sprite_index = spr_nearWall;
            image_angle = 180;
        }
    } else v = false;
}
 
S

Stac

Guest
yes, it would be better, but wont fix the problem.
seems like the potential step function doenst sense the wall object. can i see the code for this?
Of course. That is all enemy AI code:
Code:
if (distance_to_object(obj_body) < 200) &&
        (!collision_line(x, y, obj_body.x, obj_body.y, object6, false, true)) &&
        abs(angle_difference(direction, point_direction(x, y, obj_body.x, obj_body.y))) < 90 {
      
                if (place_meeting(x, y, obj_body)) speedId = 0;
                else speedId = 1;
                seen = 1;
                mp_potential_step(obj_body.x, obj_body.y, 5, false);
      
            if (instance_exists(coorId)) with (coorId) instance_destroy();
            if (instance_exists(pathId)) with (pathId) instance_destroy();
  
        } else speedId = 0;
UPD: I'm using build-in speed variable only for "after-fallen flight". And algorithm of Chase using potential_step functions
 
S

Stac

Guest
yes, it would be better, but wont fix the problem.
seems like the potential step function doenst sense the wall object. can i see the code for this?
Maybe you can recommend me better code for enemies falling (like in Hotline Miami)? :D
 
Top