Send 3 Different Objects to layers based on proximity

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have 3 different objects, I need to to put them in order based on how close they are to the player object, send the closest one to layer 1, send the middle object to layer 2, and send the furthest object to layer 3.

    Right now I have a system using a lot of "else" statements, and it works, but I'm sure there's an easier, more condensed way of doing it.

    Thank you for any and all advice or questions!

  • Use the 'For each (ordered)' to check through your objects in order of distance from the player. You can then use the expression 'loopindex' to direct each one to a layer.

  • .... "I have 3 different objects" .....

    Is it necessary? They cant be instances of the same object ?

    Do you have access to families ? (payed version)

    Using families it is easy:

    Example = offline

    It will work the same way using instances. A 'family and its members' is the same principle as a 'sprite and its instances'.

  • Try Construct 3

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

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

    That sounds like a good solution, I'll look into it.

    99Instances2Go

    I'm taking a look at your capx right now and it's definitely on the right track, I just have to figure out how to implement it here.

    Thanks so much!

  • Not to mention, doesn't a family cause everything to happen to every object in that family?

    Obvious not. Example would (and 99,6% of other c2 projects) not work. Example is offline. Call me when you are ready.

  • Okay, the issue with doing it by families is that if I put those 3 objects into a family, the distance of each corresponds to moving 3 different objects. The game uses a 2D map to create fake 3D ala Doom, so what it has to do is order Planet1, Planet2, and Planet3, then move Planet1vis, Planet2vis, and Planet3vis to the correct layers.

    Sorry if that doesn't make much sense, if I had known what I do now now I'd do it differently but it's not having performance issues, and I don't have to expand on it later so I'd rather not go through 80+ events to make everything choose and use the right instances of different things.

    Here's a test build of the game as-is

    https://www.scirra.com/arcade/adventure ... ight-14461

    So the game has to put the closest planets on top so they overlap the others.

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