- Home /
fixed angle grid movement issue
Hi all, I have a background picture of an angled greed
Assume I have a player object on a tile and I want the player to be able to move from tile to tile in any of the directions (up+right) (down+right) (up+left) (down+left), the problem is that because I'm adding an X value and Y value to its current position, after I move about 100 tiles I will notice that I'm no longer in the middle of the tiles because of a minor deviation in every step (because I cant seem to find a way to always move an exact distance that will never cause a deviation). Any idea as to how to solve it ? or is there any asset that is relevant to non square grids?
Answer by yashpal · Mar 14, 2015 at 06:29 AM
hello @barzelas,
I assume your grid is always same size.
Player start at position.x = 0, position.y = 0. store this as int x= 0, y= 0(position in grid) at your player script. and when player press button to move in one direction just find target location from x,y int. and move player at there.
in short.
Don't find target position from current position(in world point). Just find target position from previous position in grid(which store as int).
Hope it helps.
Your answer

Follow this Question
Related Questions
Gameobject follow mouse on center 1 Answer
Having trouble with grid movement 1 Answer
Change grid scale or scale whole library 0 Answers
Destroying an object in a matrix 1 Answer
Snap object to grid with offset? 1 Answer