Question about calculating distance to multiple family objects in Construct 3

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello,

    I’m trying to scale a card depending on how close it is to a character. The problem is that I have several different character objects grouped into a Family, and I want the card to scale based on the nearest character in that family.

    However, I cannot find a Nearest function in Construct 3 that works like this.

    Here is the code I tried:

    Set Scale ---> max(0.2, min(2,

    distance(Card.X, Card.Y,

    Familie1.Nearest(Card.X,Card.Y).X,

    Familie1.Nearest(Card.X,Card.Y).Y

    ) / 400))

    My question is:

    How can I calculate the distance from a card to the nearest object in a family, when there are multiple objects in that family?

    Is there a recommended way to do this in Construct 3?

    I’m still new to Construct 3, so any tips would really help.

    Thanks a lot!

    Thorsten

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ...

    My question is:

    How can I calculate the distance from a card to the nearest object in a family, when there are multiple objects in that family?

    Is there a recommended way to do this in Construct 3?

    I’m still new to Construct 3, so any tips would really help.

    Thanks a lot!

    Thorsten

    Hello,

    If you have several objects on the stage, you need to specify which one you want to select. In your case, you can select the one closest to the Card. Once we have selected the object, we can determine the distance to it.

    Here is a simple example.

    fex.net/s/zorpvbe

  • Thank you, igortyhon. Your example was really good. I had actually managed to do it myself in a different way, but your example is very good. I appreciate your help.

    I do have one external question though: I saw that there were problems with the Steam extension and I read a bit about it, but it seems to be fixed now, according to Ashlay, right?

  • ...

    I do have one external question though: I saw that there were problems with the Steam extension and I read a bit about it, but it seems to be fixed now, according to Ashlay, right?

    I publish games for the web and mobile devices. I’m not qualified to answer your question.

    But I know we have people here who do that and are always discussing it; I don’t think they’ll notice your question about Steam here.

    It might be better to check out the latest threads about Steam or create a separate question.

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