- Thank you for the suggestion to clear the cache but the problem is still happening...
- I am also using the same sprite as parent object so there shouldn't be a size/origin problem that I can think of.
- I looked for any reference to the parent object's name (oEnemy) throughout my code and it is never referenced. The only search that came up was the reference to oEnemyDead, which you can see in the code below.
- I have included the code for my parent enemy object and a short video capture of the parent and child objects in the same scene. Let me know if anything else would be helpful.
- In the video, you can see that the issue comes into play when my airborne enemy comes back in contact with the ground. I am new to GameMaker so any advice helps, thank you!
Begin Step Event:
if (hp <= 0)
{
with (instance_create_layer(x, y, layer, oEnemyDead))
{
direction = other.hitfrom;
hsp = lengthdir_x(3,direction);
vsp = lengthdir_y(3,direction)-4;
if (hsp!=0) image_xscale = (sign(hsp));
//image_yscale = other.size;
}
instance_destroy();
}
Step Event:
vsp = vsp + grv;
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x+sign(hsp);
}
hsp = -hsp;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,vsp+y,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y+sign(vsp);
}
vsp = 0;
}
y = y + vsp;
// Periodic Jumping
jumpdelay = jumpdelay - 1;
if (jumpdelay < 0)
{
jumpdelay = 200;
vsp = -10;
}
//Animations
if (!place_meeting(x,y+1,oWall))
{
sprite_index = sEnemyA;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = sEnemy;
}
else
{
sprite_index = sEnemyR;
}
}
image_xscale = (sign(hsp));
//image_yscale = size;
Draw Event:
draw_self()
if flash > 0
{
flash--;
shader_set(shWhite);
draw_self();
shader_reset()
}