Тёмный

Unity Movement [RigidBody vs Translate] 

Press Start
Подписаться 24 тыс.
Просмотров 285 тыс.
50% 1

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 458   
@only2megabytes139
@only2megabytes139 3 года назад
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 года назад
pain
@NotASpyReally
@NotASpyReally 3 года назад
@jonathon boiragee no u are sus
@draxnos506
@draxnos506 3 года назад
What's the issue? The issues he had with the first two are actually really easy to fix.
@only2megabytes139
@only2megabytes139 2 года назад
@Susan Reed What the fuck
@backgroundmusic250
@backgroundmusic250 2 года назад
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
@lee1davis1
@lee1davis1 5 лет назад
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 лет назад
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 года назад
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 года назад
thank you, saved me
@gridvid
@gridvid 2 года назад
Sadly, it still keeps happening to me. I had to stop all movement on collision events to prevent it.
@thepolyglotprogrammer
@thepolyglotprogrammer 2 года назад
Me too, for some reason, just changing to continuous does not seem to work for me.
@rad6626
@rad6626 Год назад
@@thepolyglotprogrammer have you found a fix yet?
@anatoly.larkin
@anatoly.larkin 5 дней назад
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.
@hiteelperado4318
@hiteelperado4318 5 лет назад
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 лет назад
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 года назад
@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!!!
@Sakros
@Sakros 4 года назад
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 года назад
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 года назад
Not on translate if the speed is too high, that only applies to Velocity
@adesinausman2478
@adesinausman2478 Год назад
@computerbrand9701hey, have you figured it out?
@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!
@Term1nus3st
@Term1nus3st 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!
@NaderTaghinia
@NaderTaghinia 4 года назад
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 ❤️
@cemugurkaracam
@cemugurkaracam 5 лет назад
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 лет назад
Wow, thank you for your nice words
@etistyle96
@etistyle96 Год назад
i can't agree more on this one. This is a masterpiece !
@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.
@axelkagstrom4418
@axelkagstrom4418 5 лет назад
Hehe, I sat for 2h before and didnt understod why that damn box collision didnt work... Transform...
@joshuavancuyck2669
@joshuavancuyck2669 5 лет назад
dude your videos are so informative and relevant and you deserve WAYY more subscribers!! Carry on man you'll soon be noticed
@pressstart6864
@pressstart6864 5 лет назад
Appreciate the love!
@auser-e47ca369
@auser-e47ca369 4 года назад
when I use movePosition it overrides my gravity
@tomasmileto
@tomasmileto 3 года назад
same here dude
@magic_nanito
@magic_nanito 3 года назад
@@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 года назад
@@magic_nanito I ended up going for rb.velocity but I'll make sure to try it out
@ScilexGuitar
@ScilexGuitar 3 года назад
2:18 So THATs why my OnCollisionEnter2D method didnt work! I get it now
@candycodes4575
@candycodes4575 3 года назад
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...
@pressstart6864
@pressstart6864 5 лет назад
Full source code can be found here: pressstart.vip/tutorials/2018/10/19/71/rigidbody-vs-translate.html
@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
@technofeeliak
@technofeeliak 5 лет назад
//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?
@klaus117gaming
@klaus117gaming 2 года назад
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 👌🏾
@hershmysson
@hershmysson 4 года назад
Oh my god you explained all of this SOOO well, dude thanks
@jojobee228
@jojobee228 5 лет назад
finally, I understood the movement, thank you for the video.
@GrumpSkull
@GrumpSkull 3 года назад
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 RU-vid.
@Yoctopory
@Yoctopory 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;
@majora4896
@majora4896 5 лет назад
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.
@smartandfunny6140
@smartandfunny6140 5 лет назад
wow , amazing! well explained ! thanks man keep up the good work!
@LetsPlayCrazy
@LetsPlayCrazy 2 года назад
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!
@issacthompson330
@issacthompson330 4 года назад
If you call for the current Y velocity in rb.Velocity calls you could maintain gravity and with an if statement or another line of code you could add a jump. The problem with Velocity is it throws out the old Velocity if you do not do something to preserve it making gravity not work right.
@kruth6663
@kruth6663 2 года назад
is there a benifit to update "movement" separately in update method instead of also in fixedupdate where the moveCharacter method is called?
@prathamesh_dalvi
@prathamesh_dalvi 6 лет назад
Please Bro.. Make an Alphabet Tracing Tutorial
@foreducation408
@foreducation408 2 года назад
thanks for the tutorial helped me a lot.
@joelthescientist
@joelthescientist 5 лет назад
Another option which is more work but gives you more control over how your character moves is to write custom physics for your character controller, like this: github.com/prime31/CharacterController2D
@pressstart6864
@pressstart6864 5 лет назад
Thank you for sharing :)
@lip3gate
@lip3gate 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. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-P_VvEouFo8w.html
@yoyo12345
@yoyo12345 2 года назад
8:25 u could set collision detection to discrete
@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
@VenusAviation
@VenusAviation 3 года назад
2:18 "The biggest problem with transform.translate is that it doesn't detect collision." I have just tested this and this statement doesn't appear to be true. In your example, If you give your ball a boxCollider2D and a rigidbidy2D and you do the same for your wall, and you then move the ball using "transform.translate", it will collide with the wall. So I'm now confused?
@MrTeteX9
@MrTeteX9 3 года назад
It because at the current frame, two collider with one of these have a rigibodie attach are colliding. But move positon will predicate the next frame to know if the WILL be a collision. So in general, Move Positon is way more accurate than Translate if you need collision
@VenusAviation
@VenusAviation 3 года назад
@@MrTeteX9 Thank you for your reply. That was very helpful. Yes, I repeated the same test with a very high speed. Transform translate did not collide with the wall. MovePosition did collide with the wall. :)
@twisting.nether
@twisting.nether 3 года назад
Great tutorial, but movePosition has some problems, it has some disorder with other method behavior such as jumping especially when you're using AddForce to jump. I don't know but it seems movePosition is useful just in some cases.
@AriesT1
@AriesT1 3 года назад
movePosition is only recommended for Kinematic objects, according to the Scripting Reference. Using velocity directly is the best practice for 2D, ALTHOUGH it has massive issues when AddForce (for Knockbacks, explosion forces etc.) comes into play.
@sardinxp
@sardinxp 3 года назад
do you have any movement tutorial like this for vector3?
@AmIThePresident
@AmIThePresident 4 года назад
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.
@JohnyLMS
@JohnyLMS 5 лет назад
Just what i needed. Thanks for the video, dude
@cbox_
@cbox_ 5 лет назад
Clear and concise, Cheers.
@arabiannights7183
@arabiannights7183 3 года назад
the last one doesnt work. it gives error message Transform' does not contain a definition for 'Position' and no accessible extension method 'Position' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
@Antvnio-B
@Antvnio-B 4 года назад
Amazing explanation thanks
@DineshKumar-by5lw
@DineshKumar-by5lw 4 года назад
The object is slowly coming down in move position as well
@reddragon6317
@reddragon6317 4 года назад
awesome content bhrastar(farcry primal).
@amerging8687
@amerging8687 2 года назад
Thanks to you Please continue this Amazing work 😍😍😍😍🥰🥰🥰🥰🥰
@munyamunya313
@munyamunya313 4 года назад
Very good video easy to understand, im still a newbie so i need to know how long it will take me to master unity watching tutorials and reading books
@igorthelight
@igorthelight 5 лет назад
There is another way to move an object similar to Translate() transform.position += (Vector3)(direction * speed * Time.deltaTime); So it's basically changing it's position. It's even more "raw" than Translate() It there an reason to use this method? The answer is "no" :-)
@ОлексійШвець-ь1ю
@ОлексійШвець-ь1ю 4 года назад
Why my rigidbody.moveposition controller goes through walls ?
@cajmichaelandersson5072
@cajmichaelandersson5072 5 лет назад
I am pretty new to game development and this is one of my biggest problems, thanks a lot! :)
@ryanmoulla2409
@ryanmoulla2409 5 лет назад
Do you know how to instantiate a prefab and make it move with the player and enemies
@pressstart6864
@pressstart6864 5 лет назад
Unity - Enemy Follows Player [Beginner Tutorial] ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4Wh22ynlLyk.html
@iamthebubb
@iamthebubb Год назад
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!
@ber2996
@ber2996 4 года назад
I like AddForce better it preserves gravity unlike when you set Velocity, in that way you can get the effect of inertia
@romelian3754
@romelian3754 4 года назад
I prefer transform.position
@chocobochick5390
@chocobochick5390 5 лет назад
How would I take car physics and turn them into character physics, keep the momentum, lose the wobble and shake, and I can move around like a character in a 3d platformer? I'm using the code from this demo: github.com/SergeyMakeev/ArcadeCarPhysics/releases/tag/1.0
@flangeditz4099
@flangeditz4099 2 года назад
Bro your are the best
@Dexter-rx3xg
@Dexter-rx3xg 2 года назад
Thank you so mach i was using translate all the time 😂🙈
@zilverman7820
@zilverman7820 5 лет назад
wait I've tried rb.moveposition() on a 3d game and the ball just move unlike in the rb.addforce() the ball is rolling with physics?
@soran2290
@soran2290 4 года назад
Use character controller is better
@parijatprasadsarkar1163
@parijatprasadsarkar1163 3 года назад
Can you plzz create a video with tips on How to prevent objects passing through each other due to high speed(while using rb.moveposition)?
@kovidkhokar298
@kovidkhokar298 2 года назад
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
@Tutterzoid
@Tutterzoid 5 лет назад
Thanks for covering those different ways of going about Movement in Unity :)
@pressstart6864
@pressstart6864 5 лет назад
Tutterzoid thank you
@MorgurEdits
@MorgurEdits 4 года назад
My problem with movement is that I want to reinvent the wheel and make "Original" code for some unpractical and hard movement
@AliHosseiniDev
@AliHosseiniDev 5 лет назад
a very complete toturial ty very much
@mushkela357
@mushkela357 5 лет назад
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 лет назад
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 :)
@Zzepish
@Zzepish День назад
Very good guide! Thank you so much. Is it still the same way? So - there is no silver bullet? Everywhere is compromise?
@HakimIrbah
@HakimIrbah 4 года назад
Thank you for this explanation. I was struggling to understand when to use RB or translate. But I have a question about this subject. Why the box collider won't detect an other collider when using translate?
@antonymorsas
@antonymorsas 5 лет назад
Great great great, so informative, just what i want
@zk2611
@zk2611 5 лет назад
If your like me and you can't get this to work with a 2D build check to make sure you're not using the 'Rigidbody 2D' component on your object. If you are, then make sure you specify 'Rigidbody2D' in your .cs file.
@pressstart6864
@pressstart6864 5 лет назад
Good points, thanks for sharing!
@fongaming101
@fongaming101 3 года назад
Rb.velocity = new Vector2(direction *speed, rb.velocity.y) is what i use
@bazingazeroni
@bazingazeroni 3 года назад
Maaaan thank you sooo much. I was looking for a rb.moveposition() type of thing for ages!!!
@baabaaer
@baabaaer 5 лет назад
When I have Rigidbody component for both my obstacle and player, and I use Translate function, I still get a collision. Is this supposed to happen?
@pressstart6864
@pressstart6864 5 лет назад
Yes technically physics still occur during translate. But if you move too quickly with translate the object could teleport around obstacles, skipping collisions altogether. For best practices... use add force.
@baabaaer
@baabaaer 5 лет назад
@@pressstart6864 I see.
@carlosjunod5424
@carlosjunod5424 5 лет назад
nobody could explain it better, keep with this tutorials pls
@pressstart6864
@pressstart6864 5 лет назад
Appreciate it :) - new video on Sunday
@ApexArtistX
@ApexArtistX 4 года назад
Transform. Translate is lazy coding. Use transform.position
@YaBoyUneven
@YaBoyUneven 3 года назад
Hey Visual Studio doesn't recognize moveCharacter. Any fix?
@araizhassan2511
@araizhassan2511 Год назад
collisions don't work without RigidBody, You should add RigidBody before using the Transform.Translate Logic...
@SWFGaming
@SWFGaming 2 года назад
Where do you get the variable direction from? That is the only reason mine doesn't work.
@jaimemedina3351
@jaimemedina3351 5 лет назад
Thank you! Great, straight forward exposition. You pack a lot of information in a short period of time.
@pressstart6864
@pressstart6864 5 лет назад
That’s my goal. Thanks for the feedback!
@mohamedelkehaoui7226
@mohamedelkehaoui7226 3 года назад
the best unity tutorial I ever watched hope you keep adding tutorials or even a paid course.
@atu9776
@atu9776 5 лет назад
Thank you very much !!!
@goigle
@goigle 4 года назад
I don't think the issues with transform.translate are the same anymore because I have used it on a character that does have collisions w/o issue
@ronin6158
@ronin6158 2 года назад
I realize the following is a translate, but w rigidbody and 'dynamic' added, it does use collisions and physics. It will also do trigger w no 'dynamic'. Where does this fit in? void OnMouseDrag() { Vector2 point = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = point; } Thanks!
@ArbitraryP
@ArbitraryP 3 года назад
Hello, I have a problem using either rb.AddForce() or rb.MovePositive() just like rb.MovePosition(), I wanted the character to interact with collision while moving with a fix speed. But I also wanted that external forces applied to character will affect its movement... (Not Kinematic) for example, when a fireball is shot to my character, the player will be knocked back... if my character is moving the same direction of the impact, I move faster/further... But if my character is moving against the impact, I reduce the effect of the knockback... If I just added the impact force to the character rb while walking, the character will not be knockbacked until I stop walking. I found out that this is somewhat achievable with rb.AddForce(). Since the Forces from the fireball and walking applied to the character will be calculated automatically. But I don't want my Character to walk like it is Accelerating.. How do you work around it? Thankyou [For reference, The physics will look like in the Warcraft3mod: Warlocks, instead its 2D for Android.]
@psychogears
@psychogears 4 года назад
It's January 2020 and Unity changes often so this might not be the case at the time this video was created, but changing Rigidbody.velocity or using Rigidbody.AddForce can be done in the frame-bound Update() since Rigidbody actually applies the physics-law-abiding and interpolation-enabled translation during FixedUpdate(). I think it's just Rigidbody.MovePosition() that should be done in physics since this actually moves the transform. I might be wrong, though.
@daryll4645
@daryll4645 2 года назад
4:48 wait, you already defined a vector2 for movement then for no reason you are creating a new vector2 hundreds of times a second in update! WHY DO YOU DO THIS? BAD BAD BAD!@
@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.
@draxnos506
@draxnos506 3 года назад
Just so everyone knows, the issues he was having with .AddForce() and .velocity have easy fixes! *Solutions to the Rigidbody issues he was having:* _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.
@neverstepd7
@neverstepd7 6 месяцев назад
F0ck... I made a game with .velocity, and already uploaded it. The thing is I wanted to have physical objects actually pushing the character, but I didn't find your video on time.
@anonymoussloth6687
@anonymoussloth6687 3 года назад
at 7:42, why do u use Time.deltaTime in movePosition()? I read that movePosition automatically interpolates between 2 positions for intermediate frames. so why use Time.deltaTime? Also, even if you are using Time.deltaTime, why use that? why not Time.fixedDeltaTime since movePosition is being called from fixedUpdate?
@NotASpyReally
@NotASpyReally 3 года назад
8:59 but you call moveCharacter() inside of FixedUpdate() ... shouldn't you be using Time.fixedDeltaTime? I never understand this
@anonymoussloth6687
@anonymoussloth6687 3 года назад
same. did u find the answer?
@L1ghtOn3
@L1ghtOn3 2 года назад
Need help with: if(player is moving in world space z or -z direction){do other code here to move UI Icon direction of x direction as the player is being pushed in the x direction always and UI Icon must show this when player is facing in either z or -z world space ditection movement the icon either points right or left depending on the player z movement} The code inside the brackets is fine but the if( player is moving in z or -z world space) I can not figure out 3 weeks later. Alll the best from 🏴󠁧󠁢󠁳󠁣󠁴󠁿👨‍💻 👍
@JonTopping
@JonTopping 3 года назад
What is the purpose behind having an additional function for moving it? Why not just have the lines of code within your MoveCharacter method go directly in the FixedUpdate? Also, ( I could be totally wrong here, but) should you have *Time.deltaTime? It's being run in the FixedUpdate, so wouldn't it be better to actually not have it in reference to time? Lastly, when I move a 3d rigidbody using velocity, the moment it touches a ramp ever so gently, it skyrockets into the air. Why? lol
@starskull1420
@starskull1420 3 года назад
This video is amazing. It's too bad I don't know how to convert this MovePosition script to Rigidbody2D to keep the game optimized. The reason? My eyes are heavy and sleep would definitely be required to learn coding, otherwise I'll just have to watch this video again tomorrow to relearn everything I forgot.
@HMGameDev
@HMGameDev Год назад
What about updating transform.position of an object directly without using rb?
@TheNjyon
@TheNjyon 4 года назад
Ok, First of all, cool that u make vids for people who wanna learn game development. BUT Saying that the rigid body movement is superior to the Translate one ist just awfully wrong. I mean as long as you wanna prototype or play a little bit around, yeah sure u might have a point there but everything else... I'm sure u need to code a lot more to make the Translate movement nice but u will have 100% control about everything and u won't lose 1 feature (Sure, If u know how). But that just what I wanted to say if u know how Translate > Rigidbody. I dont even know if there is 1 Character Controller in common games that aren't based on Translate (With Translate I mean setting the position yourself and not letting some physics engine doing the work).
@backgroundmusic250
@backgroundmusic250 2 года назад
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
@darkmagiciansels5833
@darkmagiciansels5833 3 года назад
why you multiply by Time.DeltaTime in fixed update why didnt use Time.FixedDeltaTime
@janmarcbaniqued7612
@janmarcbaniqued7612 5 лет назад
I thought using rb.movePosition is only good when the rigidbody is Kinematic. Is there any difference when using rb.movePosition on kinematic and non kinematic rigidbodies? Great tutorial btw.
@pressstart6864
@pressstart6864 5 лет назад
When a Rigidbody is kinematic - forces, collisions or joints will not affect the rigidbody anymore. So yes, you would need to use rb.movePosition in this case to move the rigidbody, but it can also be used for non-kinematic rigidbodies as well.
@prokeikas7284
@prokeikas7284 Год назад
But doesn't transform.Translate work with collisions if you add a rigidbody to your character?
@KillerFrog11
@KillerFrog11 4 года назад
Thanks for this, I needed it, I am going to use move position but I want to move it on x and z not y axis? Thanks
@adnansamol8464
@adnansamol8464 4 года назад
Use Vector3 and Makes the y value 0
@Koujujutsu
@Koujujutsu 5 лет назад
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.
@martinteruel7705
@martinteruel7705 3 года назад
Hey Buddy you totally rock!!! i was looking something like for days!! In fact you made my day really. I was struggling with the addforce movement of my character ( it really not for a character for sure ) and i just changed to use the movePosition and looks amazing now. I just suscribe to your channel. One question i have, i am trying to use movePosition in my click to move script and it seems like kind if different method than the one i was using ( velocity ) but since it was not working well i want to make something that use movePosition, can you point me o how to use it? thanks a lot!
Далее
Unity3D Physics - Rigidbodies, Colliders, Triggers
30:25
🛑самое главное в жизни!
00:11
Просмотров 132 тыс.
ХОМЯК ВСЕХ КИНУЛ
10:23
Просмотров 635 тыс.
How to jump in Unity (with or without physics)
16:09
Просмотров 46 тыс.
Unity Physics: Static, Kinematic, Dynamic
7:07
Просмотров 48 тыс.
choosing a game engine is easy, actually
15:08
Просмотров 506 тыс.