Zabicka
Member
Hello, I have an issue with my Player getting stuck in Walls, I don't know how to handle this issue. Does anybody have an idea how to solve it?
Here are some codes:
Collision Code Script
Create Event (Player)
Step Event (Player)
Draw Event (Player)
I know what the issue is,
when the Player lands back to the ground he does have a collision again,
but I don't know how to solve it.
Here are some codes:
Collision Code Script
Code:
/// @desc collision(object)
/// @arg object
// Horizontal
if (place_meeting(x + hspd, y, argument0)) {
while (!place_meeting(x + sign(hspd), y, argument0)) {
x += sign(hspd);
}
hspd = 0;
}
x += hspd;
// Vertical
if (place_meeting(x, y + vspd, argument0)) {
while (!place_meeting(x, y + sign(vspd), argument0)) {
y += sign(vspd);
}
vspd = 0;
}
y += vspd;
Code:
// Z axis
z = 0;
// Position
hspd = 0;
vspd = 0;
zspd = 0;
// Stats
run_speed = 2;
walk_speed = 1;
move_speed = walk_speed;
jump_power = 3;
Code:
// Key input
var hinput = keyboard_check(ord("D")) - keyboard_check(ord("A"));
var vinput = keyboard_check(ord("S")) - keyboard_check(ord("W"));
var kshift = keyboard_check(vk_shift);
var kjump = keyboard_check_pressed(vk_space);
// Movement
if (place_meeting(x + hinput, y, obj_wall)) { hinput = 0; }
if (place_meeting(x, y + vinput, obj_wall)) { vinput = 0; }
if (hinput != 0 || vinput != 0) {
dir = point_direction(0, 0, hinput, vinput);
hspd = lengthdir_x(move_speed, dir);
vspd = lengthdir_y(move_speed, dir);
// Collision
collision(obj_wall);
}
move_speed = kshift ? run_speed : walk_speed;
// Jump
if (z > 0) {
zspd -= 0.2;
z += zspd;
} else {
z = 0;
if (kjump) {
zspd = jump_power;
z = zspd;
} else {
zspd = 0;
}
}
// Jumping over walls (Laggy)
if (z > 0) {
mask_index = spr_empty;
} else if (z == 0) {
mask_index = spr_player_mask;
}
Code:
// Draw self
draw_sprite_ext(sprite_index, image_index, x, y - z, image_xscale, image_yscale, image_angle, image_blend, image_alpha);
when the Player lands back to the ground he does have a collision again,
but I don't know how to solve it.