Pick (nearest) instance in expression

0 favourites
  • 10 posts
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.
  • Hi folks,

    I have a layout with many small objects. All of them are constantly moving to the left and when one of them leaves the layout to the left, I send them to the right of the layout.

    My problem now is, that I want the instance that I send to the right to have its values like size changed corresponding to the values of the instance just left to it.

    Does anyone understand what I mean? ^^

    I have this acquired with an expression like this:

    "Set height to: Object(Object.Count-1).Height"

    But the problem is that I have two rows of the objects, one at the top of the layout and one at the bottom and each should react on its own.

    So in conclusion my question is whether it is possible to pick the nearest instance of an object in an expression. I know there is the condition for this, but I need it in an expression.

  • Perhaps this would work?

    localvalue TempUID

    Pick nearest --> set TempUID to object.UID

    Then use TempUID in the expression?

  • Could you please explain furter what you mean with that?

  • Use the common condition "Pick nearest".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried that, but I need to pick the nearest not in the condition but in the expression...

  • Then you could try and use distance(x1,y1,x2,y2).

  • This checks the distance between to points? But I want to know which of the instances the nearest is. For this function I already need the points of the instance, don't I?

  • Yeah, you would need a loop, or a for each.

    In any case, the condition is a better choice.

  • For now I have changed the layout to have just one row of the instances at the top and a second one at the bottom but these are a different object. So I can handle them seperatly. Works for this, although I have to double every action for them. I am really missing an OR in conditions...

  • I'have similar issue for instances of the same object, something like

    Sprite: Pos = "exit" -> Sprite: Set Y to Sprite.Pos("enter") could be nice ;)

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