GML Stopping sprite image_angle from changing angle once shot

A

Andrew6876

Guest
Hi,

I have an animation that triggers on an Enemy Object once it is shot......but the image_angle continues to follow my Player position while mid animation. I want the image_angle to stop in its tracks once shot.
Hope this makes sense what I'm after.

I've changed the speed of the enemy to 0 once shot
I'ts just the rotation of the sprite I cant seem to stop

Ps.. my previous code is making the enemy object move towards the player
and image_angle is set to direction

Thank You
 
create event:
Code:
is_shot = false;
step event:
Code:
if !is_shot
{
image_angle = direction
}
Reset 'is_shot' afterwards if you want the enemy to resume facing the player at some point
 
A

Andrew6876

Guest
Thanks for the reply but how would I apply that to my code?

.......

if distance_to_object(oPlayer1) < 60
{
move_towards_point(oPlayer1.x,oPlayer1.y, 0.6)
}
image_angle = direction

InComingBullet = instance_place(x,y,oBullet1)
if instance_exists(InComingBullet)
{

// only play eneny explosion sound once when collision with bullet

if SoundTimer == 0 {
audio_play_sound(EnemyExplosion,1,false)
}
SoundTimer = 1


// change sprite to dying animation
sprite_index = sprite2deathanimation

}


// if the animation has changed then stop object in tracks then destroy
if sprite_index == sprite2deathanimation
{


speed = 0


// pick particular image of animation to destroy object on animation image 4

if image_index >= 4
{

instance_destroy();

}

}



Thank You
 
Code:
InComingBullet = instance_place(x,y,oBullet1)
if instance_exists(InComingBullet)
{

// only play eneny explosion sound once when collision with bullet

if SoundTimer == 0 {
audio_play_sound(EnemyExplosion,1,false)
}
SoundTimer = 1


// change sprite to dying animation
sprite_index = sprite2deathanimation
}
else
{
image_angle = direction // move this from it's position earlier in your original code
}
Taking your code as is, I think that would be right.
 
Top