0 Favourites

Check the distance between multiple Instances?

  • Hi,

    I got it working with 2 instances, but for more i get stuck.

    The aim is, if X instances of an object are nearby EACH other these should all perform an action once, and switch back when they are out of the range to each other.

    Any help welcome :)

    PS: Guess I could make it if I would know how to override the loopindex inside a for-Loop, or a command like "nextLoop".

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • + local variable X = Object (First Instance)

    + local variable Y = Object (First Instance)

    for each ordered by distance(X, Y, Object.X, Object.X)

    if (distance(..) == 0)

    set X = Object

    set Y = Object

    perform action

    else

    stop loop

    If you have any question aks me, it works fine for me

  • yes, would you like to give me a screenshot of your event?

    I am not sure how you check the distance between all instances here.

    for each ordered by distance(X, Y, Object.X, Object.Y)

    just checks from the first instance, not all instances to each other.

    also only the first nearest instance is picked. If you leave the loop there, maximum 2 instances can do an action.

    many thanks for additional information!

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