• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Every time my eneimes die they spawn elsewhere from where they died plz help:D

S

Sroft

Guest
Here is my code and stuff
if ( hp <= 0)
{
instance_create_layer(x,y,layer,OEdead);
instance_destroy();
}
every time an enemy dies there death animation is spawned somewhere else plz help
(p.s newbie starting programmer anyone with experience that would like to help me out would be amazing:D)
(p.s.s i give great high fives to people who help me just sayin)
 
S

Sroft

Guest
This is in the begin step of my enemy object so I don’t think that is the problem unless I’m missing your point here(sorry still new)
 
S

Sroft

Guest
It might be that you set the x and y in OEdead. So you overwrite the x and y in OEdead create event.
This is in the begin step of my enemy object so I don’t think that is the problem unless I’m missing your point here(sorry still new)
 
S

Sroft

Guest
It might be that you set the x and y in OEdead. So you overwrite the x and y in OEdead create event.
This is in the begin step of my enemy object so I don’t think that is the problem unless I’m missing your point here(sorry still new)
(Yes I am so new that I’m trying to figure out how to send a reply message the right way...kinda sad but I figured it out: ^)
 
M

MirthCastle

Guest
Where exactly in the room is "somewhere else" Is it consistent or random?

Check your sprite origin?

try using an actual layer name in the instance_create_layer function too - like: (x, y, "layer_name", Odead)

for debugging purposes.
 

TheouAegis

Member
Replace "OEdead" with some other object. Just for a moment. For debugging purposes. Make sure the new object is also spawning in the wrong place. If the new objects ponds were supposed to, then the issue is with OEdead (even if not directly).
 
S

Sroft

Guest
Where exactly in the room is "somewhere else" Is it consistent or random?

Check your sprite origin?

try using an actual layer name in the instance_create_layer function too - like: (x, y, "layer_name", Odead)

for debugging purposes.
I put now (x,y, “Enemy”,ORdead) and it dosent work either. How do I check sprite origin also(sorry really new to this stuff)
 
S

Sroft

Guest
Replace "OEdead" with some other object. Just for a moment. For debugging purposes. Make sure the new object is also spawning in the wrong place. If the new objects ponds were supposed to, then the issue is with OEdead (even if not directly).
I’m working on a simple thing from a guide that I’m doing a bit differently(he has more simple animations like 2 frames for a death animation while I have 10 for a death animation for our enemies) so I don’t really have another thing I can replace and see if when it dies it will spawn somewhere else( I don’t know if that made sense this is the first thing I am coding ever sowwy)
 
S

Sroft

Guest
I put now (x,y, “Enemy”,ORdead) and it dosent work either. How do I check sprite origin also(sorry really new to this stuff) and by somwhere else I mean the enemy dies at a location and the instance for there dead body spawns accord the room.
 
S

Sroft

Guest
Where exactly in the room is "somewhere else" Is it consistent or random?

Check your sprite origin?

try using an actual layer name in the instance_create_layer function too - like: (x, y, "layer_name", Odead)

for debugging purposes.
and by somwhere else I mean the enemy dies at a location and the instance for there dead body spawns accord the room. But it is consistent.
 

TheouAegis

Member
you do have something you can replace it with. You obviously have a minimum of two objects in your project right now. You You have the enemy you just killed as well as the dead object. If you have no other objects that you can use, then have the enemy spawn another enemy as soon as it dies. It will look like you didn't kill the enemy but you obviously know that the enemy gets killed just fine. So if you kill the enemy and it spawns another enemy elsewhere, then we ruled out OEdead; but if it appears that your enemy is not getting killed, then we know that the issue is indeed with OEdead (in)directly.
 
S

Sroft

Guest
you do have something you can replace it with. You obviously have a minimum of two objects in your project right now. You You have the enemy you just killed as well as the dead object. If you have no other objects that you can use, then have the enemy spawn another enemy as soon as it dies. It will look like you didn't kill the enemy but you obviously know that the enemy gets killed just fine. So if you kill the enemy and it spawns another enemy elsewhere, then we ruled out OEdead; but if it appears that your enemy is not getting killed, then we know that the issue is indeed with OEdead (in)directly.
Ok your right inreplaced the OEdead with a wall object(WObject) and it spawns in the same place as the enemy so the issue has to be with OEdead. Should I post my step with OEdead?
 

TheouAegis

Member
Post all code for OEdead. Also, find out where OEdead is spawning (the exact coordinates) and look through the rest of your project for anything that might be spawning or moving objects to those coordinates as well.

Also, in your resource tree, where is OEdead located? You can also use

show_message(object_index)

in the create event of OEdead to find out what its position in the resource tree is.
 
S

Sroft

Guest
Post all code for OEdead. Also, find out where OEdead is spawning (the exact coordinates) and look through the rest of your project for anything that might be spawning or moving objects to those coordinates as well.

Also, in your resource tree, where is OEdead located? You can also use

show_message(object_index)

in the create event of OEdead to find out what its position in the resource tree is.
OEdead events
Create-
hsp = 3;
vsp = -4;
grv = 0.3;
done = 0;

image_speed = 0.5;
show_message(object_index)
Step-
if (done == 0)
{
vsp = vsp + grv;

//Horizontal Collision
if (place_meeting(x+hsp,y,WObject))
{
while (!place_meeting(x+sign(hsp),y,WObject))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,WObject))
{
if (vsp > 0)
{
done = 1;
image_index = 9;
image_speed = 0;
}
while (!place_meeting(x,y+sign(vsp),WObject))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
}
And the resource tree message said 4
 

TheouAegis

Member
What's the full code in your enemy object? I'm not seeing anything as far as usual suspects in the OEdead.

You can remove that show_message() now. I was not expecting a value of 4, but I'll keep that in mind later.

Also, does OEdead have a parent object assigned to it?
 
S

Sroft

Guest
What's the full code in your enemy object? I'm not seeing anything as far as usual suspects in the OEdead.

You can remove that show_message() now. I was not expecting a value of 4, but I'll keep that in mind later.

Also, does OEdead have a parent object assigned to it?
EObject
Step-
vsp = vsp + grv;

//Horizontal Collision
if (place_meeting(x+hsp,y,WObject))
{
while (!place_meeting(x+sign(hsp),y,WObject))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,WObject))
{
while (!place_meeting(x,y+sign(vsp),WObject))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;

//Animation
if (!place_meeting(x,y+1,WObject))
{
sprite_index = EnemyA;
image_speed = 20;
if (sign(vsp) > 20) image_index = 1; else image_index = 1;

}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = Enemy
}
else
{
sprite_index = EnemyR;
}
}
if (hsp != 0) image_xscale = sign(hsp);
Create-
//move vari
hsp = 0;
vsp = 0;
grv = 0.3;
walksp = 4;

hp = 6;
//flashing sprite when hit by a bullet:D
flash = 0;
begin step-
if ( hp <= 0)
{
instance_create_layer(x,y,"Enemy",OEdead);
instance_destroy();
}
Draw-
draw_self();

if (flash > 0)
{
flash = -1;
shader_set(SWhite);
draw_self();
shader_reset();
}
(sorry for late response and thanks for trying to help)
 

TheouAegis

Member
what do you mean exactly?
(thanks for trying to help also: D)
The way you phrased it, it sounded like maybe you were trying to spawn the explosion relative to the view or something.

So did you look through your project for anything that is moving anything to those coordinates? From all I can tell, it would seem like you have something trying to target a variable that holds a value of "4" for some reason and it's setting the coordinates. E.g.

somevariable.x = 480;
somevariable.y = 240;

It's also possible the OEdead is just being drawn in the wrong place for some reason.


....Wait, why does OEdead have hsp and vsp values? Is that like an item drop object?
 
S

Sroft

Guest
The way you phrased it, it sounded like maybe you were trying to spawn the explosion relative to the view or something.

So did you look through your project for anything that is moving anything to those coordinates? From all I can tell, it would seem like you have something trying to target a variable that holds a value of "4" for some reason and it's setting the coordinates. E.g.

somevariable.x = 480;
somevariable.y = 240;

It's also possible the OEdead is just being drawn in the wrong place for some reason.


....Wait, why does OEdead have hsp and vsp values? Is that like an item drop object?
OEdead has hsp and vsp values because.... well a good example is when you shoot a guy and they fly back something like that and i looked the closest thing I could find was when my fireball wasent acting right and not spawning with my player I used this
x = PObject.x;
y = PObject.y;
at the create event but when i did somthing similar to this like
x = EObject.x;
y = EObject.y;
when i killed eneimes all there EOdead would spawn in the same place instead of some random place thats all I could find or think of really.
 

Pfap

Member
Back to what @MirthCastle said, you should check your origins match. Also, I always like to use the same size canvas for any sprites that I want to animate predictably together and normally I just leave the origin in the top left.
When you click to edit a sprite, in the overview there will be an origins section with a drop down menu.
 
S

Sroft

Guest
LOL did you accidentally make the origin of OEdead's sprite 160,160 instead of 16,16?
Holy crap I’m dumb the origin was 399 x -95...holy crap
Thank you for helping never would have figured it out you deserve a high five
To bad I’m to far away so I’ll do a air high five and you do one back I’m pretty sure it will work.
Thanks again
 
S

Sroft

Guest
Back to what @MirthCastle said, you should check your origins match. Also, I always like to use the same size canvas for any sprites that I want to animate predictably together and normally I just leave the origin in the top left.
When you click to edit a sprite, in the overview there will be an origins section with a drop down menu.
Holy crap I’m dumb the origin was 399 x -95...holy crap
Thank you for helping never would have figured it out you deserve a high five
To bad I’m to far away so I’ll do a air high five and you do one back I’m pretty sure it will work.
Thanks again
 
M

MirthCastle

Guest
Lol ive done that before. Had me digging forever till I looked at the sprite itself.

So. Is it spawning correctly?
 
Top