26 posts
• Page **2** of **3** • 1, **2**, 3

**Posts:**250**Reputation:**5,074

B

54
S

11
G

4
**Posts:**1,096**Reputation:**11,038

B

45
S

15
G

9
Hey @R0J0hound

I was wondering if there are now better alternatives to your examples, I am trying to achieve something like this:

https://www.youtube.com/watch?v=3pmQZi5-Ghw

The issue I am facing is finding the right balance between accuracy and speed. I was thinking on maybe using line of sight to pick up the nearest reflecting surface, draw the laser, then move to the next segment. But I have no idea if it's currently the best approach.

Also why are you multiplying sin and cos by 16 in the example?

I was wondering if there are now better alternatives to your examples, I am trying to achieve something like this:

https://www.youtube.com/watch?v=3pmQZi5-Ghw

The issue I am facing is finding the right balance between accuracy and speed. I was thinking on maybe using line of sight to pick up the nearest reflecting surface, draw the laser, then move to the next segment. But I have no idea if it's currently the best approach.

Also why are you multiplying sin and cos by 16 in the example?

**Posts:**525**Reputation:**8,294

B

29
S

9
G

6
@0plus1

There are probably other ways to do it. One would be to use raycasting by calculating the intersection of two lines. The example here just does it by steps. The 16 is the distance the laser moves per step. It works only with horizontal or vertical walls though.

The problem is basically:

Thinking of the end of a laser as a moving object,

move it till it hits a wall,

using the angle of the wall calculate the new angle of the object and repeat.

If you use raycasting math it can be 100% precise. I did the math for it a while ago and made a quick example here:

https://dl.dropboxusercontent.com/u/542 ... _math.capx

There are probably other ways to do it. One would be to use raycasting by calculating the intersection of two lines. The example here just does it by steps. The 16 is the distance the laser moves per step. It works only with horizontal or vertical walls though.

The problem is basically:

Thinking of the end of a laser as a moving object,

move it till it hits a wall,

using the angle of the wall calculate the new angle of the object and repeat.

If you use raycasting math it can be 100% precise. I did the math for it a while ago and made a quick example here:

https://dl.dropboxusercontent.com/u/542 ... _math.capx

**Posts:**4,753**Reputation:**40,769

B

79
S

24
G

54
@Ken95

The process? It's basically just finding the intersection between lines a bunch of times. The objects have a border made up of lines and the ray is a line. You can just place the lines of the objects manually or use math to place them.

It finds all the lines that intersect the ray, then uses the intersection closest to the start of the ray. From there you can calculate the normal of where the lines intersect and in turn calculate the reflection angle. Then it's just a matter of setting the ray to be from the intersection going at the reflection angle and repeating the process a number of times.

The calculating of the line intersections and reflection angles is easily found in a search engine.

The process? It's basically just finding the intersection between lines a bunch of times. The objects have a border made up of lines and the ray is a line. You can just place the lines of the objects manually or use math to place them.

It finds all the lines that intersect the ray, then uses the intersection closest to the start of the ray. From there you can calculate the normal of where the lines intersect and in turn calculate the reflection angle. Then it's just a matter of setting the ray to be from the intersection going at the reflection angle and repeating the process a number of times.

The calculating of the line intersections and reflection angles is easily found in a search engine.

**Posts:**4,753**Reputation:**40,769

B

79
S

24
G

54
Message: Ken95 can only post plain text URLS until they have 500 rep. **1** URLS modified. Why?

https://www.dropbox.com/s/cx2l2ex8p31n6 ... .capx?dl=0

here is my capx mr r0j0hound.

there are two laser machines that produces the laser beam.

the problem is that only one of the laser machines produces the beams.

would you please fix my event sheet so that it produces 2 laser beam with each has its own reflecting properties. O would be glad if i fixed that problem. Thanks in advance

here is my capx mr r0j0hound.

there are two laser machines that produces the laser beam.

the problem is that only one of the laser machines produces the beams.

would you please fix my event sheet so that it produces 2 laser beam with each has its own reflecting properties. O would be glad if i fixed that problem. Thanks in advance

**Posts:**26**Reputation:**479

B

9
S

1
26 posts
• Page **2** of **3** • 1, **2**, 3

## Who is online |

Users browsing this forum: Renfd, supreme676 and 30 guests |