About Picking

0 favourites
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • I'm making my enemies AI. So picking is really important here. My question:

    In an event like this:

    Object1.X > Object2.X -> Object2.SetMirrored

    Does all Object2 instances get's affected or just the one picked by the condition ? It seems the all Object2's are getting affected.

  • Big difference between object1.x > object2.x, and object2.x > object1.x.

    Basically your first comparison is picking object1, if any of object2 meet the condition.

    What you want is to pick object2 if any of object1 meet the criteria.

  • Ok, got it thanks !

  • Well it turns out that i'm using System Compare Two Values. So it not picks as expected. In my example. I have:

    System: abs(Object2.X - Object1.X) <= Value -> Object2.Var = Something

    All Object2 instances get affected. Resuming what is happening is that my Object2 acts defined by an AI. But when an event triggers an action on one instance all other instances do the same action. Clearly a picking problem. I'll try to find a workaround.

  • Don't use system compare, it doesn't do any picking.

  • If you want your ennemies to always look at the player (that's how I understand your AI) you just have to do :

    enemy: X <= Player.X
      -> enemy: set not mirrored
    enemy: X > Player.X
      -> enemy : set mirrored
  • Ok about the mirroring that's it thanks. But the problem is that i want enemies to act when at a determined distance from player (but of course individually :) ), that's why i'm using system compare. There's sight distance and stuff. The problem is that i must track exactly which enemy triggered the event so that i can act only on it and not on them all. Well, i think that's when using detached (not assigned to an object in particular) events falls short. Maybe it's something simple and i'm missing. Maybe i could instead of comparing distances use a bit sprite detector around my player so that when enemies overlap it i can pick them correctly. But i'd prefer not have to resort to that. I'll keep trying.

  • I did this capx a while ago.

    Making another instance of the enemy works a bit (not perfect), but the distance/targeting seems to work as intended.

    You might find it useful hopefuly.

  • enemy: X <= Player.X
    enemy: X > Player.X-distance
      -> enemy: set not mirrored
    enemy: X > Player.X
    enemy: X < Player.X+distance
      -> enemy : set mirrored

    Like that? o.o

  • Ashley should be adding overlap at offset soon.

    Thats whats needed here.

    Other wise you would be checking enemy.x < player.x +offset

  • Not that but thanks anyway! It has nothing to do about the mirroring. It's the "begin following player when get near enough" . I think i didn't express myself correctly. I've used the wrong example at start sorry ! I can't express the logic i want just using object compare X since i'm using the vertical distance between player and enemy calculated simply with abs(player.x - enemy.x). There's no way to pick it correctly with expressions yes ? So i'll have to separate it and detect when approaching from the left and from the right ? Duplicating code ? Or is there a better way ?

  • well

    System: abs(player.x-enemy.x) < distance 
        -> do things

    is exactly the same as

    enemy: X > player.x-distance
    enemy: X < player.x+distance
        -> do things

    And I think the picking would work

    But if you really insist on using the system comparison, just put a foreach on top

    foreach enemy
    System: abs(player.x-enemy.x) < distance
        -> do things
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Damn i had a signal wrong that it. Thanks for the patience :)

  • Damn this is getting boring. It turns out the above solution only is not sufficient for my case. I remember Classic had Pick by Comparison. How it works exactly ?

  • Did a research and found out the the behavior i want is exactly like Cooper Enemy on Plaform School by deadeye. I'll just steal it all damn :) Though it uses Pick By Comparison as it facilitates things greatly. Anyway thanks all for the help.

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