Loop through UIDs

  • I've been reading through this thread about UIDs and selection, but I'm not sure how I would loop through all the UIDs.

    In particular, I am trying to determine the distance from an object to every instance of another object and then save the closest one. This involves looping through every UID of the object and checking the distance.

    Does anyone have any idea how to do this?

  • So basically you're saying you need a condition to pick the nearest, or farthest instance based on an xy?

    Something like the pick by uid condition, but shall we say right next to it?

  • I might have misunderstood therefore I might be over-simplifying..

    But there's already a "pick nearest" condition you could use?

    Cond: myObject Pick Nearest X=SourceObj.X Y=SourceObject.Y

    Would return nearest "myObject" to a source object.

  • Why not use the 'pick nearest' condition?

  • Does that work for multiple instances?

    Find Path to Object.X, Object.Y doesn't work if that object has multiple instances. Does 'pick nearest' work for instances?

    If so, then perhaps this is simpler than I thought!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Does that work for multiple instances?

    Find Path to Object.X, Object.Y doesn't work if that object has multiple instances. Does 'pick nearest' work for instances?

    If so, then perhaps this is simpler than I thought!

    In case of event "Player: Pick nearest Enemy"

    pick nearest picks the instance of the Enemy object, that is closest to the picked player object. So yes, it would work in your case to pick the nearest enemy. :)

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