Laser Hitting Solid Objects & Walls

Wednesday, April 29th, 2009 | Game Examples AS2, Game Weapons

As the title suggests, this is a laser weapon script that shoots a laser beam. The beam stops when it hits solid objects. Written in AS2 to be used in Flash shooter games.

This script was written in collaboration with InvisGhost. Check out his site at http://invisghost.com/.

Download Fla Sample

Download Fla Sample

If you’re having trouble understanding how this script works, please review previously posted examples that were incorporated in to this script: Shooting Laser Weapon & Apply Filters Dynamically.


Tags: , , , , , , ,

8 Comments to Laser Hitting Solid Objects & Walls

imoncloudnine69
May 5, 2009

epic.

im just a little confused about accuracy, when i change it, it doesnt change how close to the mouse it is shooting, but rather how far through the blocks it goes? or like sometimes the blocks dont stop them and othertimes it stops in the middle. you might want to make that a var you shouldnt change? or if you could explain your reasoning.

maybe a name like penetration or something would be better suited?

pradvan
May 29, 2009

Hi imoncloudnine69,
Yes, you are absolutely correct. It should be called penetration instead.

jonathanasdf
August 1, 2009

Thank you! I believe it was I who requested this. However, I don’t think I’ll be able to use this much. Checking every pixel on its path is pretty resource heavy, and if I have a big array of enemies that move, that might be too much. On the other hand, I could possibly give this to some boss.. hmm.

pradvan
August 3, 2009

Hi jonathanasdf,
Yes, the script IS pretty heavy, but there’s no way around that. You can tweak the accuracy (which should’ve been called penetration), so it doesn’ check every pixel.
-
Also, you should not be doing a laser hit test on every enemy on the map. You need to start using broad phase/narrow phase collision detection.

StapledPuppet
August 4, 2009

Hey, maybe someone could try ( I know you’re busy ) the same script but with reflections off certain surfaces?

I know that would be pretty hard, but it would be worth it…

azzjr6
February 16, 2010

hi am doing something similar in flash. i want to know how to make the laser bounce of a mirror? please help me.
many thanks ^_^

pradvan
February 17, 2010

Hi azzjr6,

I believe you’re looking for this:
http://www.metanetsoftware.com/technique/tutorialA.html

azzjr6
February 18, 2010

Thanks very much pradvan ^_^

Leave a comment

You must be logged in to post a comment.