Object with multiple line of sight behaviours and generating sprites between intersection points

0 favourites
  • 3 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi all, this is driving me nuts so just wondering if I can get a second pair of eyes on it to tell me where I am going wrong!

    Here's a capx

    What I'm trying to do:

    When spacebar is pressed the emitter sprite generates a projectile.

    This projectile has 4 line of sight behaviours attached to it - I want each of these to pick a random point on the screen at specific intervals.

    When they intersect with a solid they generate a sprite at the intersection point. In addition to this, to represent each line of sight path, 20 dot sprites are generated and these should be spaced evenly between the projectile and the intersection point and continue to adjust position accordingly until a different intersection point is chosen.I'm trying to do this by lerping between the projectile position and the intersection point.

    To keep track of which dots are linked to which line of sight behaviour they are given a variable on creation which is set to 0, 1, 2 or 3 and are picked accordingly.

    The problem is - none of this is working!

    I'm not sure where I am going wrong - possibly the way I am using the viewport to pick positions? The way I am picking things? The way I am using Line of Sight?

    Any help or insights is greatly appreciated! :)

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are quite a lot of problems..

    Events 2-5 should be done with Timer behavior on the projectile.

    NEVER use "trigger once" with objects that have multiple instances. "Ray intersected" should be nested in the same event where you cast rays.

    Instead of using 4 copies of LOS behavior, you can use one and cast a ray 4 times.

    In the functions 11-17 you need to pick the correct projectile instance by UID, otherwise it won't see the newly created instance. It would be easier to just move dots creation loops to "On space pressed" event.

    It also may be easier to use an invisible Line sprite - create 20 dots on it and add them as children to the Line sprite. Then you can just adjust the position, angle and width of the Line sprite, and all dots will re-position automatically. Or use a single TiledBackground object :

    dropbox.com/scl/fi/cdvnhadvcocu207w2g4ei/Dots.c3p

  • Thank you very much, I really appreciate the detailed breakdown of where this has gone wrong and how it can be done properly. Your solution is so elegant in comparison to what I was trying to do! Thanks so much for sharing your knowledge!

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