- Home /
2D Smooth movement and collision detection problem
Hello guys, I'm trying to figure out a solution for my game, I created it but am not happy with the "mechanics" so far. So, the game is a board game the board is 42x42, there is a character of course that can move in the board, also there are collisions with enemies and walls and other objects. The game being mostly a strategy game i represent the player's position with (x, y) while x and y are in N (1, 2 , 3 ... 42).
The first problem is the movement, since i want my player to be able to move, I increment or decrement x or y to change the position on the board, but this had a fast movement for the player so i added a slide effect, which checks the position (x and y) and it's equivalent position in the world, and moves smoothly the player in a period of time using the function: Lerp but the movement is still not there, something is missing.
The second problem is collisions, for the collision system, i disabled all Unity's collision system + physics system, i check collision against the 42x42 array (ex: if the player(1, 2) is trying to move right and the column(2,2) contains a wall => deny movement) it's working like a charm but it's a pain to iterate throught an array of 42x42(i don't iterate every update but it still a pain), so I guess if i can move the objects "properly", i can enable the 2D collision system because it's more optimized.
Enough bla bla, time for direct questions. How do i get a smooth and correct 2D movement in Unity, By correct i mean moving in the board from (1, 2) to (21, 2) with the same speed and without any sluttering ... I've seen the ROGUELIKE tutorial, i don't want that kind of movement since the player can do only one step at a time, in my game the player can move in the board from (1,2) to (42, 2) with the same speed, and if you repeat the process (moving from(1,2) to (42,2)) it will be always the same time.
Any questions, i'm here, thanks a lot :)
Your answer
Follow this Question
Related Questions
Is there a standardized way for creating a 2D ball physics movement method? 0 Answers
Need help with my movement script.. :( 1 Answer
Problem is not Bouncing 0 Answers
Moving a non-player object in a random direction which bounces off other objects. 2 Answers
How do I make my character controller jump when I use this code? 0 Answers