ENDEU's Recent Forum Activity

  • The way you do this in C2 is not much different from C3. Use LineOfSight, Pathfinding and Timer behaviors. On Timer event change the entity state. Use LineOfSight to check if the player is in sight. If not - pick a random item in range and find path to it.

    An example of logic:

    > Initially the entity is in "idle" state.
    
    On "idle" timer: 
    -> Check if the player is in LOS. If true, find path to it, set state to "chase"
    -> Else : Pick a random item, find path to it, set state to "patrol"
    
    On Path found : move along path
    
    On Failed to find Path : set state to "idle" and start "idle" timer
    
    On Pathfinder arrive and state="patrol" : set state to "idle" and start "idle" timer
    
    If state="chase"
    Every 1 second : 
    -> Check if the player is in the attack range. If true, then stop and attack
    -> Else: check if the player is in chasing range. If true, find new path to the player
    -> Else: set state to "idle" and start "idle" timer
    
    If state="patrol"
    Every 1 second :
    -> Check if the item still exists. If not - set state to "idle" and start "idle" timer
    
    

    Thank you for trying to help! I followed your suggestion, but it didn’t work out very well. This is my first time creating an "artificial intelligence" for an enemy, and I ended up getting a bit confused along the way. If you could take a look and explain what I might have done wrong, I’d really appreciate it!

    https://www.dropbox.com/scl/fi/6f0p7w4zn05j3i1w8wzm3/Entity-Test.capx?rlkey=nm2gu8lhz06am57tkh1em1r4c&st=7xbhoku6&dl=0

  • Can anyone help me implement an entity in Construct 2 with the following behavior?

    1. Patrolling random items

    - The entity should randomly choose an item scattered around the map to patrol.

    - It should move to the item and patrol around it for a random time (between 20-50 seconds).

    2. Following the player:

    - If the player enters the entity's field of view or radius, the entity should start following the player.

    - The entity should stop following the player when they leave the field of view or radius.

    3. Item switching:

    - After the patrol time is over, the entity should pick another random item on the map and start patrolling it.

    - This process of choosing and patrolling should repeat indefinitely.

    Additional Notes:

    - The player needs to collect the items, which get destroyed upon being touched. Therefore, the entity should avoid following items that have already been collected.

    - The same item sprite appears throughout the entire map.

    - The game is top-down.

    I've tried to do this on my own, but the entity barely moves, and I'm getting stuck. Any tips or examples on how to achieve this in Construct 2?

  • You just need the condition I mentioned trigger is used=false so it only picks from ones that are not used yet.

    Oh yes, I had misunderstood. Now everything is clear. Thank you very much for your help lionz!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To stop it picking the same one twice you can use a variable on 'trigger' to mark it as used, so then the above would be pick a random instance of 'trigger' where used=false : spawn 'collectible' and set used to true.

    The condition for spawning the collectibles worked perfectly, but as you lionz mentioned, there is still a chance that the collectible will spawn on the same trigger. I tried following your steps about the instance variable, but it still keeps spawning twice in the same trigger. I probably misunderstood something and ended up making a mistake. I'll send you the file if you'd like to take a look, I'd appreciate it.

    https://www.dropbox.com/scl/fi/2x2tw4uabjilutfnrgqtd/Trigger-Spawn-Test.capx?rlkey=jen63t79p14coq37k6udfi2e1&st=zw8uwskf&dl=0

  • I'm creating a game in which, when I start the layout, I need exactly 9 collectibles to appear randomly in 9 of the 28 triggers scattered around the map.

    To consider:

    • Whenever the layout is started, the collectibles should appear in different locations. Therefore, their position should be randomly drawn at each layout start.

    • I created 28 triggers in total, all of which are copies. Each trigger is a sprite with a solid color, and these sprites are scattered all over the map. The collectibles should be placed on these triggers.

    • Exactly 9 collectibles need to appear, randomly positioned on 9 of the 28 triggers.

    In short, the idea is that, when the layout starts, the game draws 9 triggers out of the 28 that exist and places a collectible item on each of these 9 drawn triggers.

ENDEU's avatar

ENDEU

Member since 18 Jul, 2024

None one is following ENDEU yet!

Trophy Case

  • RTFM Read the fabulous manual
  • Email Verified

Progress

2/44
How to earn trophies