Q
QuinnlanVos
Guest
I was creating a custom script to find the exact point a line hits an object.
so i made one tracking a line to the mouse coordinates
however sometimes collision_line wouldn't register a collision (returns -4, or 0 for collision_line_list)
when going through the corners of a rectangle
It is only when the distance is very specific, if I made the mouse closer of farther, and the same angle it then registers.
So thinking I'm making some silly mistake, i used YellowAfterLifes code that he wrote here
https://yal.cc/gamemaker-collision-line-point/
and the same thing happens....
Screens and Codes below
I tired it with the code and sprite being precise and not.
Am I missing something obvious or is this a possible glitch
There's my Code, and of course YellowAfterLifes is in the link above.
Both have the same outcome....
so i made one tracking a line to the mouse coordinates
however sometimes collision_line wouldn't register a collision (returns -4, or 0 for collision_line_list)
when going through the corners of a rectangle
It is only when the distance is very specific, if I made the mouse closer of farther, and the same angle it then registers.
So thinking I'm making some silly mistake, i used YellowAfterLifes code that he wrote here
https://yal.cc/gamemaker-collision-line-point/
and the same thing happens....
Screens and Codes below
I tired it with the code and sprite being precise and not.
Am I missing something obvious or is this a possible glitch
Code:
var dir, dist, obj, xx, yy, col_x,col_y, i, o, p;
ds_list_clear(global.OBJ_LIST)
obj = collision_line_list(x,y,mouse_x,mouse_y,obj_block,true,true,global.OBJ_LIST,true);
if obj = 0
{
draw_set_color(c_green);
draw_line(x,y,mouse_x,mouse_y);
}
else
{
obj = ds_list_find_value(global.OBJ_LIST,0);
dist = point_distance(x,y,obj.x,obj.y)+100
dir = point_direction(x,y,mouse_x,mouse_y);
dist = 1
while collision_line(x,y,x+lengthdir_x(dist,dir),y+lengthdir_y(dist,dir),obj,false,false) < 0
{
dist += 1;
}
draw_set_color(c_red);
draw_line(x,y,x+lengthdir_x(dist,dir),y+lengthdir_y(dist,dir));
}
Both have the same outcome....