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

SOLVED Problem with collisions and line of sight

M

MagicPolygon

Guest
So, long story short, I'm having difficulty getting an object's collision detection to work properly.

The screenshot below sorta explains what's going on. It only happens with diagonal objects like the car. I've already enabled precise collision detection (plus I'm also using another sprite as the collision mask, which likewise has precise collision), but for some reason, when it comes to detecting any kind of collision that isn't movement-related, it treats the object as if it's a big square that nothing can pass through. No line of sight, and no bullets. Yes, the player's bullets immediately stop if fired inside the pink box. However, the player and enemies are able to move inside. So, movement collision works. Everything else doesn't.

If it helps, the car object is a child of a parent object called Block, which I use as the main obstacle that nothing can pass through. For example, one of the lines in the enemy's code that searches for players goes like this:
Code:
if !collision_line(x,y,Player.x,Player.y-11,Block,false,true)
In other words, it will detect a player if they are within their line of sight and there is no Block object inbetween.

So, I'm somewhat confused here. Any ideas?

1594176075250.png
 
M

MagicPolygon

Guest
Problem resolved. I had to enable precise collision detection in my collision_line code.
 
Top