• 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!

Enemy Tank AI script

R

Remo Munk-Olesen

Guest
I'm coding a small Tank game, where the player is a tank.
There are some enemys too.
I have used HeartBeast, script, from his old RPG tutorial.

if (instance_exists(oPlayer)){
if(distance_to_point(oPlayer.x,oPlayer.y)<=256 && !collision_line(x,y,oPlayer.x,oPlayer.y,oWall,false,true)){
friction = 0;
motion_add(point_direction(x,y,oPlayer.x,oPlayer.y),1);
if(speed >=4) speed=4;
} else {
friction = 1;
}
}

My question is, how to make the sprite(Enemy
) rotate, and face the direction it is moving.

Best Regards
Remo
Denmark
 
R

Remo Munk-Olesen

Guest
TsukaYuriko>> I'm lost how to fix it, Can you help me??
 

TsukaYuriko

☄️
Forum Staff
Moderator
direction holds the direction the containing instance is currently moving into. image_angle holds the rotation of the instance's default sprite. Both of them can be written to and read from. Take a look at image_angle's manual entry for a code sample which is not all that different from what you're trying to do - it should set off a chain reaction that leads to a eureka moment.
 
Top