Unity Movement [RigidBody vs Translate]

Поделиться
HTML-код
  • Опубликовано: 18 дек 2024

Комментарии • 459

  • @lee1davis1
    @lee1davis1 5 лет назад +272

    This is the first tutorial I've seen that shows the difference between RB and translate since I started using unity a year ago. Thanks.

    • @pressstart6864
      @pressstart6864  5 лет назад +14

      Awesome, glad I could help!

    • @palomapaloma811
      @palomapaloma811 4 года назад

      my character just goes up, what do i do?

    • @Semaj0z
      @Semaj0z 4 года назад

      @@palomapaloma811 well, its kinda help with no code

  • @quintongordon6024
    @quintongordon6024 4 года назад +82

    To stop objects from moving through colliders when moving at a fast pace you can set the objects rigid body's collision detection from discrete to continuous. It's more performance heavy which is why it's not the default.

    • @Borna688
      @Borna688 2 года назад +3

      thank you, saved me

    • @gridvid
      @gridvid 2 года назад +4

      Sadly, it still keeps happening to me. I had to stop all movement on collision events to prevent it.

    • @thepolyglotprogrammer
      @thepolyglotprogrammer 2 года назад +1

      Me too, for some reason, just changing to continuous does not seem to work for me.

    • @rad6626
      @rad6626 Год назад +1

      @@thepolyglotprogrammer have you found a fix yet?

    • @anatoly.larkin
      @anatoly.larkin 2 месяца назад +1

      Looking for a fix myself. I have tried everything. Continuous Dynamic on all rbs with interpolate turned on. The rb I am moving still "goes inside" the RB it's colliding with.

  • @only2megabytes139
    @only2megabytes139 3 года назад +144

    You know whats more fun then finding which is best for your game? Finding out that apparently none of them will work.

    • @NotASpyReally
      @NotASpyReally 3 года назад +6

      pain

    • @NotASpyReally
      @NotASpyReally 3 года назад +1

      @jonathon boiragee no u are sus

    • @draxnos506
      @draxnos506 3 года назад +1

      What's the issue? The issues he had with the first two are actually really easy to fix.

    • @only2megabytes139
      @only2megabytes139 2 года назад +15

      @Susan Reed What the fuck

    • @backgroundmusic250
      @backgroundmusic250 2 года назад +1

      when I rotate the capsule with the mouse the axes change direction (W becomes S and A becomes D and vice versa), so to go forward I have to use A, D or S depending on where the player is looking . Does anyone know how I fix this?
      I tried transform.Translate, but as said in the video, it doesn't work along with physics

  • @LetsPlayCrazy
    @LetsPlayCrazy 2 года назад +4

    This video is a gift from heaven.
    I just started unity a week back and my script is super complicated because i never knew how to do movement, so I experimented.
    This REALLY helps a lot! Thank you!

  • @hiteelperado4318
    @hiteelperado4318 5 лет назад +54

    Thanks, man this helps me. By giving an example for each method it really helps me to understand when to use them.

    • @wonderpouchstudios
      @wonderpouchstudios 5 лет назад +4

      Yeah same, not a lot of people do this, they just show you one way "How To Move a Player In Unity"

    • @battosaijenkins946
      @battosaijenkins946 4 года назад +1

      @Press Start, aw man I'm like 2 years too late but your explanations are so specific and to the point I'm learning so much. Thanks again great vids!!!

  • @klaus117gaming
    @klaus117gaming 3 года назад +6

    This is what a tutorial should look like. Been searching for a simple and well detailed answer for eternity and i got even more confused each time, but finally, I got a good answer. Thanks man 👌🏾

  • @cem.ugur.karacam
    @cem.ugur.karacam 5 лет назад +83

    I've seen a lot of rigidbody lesson on both unity official tutorials and youtube but this is the best well explained and distilled version ever! Keep on your journey, I'll be following!

    • @pressstart6864
      @pressstart6864  5 лет назад +2

      Wow, thank you for your nice words

    • @etistyle96
      @etistyle96 Год назад

      i can't agree more on this one. This is a masterpiece !

  • @kovidkhokar298
    @kovidkhokar298 2 года назад +1

    bro MovePosition is a life saver it is weird that after 1year of struggling i still hadn't heard of it. You are in need of this movement system 7:09

  • @phi4108
    @phi4108 5 лет назад

    This video help me so much. On youtube people only show how to move player but they don’t explain the different between these . Thank you so much !!

  • @yoyo12345
    @yoyo12345 2 года назад +1

    8:25 u could set collision detection to discrete

  • @Sakros
    @Sakros 4 года назад +90

    8:06 if you turn the collision detection in the Rigidbody componont from "Discrete" to "Continous" this won't happen. Nice Video :D

    • @Theasstasticvillain
      @Theasstasticvillain 4 года назад +19

      Note that changing from discrete to continuous is much more performance intensive though, so be careful

    • @b.alejandres8230
      @b.alejandres8230 2 года назад

      ty buddy, you rock.

    • @BorbsJSKF
      @BorbsJSKF 2 года назад +1

      Not on translate if the speed is too high, that only applies to Velocity

    • @adesinausman2478
      @adesinausman2478 Год назад

      @computerbrand9701hey, have you figured it out?

  • @coldxcalculated9191
    @coldxcalculated9191 3 года назад

    Sir, please make more of these. As a complete beginner your way of describing makes so much sense than the traditional “ follow me” tutorials where when you finish you are just as clueless if not more than when you began

  • @majora4896
    @majora4896 5 лет назад +7

    This was information I needed for a long time. I kept trying to have the translate behavior, while avoiding clipping issues. I couldn't find an answer until your video. Thank you.

  • @hershmysson
    @hershmysson 4 года назад +4

    Oh my god you explained all of this SOOO well, dude thanks

  • @jeremiebeaulieu8501
    @jeremiebeaulieu8501 3 года назад

    This video is the best explained video on the subject that I've ever seen. Even my teacher in college didn't explained that well. This will help me alot, thanks

  • @Borna688
    @Borna688 2 года назад

    Thank you so much, I've been through about 50 videos today - no luck untill I found this one, god bless man

  • @bimokayoba
    @bimokayoba Год назад

    i started learn unity from 2019 when i was 10 years old, and i wasn't know this, Thanks a lot ❤❤

  • @ingvmbv
    @ingvmbv 2 года назад

    Pretty good explanation, now I understand why there are so many ways to move a gameObject

  • @GrayGriffonKnight
    @GrayGriffonKnight 3 года назад

    hey, I've been using this video since it was released on like, a dozen or so different projects of mine for any number of functions and tasks.
    So, thank you so much.
    It has really made my life so much easier.

  • @drominus3875
    @drominus3875 3 года назад

    Easily the best rigidbody vs translate explanation of why you'd use one over the other and simple examples without needless complication. thank you!

  • @carlosjunod5424
    @carlosjunod5424 5 лет назад +2

    nobody could explain it better, keep with this tutorials pls

  • @Hydraxouz
    @Hydraxouz 2 года назад

    Thank you for this! I made the mistake of using the Translate function for my game prototype only to then realize after a bit of work that physics, collisions, and almost every planned mechanic was non-functional. You've done a fantastic job of explaining how the rb methods work.

  • @amandachristina9746
    @amandachristina9746 Год назад

    This is the most helpful character movement video I've ever seen. Thank you!

  • @AmIThePresident
    @AmIThePresident 4 года назад +2

    You can use a raycast before moving to see how far you should move, if the raycast hits something then get the position and use that to move instead of the usual calculation.

  • @mohamedelkehaoui7226
    @mohamedelkehaoui7226 4 года назад +1

    the best unity tutorial I ever watched hope you keep adding tutorials or even a paid course.

  • @totallyrandompersob1664
    @totallyrandompersob1664 4 года назад

    I watched a tutorial on ai and it used add force but I wanted to use move position. Long story short took me four days and lots of thinking, you definitely helped.

  • @X1th
    @X1th Год назад

    Thanks to the god of random that I stumbled upon this video after watching others on the same theme. Very helpful, thank you!

  • @volkerherfeld3225
    @volkerherfeld3225 Год назад

    One of the best explanations on RUclips. Thanks!

  • @jamesjeoffreysarmiento3224
    @jamesjeoffreysarmiento3224 2 года назад

    Dude this helped me so much! Thank you for the tutorial now I know why when I use transform.Translate it keeps on vibrating thank you!

  • @dennis2599
    @dennis2599 4 года назад

    I can now fix my game with your help: instead of using AddForce(), I am now using MovePosition(), which doesn't break my game. Thanks :D

  • @NaderTaghinia
    @NaderTaghinia 4 года назад +2

    Really useful information, good voice, high quality recording both visually and vocally, nice editing, not too short and not too long a video, clear explanation about the subject, proper examples and many other details that I am sure you have considered but I cannot immediately get it.
    I badly needed this piece of information and you just delivered that in the best way possible. Thank you so much sir ❤️

  • @gregoryfenn1462
    @gregoryfenn1462 5 лет назад +1

    I like the format of these videos, and I think the speaking and demonstrations are clear. So I'm surprised it's still so small.

    • @pressstart6864
      @pressstart6864  5 лет назад

      Thanks Gregory! We're slightly new but our numbers are climbing. We just need to breach through RUclips's algorithm, but I appreciate your kind words and support!

    • @gregoryfenn1462
      @gregoryfenn1462 5 лет назад +1

      Maybe, I don’t know how these things work. My friend Chris (Cynical Reviews (previously Cynical CJ)) started from nothing and now has like 100k subs after a year. And Sykoo does Unity stuff and is doing very well (I think he’s friends with the guy from Brackeys so that might help.) maybe you need to say more controversial opinion stuff? Seems to work for other RUclips stars. I don’t know. I would like more channels like yours to grow because it’s great for learning Unity and generally making the community feel at home.

  • @jojobee228
    @jojobee228 5 лет назад +7

    finally, I understood the movement, thank you for the video.

  • @cajmichaelandersson5072
    @cajmichaelandersson5072 5 лет назад +2

    I am pretty new to game development and this is one of my biggest problems, thanks a lot! :)

  • @Lily-cn1bp
    @Lily-cn1bp 4 года назад

    This is a very good explanation, it's easy to follow and it highlights important points that most other tutorials don't.

  • @thefallenlime
    @thefallenlime 4 года назад

    This was far easier to understand than some of the other tutorials I'd watched. It also gave me a couple of ideas on how to use the other movement types for different enemies. Thanks!

  • @candycodes4575
    @candycodes4575 4 года назад

    This video is gold, short, direct, and actually full of information. Getting the How, why, and what for... One of the best videos in terms of knowledge given for time spent on a video. Subscribed immediately... :D will be watching out for your contents man...very nice...

  • @Term1nus3st
    @Term1nus3st 5 лет назад +5

    This was so informative, I've tried everything without understanding anything, havent tried only movePosition and this was what I needed. Thanks a lot for the time you spent to make this video

    • @pressstart6864
      @pressstart6864  5 лет назад

      Thank you for your kind words and I'm glad this video helped!

  • @gui31santos
    @gui31santos 4 года назад

    Wow! I watched so many videos this week trying to understand this, but your video was definitely the best one. Thanks a lot! Please keep making more of those

  • @pac4games253
    @pac4games253 4 года назад

    I loved the video! I was having problems with my 2D game because the player character was hitting the colliders but passing through after sometime, the Rigidbody.MovePosition() function was so helpful and you explained very clearly how to use it and how it works, thank you so much! :)

  • @Yoctopory
    @Yoctopory 3 года назад +3

    If you use velocity but still want the object to have gravity, you can also do it like this (it's like applying a force):
    rb.velocity += direction * speed;

  • @BossFlight
    @BossFlight 4 года назад

    Thanks! Finally! This should be added as a Official movement tutorial in Unity website itself!

  • @mushkela357
    @mushkela357 5 лет назад +2

    First of all, I like all you videos and how well done they are just made (recorded, edited, and even sound and visual quality.
    I've been watching you videos on Patreon for the most part, but I just had to comment on this video.
    It's just very well explained and the demonstration and the way you broke things down just couldn't have been done better!
    Thank you very much, and keep up the good work. especially those video where you explain how things work or what certain functions/methods do or how they work. I'll be waiting for more videos like this.

    • @pressstart6864
      @pressstart6864  5 лет назад +1

      It means a lot to me that you took time out of your day to write this. Appreciate the love. Tons more to come, thanks for following :)

  • @quintongordon6024
    @quintongordon6024 4 года назад

    With setting velocity you can set it to: rb.velocity(new Vector2(direction * speed, rb.velocity.y));
    This will stop it from affecting the objects gravity.

  • @Prudenprocom
    @Prudenprocom 3 года назад

    You have finally made me understand parameters! At last!!!

  • @briwal8975
    @briwal8975 4 года назад

    SIIIIIIIII Luego de buscar solucion para el movimiento de mis personajes por fin encontré el video correcto. Excelente❤!!!

  • @Noisey_fox
    @Noisey_fox 3 года назад

    Thorough, specific, understandable, and epic. You have saved my life once again brother.

  • @andrewporter1348
    @andrewporter1348 4 года назад

    Just wow, thanks I had trouble with the addforce function and you solved it in a second.
    Thank you!

  • @Glisean
    @Glisean 5 лет назад

    This is such a helpful video! I've been going through so many videos and tutorials that just say "move your character this way" without explaining why that method was used or how it doesn't make sense for every game. The first tutorial I followed used translate because collisions did not have an affect on the player movement but it doesn't make sense for something like a 2D platformer.

  • @bazingazeroni
    @bazingazeroni 3 года назад

    Maaaan thank you sooo much. I was looking for a rb.moveposition() type of thing for ages!!!

  • @Rovsau
    @Rovsau 3 года назад

    Great tutorial.
    One flaw at the end: Set Rigidbody Collision Detection to Continuous instead of Descrete.
    That will prevent moving through walls at high speeds.

  • @ToastThemm
    @ToastThemm 2 года назад

    OMG bruh i was wondering why my movement was so janky I WAS USING THE WRONG THING!!! Thank you so much u just saved a project lmao.

  • @yudingzhou8683
    @yudingzhou8683 4 года назад

    thank you! this is the most simple yet comprehensive tutorial for introducing moving an object. i got the big picture.

  • @gabetheborkingdog5985
    @gabetheborkingdog5985 3 года назад

    U can use add force and create a physics Material of zero friction and apply it to ground. U can also play around with drag. Doing this will help get faster stopping and accelerating time.

  • @jaimemedina3351
    @jaimemedina3351 5 лет назад +2

    Thank you! Great, straight forward exposition. You pack a lot of information in a short period of time.

    • @pressstart6864
      @pressstart6864  5 лет назад +1

      That’s my goal. Thanks for the feedback!

  • @GrumpSkull
    @GrumpSkull 3 года назад +1

    I fell through the terrain into the abyss of nothingness, never to return to the physical realms and have now become just an avatar on RUclips.

  • @2000GHz
    @2000GHz 3 года назад

    Finally someone explained this clearly! Thank you so much for this

  • @raffdev
    @raffdev 5 лет назад +1

    Great video. Explained simply, shortly, with practical examples and comments. I don't know how you could make it any better, keep it up. You've got my recommendation :D

    • @pressstart6864
      @pressstart6864  5 лет назад

      Thank you for your support! Means a lot to me.

  • @joshuavancuyck2669
    @joshuavancuyck2669 5 лет назад +2

    dude your videos are so informative and relevant and you deserve WAYY more subscribers!! Carry on man you'll soon be noticed

  • @humadi2001
    @humadi2001 4 года назад

    one of the BEST ,BEST, BEST Unity Tutorials. Thank you!

  • @Koujujutsu
    @Koujujutsu 5 лет назад +2

    Thank you so much! I've been flipping through tutorials and manuals for a week straight trying to find the simplest way to give an object flight. And...ha...for some reason, my sphere ended up flying around the X access instead of the Y, like yours. But THANK YOU. That was a succinct yet thorough explanation. I prefer the AddForce option, because I am trying to similate movement through fluid. However, I still have to look into how to include the Z axis. Maybe I should go for a follow the (3d)camera and move option.

  • @prithvimohanjanak8818
    @prithvimohanjanak8818 3 года назад

    Thank you so much. Your video has helped in understanding the distinction in each of the function methods.

  • @lukedeets5016
    @lukedeets5016 4 года назад

    Best explanation I've found on RUclips !!

  • @Tutterzoid
    @Tutterzoid 6 лет назад +3

    Thanks for covering those different ways of going about Movement in Unity :)

  • @ahsan4457
    @ahsan4457 3 года назад

    2:14 In my 2d player script i am using transform.Translate to move character the strange this is it is acting opposite of what you just explained it can deteted collisions and gravity is applied i am using 2018.4 version of unity.

    • @marcus_74
      @marcus_74 2 года назад

      Do u have Rigidbody component enabled?

  • @anotherrandominternetperso4994
    @anotherrandominternetperso4994 4 года назад

    Oh my god! I sit here since two days and I as wonderi ng why my collision skript on my Object, which I have moved with translate, didn´t worked. Thank You sooo much for your help, your awesome!

  • @nischitasudharsan9883
    @nischitasudharsan9883 4 года назад

    Thanks for the awesome explanation! I have been wanting to understand this from a long time and this was the best video that explained it clearly

  • @izzurumusic
    @izzurumusic 4 года назад

    What is coding language were used in unity?

  • @vicenteperez2136
    @vicenteperez2136 2 года назад

    thank you so much im trying to get into unity and game dev this helped a lot

  • @ScilexGuitar
    @ScilexGuitar 4 года назад +6

    2:18 So THATs why my OnCollisionEnter2D method didnt work! I get it now

  • @naturelist
    @naturelist 2 года назад

    That is absolutely what I wanted! Thank you so much!

  • @vargasxr421
    @vargasxr421 4 года назад

    Great display of options! Thanks

  • @hugomiramontes7630
    @hugomiramontes7630 5 лет назад +1

    I just saw this video and it helped me understand all those concepts well, thank you very much, awesome work.

  • @stephulz
    @stephulz Год назад

    Amazing tutorial, finally understood it

  • @lip3gate
    @lip3gate 5 лет назад +5

    You are very talented to teach and I love how you can explain 3 different ways for achieve movement with scripts. Could you make a series with this theme? I mean, wich different functions could do the same? Thanks!

    • @technofeeliak
      @technofeeliak 5 лет назад

      Well, what drives me absolutely up the walls is that the minor details tutorials often skip like the is kinematic checkbox will have me looking for hours thinking I did something wrong with the code. I'm not setting up a script directly on the GameObject you see? So it's just easy to imagine that I've done something wrong. In the end, all of this is just so simple. It's like, when I was desperately trying to get the mesh data, I'm talking about the vertices and the triangles... someone on Twitter showed me a sample of his code. It didn't work for me at all. I kept getting error messages that read something like I didn't have permission to read or write the data. When I found that stupid checkbox everything seemed to work... Oh, but no, there had to be something else. I had all the coordinates, it was so beautiful. But they looked strange, and I got to understand that I had a long list of doubles and not floats. I spent days scratching my head, trying to figure out how I would solve this or just make a tool again that I'd use to trace all the graphics. It was just a checkbox... one that determined whether to change the units of the imported mesh into Unity units. I turned that off and everything was great. So, when these experienced users and teachers don't explain things in depth missing minor details that change everything, the learning process isn't just extended it's made a torment. I say, thanks for the information but next time please make it comprehensive. You have no idea just how discouraging it is.
      ruclips.net/video/P_VvEouFo8w/видео.html

  • @Ghost-2079
    @Ghost-2079 4 года назад

    perfect video, i'v used velocity for camera photo mode in game !

  • @JohnyLMS
    @JohnyLMS 5 лет назад +4

    Just what i needed. Thanks for the video, dude

  • @tPlayerioT
    @tPlayerioT Год назад

    THANKS it fixed my collision issue.

  • @Skipzilla01
    @Skipzilla01 5 лет назад

    This was explained so clearly and objectively. Definately subbing

  • @AliHosseiniDev
    @AliHosseiniDev 5 лет назад +2

    a very complete toturial
    ty very much

  • @marcusmorrow3900
    @marcusmorrow3900 5 лет назад +2

    This was a great tutorial. I really needed the help.

  • @jijigri9224
    @jijigri9224 4 года назад +1

    I'm really late, but I just wanna add that using Translate CAN be a really good solution, if you want to have precise control over your character movement, but it is way longer to program than using Rigidbodies since you pretty much have to code the physics by yourself. For the collision detection, you can use raycasts instead of box colliders, it works great !

    • @shahid-habibi
      @shahid-habibi Год назад

      Can you mention a video of raycast?
      I don't know what can i prevent my character from hitting objects when fast moving
      will raycast be a solution?

    • @jijigri9224
      @jijigri9224 Год назад

      @@shahid-habibi I suggest watching Sebastian Lague's 2D platform controller video series if you're interested in making a character controller with raycasts.
      If you just want to do a simple collision test, you can refer to Unity's documentation

    • @shahid-habibi
      @shahid-habibi Год назад

      @@jijigri9224 Thanks from your reply bro

  • @B4NTO
    @B4NTO 3 года назад

    Thanks for a Short simple and straight forward video 😀✨

  • @iamthebubb
    @iamthebubb 2 года назад +1

    I spent ages using a character controller, and although it gives smooth movement, it causes so many issues with collisions. I'm using rigibody now!

  • @auser-e47ca369
    @auser-e47ca369 4 года назад +25

    when I use movePosition it overrides my gravity

    • @tomasmileto
      @tomasmileto 3 года назад

      same here dude

    • @magic_nanito
      @magic_nanito 3 года назад +1

      @@tomasmileto idk if this works but you can try putting something similar like this in the code
      float Gravity = 9.81f;
      Vector 2 movement = (xAxis, Gravity + yAxis);
      MovePosition(transform.Position + movement);

    • @magic_nanito
      @magic_nanito 3 года назад

      @@tomasmileto and set to false the rigibody gravity

    • @tomasmileto
      @tomasmileto 3 года назад +1

      @@magic_nanito I ended up going for rb.velocity but I'll make sure to try it out

  • @technofeeliak
    @technofeeliak 5 лет назад +7

    //Moving the character
    //1st way to move a character overrides the physics of the 3D game and doesn't affect collisions
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class translate : MonoBehaviour
    {
    public float speed = 10.0f;
    //Use this for initialization
    void Start()
    {

    }
    //Update is called once per frame
    //Update runs once per frame so it's ideal for capturing the keyboard input
    {
    moveCharacter(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")));
    }
    void moveCharacter(Vector2 direction)
    {
    transform.Translate(direction * speed * Time.deltaTime);
    }
    }
    //2nd way to move a character involes physics in Unity
    //*****REMEMBER TO SET "is kinematic" in the inspector to OFF
    //kinematic sets the Rigidbody to accept instructions from code and not consider physics
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class translate : MonoBehaviour
    {
    public float speed = 10.0f;
    public Rigiddoby rb;
    public Vector2 movement;
    //Use this for initialization
    void Start()
    {
    //If your script is a component (just linked to a gameObject with a rigidbody of its own)
    //then call on this and get its rigidbody component
    rb = this.GetComponent();
    }
    //Update is called once per frame
    //Update runs once per frame so it's ideal for capturing the keyboard input
    {
    movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    }
    //FixedUpdate is run every physics step, so once, none, or many times per frame
    //It's the update you want to use for dealing with instructions related to physics
    //Don't use Update for physics... just FixedUpdate
    void FixedUpdate()
    {
    //this fixedUpdate will handle the pace at which the moveCharacter function is called
    moveCharacter(movement);
    }
    //this is the moveCharacter function that takes the direction determined by your keypress in Update
    //Horizontal left (-1) and right (1) and zero (0) for it's point of departure
    //Vertical up (1) and down (-1) and zero (0) again
    void moveCharacter(Vector2 direction)
    {
    //There is more than one way to move the RigidBody (what we've called rb here)
    //We can use the method RigidBody.AddForce(); to add force to the object
    //This will have a sliding effect
    rb.AddForce(direction * speed);
    //We can instead set the RigidBody's velocity this way RigidBody.velocity;
    //Manipulating the velocity will move an object at a constant rate over time
    //Controlling an object this way overrides physics including gravity but will still have collisions
    rb.velocity = direction * speed;
    //Or we can use RidigBody.movePosition;
    //This may be the best option for moving a character because it works with physics & is more easilty controlled
    //In this case we're only concerned with moving on the X axis so we're using Vector2 and convert this to a x
    and y transformation by adding a (Vector2) before transform and don't forget the brackets
    //If on the other hand you want to move the character on all axis including Z then you don't need the Vector2 variable for movement above and you also don't need to convert this code to adjust it with (Vector2) before transform
    rb.MovePosition((Vector2)transform.position + (direction * speed * Time.deltaTime));
    }

    • @pressstart6864
      @pressstart6864  5 лет назад

      Thanks for sharing

    • @draxnos506
      @draxnos506 3 года назад

      @@pressstart6864 The issues you were having with .AddForce() and .velocity have easy fixes.
      _For AddForce():_
      If you want to stop at a certain speed without including drag, an if statement checking your speed vs your maximum helps.
      _For .velocity:_
      If jumping and gravity are the only ways you plan to move vertically, rb.velocity.y as the movement vector's y should fix this.
      Could you maybe pin the main comment so people may be more likely to see the fixes to those issues?

  • @noahschierenbeck6375
    @noahschierenbeck6375 4 года назад

    Thank you for this! Great explanation about the different choices!

  • @ossiexs
    @ossiexs 5 лет назад +1

    Great explanation , great animated , great example , just wow thanks so much ,

  • @pressstart6864
    @pressstart6864  6 лет назад +4

    Full source code can be found here:
    pressstart.vip/tutorials/2018/10/19/71/rigidbody-vs-translate.html

  • @_jenfi
    @_jenfi 5 лет назад +1

    This is exactly what I'm looking for! Thank you so much!

  • @nurielfreeman7809
    @nurielfreeman7809 4 года назад

    got a subscription only because of this great explanation !!
    thanks a lot buddy, finally!

  • @smartandfunny6140
    @smartandfunny6140 5 лет назад +2

    wow , amazing! well explained ! thanks man keep up the good work!

  • @Fmlad
    @Fmlad 3 года назад

    I much prefer using Velocity to control my rigidbody such as:
    public Rigidbody2D rb2D;
    public float speed;
    //placed somewhere you have check for button press
    direction = Input.GetAxisRaw("Horizontal");
    rb2D.velocity = new Vector2(direction * speed, rb2D.velocity.y); // this ensures that gravity still effects you even whilst moving

  • @yaxyz1030
    @yaxyz1030 5 лет назад +1

    I love your tutorial man! Very useful information

  • @UnitCodesChannel
    @UnitCodesChannel 5 лет назад

    Translate like the wise say, is when you need to teleport an object through mediums. Nice video 👍🏼

  • @sinistergeek
    @sinistergeek 4 года назад

    bravo explaination iz off the chart i humbly thank You for Making video as beginner it's really helpful!!

  • @glumb8968
    @glumb8968 2 года назад

    Thanks a lot for this very helpful composition! 👍
    Two small thoughts:
    I think, as moveCharacter is called from FixedUpdate, you should use Time.fixedDeltaTime when calling MovePosition on the Rigidbody. Also, the magnitude of the direction vector may reach ~1.41, if two direction keys are pressed together. This should make you cover more distance with diagonal movement, which may not be ideal, but I'm currently unsure how to solve this elegantly.

    • @byekim
      @byekim 2 года назад

      I believe normalizing (.normalized) the "movement" vector will solve this diagonal speed issue.

  • @youssefbahomman161
    @youssefbahomman161 5 лет назад +1

    Nice and cool and very comprehensive thanks dude

  • @reddragon6317
    @reddragon6317 4 года назад

    awesome content bhrastar(farcry primal).

  • @jaopreto-wlock
    @jaopreto-wlock Год назад

    Dude, this video saved me a lot of time, thank u