S
Stratos.la
Guest
so i have a parent enemy and a parent obstacle. there is a collision happening that makes the enemies stop and go into attack animation. it works great with the first object that has the same values as the parent but the rest i dont know how to check them.
WIth details now . i have a barricade object that when spawned the enemies stop and attack it for 5 seconds. in the barricade object collision event i have this
and when it gets destroyed i want to set tha animation back to the walk one and the speed to the speed of each object.
Now i have one EnemyParent object that has all of the code for animations, behaviors etc and all of the create event is inside variable definitions which i change for all 3 enemies that are its children. So if enemy1 has 3 speed and enemy 2 has 5 speed how can i check with which instance the barricade has collided with so it sets its speed back to the correct value?
I know i should put the collition in the enemy parent but im just testing things now . i do want to make a parent obstacle object so maybe that is the answer?
this is the enemy parent step event . the actuall object doenst have a create event
WIth details now . i have a barricade object that when spawned the enemies stop and attack it for 5 seconds. in the barricade object collision event i have this
GML:
with other{
if distance_to_object(oBarricade) <= 1
{
spd = 0;
sprite_index = oEnemyParent.attack
image_speed = 0.6
}
}
GML:
with other
{
spd = 2; // it should be if enemy == 1 spd = 2 else if else if but i dont want to do it like this!
sprite_index = other.walk // and here it should see which object it was and continue with its walk animation
image_speed = 1
}
I know i should put the collition in the enemy parent but im just testing things now . i do want to make a parent obstacle object so maybe that is the answer?
this is the enemy parent step event . the actuall object doenst have a create event
GML:
if (instance_exists(oPlayer))
{
x -= spd*global.spdScale
sprite_index = walk // this is defined as a sprite in the variable definitions of each child
if (global.spdScale > spdSlow)
{image_speed = 1;}
else
{image_speed = 0.1;}
}
///attack
if distance_to_object(oPlayer) < 1
{
spd = 0;
sprite_index = attack // this is defined as a sprite in the variable definitions of each child
image_speed = 0.9
}
///die
if hp <= 0
{
spd = 0;
image_speed = 0.9
if image_speed > 0
{
if image_index > image_number - 1 instance_destroy();
instance_destroy();
instance_create_depth(x,y,200,DeathObject) // this is defined as a sprite in the variable definitions of each child
}
}