1
\$\begingroup\$

I've just recently started programming using Unity and made a couple of games with it, I'm trying out more and more advanced stuff as I do more games, but right now...

I'm trying to make a game that's basically a way simpler clone of pokemon y/r/g/b (I'm only concerned about tile placement, player movement / collision, and dialogue boxes at this time)

I tried about 3 methods for tile placement and found that using a mesh worked best for me (using tiled and tiled2unity) and imported the tmx files into unity.

Now, I just dont know where to go from here.

Starting with the player, I don't want to add physics since most games like this doesn't really have physics involved. So I tried adding a box collider to the player then a controller that uses transform.translate. Unfortunately, I dont think the colliders work nicely with transform.translate.

In this scenario, is the best setup for the player simply just using a kinematic rigidbody2d then adding the code/methods to collide with the map? Also since translate might be a bad idea, is transform.position a better alternative to use? (note that the player moves in increments in a "tile-like movement", any comments or suggestions?)

I'm also quite surprised by the lack of simpler games such as this one. Most of the examples I can find online are physics based platformers and top-downs that use code like velocity, addForce, with physics components involved. Any available source code that I could study would be welcome.

(I've also posted this on Unity Forums but people frequent here more often)

\$\endgroup\$
0
\$\begingroup\$

I have a simpler solution without using any physics or rigid bodies. For your character, it need to have both x,y position as position in screen and i,j as position on the grid with a flag called isMoving. When the character wants to move to i+1, j. Check if the cell at i+1, j is free. If so, set flag isMoving to true and set character i,j to i+1, j and do the necessary animations(changes to x,y) that walks the character from i,j to i+1,j. As long as isMoving is true, the character will not respond to any movement commands. When the character finishes his walk to the destination grid, set isMoving to false and repeat.

\$\endgroup\$
0
\$\begingroup\$

Actually, there's no ready response for your problem. You can solve it in a variety of ways.

If you are working with a "tile-like movement", you can simple check the next tile to see if is passable and only compute the movement if it is. It's a simple check if you have a array representing your world. Or a limited raycast if not.

Also, Unity documentation says something in the lines "if it moves, attach a rigidbody to it". So, you can do it, and set "Gravity Scale" to 0. But depends on what works best for your particular case.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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