Hello Guest

Author Topic: 2D Top Down game best practices  (Read 5572 times)

DeCeOnline

  • Newbie
  • *
  • Posts: 6
    • View Profile
2D Top Down game best practices
« on: March 12, 2014, 11:02:29 am »
Hi there!

I've been reading and looking for similar posts in this forum and in Unity forums, but, although I've found some useful information, I'm still trying to figure out what would the best practices be.

Here's my context:

I'm trying to develop a top down view game, but I don't know if tilemaps are right for me in this case since I will be using drawn maps, like the images shown:





Video: https://www.youtube.com/watch?v=GmMosNHhyxI

If you look at the map, it seems that tiles are not the best option since each one will be different. What would be the best approach to get something like this? Right now I'm using the map as a background image.

Another problem I'm facing is the map bounds (like rocks or free falls). A mesh collider would be the best option for this?

Last, but not least, when I want an object to be surrounded by my player, the front part of it should be placed behind my player so he is above (in Z axis) of it. The opposite happens when the player is behind the object. I've approached this problem by two different ways:

1) Splitting up my object in two: one to be placed behind my player and the other to be placed in front of it. Although it works, I feel it's not optimal at all.
2) Attaching a trigger to the base of my object so when it's triggered I'm changing the Z axis back or forward, depends on my player position. It also works, but I don't know if this is the best option.

Any tip will be highly appreciated  :)

Thanks!

zeteginara

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: 2D Top Down game best practices
« Reply #1 on: March 12, 2014, 09:11:44 pm »
1.  Even if you have a large image, I believe tiles are still more efficient memory wise, and it's best to split it up.

2.  It seems like some tiles are the same, but they have a transparent layer of 'shadows' (in this case, a dark texture that's extremely transparent) over it.

3.  I don't know if it's the best practice or not, I'm designing a similar game and I calculate my Z attribute every frame based on the Y attribute like so:

Code: [Select]
        private Vector3 MoveZPositionBasedOnYPosition(Vector3 position)
        {
            return new Vector3 { x = position.x, y = position.y, z = zAttribute + (position.y * .001f) };
        }

zAttribute in the above is simply a constant that's equal to the zAttribute that I want my characters to have.  You could also pass it in if you want this to be a common utility function.

DeCeOnline

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: 2D Top Down game best practices
« Reply #2 on: March 17, 2014, 04:44:40 pm »
Thank you for your reply, zeteginara. It works just perfect with the technique you're using. Thanks a lot for the tip!  :)