S
Stac
Guest
How to make smooth enemy collision with speed == 20 and friction == 4?
I mean enemy colliding with wall.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?
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 mean enemy colliding with wall.
UPD: my code doesn't work right, because enemy can pass first couple of pixels of wall.
Thanks. I will trywhat 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.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.
if place_meeting(x,y,wall)
{
hsp = 0;
vsp = 0;
//Other things
}
it doesnt matter, simply set the value to -1 and it will do move by just the right amount.By the way, how can I detect how many pixels of enemy is in wall? For "push" it from wall on N pixels.
Thanks for tutorial, but my enemies using potential_step. I'm just want to know how to fix that: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.
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;
}
Oh, yes. I should use move_outside_solid function?Did you mark your walls as being solid objects?
yes, it would be better, but wont fix the problem.Oh, yes. I should use move_outside_solid function?
Of course. That is all enemy AI code: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?
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;
Maybe you can recommend me better code for enemies falling (like in Hotline Miami)?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?