Check for collision along a path?

7 posts

Flag Post

I’m making a top down shooter and I’m about to get started on firing guns. Ideally I want to just draw a line from the gun to the wall it hits, rather than making an actual object for the bullet.

But I have no idea how to check to see which wall the bullet will hit based on the rotation of the gun. :(

How do you do it?

 
Flag Post

Tiled based? If so, I solved this issue a few days ago.

Also, everyone is doing games with shadows it looks like. :D (saw your game in screenshot thread)

 
Flag Post

Yeah tile-based.

(And it might be because of the recent halloween themed quest, there were a few with shadows in that IIRC)

 
Flag Post

I was going to give you pseudocode for what I use, but I’ll just link the article I used to create mine: http://dev.mothteeth.com/2011/11/2d-ray-casting-on-a-grid-in-as3/

Also, might as well. Screenie of it in action in my prototype:

In addition, remember that if you have any objects not part of your grid that you want to collide with, you’ll need to do a second pass to deal with those. Picture shows grid collision and object collision (circle to line collision).

 
Flag Post

Looks really good!

 
Flag Post

UG do you have support for multiple lights? Also in your game do walls have textures? I’m reconsidering my methods.

 
Flag Post

Haha me too! His looks fantastic! :P
Mine works but it’s not very efficient or powerful.