P
piksil_demon
Guest
so my problem is that when i press up against the wall, then rotate my character, the corners of it clip into the wall and i glitch though. this happens with rectangular, elipse, and presice collision. i know the sollution but i dont know how to make it. what i want to do is if part of my body it touching the wall, i cant turn any more in that direction (im using a square model).
another problem im having is that its not pixel perfect collision. if you can help with that aswell then big thanks. here is my move and colision code-
//variables
var up, down, left, right, arrow;
up = keyboard_check (ord('W'));
down = keyboard_check (ord('S'));
left = keyboard_check (ord('A'));
right = keyboard_check (ord('D'));
//player movemnt
//image_angle = point_direction(x, y, mouse_x, mouse_y);
old_angle = image_angle;
image_angle = point_direction(x,y,mouse_x,mouse_y);
if place_meeting(x,y,obj_wall) {
image_angle = old_angle;
}
x+= (right - left)*spd;
y+= (down - up)*spd;
if speed > spd {speed = spd;}
//collision
if(place_meeting( x + spd, y, obj_wall) ){
x -= spd;
}
if(place_meeting( x - spd, y, obj_wall) ){
x += spd;
}
if(place_meeting( x, y + spd, obj_wall) ){
y -= spd;
}
if(place_meeting( x , y - spd, obj_wall) ){
y += spd;
}
another problem im having is that its not pixel perfect collision. if you can help with that aswell then big thanks. here is my move and colision code-
//variables
var up, down, left, right, arrow;
up = keyboard_check (ord('W'));
down = keyboard_check (ord('S'));
left = keyboard_check (ord('A'));
right = keyboard_check (ord('D'));
//player movemnt
//image_angle = point_direction(x, y, mouse_x, mouse_y);
old_angle = image_angle;
image_angle = point_direction(x,y,mouse_x,mouse_y);
if place_meeting(x,y,obj_wall) {
image_angle = old_angle;
}
x+= (right - left)*spd;
y+= (down - up)*spd;
if speed > spd {speed = spd;}
//collision
if(place_meeting( x + spd, y, obj_wall) ){
x -= spd;
}
if(place_meeting( x - spd, y, obj_wall) ){
x += spd;
}
if(place_meeting( x, y + spd, obj_wall) ){
y -= spd;
}
if(place_meeting( x , y - spd, obj_wall) ){
y += spd;
}