Y
Yusufpopen
Guest
Hi im a new to programming and im trying to make a pirate game. But im having problem with the enemy ship AI. I wanna make it so that when the ship gets near the player it will smoothly rotate to one of it sides to shoot. Im have been trying some stuff but i can only make it so that it works when it's chasing the player but as soon as it gets close ,it will start spinning uncontrollable.
im on GM 1.4
Here is my code
im on GM 1.4
Here is my code
Code:
-Create event-
pointdir = point_direction(x, y, obj_player.x ,obj_playerj.y)
rspeed = 4
range = 64
-Step event-
if (distance_to_object(obj_player) <= minimumDistance)
{
image_angle += sin(degtorad(pointdir - 90)) * rspeed
direction = image_angle
} else {
mp_potential_step(obj_player.x,obj_player.y,2,true)
image_angle = direction
}