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

Best practice for player movement.

Discussion in 'General Discussion' started by omemomem, Jun 1, 2023.

  1. omemomem

    omemomem

    Joined:
    Nov 9, 2016
    Posts:
    1
    Tl;dr: What are different ways to implement a simple 2d movement and do they have a different outcome in terms of "feel" and performance? Also am i overthinking this topic?


    So for background i am a developer and been developing for years (not anything that's connected to games), However Unity is new for me and i am really interested in getting good at it.
    I've been searching the web about this topic but haven't found any detailed videos/posts about it.

    What are the different ways to implement player movement, and also am i just overthinking this topic?
    and by different ways to implement player movement i mean
    1. use the velocity attribute to move the player
    2. use the x,y,z attributes to move the player
    and i am sure there are tons of other ways to do so... Thanks!
     
  2. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    It entirely depends on your game. 1st person, 3rd person, top-down, 2D, and other formats all have their own needs, and will also vary by genre, even within genre.

    But a good place to start is Unity's Standard Assets that included 1st person and 3rd person controllers the last time I looked. I think they are on the Asset Store now instead of within the Unity install.
     
    Ryiah and omemomem like this.
  3. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    the best practice is to start from a clear definition of the game. otherwise somebody might tell you that you need a socket wrench but you actually needed a jigsaw.

    in general i think a simple system just using a few curves or basic interpolation math is better than fussing with physics simulation. If you want character to jump, the jump to last exactly X milliseconds long and go exactly X units high and you want it to peak at 1/3 time and hang for so long... etc, that's much easier if you just code it to do things directly, instead of trying to tweak a billion physics parameters.

    if you aren't sure what you want and just want to mess around with different styles it's always good to start with the standard controllers (just repeating whats already said above)
     
    Ryiah and omemomem like this.