U
UberhenriK
Guest
Hi everybody.
Me character stops before reaching the wall.
Probably problem is in my collision system but i don't know where exactly.
Video with problem:
Collision part of "Step" event:
If you need it, here is full "Step" event code:
How can i fix that issue?
Thank you.
Me character stops before reaching the wall.
Probably problem is in my collision system but i don't know where exactly.
Video with problem:
Collision part of "Step" event:
GML:
if (place_meeting(bbox_left, y, Obj_WallsParentV)) {
if (XSpeed < 0) XSpeed = 0;
}
if (place_meeting(bbox_left, y, Obj_WallsParentCLeft)) {
if (XSpeed < 0) XSpeed = 0;
}
if (place_meeting(bbox_right, y, Obj_WallsParentV)) {
if (XSpeed > 0) XSpeed = 0;
}
if (place_meeting(bbox_right, y, Obj_WallsParentCRight)) {
if (XSpeed > 0) XSpeed = 0;
}
if (place_meeting(x, bbox_bottom, Obj_WallsParentH)) {
if (YSpeed > 0) YSpeed = 0;
}
if (place_meeting(x, bbox_bottom, Obj_WallsParentCBottom)) {
if (YSpeed > 0) YSpeed = 0;
}
if (place_meeting(x, bbox_top, Obj_WallsParentH)) {
if (YSpeed < 0) YSpeed = 0;
}
if (place_meeting(x, bbox_top, Obj_WallsParentCTop)) {
if (YSpeed < 0) YSpeed = 0;
}
If you need it, here is full "Step" event code:
GML:
XSpeed = 0;
YSpeed = 0;
if (keyboard_check(ord("A"))) {
XSpeed -= PlayerSpeed;
}
if (keyboard_check(ord("D"))) {
XSpeed += PlayerSpeed;
}
if (keyboard_check(ord("W"))) {
YSpeed -= PlayerSpeed;
}
if (keyboard_check(ord("S"))) {
YSpeed += PlayerSpeed;
}
if (XSpeed > 0 && YSpeed = 0) image_angle = 0;
if (XSpeed < 0 && YSpeed = 0) image_angle = 180;
if (XSpeed = 0 && YSpeed > 0) image_angle = 270;
if (XSpeed = 0 && YSpeed < 0) image_angle = 90;
if (XSpeed > 0 && YSpeed < 0) image_angle = 45;
if (XSpeed < 0 && YSpeed < 0) image_angle = 135;
if (XSpeed < 0 && YSpeed > 0) image_angle = 225;
if (XSpeed > 0 && YSpeed > 0) image_angle = 315;
if (place_meeting(bbox_left, y, Obj_WallsParentV)) {
if (XSpeed < 0) XSpeed = 0;
}
if (place_meeting(bbox_left, y, Obj_WallsParentCLeft)) {
if (XSpeed < 0) XSpeed = 0;
}
if (place_meeting(bbox_right, y, Obj_WallsParentV)) {
if (XSpeed > 0) XSpeed = 0;
}
if (place_meeting(bbox_right, y, Obj_WallsParentCRight)) {
if (XSpeed > 0) XSpeed = 0;
}
if (place_meeting(x, bbox_bottom, Obj_WallsParentH)) {
if (YSpeed > 0) YSpeed = 0;
}
if (place_meeting(x, bbox_bottom, Obj_WallsParentCBottom)) {
if (YSpeed > 0) YSpeed = 0;
}
if (place_meeting(x, bbox_top, Obj_WallsParentH)) {
if (YSpeed < 0) YSpeed = 0;
}
if (place_meeting(x, bbox_top, Obj_WallsParentCTop)) {
if (YSpeed < 0) YSpeed = 0;
}
x += XSpeed;
y += YSpeed;
if (mouse_check_button(mb_right))
image_angle = point_direction(x,y,mouse_x,mouse_y);
if (XSpeed != 0) | (YSpeed != 0)
sprite_index = Spr_PlayerWalk;
else
sprite_index = Spr_PlayerIdle;
How can i fix that issue?
Thank you.
Last edited by a moderator: