B
Ben26
Guest
i have a rolling ball obstacle and i want it to move over walls and spikes
so i cant make the wall the parent of the spikes
because then the player will walk on spikes and i dont want that
code of the ball
i tried using "or" place_meeting obj_spikes in the collision code but it freeze the game
so i cant make the wall the parent of the spikes
because then the player will walk on spikes and i dont want that
code of the ball
Code:
hsp = dir * movespeed;
vsp += grav;
//HORIZONTAL COLLISION
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
dir *= -1;
}
x += hsp;
//VERTICAL COLLISION
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;