Search Unity

2D Map Boundaries and Linear Movement

Discussion in '2D' started by Robotsan, Oct 24, 2016.

  1. Robotsan

    Robotsan

    Joined:
    Feb 3, 2015
    Posts:
    3

    mapQuestion.PNG
    I have a map like this and my player (black circle) must move linearly between two grid after every command. I tried Lerp for linear interpolation but still it is jumping to other grid, not linearly moving.

    My second problem is I cant fix movement amount at different screen sizes. How can I move the player to spesific distance according to map at different resolutions ?

    Another issue is how can I set boundaries around map so my player stay in the map area?

    Thank you!​
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Show us your movement script with code tags. Lerp is often misunderstood at first, so I bet there's a problem with that.

    How does the player initiate movement? Mouse clicks? Keys? If the dot only moves to the squares, you can use empty "slot" objects at each space for position reference. This should fix your resolution scaling issue, and may partially or fully eliminate the need for hard movement limits.