My character moves right and left correctly,Right & left movement Right & left movementI want to know if it is possible to move character forward and backward to collect hearts idle (I know that in 2d no z axis I want to know if it is possible or not? )

up vote 2 down vote accepted

There are definitley ways of accomplishing this without altering actual position of the character but instead making it appear that way.

For instance : You could try adding animations that show the character walking forward and backward (toward/away from screen) and scale his size to make it look like he is moving in the z axis.

  • scaling his size to make it look like he is moving in the z axis during forward and backward only? @Gav – Sh.Adel Dec 3 at 11:37
  • Yup, let me know if it works for you – Gav Dec 3 at 21:26
  • I made animations (moving forward and backward) and tried to scale it on script if player clicked up arrow decrease the scale of y play downward animation, and if clicked down arrow increase the scale of y and play forward animation .but my problem now detecting collision (normal size of player's collider detect collision of near and far hearts without needing to move forward and backward) – Sh.Adel Dec 4 at 6:49
  • I changed position on script like scale and it works. thanks – Sh.Adel Dec 4 at 9:03

Giving the illusion that there's a 3rd dimension has always been used on video games. It can be as simple or as complicated as you like, depending how you'd like the final result to look like.

In your case for example, you can move the character up/down using the Y-axis, to simulate that the character moves "back and forth". As long as the character interacts properly with the environment (in your case, picking up hearts when moving on the same plane as them) the illusion will not be noticed.

One example being Streets of Rage, which didn't even have an animation for moving up and down (it was just using the walk left/right one) and it made a very nice illusion. The character interacts perfectly with objects on the same plane as them, forcing the player to simulate this as 3D while they play.

enter image description here

You can of course change the scaling of the character as well, making them smaller as they move upwards, and bigger as they move downwards. This adds complexity, but gives a more realistic effect.

You can always add more complexity to add realism, but at the end of the day, it depends on the style you want your game to have. There is no wrong or right solution.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.