I Tried making a function for collision for an enemy Object. The horizontal collision works fine, but verticaly the enemy just drops through the walls.
Additionally global.grv has a value of 0.15 but the enemyObject falls slower than the PlayerObject
Thanks in Advance
Code:
function scr_move_and_collide(HSpeed,VSpeed){
if !place_meeting(x+HSpeed,y,oWall and oPlayer)
{
x+=HSpeed;
}
if !place_meeting(x,y+VSpeed,oWall and oPlayer)
{
y+=VSpeed;
}
}
Code:
image_xscale = sign(oPlayer.x - oDemon.x);
if image_xscale == 0
{
image_xscale = 1;
}
var distance_to_player = point_distance(oPlayer.x,oPlayer.y,oDemon.x,oDemon.y);
if distance_to_player < 100
{
scr_move_and_collide(image_xscale*3,0+global.grv)
}
Thanks in Advance