Picking between instances of the same object

From the Asset Store
112 High-Quality destruction sounds for videogames
  • Okay, how can I explain this...

    I have a sprite object called Critter.

    I want critters to do things (run away) if they get too close to each other.

    In order to do this I want to use...

    For Each Critter

    Get Nearest Other Critter

    Get Distance Between the two

    If Distance is Less than 500

    Run Away Function

    The problem is all critters are instances of the same object, which means... I don't really know what it means but it's fucked up.

    Pick nearest without picking yourself just... Doesn't seem to work.

    This is what I've got...

    I'm testing to see if I can just get a critter to move towards the closest other critter.

    With this code, the movement actions just don't run.

    I understand if further clarification is required.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are missing a "Pick all Critter" somewhere along the way. The "For Each" essentially limit the SOL to a single Critter, to test against all critters in a sub-event, you have to include a "Pick all".

  • Alright!

    It's still a bit weird but seems to be working to some degree.

    To help anyone else out: It only works in the following order:

    System - Pick All

    Object - Pick instances where not equal to UID

    Object - Pick nearest

    Now that I read it that makes sense. Thanks!

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