How do I Use Line of Sight to detect multiple instances of the same object?

0 favourites
  • 8 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • So, I'm working on AI detection with line of sight. I want the AI to be able to get the UID of other instances of the same object, and I've got the AI to detect other AI but there is an issue. When creating a new AI it resets every AI's Line of Sight as shown here, it also detects its own mask as an enemy. My events are as follows

    Is there a way to fix? I've tried using families and for each events and nothing has worked so far.

    Heres a .c3p of the project if that helps.

  • Your project doesn't work properly for me sorry. Most of the time the pawns spawn to the left of screen and fall continuously and when they do spawn correctly there is no AIFOV visible.

    Also your events in the file are different to those in the pictures.

    I can see that in event 60 you have for each pawn followed by pick all pawn which seems to be incorrect.

    Can you explain more clearly what the the issue is and what you are trying to achieve?

  • Here is a link to a thread where a user had a similar issue I believe. construct.net/en/forum/construct-3/how-do-i-8/why-not-enemies-attacking-155835

    While it's not the same thing you are trying to do, if you have a look at my project file in that link i think it could help you.

  • Your project doesn't work properly for me sorry. Most of the time the pawns spawn to the left of screen and fall continuously and when they do spawn correctly there is no AIFOV visible.

    Also your events in the file are different to those in the pictures.

    I can see that in event 60 you have for each pawn followed by pick all pawn which seems to be incorrect.

    Can you explain more clearly what the the issue is and what you are trying to achieve?

    You'd press spacebar to spawn them at the mouse position. And press L to enable FOV.

    So, what i'm trying to achieve is for each pawn to be able to see and detect an instance of itself using line of sight.

    What my code is supposed to do is when a pawn sees another pawn mask, it'd store the pawnID (UID) of the detected pawn in an instance variable then set a boolean to true.

    What it does is completely ignore any other pawn and it'd only detect itself. And when I create a new pawn then every pawns line of sight will just reset and they wouldn't detect anything.

    Also, the capx you created in that thread will most definitely help!

    And the image is different from my events yes, I was testing different things and I saved before I got off..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok now I understand what you are trying to do :) Here I made a capX to show you the method without getting it confused in your project. 1drv.ms/u/s!AkmrWgxeuxlKhIctBZUxl16ODNsyoQ

    You need to add the units to a family and have the line of sight behaviour on the family, then search for los to the unit, not the family.

  • Ok now I understand what you are trying to do :) Here I made a capX to show you the method without getting it confused in your project. 1drv.ms/u/s!AkmrWgxeuxlKhIctBZUxl16ODNsyoQ

    You need to add the units to a family and have the line of sight behaviour on the family, then search for los to the unit, not the family.

    I do believe this works like a charm! Now I just need to have the line of sight flip when the pawn does.

  • LOS is linked to the angle of the object so when the pawn flips set the family object that contains the los behavior to 180°

  • LOS is linked to the angle of the object so when the pawn flips set the family object that contains the los behavior to 180°

    Everything works perfectly! Thank you!

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