4 Ways to MOVE (Pros and Cons) in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024

ความคิดเห็น • 44

  • @THEBLNKY
    @THEBLNKY 6 หลายเดือนก่อน +9

    Watching the video I thought "This is great - I should put that into a cheat sheet for quick reference"...and then you ended with "Here's a cheat sheet." Thank you! ❤

  • @Konitama
    @Konitama 6 หลายเดือนก่อน +5

    For my own top down game I use rigid body with AddForce. It's by far the most flexible just because it plays nicely with the physics system. As you said, you can add knockback or other physics based things directly on top of the player's movement... so things can push the player around while the player can still move.
    For my player controller, I didn't add artificial acceleration/deceleration and just used the Rigidbody2D settings. I created a frictionless material, then set Mass to 150, Linear Drag to 40 and Angular Drag to 0.05. Then when I add enough force to the rigidbody, it will move perfectly. There is no acceleration/deceleration, so when you move around it's 1:1 and feels very responsive. The character moves at full speed immediately and stops instantly, but has all the benefits of physics collisions. The movement is basically Legend of Zelda top down movement but with physics.
    I think what trips most people up is that they don't mess with the Rigidbody 2D settings enough, so they think using AddForce just results in a floaty mess, but you can tweak these settings to be perfect for the movement you're looking to create.

  • @ZacMarvinGameDev
    @ZacMarvinGameDev 6 หลายเดือนก่อน +6

    This is a really solid video for understanding the difference between the types of movements. And would be a great reference for any Unity developers starting a new project and deciding which route to go. I will be saving this and referring to it at each project as a quick refresher. Good work!

  • @seaderwerks3046
    @seaderwerks3046 6 หลายเดือนก่อน +2

    I wish you posted this a week ago when I was having issues with applying a knockback while my movement handling was in Update. I ended up figuring out on my own that I needed fixedUpdate to get it to work. Just find it funny that I was dealing with this issue that took me hours to figure out for you to only post this video today lmao! Good stuff!

  • @castlecodersltd
    @castlecodersltd 6 หลายเดือนก่อน +1

    This is a great reference video, definitely bookmarking. Thanks 🙂

  • @gameboardgames
    @gameboardgames 6 หลายเดือนก่อน

    Super-useful video thanks! I'm reworking my object movement today in my solo-indie-dev game, RoadHouse Manager, and this has been so helpful.

  • @beatrageGameSalad
    @beatrageGameSalad 5 หลายเดือนก่อน +1

    This is called BEST PRACTICE!
    Learn this and you're half way to make a good game my friends! 😎👍

  • @FrogKin9
    @FrogKin9 6 หลายเดือนก่อน

    Nice to have a video seeing it explained this quick and well. I was always struggling with this topic. It definetly gets into my GameDev Playlist! :) Thanks. Just have to figure out what's different for my 3D games.

  • @MarushiaDark316
    @MarushiaDark316 6 หลายเดือนก่อน

    One thing that's a bit more advanced that helps with any of these, but especially with the rb.velocity method is using a Finite State Machine to set the velocity based on state changes. So Idle is defined as velocity zero, Jump is defined as velocity.y being positive, Falling as velocity.y being negative, etc. Alternatively, you could use GOAP as well, which is even more advanced.

    • @sasquatchbgames
      @sasquatchbgames  6 หลายเดือนก่อน +1

      very true, i mainly use rb.velocity along with a finite state machine as mentioned. Haven't tried the GOAP yet though

  • @_jonathancollins
    @_jonathancollins 6 หลายเดือนก่อน +1

    It's nice to see these side by side. I generally knew the basics of each, but the pros and cons are really handy. Thanks!
    Are there any notable differences in these from 2d to 3d?

    • @sealsharp
      @sealsharp 6 หลายเดือนก่อน

      Yes, there are.
      In 3D there is vertical movement like stairs and uneven ground. The unity CharacterController briefly mentioned at 07:28 is made specifically for that purpose.
      In 3D first person, the camera is linked to the character position which means that even a little unevenness in movement looks absolutely horrible. Standing on moving objects like elevators is often done by temporarily parenting the player but physical movement happens in FixedUpdate and so any combination of player character being moved by other objects gets kinda tricky.
      Depending on the artstyle and camera perspective, the syncing of animations and movement requires more work and using root animations, where the animation system drivers the movement, may be required for it to look good.

  • @newleafgames
    @newleafgames 6 หลายเดือนก่อน +1

    Very informative. Appreciated

  • @galassie-dev
    @galassie-dev 6 หลายเดือนก่อน

    Nice video!
    One "problem" is that you are not mentioning anything about linear drag that interacts with forces applied to a rigid body! It could be useful to have an update on this topic! :)

  • @Nicolas-tr3sk
    @Nicolas-tr3sk 5 หลายเดือนก่อน

    Nice video, it really helps understanding movement for beginners. Every other tutorial for moving just chooses a method and doesnt tell you about the other ones

  • @asig396
    @asig396 5 หลายเดือนก่อน

    You are the best of the best explaining things. I hope you can upload a tutorial for picking objects in 2D and in 3D not using RayCast, it cost me a lot to understand the power of the trigers.

  • @Dinkymod
    @Dinkymod 6 หลายเดือนก่อน

    Loved the video! I'd actually be interested in coverage of the Character Controller if you get around to making a 3D version of this vid.

  • @ReservedLaughter
    @ReservedLaughter 6 หลายเดือนก่อน

    nice video! RB.Velocity ftw!

  • @User609-iu5co
    @User609-iu5co 6 หลายเดือนก่อน

    There is also one good method for tilebased games that uses interpolation between discrete tile positions.Its fast, since no physics calculations are needed and positions are always exact.

  • @briantrochim474
    @briantrochim474 5 หลายเดือนก่อน

    i see you have input manager up there on the 4th option, are you using the new input system for just the forth option? or are you using it for all of them? also which of these four are best for combat? such as dashing, dodging, and knockback?

  • @t33h33studio
    @t33h33studio 6 หลายเดือนก่อน

    Personally, I love rb.Velocity. You need to modify your thinking/setup such that it's open to forces being added. Rather than setting the velocity directly through movement, you should have player's intended movement be one part of setting a velocity. With it getting either multiplied. subtracted, or added with to other forces that intended to interact with the Player.

  • @Luckypanther
    @Luckypanther 6 หลายเดือนก่อน

    So question I been looking for is why do others use vectors? Instead of using translate( 0, 0, 1) or whatever.

  • @1oglop1
    @1oglop1 6 หลายเดือนก่อน

    Is there a way to emulate canvas-like selection but with a game object? I am trying to emulate the feel of cursor hopping from one item to the other. But it is really fast (fps fast), so I implemented it as a coroutine which delays the next move. I wonder if there's a better way to do it.

  • @FeyFen
    @FeyFen 6 หลายเดือนก่อน

    great tut!

  • @Reistoge
    @Reistoge 6 หลายเดือนก่อน

    dude you are awesome

  • @roarlee6387
    @roarlee6387 6 หลายเดือนก่อน

    Beginner comment here: That InputManager.Movement looks like it should be a vector based on the x and y input. Where is that defined? I don't seem to have that input capture method available to me in my script.

    • @sasquatchbgames
      @sasquatchbgames  6 หลายเดือนก่อน +1

      that's based on a manual input script I created. (You could check out the Top-down movement tutorial, it's exactly the same) - Just a personal preference of mine

  • @BottleHeadGames
    @BottleHeadGames 6 หลายเดือนก่อน

    What about the velocity one? You didn't tell how to overcome the overriding of it and using add force a long side it... I was once stuck because of this thing couldn't find why or how to resolve it when manipulating the velocity directly.

  • @sealsharp
    @sealsharp 6 หลายเดือนก่อน

    Using the animators root motion is also a way to control. In modern realistic games with a visible character, that is the primary way to do it because it syncs movement and animations the best.
    One big issue is also the linking between hero and camera. In 2D that is not muhc of an issue as the camera is external and its so easy to tween. 3D first person, holy fuck that is a mess.

  • @gersti_15
    @gersti_15 6 หลายเดือนก่อน

    Is it possible to make a dash with all of this methods?

    • @BailyGameDev
      @BailyGameDev 6 หลายเดือนก่อน

      Yes. rb.AddForce is the easiest to add a dashing mechanic to it, but the others are all very possible. I use rb.Velocity and added an if(dashing == true){dash code}else{move code} in the fixed update.

    • @kingbling7571
      @kingbling7571 6 หลายเดือนก่อน

      Yup, u stop the movement code when dashing and start the movement code when done with dashing

    • @MarushiaDark316
      @MarushiaDark316 6 หลายเดือนก่อน

      To answer the question, we just have to think about what it means to actually dash. When we say dash, we mean a sudden and usually temporary burst of speed. Each of these methods is just a way of applying speed. So you would just use that method to raise the speed and then wait a bit and lower it back down again.

  • @emreberatkr
    @emreberatkr 6 หลายเดือนก่อน

    02:57 You don't have to multiply by neither deltaTime nor fixedDeltaTime. In FixedUpdate their value remain the same every call so its an unnecessary calculation. Both of them always return 0.02f by default.

    • @sealsharp
      @sealsharp 6 หลายเดือนก่อน

      If we are technically pendantic, then no.
      The FixedUpdate does not run at 50FPS default, it runs as often as it is required before the visual frame to ensure that physics happen in small enough steps for the physics algorithms to work. The FixedUpdate-Calls are also not equidistant in their time of appearence.
      If you search the unity forums, you can find people doing statistics and standard deviations of the true frequency and deltas of FixedUpdate-Calls depending on actual Update-FPS.
      Also, the FixedUpdate frequency can be changed, but even changing it to match 60FPS on an 60FPS locked games does not ensure a 1:1 between Update() and FixeUpdate().

    • @emreberatkr
      @emreberatkr 6 หลายเดือนก่อน

      @@sealsharp I didn't say that its runs at 50fps but the value is never changed during the runtime. So the value is constant and unnecessary to multiply with it. You may log the value and see its never change.

    • @gameweavers
      @gameweavers 6 หลายเดือนก่อน

      Official examples include multiplying by Time.fixedDeltaTime,docs.unity.cn/cn/2022.1/ScriptReference/Rigidbody2D.MovePosition.html

  • @MehmetSarkd
    @MehmetSarkd 6 หลายเดือนก่อน

    No charactercontroller ?

    • @sealsharp
      @sealsharp 6 หลายเดือนก่อน

      At 07:28 our hero, the CharacterController get's a mention. In a 3D game, this would be weird to leave out since CharacterController is a solution to so many complications on 3D.

    • @MehmetSarkd
      @MehmetSarkd 6 หลายเดือนก่อน

      @@sealsharp thanks i didn't watch the video cuz i wasn't interested in other methods

  • @Coco-gg5vp
    @Coco-gg5vp 6 หลายเดือนก่อน

    First