Тёмный

2D CHARACTER MOVEMENT IN UNITY 🎮 | Rigidbody2D Movement And Jumping In Unity | | Unity Tutorial 

Dani Krossing
Подписаться 483 тыс.
Просмотров 161 тыс.
50% 1

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

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 562   
@protophase
@protophase 2 года назад
Finally someone who acknowledges the importance of why. So many videos that I have watched just instruct you WHAT to type in to the code and which checkmarks you should have but never do they tell you WHY, which makes the information totally useless because you can never use it in any other situation.
@alexandratrenkova9339
@alexandratrenkova9339 Год назад
Give a man some food,, and he'll live for a day. Teach a day how to fish, and he'll survive for years. So important!
@vihansgaming
@vihansgaming 10 месяцев назад
yeah i just watch tutorial nothing what i learn from but in this video he is telling everything this video is awesome
@wingingglobe4095
@wingingglobe4095 9 месяцев назад
This is exactly what made me give up on game development before. You can watch a tutorial and implement everything correctly but if the video doesn't explain, you still don't understand anything
@leet37a9
@leet37a9 2 года назад
This, by far, actually taught me something. Thank you so much for making this video, Dani. At the very least, I think I've learned some core concepts of the codes you have introduced here.
@average337
@average337 2 года назад
Im just seeing this now after using many other vids that didn't explain as well as yours. I have decided to make a game on spring break, thanks a ton and i'm sure i'll watch more of the vids you have made to help me
@theoneandonlyginger6098
@theoneandonlyginger6098 Год назад
The first time i actually understand what i'm doing, thank you
@KingAbodi206
@KingAbodi206 3 года назад
nice video, keep going. I really like your tutorials
@dylanc5636
@dylanc5636 Год назад
This is the first video of yours I've watched, and the best tutorial I've seen that (as many others have pointed out) actually explains WHY you're writing a certain line of code and how everything interacts with each other as opposed to just telling you what to write. I ended up taking notes on paper and also adding notes into the script so I can go back and remember what the fields and everything are actually doing. Thanks SO much for this, subscribing and probably devouring all the rest of your videos!
@almaaanea
@almaaanea Год назад
This is the first player movement script that REALLY worked for me, that I understood. I'm relearning Unity after I took a huge break from coding so thank you so much for helping me bounce back
@Dani_Krossing
@Dani_Krossing Год назад
You are so welcome 🙂
@antonioalmeida7856
@antonioalmeida7856 2 года назад
you record with hardware outside of the program. Great tutorial btw it was very detailed but still just right for beginners.
@jamesjam
@jamesjam 2 года назад
This walk through is amazing so detialed but still welcoming for new game designer and programers like myself. Thanks so much!!!
@abdallahgamer6298
@abdallahgamer6298 Год назад
Actually this is the tutorial that I am going to stick with and ur channel is great keep going
@denberz711
@denberz711 Год назад
Did code perfectly but it doesn't make my character move at all. Rip
@toddietubby7450
@toddietubby7450 Год назад
Thanks, my player was able to randomly jump higher before i used trigger2D to detect instead of collider2D
@Viltzu-hk5wh
@Viltzu-hk5wh Год назад
I'm the blup guy, this is pog.
@bubblegum1653
@bubblegum1653 Год назад
you're a life safer. Most tutorials dont explain what we're coding and when i did something wrong i wouldnt know how to fix it. But you explained very well. thx
@mahiincheck
@mahiincheck Год назад
Man u really cool and the way you explained everything deserves a like
@beastmasterbg
@beastmasterbg 2 года назад
Thank you very much for the tutorial. Its easy and simple to follow !
@mianmasharratmurshed8790
@mianmasharratmurshed8790 2 года назад
for some reason when i put the code for vertical movement it does not work on unity and it does not say any specific error how can i fix this?
@parloleiton20
@parloleiton20 10 месяцев назад
best tutorial ive seen on programming for beginners!! like any new subject youre completely unfamiliar with, there's a whole universe of things you need to learn in order to make your own mental image and understanding of the topic in order to really learn stuff instead of memorizing. the way its explained on this video really helps with that
@wildcat3025
@wildcat3025 Год назад
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { private Rigidbody2D rb2D; private float moveSpeed; private float jumpForce; private bool isGrounded; private float moveHorizontal; private float moveVertical; void Start() { rb2D = gameObject.GetComponent(); moveSpeed = 3f; jumpForce = 60f; isGrounded = true; } void Update() { moveHorizontal = Input.GetAxisRaw("Horizontal"); moveVertical = Input.GetAxisRaw("Vertical"); } void FixedUpdate() { if (moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal * moveSpeed, 0f), ForceMode2D.Impulse); } if (isGrounded && moveVertical > 0.1f) { rb2D.AddForce(new Vector2(0f, moveVertical * jumpForce), ForceMode2D.Impulse); } } void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Platform") { isGrounded = true; } } void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Platform") { isGrounded = false; } } }
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
HE IS THE MISAIH!
@henryr2802
@henryr2802 5 месяцев назад
i love you
@himiko4202
@himiko4202 2 года назад
This is one of the best videos i've seen for learning this! You really go into detail about what things mean and when you should use them. Thanks alot! I'll definitely recommend this video to anyone i know who wants to get into coding :))
@mcnugget4227
@mcnugget4227 2 года назад
Every time I typed Rigidbody2D in my code it didn't call it, and I have no clue how to fix this. Did something change in the 2022 version or am I making a mistake? I saw your comment was from only one month ago so I was wondering if something similar happened to you.
@vagabxndd
@vagabxndd 2 года назад
@@mcnugget4227 same thing here, it doesnt call the rigidbody
@joshuadelgado9145
@joshuadelgado9145 2 года назад
I have an error (Assets\Scripts\BirdGoFly.cs(7,13): error CS0246: The type or namespace name 'RigidBody2D' could not be found (are you missing a using directive or an assembly reference?)) and I'm confused on how to solve it, do you have any suggestions?
@joshuadelgado9145
@joshuadelgado9145 2 года назад
never mind, It's supposed to be Rigidbody2D not RigidBody2D
@sb12812
@sb12812 10 месяцев назад
When I go to write the code in C# it doesn't show me an option to connect to Unity. Alongside that it tells me that it is in 'Miscellaneous Files' rather than 'Assembly-CSharp. And when I go to call on RigidBody2D like you do at 18:15 it doesn't connect to anything. Would you know the reason? I also wanted to say thank you for taking the time to make this wonderful video.
@localuhu8657
@localuhu8657 Год назад
Hey, I'm new to game development so your tutorial is super helpful but I have trouble implementing what you've shown. I think I have copied everything but I can only move to the right but not to the left why could this be?
@dazza22
@dazza22 2 года назад
finally a tutorial that actually EXPLAINS why and what the code that we need to type does. I've been looking all over for this. Thanks so much!
@JoshWichert
@JoshWichert Год назад
I have one problem with my code is that if I hold down my jump key I fly to outer space but other than that this has been a great tutorial
@heroyale8138
@heroyale8138 2 года назад
w tutorial channel, w video
@meliasnahtony2951
@meliasnahtony2951 3 года назад
Out of every channel I've looked at, you were the most informative. Thank you!
@Michael-yw4ul
@Michael-yw4ul Год назад
You are really nice Thank you for the help May The Lord and Saviour Jesus Christ bless you
@bananalord717
@bananalord717 2 года назад
Why doesn't this work (the jump) using System.Collections; using System.Collections.Generic; using UnityEngine; public class move : MonoBehaviour { // references private Rigidbody2D rb2D; // float is an decimal number private float moveSpeed; private float jumpForce; // bool is an true or false statement private bool isJumping; private float moveHorizontal; private float moveVertical; // Start is called before the first frame update void Start() { // giving values rb2D = gameObject.GetComponent(); moveSpeed = 3f; jumpForce = 60f; isJumping = false; } // Update is called once per frame void Update() { // i dont remember what these do moveHorizontal = Input.GetAxisRaw("Horizontal"); moveVertical = Input.GetAxisRaw("Vertical"); } private void FixedUpdate() { // make it MOVE if(moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal * moveSpeed, 0f), ForceMode2D.Impulse); } // make it jumpaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if (!isJumping && moveVertical > 0.1f) { rb2D.AddForce(new Vector2(0f, moveVertical * jumpForce), ForceMode2D.Impulse); } void OnTriggerEnter2D(Collider2D collision) { if(collision.gameObject.tag == "Platform") { isJumping = false; } } } void OnTriggerExit2D(Collider2D collision) { isJumping = true; } }
@hjonkwegoos
@hjonkwegoos 2 года назад
you didnt do an if statement for ontriggerexit2d
@paulfromtoronto3052
@paulfromtoronto3052 2 года назад
also your void OnTriggerEnter2D should be below FixedUpdate, not in it
@carlospinilla2940
@carlospinilla2940 2 года назад
I need help with something for my own game, The code itself works fine. But the inputs moveSpeed and jumpForce are way to high for my character, is like if he was sonic. I tried changing them to a lower value, like moveSpeed to a 1f and the jumpForce to a 5f but when I did it. The player moved but only for a little bit, after a certain amount of time it would just freeze and I could only go the opposite way of the freeze, also. The jumping, after I changed the values, Did not work! Please Help me! thank you for the rest of the tutorial but I need lots of helps!
@blockybrainz4026
@blockybrainz4026 8 месяцев назад
i can actually make my game now ty so much love your vids bro!
@iPokexU
@iPokexU Год назад
First, thanks for the tutorial! But I'm having issues with moving the character still. I don't know where I've gone wrong. For some reason I can move the character by keyboard input BUT the character keeps moving without stopping even though I'm no longer clicking on the keyboard. Do you have any ideas why? I have the exact same script so I'm not sure if it's a setting else where that I have wrong.
@Feztek626
@Feztek626 Год назад
So at 22:33 I can’t figure out how to type those pipe things. Is it a copy paste thing or can I just not find it on my keyboard. Thanks!
@rasspery
@rasspery Год назад
the same key as backslash, just hold shift and press the backslash key
@Dronage_x
@Dronage_x 2 года назад
whyen i try and move player controoler into player it has an erro
@Babtu
@Babtu Год назад
I just wanne say thank you for the course! You're not only explaining it flawless but you're making it fun!
@rcrazersp9312
@rcrazersp9312 2 года назад
I'm having trouble with my player being able to jump in the air. if it helps diagnose, my OnTriggerExit2d is not being used is what unity says. Code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { private Rigidbody2D rb2D; private float movespeed; private float jumpforce; private bool isjumping; private float moveHorizontal; private float moveVertical; // Start is called before the first frame update void Start() { rb2D = gameObject.GetComponent(); movespeed = 4f; jumpforce = 23f; isjumping = false; } // Update is called once per frame void Update() { moveHorizontal = Input.GetAxisRaw("Horizontal"); moveVertical = Input.GetAxisRaw("Vertical"); } void FixedUpdate() { if(moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal * movespeed, 0f), ForceMode2D.Impulse); } if (!isjumping && moveVertical > 0.1f) { rb2D.AddForce(new Vector2(0f, moveVertical * jumpforce), ForceMode2D.Impulse); } } void OnTriggerEnter2D(Collider2D collision) { if(collision.gameObject.tag == "Platform") { isjumping = false; } void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Platform") { isjumping = true; } } } }
@Dani_Krossing
@Dani_Krossing 2 года назад
You placed your OnTriggerExit inside your OnTriggerEnter.
@rcrazersp9312
@rcrazersp9312 2 года назад
@@Dani_Krossing thanks man!
@thissideofmyworld7216
@thissideofmyworld7216 2 года назад
I am getting intetested in game dev and you are beautifully teaching me the way through it. I thank you so much, I devoured this video in the best sense of the term. It shows the crazy amount of devotion you have to teaching. Thank you once more.
@mrderpyofficial21
@mrderpyofficial21 7 месяцев назад
finally I get it, I think, it's this player movement video is better than brakeys 2d movement. It's easier and easy to understand. I love this guy.
@aidanprince3912
@aidanprince3912 2 года назад
The moving code is not working when I go to unity it shows "The name ForceMode2D doesn't exist in the current context" please tell me how to fix this error I even put the Add Force but it still shows the same error
@Dani_Krossing
@Dani_Krossing 2 года назад
The error message means that you aren't supposed to be able to use "ForceMode2D" in that location. So the most likely explanation is that you made a typo in that line of code. My guess based on peoples typical mistakes, is that your () aren't correctly setup there. 🙂
@aidanprince3912
@aidanprince3912 2 года назад
@@Dani_Krossing Thanks now the code is workinh
@mr.gray_skies9419
@mr.gray_skies9419 2 года назад
So, I know this has probably been asked but, I've followed the tutorial character for character and ensure all of my capitalization and symbols are exactly the same as in the video. However I cannot seem to get away from a "CS0246" error saying that the namespace name RigidBody2D couldn't be found. Can anyone offer any help or advice? Because I have no ideas, since you clearly didn't get this error in the video and I'm following along to the letter.
@FondsRL
@FondsRL Год назад
It finally worked! After two months of watching tutorials he moves!!!!!
@stanleyhavok
@stanleyhavok 11 месяцев назад
Thank you, for taking the time to just explain(with examples) the little things Even when you say your not going to. !
@francoisdebruin6293
@francoisdebruin6293 Год назад
Na this dude is legit he makes sure to think about what would a new Dev be thinking he does not only think from an experienced point of view subbed man
@me3699-f7f
@me3699-f7f Год назад
This is really well explained
@maka_dev
@maka_dev 2 года назад
Best guide i've watched about the topic 👍 Im also learning c# from zero, your video helped a lot, thanks
@cookiecrayon
@cookiecrayon 2 года назад
This is a great tutorial! I've been searching for a way to use addForce to move a character around and this has been really helpful! With regards to the 3 different ways of checking if the character is grounded before it can jump, is there much of a difference between using raycasts, overlaps and layer masks, and the collision detection method that you used? Is one easier to control than the other or does one perform better than the other? Thanks again for the great vid!
@josephfrost2765
@josephfrost2765 2 года назад
Even though I knew how the character movement worked this video just helped me a lot with understanding it again. Thank you
@Declan-u6d
@Declan-u6d 10 месяцев назад
Dude i just started 😂..... 😢
@Dani_Krossing
@Dani_Krossing 10 месяцев назад
I have another Unity playlist for complete beginners on my channel 🙂 it can be found on my channel page
@Yurem_
@Yurem_ Год назад
Thank you Thank you Thank you!! this is so far the most detailed tutorial I've seen
@PROFPANDA-jm7ru
@PROFPANDA-jm7ru Год назад
The best tuto ever, finally someone I understand and find easy to follow with! Just started out and your video really helped out so much, thank you! cheers
@ThePojks
@ThePojks Год назад
i follow the tutorial from point a to point b but i never get those pop ups that for example say Rigidbody2D and so when I go back into Unity my player doesnt move
@GRACENDON
@GRACENDON Год назад
14:50 why does my rigidbody2d doesnt turn green in the script ?
@flydiegofly
@flydiegofly Год назад
I'm having the same problem. Does anyone have a solution for this?
@bluefiregamingandcards
@bluefiregamingandcards Год назад
A very well made video. You are truly a great teacher for this subject. Thank you.
@xXcoolguyXx2011
@xXcoolguyXx2011 Год назад
the private FixedUpdate method doesnt return anything (new to C#), i get this conole error: error CS1520: Method must have a return type. Full code: public class PlayerController : MonoBehaviour { private Rigidbody2D rb2D; private float moveSpeed; private float jumpForce; private bool isJumping; private float moveHorizontal; private float moveVertical; // Start is called before the first frame update void Start() { rb2D = gameObject.GetComponent(); moveSpeed = 3f; jumpForce = 60f; isJumping = false; } // Update is called once per frame void Update() { moveHorizontal = Input.GetAxisRaw("Horizontal"); moveVertical = Input.GetAxisRaw("Vertical"); } private FixedUpdate() { if(moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal * moveSpeed, 0f), ForceMode2D.Impulse); } if(moveVertical > 0.1f) { rb2D.AddForce(new Vector2(moveVertical * moveSpeed, 0f), ForceMode2D.Impulse); } } }
@emilian_spielt300
@emilian_spielt300 2 года назад
hey guys. his Scipt doesnt work for me so i decidet to make it work. i dont know if it work for u too but here is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { private Rigidbody2D rb2D; private float movespeed; private float jumpforce; private bool isjumping; private float moveHorizontal; private float moveVertical; // Start is called before the first frame update void Start() { rb2D = gameObject.GetComponent(); movespeed = 1.5f; jumpforce = 10f; isjumping = false; } // Update is called once per frame void Update() { moveHorizontal = Input.GetAxisRaw("Horizontal"); moveVertical = Input.GetAxisRaw("Vertical"); } void FixedUpdate() { if (moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal * movespeed, 0f), ForceMode2D.Impulse); } if (isjumping && moveVertical > 0.1) { rb2D.AddForce(new Vector2(0f, moveVertical * jumpforce), ForceMode2D.Impulse); } } void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Platform") { isjumping = true; } } void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Platform") { isjumping = false; } } }
@beastNick7713
@beastNick7713 Год назад
why i have an error that says top level statements must percede namespace and type declerations on the line void FixedUpdate()
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
i got it too did you fix it
@beastNick7713
@beastNick7713 Год назад
@@GunSpyEnthusiast unfortunately no
@shadysheep539
@shadysheep539 Год назад
@@GunSpyEnthusiast took me a bit but i fixed it. check the "void FixedUpdate" part and make sure the f in fixed is capital. thats why mine didnt work at least
@Guavacado1
@Guavacado1 2 года назад
Cant move left Please help me void FixedUpdate() { if(moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal = moveSpeed, 0f), ForceMode2D.Impulse); } } }
@not_lukie3248
@not_lukie3248 Год назад
Good vid but I keep getting this error when I try to use OnTrigger/CollisionEnter "OnTriggerEnter(Collider2D) must declare a body because it is not marked abstract, external, or partial [Assembly-Csharp]
@im.majorfrazier
@im.majorfrazier 2 года назад
The jumping while only on ground is not working ... I have tried twice . Can you help me?
@dodo9884
@dodo9884 2 года назад
I copied the video exatcly but I have a problem qwq. I can't get the Collider part right. I did everything correct in the code and in unity but it won't work. I also know it definetly has something to do with the last two coding blocks...everything else works. Does anyone have an idea what i could try to fix it qwq.
@42brow
@42brow 7 месяцев назад
When I hold down my uo key it just keeps moving up (like flappy bird) I believe I followed the code exactly as shown so why isn't the jump deactivating when it leaves the ground..
@AhmedRamy585
@AhmedRamy585 Год назад
Fantastic Video
@N9TN9
@N9TN9 2 месяца назад
I have watched so many tutorials on youtube by now and this is by far the best one! you explain things so thoughtfully and clear. keep it up, you gained a new subscriber!
@yourcool7489
@yourcool7489 Год назад
I put in walls to change my speed freely without falling off, but whenever I touch a wall, I lose the ability to jump, I'm looking at the code and I don't know why
@trashikan
@trashikan 3 года назад
My player seems to accelerate when applied force and slides a bit due to the inertia. Could someone help me move the player at a constant speed and not slide in the end?
@andrzej.s
@andrzej.s 2 года назад
Hi, have you solved this problem?
@lupi2067
@lupi2067 2 года назад
I also am curious about an answer to this question.
@trashikan
@trashikan 2 года назад
@@lupi2067 theres a video by BlackThornProd that solved this issue. Check out the player movement vid.
@samkroes4611
@samkroes4611 2 года назад
Super helpful video! I've been going through this Unity intro series and learning a ton! You are great at anticipating my questions and explaining everything. I watched your pixel art tutorial, and am excited for the C# series too. Thank you so much!! It's hard to believe resources like this are free.
@Dani_Krossing
@Dani_Krossing 2 года назад
You are so welcome Sam. 🙂 I hope I continue to anticipate questions you might have.
@grimmjowja4228
@grimmjowja4228 Год назад
For some reason, adding the player controller C# script, when I add it to the player it says "Cannot add script component "PlayerController" because the script class cannot be found."
@Nate-i2o
@Nate-i2o Год назад
thanks this really helped
@zoem6195
@zoem6195 Год назад
I've never been so thankful in my life. I've spent over 20++HRS trying to fix my jumping mechanics going through soo many tutorials hoping it would fix my issue and THANKFULLY this has been the one and only that has fixed my issue. Thank you soooo much!!! I am subscribing and liking this video and keeping this Channel as my go to for my issues. Its so informative especially for a beginner. I can't help myself but to thank you again once more.
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
why didnt you post the code in the comments or the description. im getting "Top-level statements must precede namespace and type declarations." and to my understanding i copied your working code word for word and i dont know if its diferent because its not posted in an easy to view mannor.
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
i bypass the issue of a program atuomatically refering to something using the same words as a varible, simply by calling things things like " movementing ", and " slide to the left, slide to the right. "
@MadOliveGaming
@MadOliveGaming Год назад
Do NOT forget to set the ground detection collider as a trigger xD you will take 15 minutes to figure out why your character can still take off like a spaceX rocket LOL
@dslijderink8303
@dslijderink8303 3 года назад
I can't seem to get rid of the multiple jumping effect, even though the code looks all good. Does anybody have an idea how to fix this?
@aidi6285
@aidi6285 2 года назад
Did you manage to sort this because mines doing the same 🤣
@dmn4373
@dmn4373 Год назад
i am unable to add crouching to the code because i don't really understand how to change the speed of movement while crouching, the code works fine i just couldn't find any good tutorials about crouching
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
"dont get frusterated if you dont understand- " me who obtained a headache that lasted for multiple hours because of how complacated making a sprite is in unity : a little late.
@Pixeleyesd
@Pixeleyesd 7 месяцев назад
how do you make wall jumping? (My game actually uses wall SLIDING, but I have no Idea how to make any of that)
@counterproductivegaming
@counterproductivegaming Год назад
Just curious, when is the method OnTriggerEnter2D and OnTriggerExit2D used? I see that it works but where in the code is it executed?
@konstantinkuletski6156
@konstantinkuletski6156 2 года назад
somehow only my right movement is working, pls help. (UPDATE: I Fixed it, great tutorial btw.)
@synth768
@synth768 2 месяца назад
I followed this tutorial exactly yet some words didnt change colour like his and when i went to test it, it didnt work. How can i fix this?
@qlarox
@qlarox 2 года назад
Guys lets say im writing a piece on soft soft. Is there any I can use 10 different tutorial without having to open 10 kontakt windows
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
" i dont know why it turned yellow " either he has as little understanding as I do, or he pity's my lack of intellect on the subject.
@arhamgamez8575
@arhamgamez8575 Год назад
My player keeps jumping off the screen and off the camera. But for you it does not jump off camera. Do you know why?
@gatesaims
@gatesaims 2 года назад
i self taught myself photoshop cs6... i wish i knew about tNice tutorials when i was in the self teacNice tutorialng mood
@rommelstrafe
@rommelstrafe 2 года назад
Great content! explains all details one by one. Just want to ask if this is the better approach compared to Rigidbody.Velocity when it comes to responsiveness of the movement. Some says the AddForce method makes the player like "sliding" instead of running compared to the responsiveness of Velocity. Hope you can compare those two. Cheers!
@Dani_Krossing
@Dani_Krossing 2 года назад
Velocity will make your object instantly move at a certain speed, and is great for top down games where you need full control over the Player movement. Where as AddForce uses physics to "push" a object that is affected by mass and gravity, and is great for platformers where your character is running around, and needs to be influenced by other objects. It really depends on the type of game you are creating, and how you want it to "feel" when the player moves the Player character. 🙂 Whenever I create games on my own, I always ask myself... "should my player be affected by other gameobjects?". Like for example if an enemy shoots my player, should my player bounce back? Or will I be doing a lot of platforming where the environment should affect my players movement? Then I would use AddForce. Celeste is a good example here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-70d9irlxiB4.html&ab_channel=PlayStation I would only use Velocity if I'm creating a top down RPG, where my character ONLY moves if I tell it to, and will keep standing still no matter what happens to it. Stardew Valley is a good example here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ot7uXNQskhs.html&ab_channel=ConcernedApe But you are right, AddForce does also make your gameobject "slide" around the place. ⛷ However if anyone tells you that "you shouldn't use AddForce because your player slides", then they clearly don't know how to use AddForce properly hehe. 🙂 I OFTEN hear people say they avoid AddForce because of the sliding, and then they instead try and mimic AddForce by using Velocity instead... but that is a mistake since you can VERY easily change how much sliding there needs to be using AddForce. Here are 5 ways on top of my head, to change the AddForce "sliding": - You can add a PhysicsMaterial to the ground or the player, to change the friction on surfaces. - You can change the Liniear Drag in the RigidBody component inside Unitys Inspector. - You can create a "Velocity check" using code, so that your AddForce should stop working after the player reaches a certain Velocity. - You can dampen your AddForce using code. - You can change the ForceMode on your AddForce. So to sum it all up... You should use AddForce when you wan't your character to be affected by other gameobjects, and yes you CAN change the "sliding" very easily in various ways. 🙂 Don't use Velocity if the excuse to do so, is that you don't like your character "sliding", because you can EASILY create responsive movement using AddForce. 👌
@rommelstrafe
@rommelstrafe 2 года назад
@@Dani_Krossing Wow! thanks for the super detailed reply, and I actually learned more as a bonus! Looking forward on your future Unity and C# contents.
@pasanhansaka5410
@pasanhansaka5410 2 года назад
Every ti a friend of mine ask to teach them how to use soft soft I share them the link to tNice tutorials YT video tNice tutorials helped so it will help
@evanEPIC
@evanEPIC 2 года назад
PLEASE HELP! I'm at 25:00 and my player isn't moving. No key makes the player go left or right. My code is identical to what he's typed in the video. I'm not sure what I'm doing wrong..
@Dani_Krossing
@Dani_Krossing 2 года назад
Either your script isn’t on your player, or you forgot to add a component to your player, or you made a typo in your code. 🙂 It’s one of those three. I constantly get comments from people who “followed my code exactly”, and then later it turns out they had a typo… You are more than welcome to share your player script here. 🙂
@SixFlickz
@SixFlickz 10 месяцев назад
hi ik this yt videos 2 years old but could someone help with a lil issue when i have walls near my player it goes straight up and treats it like ground
@Mona-wr9xl
@Mona-wr9xl Год назад
I want to just say, thank you so much for actually explaining how or why things work as well as the term definitions. This is literally the only channel I felt like I was learning something new, like a lesson rather than a guide or demonstration.
@Dani_Krossing
@Dani_Krossing Год назад
I'm glad you found them easy to follow :)
@GunSpyEnthusiast
@GunSpyEnthusiast Год назад
@@Dani_Krossing im getting the " Top-level statements must precede namespace and type declarations. " error and i would know if i did the code right if you pasted the code into your descripton but you didnt.
@ryanvr23
@ryanvr23 4 месяца назад
i was watching other vids and they all just exspect you to know how to code
@capim_fields5510
@capim_fields5510 Год назад
I am having a problem, when i run my game the player only jump 1 time but can move left and right, can someone help?
@theantonyjamesofficial
@theantonyjamesofficial Год назад
Assets\PlayerController.cs(36,30): error CS1729: 'Vector2' does not contain a constructor that takes 3 arguments what am i doing wrong?
@Dani_Krossing
@Dani_Krossing Год назад
It means you added in 3 arguments inside the Vector2(), when it should be 2. I’m guessing you made a typo when it comes to the () you added. In my video, I only added 2 arguments as well. 🙂 So look at the Vector2() part, and compare it with mine in the video.
@theantonyjamesofficial
@theantonyjamesofficial Год назад
@@Dani_Krossing thank you for the help, but i still dont know why its not working as i typed everything the same... void FixedUpdate() { if(moveHorizontal > 0.1f || moveHorizontal < -0.1f) { rb2D.AddForce(new Vector2(moveHorizontal, 0f * moveSpeed, 0f), ForceMode2D.Impulse); } } }
@1994Persona
@1994Persona Год назад
I love you so much
@lucapangrazi9217
@lucapangrazi9217 2 года назад
I got a giant headache trying to figure out this by myself, im just going to steal this code real quick, thanks
@AmierAzzeal
@AmierAzzeal 11 месяцев назад
Its Great to see someone explain things and does'nt just gloss over it or assume people already know what everything means.
@DaktylK4Y
@DaktylK4Y 8 месяцев назад
So what if my platform is like an obstacle in air, then when I touch it's wall it will blow me up into the sky
@kinlushchristo5126
@kinlushchristo5126 2 года назад
purchased soft soft was because there are so many resources and remake templates out there to help understand how people have
@M.ALIEFRIZKY
@M.ALIEFRIZKY 2 года назад
some code in my vs doesn't show up and color, I'm very frustrated because of this. is there any solution? please answear me🙏🙏🙏
@Dani_Krossing
@Dani_Krossing 2 года назад
This will show you how to fix it :) The video starts at the solution: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ewiw2tcfen8.html
@russian__lizard645
@russian__lizard645 2 года назад
i need help with the visual studio it didnt work but i followed everything but idk how to attach to unity pls help
@thatguyelibeats4031
@thatguyelibeats4031 Год назад
SUPER HELPFUL!
@EmileAnimation
@EmileAnimation 2 года назад
5:30 this did not work for me, when i tried it it said report bug