How do I create a reflecting path between two objects

Get help using Construct 2

Post » Wed Aug 26, 2015 1:32 pm

Hello folks,

I have 2 objects which are connected with a line using a width property, the thing is that one of this objects is moveable and between them both are several obstacles. I'd like to make this line to bounce/reflect off of these obstacles keeping the bound of object A and object B. This will give me and angle and a path which object A should follow to reach object B.

Here's a screenshot from a file provided by @R0J0hound in which I have been working:

Image

Note that object B (green box) should be the end of the path, therefore the line shouldn't go further than this point, though, it should get longer depending on the number of obstacles in-between that reflect the line.

Thanks in advance!
B
4
S
1
Posts: 34
Reputation: 416

Post » Wed Aug 26, 2015 9:11 pm

The simplest idea would be to send lots of lasers from one object and let them bounce until one hits the other object, then you can discard the rest.
B
91
S
31
G
102
Posts: 5,234
Reputation: 67,254

Post » Thu Aug 27, 2015 7:50 am

Hi R0j0hound, thanks for your fast response!

How can I achieve that? on the other hand, sending lots of laser won't affect any CPU performance?
B
4
S
1
Posts: 34
Reputation: 416

Post » Thu Aug 27, 2015 5:25 pm

A simple way would be to create a bunch of bullets from the source object and set their angle to a random direction, also save that angle to a instance variable on each. Next you just move the objects and bounce them as they hit walls. Ideally you'd do it the same way as in that laser example. Now as soon as one of those objects collides with the other object, use that object's initial angle for the laser and delete everything else.

Sending lots of lasers will use more cpu, this is true, but when it's the only solution atm there's not much you can do.
B
91
S
31
G
102
Posts: 5,234
Reputation: 67,254


Return to How do I....?

Who is online

Users browsing this forum: davidbox, Google [Bot], Mayfly, zulerf and 3 guests