How do I create a reflecting path between two objects

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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:

    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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

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

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)