Send 3 Different Objects to layers based on proximity

Get help using Construct 2

Post » Sat Jan 21, 2017 6:37 am

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!
B
16
S
5
Posts: 7
Reputation: 1,022

Post » Sat Jan 21, 2017 10:27 am

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.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 237
Reputation: 2,296

Post » Sat Jan 21, 2017 12:07 pm

.... "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'.
Last edited by 99Instances2Go on Sat Jan 21, 2017 6:07 pm, edited 1 time in total.
B
33
S
18
G
27
Posts: 2,431
Reputation: 20,326

Post » Sat Jan 21, 2017 5:46 pm

@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!
B
16
S
5
Posts: 7
Reputation: 1,022

Post » Sat Jan 21, 2017 6:06 pm

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.
B
33
S
18
G
27
Posts: 2,431
Reputation: 20,326

Post » Sat Jan 21, 2017 6:20 pm

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.
B
16
S
5
Posts: 7
Reputation: 1,022


Return to How do I....?

Who is online

Users browsing this forum: ksiads and 2 guests