Тёмный

Unity3D Physics - Rigidbodies, Colliders, Triggers 

Jason Weimann (GameDev)
Подписаться 210 тыс.
Просмотров 160 тыс.
50% 1

Check out the Course: bit.ly/3i7lLtH
-------
We'll learn about Unity3D physics for beginners, everything from rigidbodies and moving objects around, to bouncing and sliding.
I'll show how to use triggers and collisions / colliders to interact with your game in code. We'll use OnTriggerEnter and OnCollisionEnter in some example physics scenarios and use physics materials to make things bouncy.
More Info: unity3d.colleg...
Join the Group: unity3d.group
Patreon: patreon/unity3dcollege

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

 

7 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 133   
@umairmunawar132
@umairmunawar132 5 лет назад
I just wanted to say "Thanks a lot, Jason". I have been doing Unity game development as professional game developer for 5 years now and your videos even about the basic stuff still help me improve a lot. Please, keep up the good work.
@victormorris4600
@victormorris4600 5 лет назад
Even though I've been using Unity for 2 years now, this helps me improve alot
@silencedvr2048
@silencedvr2048 4 года назад
i love how after you explain stuff 100 people already tried to explain me, i get it. all these people are too stuck in their current knowledge about the engine and scripting. while you can easly re-live your newbie days and explain if you are explaining it to passed you. and thats a skill to admire. well done sir
@QuackersMcCrackers
@QuackersMcCrackers 4 года назад
"We should be able to watch. Our ball. Fall." "Let's hit play" *Ball falls* *Blep* ._. *Thunderous applause*
@cinegraphics
@cinegraphics 3 года назад
"I want my ball to be bouncy." Ummmm...... okay. But keep in mind that testing may prove painful...
@TheOneTaboo
@TheOneTaboo 3 года назад
Made my night
@QuackersMcCrackers
@QuackersMcCrackers 3 года назад
@@TheOneTaboo I am James, maker of nights :3
@bramblewoodhall4757
@bramblewoodhall4757 5 месяцев назад
thanks for this: I was going nuts tilting planes and not having objects fall off them and couldn't figure out what was going on. This video was really helpful and helped me understand Unity physics - my game might even work now :)
@williamsando4703
@williamsando4703 4 года назад
Even though I've been using Unity for a full week this has still helped me tremendously :D But seriously, it's videos like this that make all the difference, thank you!
@ZoidbergForPresident
@ZoidbergForPresident 5 лет назад
Knew about most of those, but it's nice having a video explaining all the stuff, good job.
@sunilgoswami007
@sunilgoswami007 3 года назад
I know the basics of these but there were still quite a good things that I got from this. And that about swapping OnCollisionEnter with OnTriggerEnter, oh man, been there done that several times even in my limited experience with Unity. Good to know it keeps happening.
@kingXkeith
@kingXkeith 5 лет назад
I literally am doing a lab due Monday on this subject as i got your notification. This helps alot!
@kyleme9697
@kyleme9697 4 года назад
Great video, very thorough. 26:55 In my limited experience I've found Force amounts are in the 100s, Rotation are in the 10s, and Movement are in the 1s. I was using the same value for rotation and movement speeds and spent hours trying to figure out why my thing wasn't rotating properly ... its was, just not very fast at all. Once I bumped that up it worked fine.
@dairyfreelemonstreams9493
@dairyfreelemonstreams9493 3 года назад
Very simple helpful and straight to the point. Thanks! This is a good introduction to all the physics stuff I plan on learning.
@russellthorburn9297
@russellthorburn9297 5 лет назад
Nice video again Jason. I like that you have a good mix of beginner all the way through to advanced videos (something for everyone).
@jipo50
@jipo50 9 месяцев назад
Thank you for the tutorial, this really got me. keep making other tutorials to help those who are still beginners and need knowledge in using unity like me XD
@SteadyPaceVince
@SteadyPaceVince 2 года назад
Finally, now I understood what was the problem in my game
@Livingdeadghost
@Livingdeadghost 3 года назад
Liked keyboard shortcut, then you started showing off Rider IDE Shortcuts. Lovely. As always, thanks for sharing the insights and things we might find useful :)
@Rage-wg8qi
@Rage-wg8qi 3 года назад
Thank you so much!! I have been struggling with this things since i got into Unity, you really helped me a lot
@mohandurai3002
@mohandurai3002 3 года назад
Excellent tutorial sir.. I am following all your videos. Thank you very much.
@juleswombat5309
@juleswombat5309 2 года назад
Excellent very Helpful. Life would be a lot simpler without any Physics
@Livingdeadghost
@Livingdeadghost 3 года назад
Loved the CTRL+SHIFT+F Shortcut for moving to Camera position shortcut, thanks. I'm here to learn more about using Physics and worried about physics and performance if I'm doing things wrong. Love your content. Hoping to delve more deeply into the massive world of "Destruction". Starting with C# Algorithms looping through mesh verts... Slooooow. Maybe through Voxels and on to Geometry Shaders.
@nicolenew1708
@nicolenew1708 Год назад
AMAZING
@trshpizza
@trshpizza Год назад
All we want to say is "Thank you, Jason." as this is an alternative to the source engine in our eyes.
@trshpizza
@trshpizza Год назад
And we might actually compare it to Source, Source 2, Unreal Engine Chaos, and definitely not ROBLOX, as it's just a garbage game engine with a blocky art style on a $5 budget.
@AlvosTiger
@AlvosTiger 3 года назад
"Share the video, it helps more than anything else you can do" Wow... you really motivate people to do nothing else
@Spherous
@Spherous 5 лет назад
I think something important to note that changed in 2019.3 due to an NVIDIA PhysX update is that trigger vs trigger colliders do not throw trigger callbacks to each other anymore. Other than that, great tutorial :) good job!
@SteveTheExploiter
@SteveTheExploiter 5 лет назад
Thank you for pointing that out. I am curious how other people will solve this issue. I have my ideas, but, I am not sure if it is correct.
@Spherous
@Spherous 5 лет назад
@@SteveTheExploiter a child game object that isn't is trigger on a layer that can only collide with the istrigger layer
@SteveTheExploiter
@SteveTheExploiter 5 лет назад
@@Spherous That's how I've been doing it. Great!
@SoldatDuChristChannel
@SoldatDuChristChannel 3 года назад
even though i just downloaded Unity, this tutorial helped bunches!
@ГерманФрелов
@ГерманФрелов 4 года назад
Nice tutorial about basics of physics system
@AllenAwad
@AllenAwad Год назад
Very well explained. Thanks!
@jajwarehouse1
@jajwarehouse1 5 лет назад
I often see questions from people about why their characters are jittering when on the ground, or why triggers do not register when objects pass through, and I usually find in their code that they are moving the objects or characters with Transform.Translate which effectively bypasses the physics system with teleportation. They often think that as long as they do these types of movements in FixedUpdate, then it should not be an issue. Too often I see coders spending lots of time trying to recreate systems that the engine already does very well. The gravity system is a large source of confusion for newer coders, in this regard.
@noreasonchannel4012
@noreasonchannel4012 5 лет назад
True! Do you have more tips so we can learn too? let me contact you on twitter or instagram if you got a list please. I often find myself confused as to what movement systems to use like translate or rb.vel forward and what not
@syio1
@syio1 2 года назад
you brought me back to the counter strike days when you said "God Mode" lol, classic
@artsylowtekk2502
@artsylowtekk2502 Год назад
France this video is awesome.
@samirisgood5735
@samirisgood5735 Год назад
Thank You!
@Case-A-Lace
@Case-A-Lace 3 года назад
I've learned alot from this video! Thanks!
@Transcriptor
@Transcriptor 3 года назад
Thank you for showing us things that work, a refreshing change. Good job Jason, Merry Xmas and a Happy 2021 🎅🎄🌟✨🔔⛄️👏👏👏
@simeonbeckford-tongs9391
@simeonbeckford-tongs9391 Год назад
Thank you
@josekarnikowski1711
@josekarnikowski1711 3 года назад
Really nice video! Congrats!
@talhaahmed6432
@talhaahmed6432 3 года назад
I just started unity and it is very confusing for me, but this video help with these stuff,Thanks
@공대아름이-n2e
@공대아름이-n2e 2 года назад
Thanks for the good explanation. It helps a lot. 잘 보고 가용~~~ ㅎㅎㅎ
@durgam_sumerian7815
@durgam_sumerian7815 4 года назад
Thank you very much for your efforts and awesome tutorial.
@sebastianbryant4216
@sebastianbryant4216 2 года назад
Very helpful, thanks!
@SoumyajitSarkar
@SoumyajitSarkar 3 года назад
So good
@gavincooper1731
@gavincooper1731 5 лет назад
Thanks for another great video! You are the man!
@bernhagen93
@bernhagen93 3 года назад
super helpful thanks a lot
@WSMGameStudio
@WSMGameStudio 5 лет назад
Hi Jason, Could you please make a video on PhysX limitations and best practices to avoid strange physics behaviour in Unity? I'm especially interested in the effects of the PhysX limitations on Unity joints. There is a lot of issues related to joints acting strange due to PhysX not being able to handle heavy objects with children connected using joints. Best regards
@sathvikmalgikar2842
@sathvikmalgikar2842 2 года назад
Thank you sir
@Work-ht2mr
@Work-ht2mr 3 года назад
great vid, thanks
@BrendanHasAbs
@BrendanHasAbs 3 года назад
Thanks!!!
@sompomdev3823
@sompomdev3823 5 лет назад
Thank your very much for your Tutorial.
@abhilashmukherjee9536
@abhilashmukherjee9536 3 года назад
thank u
@aimesolomon
@aimesolomon 3 года назад
subscribed
@zoldlen883
@zoldlen883 4 года назад
Good video.
@dragonninja9908
@dragonninja9908 Год назад
Thx duude
@kenhetkonijn
@kenhetkonijn 5 лет назад
thanks for this video it is really awesome
@TechwithLaughter
@TechwithLaughter 4 года назад
16:35 Trigger vs Collisions
@tigranminasyan658
@tigranminasyan658 3 года назад
I see Jesse Schell's book of lenses in background :)
@robertosapucaia1108
@robertosapucaia1108 5 лет назад
You are awesome
@baconchaney
@baconchaney 5 лет назад
Hi Jason, massive thank you for these kind of videos, they are a massive help when getting my head around the engine. It's actually reminded me of a question that's been bugging me for a while. I'm trying to create a 2.5D type platformer but having a real problem getting my head around locking the movement to only two axis with the correct kind of physics to allow proper collisions with platforms etc. Can you suggest any good resources? (also, I agree with the comment about your shirt and your chair. You look like a floating head!).
@xatazch
@xatazch 5 лет назад
Grate video. What abort a video like this but for animations :)
@lochvast1180
@lochvast1180 Год назад
So the Rigidbody tells the object how to move, and the collider defines the physical boundary of the object
@dariuspranskus
@dariuspranskus 5 лет назад
Hi Jason. Thanks for all the videos you brought to the game developer community. Really really helpful. May I ask you to consider to create a video/series on anti-cheating. In particular I have an interest in creating a puzzle game with a back-end service. All my user data and achievements I would like to have in the back end. So I would like to know what techniques high level are available to me to ensure that the user has actually completed the level. What I am thinking is some business logic, which checks the sequence, timing of the requests hitting the back end service, but really would like some advise from the professional with experience. Manny thanks.
@nikithebgfail8816
@nikithebgfail8816 3 года назад
I'm trying to make good rigidbody movement ...... for me the best is with rb.velosity ..... but you are professional so if you think something about rigidbody movement 😉 🤔
@HirenMistryhirenhcm
@HirenMistryhirenhcm 3 года назад
In the tile script. Where did you bind the A & D key in the script for the floor? BTW, great tutorial. 👍
@redi8229
@redi8229 3 года назад
by default Input.GetAxis uses WASD, so the Input.GetAxis("Horizontal") automatically returns -1 or 1 with A & D
@nnovinho
@nnovinho 4 года назад
great video man ! did some one told you that you look like dan harmon?
@TheNei
@TheNei 5 лет назад
Nice!! I will try today... Jason, can you some day create a tutor using MULTIPLES BALLS COLLISIONS in Unity? i search about on RU-vid but no find nothing about... Thanks!!
@gregoryfenn1462
@gregoryfenn1462 5 лет назад
What are you confused about? You just have several balls all with their own colliders?
@mikebely8663
@mikebely8663 5 лет назад
Is there tutorial on how to push objects around the scene with players rigid body. Also need one to interact with virtual computer (switch from player camera to static on screen and back). TY
@sebastiendube9487
@sebastiendube9487 3 года назад
Hey there, how would you face the following problem : You have a sphere which represent a tennis ball You want the physic of the ball to be pretty realistic without having to implement complex laws of physics.
@marafree4769
@marafree4769 2 года назад
Why did super collider go on + off recently?
@realitycheck1018
@realitycheck1018 4 года назад
Many thx for this tutorial, Jason. I am very new, and this helped me a lot. I mean, a lot. That being said, I was trying to use this ChangeColorOnCollision script to have a surface (the same cube you used in the examples) change color when Ellen contacted it (ran it into it, or jumped on it). The player "Ellen" I refer to is the character in the Unity 3D game kit. And it does not work. I tried adding a rigidbody to Ellen (had to make her kinematic/else fall through floor) and a mesh collider, but still no avail. Also, I'm not sure if this is part of an update, from 2019.3 to 2019.3.6, which I am using, or maybe you forgot, but I had to change the "layer" of the gameObjects to "collider" for any of it to work. or, Did I miss something there? If you have time, could you please explain to me how to make the character cause this changeColor via collision? Many thx, Wannabee Dev 101
@JeffreyThrash
@JeffreyThrash 4 года назад
Great tutorial. I've seen in fighting games, shooters and other competitive games that you can apply collision shapes to each individual limb of a character and have each of them react differently depending on where it's hit (the most obvious example being headshots). Is there a way to parent collision shapes like cubes and capsules to a specific bone on the character's rig or is it more complicated than that? I know having too many collision checks and triggers could drastically slow down the game if I overdo it, but, you know, in case the need arises...
@Subrata157
@Subrata157 3 года назад
Make a video about full Android fps/tps multiplayer game
@Whoisin3
@Whoisin3 2 года назад
What code editor is being used? Love the tutorial!
@jeremytan1051
@jeremytan1051 3 года назад
if unity is the force, you are a luke skywalker. Thanks
@אתהסתוםבלוםבצבעחום
So I set it up exactly as you did but my mesh fell through the floor :/ idk why
@mracipayam
@mracipayam 2 года назад
My man writing codes on light theme
@FinitiXgameDepartment
@FinitiXgameDepartment 5 лет назад
Dots physics too?
@mrdankinator4782
@mrdankinator4782 3 года назад
Jason! Why'd u use Awake() instead of Start()?? Is it better?
@gsus7125original
@gsus7125original 4 года назад
Jason, is it okay to use a CharacterController instead of a Rigidbody in big game projects?
@davidscutar1403
@davidscutar1403 4 года назад
wdym by big game projects? they are 2 valid ways to do two different related things.
@bigmike1432
@bigmike1432 3 года назад
how do you add angular gravity for wall running
@SonictheHedgehogInRealLife
@SonictheHedgehogInRealLife 2 года назад
why does my player with a rigid body slightly clip through the ground when it lands
@OvernightOats1
@OvernightOats1 3 года назад
Does this apply to vr? I keep falling through floor
@HarunAlHaschisch
@HarunAlHaschisch 4 года назад
I don't understand why the balls jump higher and higher with a bounciness of 1 and no friction when the bounce combine is on maximum and bounciness drops quickly when bounce combine is on average. I just want an eternally bouncy ball, not one that bounces out of control. What do I need to do?
@simpson6700
@simpson6700 4 года назад
So, get component is an expensive call? Whenever i make projectiles i get a reference to other. GetComponent() and subtract the damage from other.Status.health and destroy my projectile, is there a better way to go about this? Sure for a bullet hell shooter it would be better to let the enemies check if they've been hit, but this approach seems awkward for games where the player only occasionally shoots an arrow.
@Gius7979
@Gius7979 4 года назад
is there a plugin for VS editor which shows inline parameter hints as Rider do?
@chickennugget8158
@chickennugget8158 3 года назад
how do I have a collider on an object that isnt a cube, sphere, cylinder, etc. (I'm using a chair) and I know I could just make the collider a cube for the chair, but how do I get an exact collider for the object?
@fishy1316
@fishy1316 3 года назад
mesh collider
@loya5377
@loya5377 3 года назад
Hi! Someone help me please! How can I determine the coordinates of the vertices of the Box Collider? If the object's rotation is not (0, 0, 0), then collider.bounds doesn't help.
@Maggiethegsd
@Maggiethegsd 4 года назад
Does this man ever smile
@avi6961
@avi6961 4 года назад
On my player, I have a character Controller, animator, and player script and on the obstacle, I have a box collider and the script. When my player tries to jump close to the obstacle and hit the box collider, the player files of the game in the y-direction. When the player jumps from afar from the obstacle then nothing abnormal happens. Do you know what can be the reason for this? I am using on triggerEnter.
@cyboticIndustries
@cyboticIndustries 5 лет назад
Hey JAson - Great content - each and every time.. keep on doin what youre doing... but one odd request - Please *wear a shirt different colour from the chair* - I cant un-see your flying head !
@tambling3961
@tambling3961 4 года назад
Is this a 1st world problem?
@digitalconsciousness
@digitalconsciousness 3 года назад
huh, attaching a rigid body doesn't appear to provide any sort of gravity for me, no matter the type of object I create. You don't appear to have any script attached to your sphere. Maybe they updated this? Not that it's any problem to write gravity code, but I did spend some time trying to recreate exactly what you did and could not.
@juleswombat5309
@juleswombat5309 2 года назад
Did you Check that Gravity=True set on the Rigid Body component? It normally defaults to True, and as such no additional Script is required for it to fall. Unless you had also Kinematic checked as well. Typically I would either have Gravity = True + Kinematic = False, for typical physics OR I would have Gravity = False + Kinematics=True for when I want to remove the impact of physics.
@swarupfule3557
@swarupfule3557 4 года назад
Bro.i want to create roulette wheel and ball.but when roulette object rotate ball go out.what to do?
@JCElzinga
@JCElzinga 2 года назад
I got a rigidbody here for ya har har har
@romulino
@romulino 4 года назад
if I want everything to fall faster, is increasing the gravity value the right thing to do? Seems very weird, but I find the default fall speed to be very slow for my game. (drag already set to 0)
@essamsalah829
@essamsalah829 4 года назад
increase the weight of the rigig body component
@trashyy1630
@trashyy1630 3 года назад
:c i'm not getting a red line when i attach the debug to the Sphere
@trashyy1630
@trashyy1630 3 года назад
oh lol, i needed to rotate the ball
@INeatFreak
@INeatFreak 5 лет назад
Hey. I am making top down shooter for mobile and i have problem with making projectiles. I tryed using rigidbody continuous dynamic collision detection but this didn't detect hits when bullet goes faster. Also tryed raycasting between last and current position for detecting collisions but this method is really performance heavy. So can you help me with dome ideas ? How can i make mobile friendly accurate bullets.? Thanks.
@Unity3dCollege
@Unity3dCollege 5 лет назад
how far and fast are the bullets going? normally with bullet type shots I don't even spawn projectiles and just use raycasts, but it depends a lot on the game. Are the things they're hitting extremely small too btw? Any extra info you can give will hopefully help us get you going in the right direction and get it resolved :)
@INeatFreak
@INeatFreak 5 лет назад
@@Unity3dCollege bullets should only go for 30-50 meters. I can use raycasting but its instant and i wanna have a bullet traces so that's why i am trying make it physical. And i want them to go slow enough that player can see where his bullets are going.
@MrTenergy01
@MrTenergy01 5 лет назад
If your bullets are slow enough to be clearly seen by your player then they are definitively not fast enough to go through an object without detecting it in continuous dynamic mode. Are the layers of your objects colliding with each other ?
@INeatFreak
@INeatFreak 5 лет назад
@@MrTenergy01 i know and that's the problem i am facing. and yes i've setup layers and tags correctly
@INeatFreak
@INeatFreak 5 лет назад
does collider trigger matters? i am checking for OnTriggerEnter on my code and bullet's collider is set to trigger.(i've read on forums that it's faster so that's why)
@cargorunner9960
@cargorunner9960 Год назад
I find Unity very inconsistent and difficult to understand. If I create the ground as a plane which comes with a mesh collider attached. The ball falls straight through the floor. If I create the ground as a cube which comes with a box collider the ball will stop falling when it hits the cube. Why does the mesh collider not stop the ball falling? I have to manually add a box collider to the plane to get the ball to stop falling. I also swapped the ball for a tall rectangle. The rectangle fell straight down and then bounced perfectly straight back up. This looked totally unatural. In real life the tall rectangle would fall over. So I guess I have to use a script to make the bounce more random and natural
@Saavvas
@Saavvas Год назад
I used a plane and i worked just fine
@cargorunner9960
@cargorunner9960 Год назад
@@Saavvas I am using 2022.2.5f1 I should have mentioned that. Different Unity versions can act differently
@Saavvas
@Saavvas Год назад
@@cargorunner9960 oh that makes sense I'm using a version from 2019
@nicobrits2019
@nicobrits2019 4 года назад
It's videos like these that makes me want to give up before I start! (As a newbie)I typed all the code as per the video and in the very first piece of code I get 2 errors! I don't understand them and cannot fix them. Below is my code and the error reported on the console. (Remember I am a beginner and this video is aimed at beginners....right? using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChangeColorOnCollision : MonoBehaviour { private void OnCollisionEnter(Collision collision) { Color randomlySelectedColor = GetRandomColor(); GetComponent().material.color = randomlySelectedColor; } private void GetRandomColor() { return new Color( r: UnityEngine.Random.Range(0f, 1f), g: UnityEngine.Random.Range(0f, 1f), b: UnityEngine.Random.Range(0f, 1f)); } } ChangeColorOnCollision.cs(16,9): error CS0127: Since 'ChangeColorOnCollision.GetRandomColor()' returns void, a return keyword must not be followed by an object expression Will you tell me what is wrong please??
@nicobrits2019
@nicobrits2019 4 года назад
And: Cannot implicitly convert type 'void' to 'UnityEngine.Color'
@zerrkoo5993
@zerrkoo5993 4 года назад
@@nicobrits2019 Hello Nico , The problem is that Your " Private Void GetRandomColor() " is a void method so it is returning nothing to your " randomlySelectedColor " variable in order to make a function or method return a result you need to replace void with what you would like to return for Example : Your code --> private void GetRandomColor() { return new Color( r: UnityEngine.Random.Range(0f, 1f), g: UnityEngine.Random.Range(0f, 1f), b: UnityEngine.Random.Range(0f, 1f)); } Working code ----> private Color GetRandomColor() { return new Color( r: UnityEngine.Random.Range(0f, 1f), g: UnityEngine.Random.Range(0f, 1f), b: UnityEngine.Random.Range(0f, 1f)); } I am new to coding to but i hope this helps :)
@nocultist7050
@nocultist7050 3 года назад
I struggle to make friction based movement, like in real life.
@charlieskarts1934
@charlieskarts1934 4 года назад
26:25
@gregoryfenn1462
@gregoryfenn1462 5 лет назад
How do we define collisions and kinematic motion and physic-materials in Unity ECS? Or do we have to have a hybrid system where some of the game physics uses old MonoBehaviours?
@samljer
@samljer 4 года назад
I still remember trying to explain to someone why making the jump of a character physics based was better then 4 hours of coding it in., lol. why reinvent the wheel.
@flensim7536
@flensim7536 4 года назад
привет *привет* -привет- _привет_
@MuhammadAli-gs1co
@MuhammadAli-gs1co 3 года назад
drunken wizard.
Далее
choosing a game engine is easy, actually
15:08
Просмотров 515 тыс.
🍎 Apple Pie Cinnamon Roll Donut #Shorts
00:21
Просмотров 2,3 млн
Unity Movement [RigidBody vs Translate]
9:00
Просмотров 285 тыс.
Dear Game Developers, Stop Messing This Up!
22:19
Просмотров 717 тыс.
Unity Explained - Colliders - Beginner Tutorial
7:01
Unity Physics: Static, Kinematic, Dynamic
7:07
Просмотров 48 тыс.
The 6 Design Patterns game devs need?
24:20
Просмотров 369 тыс.
I Made the Same Game in 8 Engines
12:34
Просмотров 4,1 млн
The Most Impressive Scratch Projects
11:00
Просмотров 4,9 млн
Raycasts in Unity (made easy)
16:30
Просмотров 94 тыс.