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

collision_line() not working properly

M

manoelpdb

Guest
Hello! A weird bug is happening when I use collision_line() in GM:S 1.4. I was trying to verify if a collision was happening between two objects but it wasnt working so I decided to use draw_line_colour() to check what was going on so that what I got:



As you can see, even if the origin point of the sprite is 0,0 the red line is not being drawing from its x to its x+sprite_width. This is really weird and annoying. Someone knows why is this happening? I never had experienced this type of bug before!

Edit: Just to add, I manually "fix" the problem adding values to make it set right so I grab those values and used at collision_line(). So it's not just a problem from draw_line_colour() but both and they see to work wrong in the same way.
 
N

nickvm98

Guest
Use the debugger or your own to see what the game thinks x is and see if its you or the game that messed up.
 

toxigames

Member
I'm baffled by this as well; I can confirm this. Drawing a line from x1=0 to x2=50 for example gives the same issue, the line starts drawing at 1 instead of 0....?
 

Bingdom

Googledom
I think you get the same problem with draw_rectangle.

Do you get the same problem using primitives? pr_linelist or something.

I don't think collision_line works the same as what draw_line shows. Maybe show us your code?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Can I ask what this has to do with collision_line? The draw functions have no bearing on collisions, and cannot be trusted to accurately represent what is happening (basically since they are drawn 1:1 with the screen resolution and ignore scaling, etc... ). You are all talking about the draw function when the OP is asking about collisions...
 

toxigames

Member
Can I ask what this has to do with collision_line? (...) You are all talking about the draw function when the OP is asking about collisions...
I think he asked about both (sort of) :) But yes as far as collision_line goes, I just did some testing to be sure (see image below). collision_line does not seem to work like draw_line; so to OP's question: no, collision_line does not work that same way as draw_line; collision_line seems to work as is it should.

(draw_line does still not seem to work as it should, as have been pointed out in previous posts, which is interesting I think).

OP can you post your code for the collision_line? It should not work like draw_line as far as I can tell.
 
Last edited:

toxigames

Member
Though... if you enable precise collision, something interesting happens: there is no collision in either of the two above cases, unless you do collision_line(sprite_width-0.51,y+8,sprite_width+5,y+8,rectangleSprite16_obj, true, false)). Doing sprite_width-0.5 for example still does not yield a collision... so this seems to show that collision_line does in fact work like it should, though it only works with integers such that it does the usual rounding up for 0.5 and above, while below 0.5 is rounded down.
 
Last edited:
Top