R
RedSorcery
Guest
The way my homing bullet works now is, it'll smoothly arch towards the target if the target is in front of it.
If the bullet is behind the target, it needs to travel in a greater arc to catch up to the target. This will sometimes, given the right combo of rotation speed and speed, make the bullet circle around the target. Sometimes several rounds before hitting it. This is not my desired behavior.
I tried a few ideas with increasing the speed the closer it gets to the target, but there is always a "magic" combo of speed/rotation speed/distance that makes the bullet circle around the target.
Im looking for a way to make the bullet arc towards the target, without crossing its center y position. I have posted some amazing photoshop images to describe my idea.
Here is the current code:
If the bullet is behind the target, it needs to travel in a greater arc to catch up to the target. This will sometimes, given the right combo of rotation speed and speed, make the bullet circle around the target. Sometimes several rounds before hitting it. This is not my desired behavior.
I tried a few ideas with increasing the speed the closer it gets to the target, but there is always a "magic" combo of speed/rotation speed/distance that makes the bullet circle around the target.
Im looking for a way to make the bullet arc towards the target, without crossing its center y position. I have posted some amazing photoshop images to describe my idea.
Here is the current code:
GML:
if name == "Homing Missile"{ //if this is a seeking missile
if (alarm0){alarm[0] = 60; alarm0 = false;}//timer to delay when homing missile "activates"
if (alarm1){alarm[1] = 1; alarm1 = false;}//increase/decrease rocket speed
dist = distance_to_point(target_x, target_y); //Keep track of distance to target/point
//MOVE AND ROTATE TOWARDS TARGET
rot_spd += (dist_max/dist); //Rotate faster the closer to target *GAME MAKER FORUM: THIS JUST HAPPENS TO BE THE FORMULA I TRIED AT THE TIME I POSTED THIS
var target_point = point_direction(x, y, target_x, target_y); //what is the targets direction relative to bullet
image_angle += sin(degtorad(target_point - image_angle))*rot_spd; //rotate image towards
direction = image_angle;//move object in the direction its angle (facing)
//TRACK TARGET LAST POSITION
if instance_exists(target){ //if target exists
target_x = target.x; //keep updating its last X position
target_y = target.y; //keep updating its last Y position
}
}else x += bullet_spd; //if this is any other weapon, use the designated speed