How do I move the layer positions of individual objects within families?

0 favourites
  • 3 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Despite reading the relevant articles several times and extensive searching through the forums, I seem to still have a fundamental misunderstanding of how Families work.

    Here's what's up: My game is a top-down shooter, a la Enter the Gungeon or Binding of Isaac. As a result, I want the "Player" to be behind or in front of certain objects in the environment depending on his Y.Position, to create the illusion of depth.

    So, I have "if Player.Y > EnvironmentObject.Y , then Move EnvironmentObject to Bottom of Layer" and vice-versa. This works as intended when I create a different object and corresponding Event for every single instance. But I would much rather have a Family that takes care of this logic in one fell swoop.

    The Problem: I created a single Family for all different types of Environmental Objects in the game (lets call it Fam_EnvObjects). So now, it looks like "if Player.Y>Fam_EnvObjects.Y , then Move Fam-EnvObjects to Bottom of Layer". However, every object in the Family is affected simultaneously, as opposed to on a per-instance basis.

    I was under the impression that Events referencing a Family will apply the logic to each member of the family individually, and only when the individual conditions are met. Yet they are batched together, and only a single member of the family is used to compare the Y-Position value for all members of the family.

    Thank you for reading, and hopefully this makes sense.

    Tagged:

  • You are correct in the way you expect the filtering to work

    Are you using the System > Compare Values to compare "if Player.Y > EnvironmentObject.Y" ?

    If so, that may be why the objects are not being filtered. Compare Values doesn't do any picking. Instead you would use Player > Compare values and the filtering should work as expected

    BUT I want to throw in there is an easier way to do this kind of sorting

    Add ALL sorted objects into a single family, including the environment and player

    Then you can sort each member of the family using the System > Sort action, which will sort all objects in a family by a variable

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • BUT I want to throw in there is an easier way to do this kind of sorting

    Add ALL sorted objects into a single family, including the environment and player

    Then you can sort each member of the family using the System > Sort action, which will sort all objects in a family by a variable

    Amazing. Incredible. Perfect! Thank you Noah, this works great. Hopefully this will help many people in the future as well.

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