Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

A Better Way to Move

Discussion in 'Scripting' started by Kaarstein, Jul 24, 2014.

  1. Kaarstein

    Kaarstein

    Joined:
    Oct 15, 2013
    Posts:
    7
    Howdy,

    I'm currently in the middle of making an isometric-style retro game but something that's really putting me off continuing is that I dislike the way my character currently handles. So, I wondered if anyone had a better idea about how to approach this.

    The game involves 'mazes' as levels, in that the character can only move along a certain path, enclosed completely in walled corridors that are as wide as the character. In terms of how the character should move and react to limits, I'd ideally want something similar to Pac-Man in terms of speed and responsiveness.

    In my first attempt, I decided to try using Unity's collision system, which caused all sorts of problems with my player clipping into walls, getting stuck and so forth.

    I have since remedied this a little by switching to a tile-based grid system, where every level is basically a 2D array of values (1=player, 2=wall, etc.) With this, I attempted using the tile-based movement system by Eric5h5 (here) and modifying it a little for my needs, which does work well in that there are no longer clipping or collision issues, but it feels slow and sluggish when I move my player, even when tweaking the values.

    Sometimes, there are also issues where you'll be pressing in one direction and keypresses in any other direction just don't do anything, so you're stuck moving in that direction until you let go. I want players to be able to move and switch direction without having to take their fingers off the keys.

    Does anyone have any good advice/an example of a script that has served them well? (C# please) It only needs to go in 4 directions - no diagonals.

    Thanks in advance!