N
Nabil Kabour
Guest
I have a homing missile in my game, with the origin a bit off center on the x axis (see image). The missile can point at any angle, and I want to be able to get the coordinates of the nose of the missile (the last pixel on the right). I'm currently attempting at doing this by first getting the distance between the origin and the nose:
and then using the lengthdir functions with the length being the nose_offset and the direction being the image_angle to get the x and y offsets for the angle that the missile is pointing at. The nose x and y coordinates are then as follows:
When I test this by drawing a line from the calculated nose coordinates to an arbitrary point at the same angle, The line does not start at the nose of the missile. What am I doing wrong, and what is the correct method of getting the nose coordinates?
Code:
var nose_offset = sprite_get_bbox_right(sprite_index) - sprite_get_xoffset(sprite_index);
Code:
var nose_x = x + lengthdir_x(nose_offset, image_angle);
var nose_y = y + lengthdir_y(nose_offset, image_angle);
Attachments
-
55.8 KB Views: 16