- Home /
How do I setup fixed movement between predetermined tiles?
I setup a project where I instantiated a set of tiles using a nested for loop when my game runs. However, I'm not sure how to set up fixed movement for my player with transform.Translate or Rigidbody AddForce.
My idea is that the player should raycast in 4 directions going outwards, from left, right, up, and down. From there, the player should only be able to move once in the respective direction they choose, moving to the closest tile that is hit by the raycast. Ideally, there would also be a set delay built in, and the player would not be able to move past these tiles (as in exceed the boundaries, which are going beyond these 9 tiles). When I try to create a movement script for the player, it consists of either transform.Translate/Rigidbody AddForce, which allows the player free movement, and I'm not really sure how to "restrict" it, if that makes any sense. I don't know if my idea or train of thought is correct, but any help would be appreciated. Thank you.