GameMaker Make the enemy die in the image angle of the gun

B

Bokkie2988

Guest
Hi,

So im making this game where if you shoot the enemy it dies and slides for about a second. I want the enemy to slide in the direction of where you shot him (which works) but right now, sometimes when you kill the enemy the image angle is right, but sometimes it is reversed.

The code used:
Code:
image_angle = dir-180;
Where dir is the image_angle of the weapon at that moment.
this code sets the image_angle of the killed enemy.

Can anyone help me?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
dir is the direction the object calling the function is facing most of the time it is 0 or right.
 

SCR

Member
if you already have it working where the enemy slides in the correct direction, you can probably just set image_angle to the direction in the obj_enemy.
In the code block where you set the direction that the enemy will slide, add the following code at the end: image_angle = direction

Note that this is assuming that you setup the enemy sprite where it is pointing to the right in the sprite editor ('to the right' is the direction of 0°). (A common mistake for a top-down bullet sprite is to setup the sprite image where it is pointing up, instead of to the right.)
 
Top