2 Objects Visible for Each Other?

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hey,

    U got an idea how to easily make an event sheet, that checks if 2 objects can "see" each other? (on 2D topview like the ghostshooter tut)

    The condition is there are no solid objects crossing a straight line between them.

    And maybe an area of the current (view) angle of both objects is only affected, so that if an enemy is turned around not looking at you he doesnt see u, even if he could.

    Thanks for your suggestions :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And a similar question, I didnt find a solution before. Is there an easy way to check the distance between 2 objects, maybe in pixels?

  • For the second question, you can use "distance()" on a "Compare Two Values" condition.

    ex:

    Distance(Object1.X, Object1.Y, Object2.X, Object2.Y)

    As for the first one, you could solve this with bullets (sounds like a big workaround, but here goes):

    • Every X milliseconds, Object1 looks at Object2 and fires a bullet. I don't remember if C2 has "instant bullet" parameter (which fires it very fast), but it has to be FAST <img src="smileys/smiley17.gif" border="0" align="middle" />.
    • If the bullet collides with a solid, it is deleted.
    • If bulltet collides with Object2: BINGO.

    Hope this helps!

  • The best way to "fake" line of sight is try having a sprite like a line connecting two objects (see the "Physics - distance joint" example with C2 for a demo). Then you can check if that object overlaps any solid.

    For distance, check out the 'pick nearest' condition or the 'distance' system expression.

  • Thank you gammabeam and Ashley. I'm gonna try this right now.

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