How do I have depth in my side scroller game? Image provided

0 favourites
  • 4 posts
From the Asset Store
A very simple to set up ZElevation based depth of field system for your game. Fully commented.
  • Sorry i couldn't think of an appropriate title to match what I need help with.

    Basically, I'm making a game similar to "Cartoon Wars 2"

    The image above displays what I am trying to achieve for my game. I want the units spawned to be on different platforms(or whatever is happening there) when there are multiple units spawned relatively close to each other. This way the units don't overlap entirely to give some depth to the battlefield.

    How would I do this? I already have the ground as a solid, and my ai's walking. I just have no clue as to how I'm supposed to get the units to appear on the field like they do in the picture above.

  • Hey Sykarion,

    One possible approach might be to create two objects for each on-screen character; a "Position" Sprite object that moves along the ground platform, and a "Graphic" Sprite object, that is pinned to the Position Sprite, but with a small randomized vertical offset. The Position Sprite would be made invisable in-game, so the player would only see the Graphic Sprite objects.

    Finally, to make sure that the Graphic Sprites overlap each other correctly, (front to back), you just need to move each newly created Graphic Sprite to the correct Z-index relative to the other Graphic Sprites. To do this, you can re-sort them each time you create a new sprite, or you can move the new one to the correct Z-index on creation.

    Both methods will amount to placing the Larger Y values (southward on screen) in front, and the smaller Y values (northward on screen) in back.

  • fisholith

    Hey! Thanks for replying, I'm getting a picture of how this would work. I would have to change some events as to how my sprites currently attack when they reach the enemies. But i like this idea. I'll fiddle around with it and see if i can get it to work. Currently my methods of getting the units to attack each other isn't that great.. (unit collision and sprite overlap) Do you have a better idea of how i should get my sprites to fight each other? Every unit I spawn are currently set as platform behaviours. Is this the right way I should be going about it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I took a look at Cartoon Wars 2, and from what I saw the Platform behavior with collision and overlap checks should work just fine.

    Though you could also try using the "Is overlapping at offset" condition. It will temporarily move your object to an offset from it's current position and test to see if it's overlapping something there, then move the object back to it's original position before any other events run. This is a nice cheep way to avoid having to make invisible detector objects. Though invisible detector objects can also be handy.

    The "Is overlapping at offset" condition could allow units with ranged attacks to sense when an enemy is close enough to hit with said ranged attack.

    e.g. If ArcherUnit is overlapping EnemyUnit at offset X +200, then hold position and start firing arrows.

    This would make the ArcherUnit attack an enemy when they got within a 200 pixel range.

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