Let's look at Unity DOTS Physics! Easy to use with the promise of thousands of physics objects! What Physics demos would you like to see? 🎮 Play 7 Awesome Games (Action, Strategy, Management) and Help Support the Channel! ✅ Get the Game Bundle 67% off unitycodemonkey.com/gameBundle.php
this video is so cool :) can you make a video on gravity? ... gravity on a planet, gravity system with player moving inside a traveling ship, gravaity toward one or multiple objects, fading gravity over distance ...
There is a litte error in your update-function where you call Raycast with the direction vector, not the end-point. You call "Raycast(ray.origin, ray.direction * rayDistance)" instead of "Raycast(ray.origin, ray.origin + ray.direction * rayDirection)". Otherwise very helpful as always!
I'm getting errors on .entities in the Trigger events, is this depreciated or somthing i am doing, I appreciate this was done some time ago, could do with a heads up :)
Took me 4 days of my vacation, but I finally built a multithreaded raycast system in 3D space. Except for you & that other DOTS-guy on yt there is just no resources except for the api. We really need to share and spread the knowledge if we want more indie devs to use DOTS! I miss those official unity tutorials.... Hope you keep up the good work.
Hello! I would like to point out that when following along with a fresh project, it is also necessary to install the Hybrid Renderer package as otherwise the entities do not get rendered. This has been mentioned in your ECS tutorial, but I managed to forget that and for some time could not figure out, why the cube and sphere kept disappearing :D
Awesome! I'd love to see some sort of mini game done fully with DOTS physics. Something like a basic spaceship shoot em up. Also curious if there is some kind of animation system setup for DOTS or not
Yup I was thinking of trying to make Space Invaders, sounds like it could work as a simple game and then play around with thousands of enemy ships. I believe there's a Animation system currently in the experimental stage.
Actually the raycast job is automatically scheduled in parralel. The trick is to built->cast->execute in a multithreaded chain! But thanks to your tutorials and 2 days of my vacation I finally have 1k entities casting for the player. Point is thought, results are returned as unityEngine.Raycasthit so you need to manually convert your desired information into bittable values for further implementation in jobs. Posting my basic script on my channel soon. Thank you so much for making so good tutorials. It's just such a shame that unity hasn't made ecs tutorials like they used to with mono. Especially when it comes to such basic things as raycasting.
your tutorials are absolutely amazing! On the spot, awesome audio, and very well researched! Plus unity is finally starting to get stable again. I made one "pure ecs" game long time ago and looking to make a new one now that we have the neccesary systems in DOTS.
I read the Documentation, Manual, analyze the official samples and do lots of trial and error. These complex DOTS videos take a long time during research before I can make the video.
You can and you should mix them together where it makes sense. That's exactly what I'm covering in the video going live later today, it uses normal game objects for my animated units but then uses super fast DOTS Pathfinding to calculate the path. So you can definitely build your games the normal way using game objects and then just convert the performance intensive parts into DOTS
Thanks for the awesome tutorials. I've found them incredibly helpful for getting my head around the all this DOTS stuff. Small thing with your raycast, I'm fairly sure that should be Raycast(origin, origin + direction * distance), not Raycast(origin, direction * distance)
4 роки тому+1
What I would like to see is unity dots physics and netcode integration. Just started playing around with it a bit myself :)
With the raycast you do at around 12:00, is it possible to access the Physics Shape that the ray hit? I've previously in normal unity physics used it to make my 3rd person camera ignore objects that are very thin etc.
DOTS is definitely going to be a unique beast to work with once it is finally out of preview. I just honestly hope that they come up with a better way of actually controlling the beast that they're unleashing. What I mean by that is, it is so easy to set things up, But after that initial setup getting access to the underlying data can be nightmare. It's kind of like giving your data to a bank to look after (Unity) then having to break in to said bank just to get access to be able to use it and make simple changes to it. Not to be hard on Unity because I think they're moving in the right direction with what they are doing... But at the same time I think that they need to take a step back and really focus. and this is actually where Unreal has an advantage over Unity, Epic they themselves have made a AAA game with their own engine. Unity has not, Sure, Unity has came up with some AAA looking in game footage, but it's not intractable. It's more or less a movie and not so much a game. And making a movie vs a game is completely different, there are so many things to consider. Still keep up the good work and exploring the new tech as it comes out, it's great to see some insight in to how it all works and what is potentially possible.
Are you talking about DOTS Physics specifically or DOTS in general? I agree DOTS Physics does seem a bit too complex but DOTS as a whole is already quite a lot user friendly. They have improved usability tremendously these past 12 months and by the time DOTS Core is out of preview it should be very usable.
@@CodeMonkeyUnity The DOTS Physics seems to be overly cumbersome at this point, especially with what you showed with having to write your own function that is built on the Unit's regular physics. But that in and of itself is partly because it's still in preview so that's understandable that there is going to be some functionality missing. But I was also talking about DOTS in general. Yes it has made leaps and bounds over the past 12 months by adding several QOL features and streamlining the syntax that makes it somewhat easier to work with. But in the end you still have to go though thousands of entities just to find maybe 1 that has met a certain condition. Now to me, that sounds counter productive because it seems to be that the flow control of your program is one way and if you didn't have the mass parallelism provided by BURST it would be worse off than the current GameObject Model that people are used to. Take for example with traditional GameObjects sure there would be iteration to possibly change values on several similar objects, and once that object's data has reached a certain condition it has a way messaging the system that something needs to be done, either through events or some form of other call back feature which can identify that specific object. But with DOTS, right now there is no real way to isolate specific data (at least in the examples I've seen online), if you're creating a job to work on a set of entities, then you have to make another job just to handle entities that have met certain conditions. And to me, that seems more system oriented than it does data. if you have a scene with 50,000 tree entities that have a translation component and 1 player, and you go searching for the player using foreach, but also wanting it's translation so you can move it. it's still going to have to go through all of the trees until it finds the entity with the the player tag and the translation component. Hopefully that will make sense to you. And it could be that I am missing something here. Have they done away with using archetypes which would kind of minimize that problem because then you can just create specific entities based on an archetype and separate them out in to tree and player and just look for the player archetype and completely exclude looking through all the trees
I'm having a hard time wrapping my head around how ITriggerEvents work. Is the job you created scheduled only when there is a collision with a trigger, or is it scheduled every frame? Is there documentation anywhere where ITriggerEvents are explained?
Hello , awesome video !! . I need help, i'm trying to implement ICollisionEventJob :C, need to play a hit sound when a ball touch a wall or any other object, i need to know if a collision has ocurred, sorry about my english im from argentina
Might be a stupid question, but how do you actually use the samples? The instructions tell you to create a new project, import the Hybrid Renderer and stop there. Where do the files you download from the GitHub enter the picture?
Hey Code Monkey, for this specific tutorial, did you use the built in render pipeline or SRP? This is crucial to me since I cannot upgrade URP or HDRP from the built in render pipeline and need to make ECS collisions work on the built in render pipeline. Thanks in advance!
Physics shouldn't have anything to do with rendering. This video is pretty old, here I believe I was using the Hybrid Renderer which I believe is related to URP
Is there a significant performance gain from using this physics system over the old one? Could you for example have something like 10k rigidbodies with good performance?
I haven't tested the limits yet but yes it should work for thousands of rigidbodies. With normal game objects things start to slow down when you have something like 5k game objects whereas in ECS you can have 100k+
When I put stepPhysicsWorld.Simulation at 17:43 , Unity logs out an error that says: cannot convert from Unity.Physics.ISimulation to Unity.Entities.EntityQuery. So what can I do now?
Yup! UA-cam doesn't support updating videos but I plan to remake them using Unity 6, I'm currently playing with DOTS Physics right now for my upcoming DOTS RTS course
You implemented 'directly adding dots physics' example by adding conversion script to game object (in editor), then can I make that process fully code-driven by creating object-adding components-adding conversion script? If not, is there a way to *make dots phsics object by pure-ECS approach* ?
Can you explain why velocity of both EntityA & EntityB would be modified when collision triggered? Isn't A&B refers Ball & Ground? Why only ball jumps up despite of both entity's velocity changed?
The Floor entity does not have a Velocity component, it only has a Collider component so that's why it doesnt move. If you add a Rigidbody or a Physics Body component then it will end up with a Velocity component which will end up both jumping.
@@CodeMonkeyUnity Oh, so you mean ball can be A or B by collision case, and it's better applying velocity all of them (and nullify v of floor) than taking overhead deciding which one is ball and which one is floor... Is it right?
@@jamesmillerjo Yup the ball can be either A or B. In this simple demo I just tried to modify the PhysicsVelocity or both entities but if you want more specific logic you could add another ComponentDataFromEntity to specifically identify which one of the two is the ball.
Code Monkey. What a great vid man. Side by side comparison of using a gameobject vs DOTS. Brilliant! I hate to request another idea on top of all the others we are suggesting for you, but #Geri mentioned on here of doing a small game in DOTS. I second that idea. Similar to a Flappy Bird style game..? I would love to give you a one-time donation. You have a Paypal, GoFundMe?
Yeah a small complete game is definitely something I'm looking into. You can get the Game Bundle which really helps and you get some cool games to play! unitycodemonkey.com/gamebundle.php Thanks!
I am new to unity, I don't know why I give my entity to rigibody. My entities will fall to the bottom of the map, I am sure I have added colliders. Mine is the need to detect the entities near each entity. In addition to using rigibody.index. Is there any other way to get entity? does there have collider.index somthing like that. I check unity.physic, I need to use Overlap query to do that. Thank you. I am not sure what to do, I am not sure do you have these kind of tutorial. if has, please let me know.. Thanks very much.
How would you efficiently handle different collision pairs? For example: The player and enemies shoot a different projectile type. Each projectile plays a different sound and particle system on impact. Each projectile has their unique sounds / particles for hitting different 'pairs' such as the player, an enemy, the floor, the walls, etc. Would you write a single system, then depending on the pairs invoke the proper logic using a function pointer?
Identify objects with Tag components and do the logic based on the Tags. I haven't tested so not sure if it would be better to have a single Job handling all possible interactions or multiple Jobs each handling a specific type of interaction. I'm guessing more Jobs will have some overhead but it's likely worth it to keep your codebase nice and clean.
The API has changed a lot in this video. Nowadays all you need is to make a subscene and add a Game Object with a Rigidbody, it will automatically be converted into DOTS physics ua-cam.com/video/4ZYn9sR3btg/v-deo.html
Great video. Please, cover the joints topic in next vid. BTW. What you mean by Havok is not free? Unity don't adds Havok to the free version or what? I have to pay havok's people to make a game with havok in Unity?
Yes Havok is a third-party Physics engine used by many AAA games and yes it has a paid license. Not sure how much it will end up being, it's still available as a free trial. Unity Physics on the other hand is free included in Unity.
JobComponentSystem is depreciated and instead SystemBase is used. What modifications are required in code because if i use SystemBase, i cannot get JobHande inputDeps from anywhere
I have modified the code here a little (it working but giving errors): protected override void OnUpdate() { JobHandle jobHandle = Dependency; TriggerJob triggerJob = new TriggerJob { physicsVelocityEntities = GetComponentDataFromEntity() }; triggerJob.Schedule(stepPhysicsWorld.Simulation, Dependency); Dependency = JobHandle.CombineDependencies(Dependency, jobHandle); }
using Unity.Physics dose not work for me. im not sure why but that extension dosent exsist. i have installed the physics package like stated in the video. PLEASE HELP!!! also love your videos. a tutorial on making a space game with realistic physics would be awesome. i wanna make spaceships!
Will the DOTS code will become shorter? It looks like a lot of code for really simple mechanics trying to achieve. And the code seems to repeat for entities as well. Is it because the DOTS is still in development?
To see preview packages, enable them in the settings inside the Package Manager. But, with 2020.1 they removed the pre-preview packages, e.g. the hybrid renderer. They describe a workaround here: docs.unity3d.com/Packages/Installation/manual/index.html In short, you can click "Add package from git URL" and paste the corresponding unity package name (e.g. com.unity.rendering.hybrid )
Could you make a tutorial on everything needed to start a new project from scratch? I can't seem to figure out why whenever I start a new project, add entities, add physics etc... I get a lot of exceptions and nothing is working.
If you want to work with DOTS then open a completely blank project and install the Entities package, in doing so it will automatically get all the related dependencies like Jobs. If you add the Physics package afterwards you might get some issues with the Performance API, you need to manually select the correct versions, I'm guessing that's an issue that will be solved soon.
I haven't fully tested both in order to compare but I believe Havok works faster so if speed is absolutely necessary go with Havok. Although Havok is paid for whereas Unity Physics is free.
The ball with rigidbody stops bouncing after a second, losing all energy. :/ + the raycast is not accurate, looks like the center of sphere collider is 1cm higher than the actual shpere, but its not. So I have to 1cm higher.
Even if you give it perfect bounciness the underlying values are stored in floats so you don't have infinite precision which does mean that eventually it all comes to a stop.
Hello, difficult to use the project on Github: tons of errors ^^. On your video, the InputSystem package does not seem to be installed. Because of namespace errors, I installed it, and I went from 110 to 22 errors : \ The remaining errors are mainly "Assets \ Common \ InputActions.cs (791,39): error CS1061: 'InputActionAsset' does not contain a definition for 'GetActionMap' and no accessible extension method 'GetActionMap' accepting a first argument of type 'InputActionAsset 'could be found (are you missing a using directive or an assembly reference?) " . I will watch the video quietly and try again when I can understand these errors...
What version did you open it on? The samples github comes with the entire project so it should already have all the packages installed correctly, open the project folder with 2019.3.0f1
@@CodeMonkeyUnity 2019.3.0f1. It is nice to want to help me, but I think that I am not yet learned enough on Unity to advance on this subject. I prefer to wait until I have a little more knowledge, in particular on the new input system. I followed the rest of the video, I almost finished it, it is very interesting (still struggling with the English language, despite the efforts of those who make the subtitles). I am trying to reproduce your actions, and I will point out very small difficulties: - when you type the code, you are quite often at the bottom of the screen, where the subtitles are located. So pause, move the subtitle bar, resume reading. It's just boring. - sometimes you go very quickly with the mouse, without commenting. You must then go back and scan the screen. Nothing insurmountable, it's just boring. Your videos deserve to have more views, and I find them really very interesting, we always learn something from them. In fact, I watch very few English channels, but the lack of quality French channels is a powerful motivator ... And in addition, I feel that my level of English is improving :). As I wrote to you (it seems to me that I used the form on your site), I bought your games, and I made comments and proposals. I had a good time with these games, and I still do. Thank you again for all these videos and happy new year 2020.
How well does regular unity physics and DOTS physics play with each other? Like, say DOTS colliders hitting gameobject colliders? Or DOTS rays hitting gameobjects?
@@nukulargames6315 Technically you could have an invisible collider in the DOTS World and on every Update move a GameObject to the same position as the Entity but that is a very convoluted way of doing things.
If you're completely new to Unity start off with the Basics playlist ua-cam.com/play/PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT.html After that look through the video list for more beginner tutorials or try following one of the complete simple games I have like Flappy Bird and Snake ua-cam.com/video/b5Wpni9KPik/v-deo.html
The line: return triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps); is showing an issue: the call is ambiguous between the following methods or properties: IBodyPairsJobExtensions.Schedule(T, Simulation, ref PhysicsWorld, JobHandle) and ICollisionEventJobExtensions.Schedule(T, ISimulation, ref PhysicsWorld,JobHandle) I have posted the issue here: forum.unity.com/threads/itriggereventsjob-schedule-compile-error.877681/ and if you or anyone has the solution, or even a clue.... If I find the solution I will post back. ------------------------- EDIT 1: I attempted to run the Unity Physics samples, and they too get this error. So it seems it's something to do with my system. I will update again when I find something else. EDIT 2: Solved. I was using Visual Studio Community 2015 and upgraded to Visual Studio Community 2019 and the conflict was resolved. I have no idea why upgrading the IDE resolved the conflict between two functions... but it worked for me. ------------------------- Thanks for this video and all of them, they are a great help.
If Unity started adding this kind of complex features then they will easily lose their users because in the market game engines are coming those make your life more easy day by day. One name is Buildbox, they will provide big competition in this.
Game Objects and MonoBehaviours aren't going anywhere, if your game has no issues with performance then by all means keep making games as you've always done. DOTS is simply another option that is extremely performant. There are many (most) games which have limited design due to performance limitations, that is what DOTS is meant to solve.
@@CodeMonkeyUnity Yes I understand your point and you are doing really good :) I am just talking generally, maybe Unity make this thing compulsory in the future as like they will do LDRP as their default render pipeline.
Doing the networking for games is relatively abstracted from the actual hardware, so learning client/server and p2p architecture will be relevant regardless whether its LAN/WiFi/WAN/p2p - applications dont actually care whether their data is sent via wifi, ethernet cables or some other fake adapter as you might see in a vm. Youd wanna start looking into UDP, bidirectional communication etc
Let's look at Unity DOTS Physics! Easy to use with the promise of thousands of physics objects! What Physics demos would you like to see?
🎮 Play 7 Awesome Games (Action, Strategy, Management) and Help Support the Channel!
✅ Get the Game Bundle 67% off unitycodemonkey.com/gameBundle.php
this video is so cool :) can you make a video on gravity? ... gravity on a planet, gravity system with player moving inside a traveling ship, gravaity toward one or multiple objects, fading gravity over distance ...
There is a litte error in your update-function where you call Raycast with the direction vector, not the end-point. You call "Raycast(ray.origin, ray.direction * rayDistance)" instead of "Raycast(ray.origin, ray.origin + ray.direction * rayDirection)". Otherwise very helpful as always!
I'm getting errors on .entities in the Trigger events, is this depreciated or somthing i am doing, I appreciate this was done some time ago, could do with a heads up :)
really helpful video. Does Physics Shape support 2d
Sorry about my voice being a bit off, been a little sick lately, hope you like the video!
Took me 4 days of my vacation, but I finally built a multithreaded raycast system in 3D space.
Except for you & that other DOTS-guy on yt there is just no resources except for the api.
We really need to share and spread the knowledge if we want more indie devs to use DOTS!
I miss those official unity tutorials....
Hope you keep up the good work.
yassss!! keep making videos about complex topics like these. Thank you
Hello! I would like to point out that when following along with a fresh project, it is also necessary to install the Hybrid Renderer package as otherwise the entities do not get rendered. This has been mentioned in your ECS tutorial, but I managed to forget that and for some time could not figure out, why the cube and sphere kept disappearing :D
Very cool. Covered a lot in 20 minutes. Thank you.
Amazing video! You have one of the best videos currently available on Unity DOTS. Keep going!!
Very nice video to get our feet wet in DOTS Physics - thank you. Hope you feel better.
Awesome! I'd love to see some sort of mini game done fully with DOTS physics. Something like a basic spaceship shoot em up. Also curious if there is some kind of animation system setup for DOTS or not
Yup I was thinking of trying to make Space Invaders, sounds like it could work as a simple game and then play around with thousands of enemy ships.
I believe there's a Animation system currently in the experimental stage.
looks like an insane amount of code to let that ball jump :(
It's a pain in the ass but if we want to squeeze out any ounce of performance from it, we have to :(
@@quoctuanlee3544 But the idea of getting a huge robot swarm to work sounds pretty worth it ...
Actually the raycast job is automatically scheduled in parralel.
The trick is to built->cast->execute in a multithreaded chain!
But thanks to your tutorials and 2 days of my vacation I finally have 1k entities casting for the player.
Point is thought, results are returned as unityEngine.Raycasthit
so you need to manually convert your desired information into bittable values for further implementation in jobs.
Posting my basic script on my channel soon.
Thank you so much for making so good tutorials.
It's just such a shame that unity hasn't made ecs tutorials like they used to with mono.
Especially when it comes to such basic things as raycasting.
A tutorial of 2D Physics with 10,000 units bouncing around would be a great learn and fun :)
Yes please
your tutorials are absolutely amazing! On the spot, awesome audio, and very well researched!
Plus unity is finally starting to get stable again.
I made one "pure ecs" game long time ago and looking to make a new one now that we have the neccesary systems in DOTS.
Yess finally 😍
This channel is so good! Top tier explanation: precise & concise. Thanks a ton!!
where do u learn all this ?
there is just a few resources on the web !!
I read the Documentation, Manual, analyze the official samples and do lots of trial and error. These complex DOTS videos take a long time during research before I can make the video.
@@CodeMonkeyUnity U are Absolutely Great!
Holy ****! I was thinking about this just now!! Thanks CM!
Are there any drawbacks on using both, "normal" and DOTS stuff together in a project? Are there any benefits from partially using DOTS in a project?
You can and you should mix them together where it makes sense.
That's exactly what I'm covering in the video going live later today, it uses normal game objects for my animated units but then uses super fast DOTS Pathfinding to calculate the path.
So you can definitely build your games the normal way using game objects and then just convert the performance intensive parts into DOTS
Thanks for the awesome tutorials. I've found them incredibly helpful for getting my head around the all this DOTS stuff.
Small thing with your raycast, I'm fairly sure that should be Raycast(origin, origin + direction * distance), not Raycast(origin, direction * distance)
What I would like to see is unity dots physics and netcode integration. Just started playing around with it a bit myself :)
I'm really enjoying your content, this is great video. Thanks!
Great vid - thx :) - there is extremely small number of vids/examples etc that cover unity.physics imo
Really useful tutorial!
Thanks for your effort!
This is a gold nugget, ty!
Yay! I wanted this!
With the raycast you do at around 12:00, is it possible to access the Physics Shape that the ray hit? I've previously in normal unity physics used it to make my 3rd person camera ignore objects that are very thin etc.
DOTS implement 2D physics as well?
Thank you for sharing this valuable information
are you using any additional packages for Dot physics?
I'd love to see you implement the preview version of the Havok Physics Engine.
I have a doubt, entities can only interact with entity? Can a regular rigidbody interact with entity having rigidbody ?
DOTS is definitely going to be a unique beast to work with once it is finally out of preview. I just honestly hope that they come up with a better way of actually controlling the beast that they're unleashing. What I mean by that is, it is so easy to set things up, But after that initial setup getting access to the underlying data can be nightmare. It's kind of like giving your data to a bank to look after (Unity) then having to break in to said bank just to get access to be able to use it and make simple changes to it.
Not to be hard on Unity because I think they're moving in the right direction with what they are doing... But at the same time I think that they need to take a step back and really focus. and this is actually where Unreal has an advantage over Unity, Epic they themselves have made a AAA game with their own engine. Unity has not, Sure, Unity has came up with some AAA looking in game footage, but it's not intractable. It's more or less a movie and not so much a game. And making a movie vs a game is completely different, there are so many things to consider.
Still keep up the good work and exploring the new tech as it comes out, it's great to see some insight in to how it all works and what is potentially possible.
Are you talking about DOTS Physics specifically or DOTS in general? I agree DOTS Physics does seem a bit too complex but DOTS as a whole is already quite a lot user friendly. They have improved usability tremendously these past 12 months and by the time DOTS Core is out of preview it should be very usable.
@@CodeMonkeyUnity The DOTS Physics seems to be overly cumbersome at this point, especially with what you showed with having to write your own function that is built on the Unit's regular physics. But that in and of itself is partly because it's still in preview so that's understandable that there is going to be some functionality missing. But I was also talking about DOTS in general. Yes it has made leaps and bounds over the past 12 months by adding several QOL features and streamlining the syntax that makes it somewhat easier to work with. But in the end you still have to go though thousands of entities just to find maybe 1 that has met a certain condition. Now to me, that sounds counter productive because it seems to be that the flow control of your program is one way and if you didn't have the mass parallelism provided by BURST it would be worse off than the current GameObject Model that people are used to.
Take for example with traditional GameObjects sure there would be iteration to possibly change values on several similar objects, and once that object's data has reached a certain condition it has a way messaging the system that something needs to be done, either through events or some form of other call back feature which can identify that specific object. But with DOTS, right now there is no real way to isolate specific data (at least in the examples I've seen online), if you're creating a job to work on a set of entities, then you have to make another job just to handle entities that have met certain conditions. And to me, that seems more system oriented than it does data.
if you have a scene with 50,000 tree entities that have a translation component and 1 player, and you go searching for the player using foreach, but also wanting it's translation so you can move it. it's still going to have to go through all of the trees until it finds the entity with the the player tag and the translation component. Hopefully that will make sense to you. And it could be that I am missing something here. Have they done away with using archetypes which would kind of minimize that problem because then you can just create specific entities based on an archetype and separate them out in to tree and player and just look for the player archetype and completely exclude looking through all the trees
Great tutorial again, but I have a question: I used the bitmask (1u
if your rigidbodys don't fall down, install Havoc physics package (I think)
thanks for your video, it is very very very helpful
I'm having a hard time wrapping my head around how ITriggerEvents work. Is the job you created scheduled only when there is a collision with a trigger, or is it scheduled every frame? Is there documentation anywhere where ITriggerEvents are explained?
Check the official Unity DOTS Physics samples, there's several demos there that use Triggers
Hello , awesome video !! . I need help, i'm trying to implement ICollisionEventJob :C, need to play a hit sound when a ball touch a wall or any other object, i need to know if a collision has ocurred, sorry about my english im from argentina
Might be a stupid question, but how do you actually use the samples? The instructions tell you to create a new project, import the Hybrid Renderer and stop there. Where do the files you download from the GitHub enter the picture?
Such cool. Much helpful.
Thx! Why I didn't watch this so far?
Hi! Great tutorial!
Hey Code Monkey, for this specific tutorial, did you use the built in render pipeline or SRP? This is crucial to me since I cannot upgrade URP or HDRP from the built in render pipeline and need to make ECS collisions work on the built in render pipeline. Thanks in advance!
Physics shouldn't have anything to do with rendering. This video is pretty old, here I believe I was using the Hybrid Renderer which I believe is related to URP
I only need 2D raycasts to detect clear driving paths for cars. Is there a lot of speed to be gained by switching to DOTS physics?
Is there a significant performance gain from using this physics system over the old one? Could you for example have something like 10k rigidbodies with good performance?
I haven't tested the limits yet but yes it should work for thousands of rigidbodies.
With normal game objects things start to slow down when you have something like 5k game objects whereas in ECS you can have 100k+
Unfortunately the scripts from DOTS/Physics has gone...
All right, install unity physics from package manager and then scripts come out..
Really awesome video. I know its in its early stages, but who man they need to make Raycasting way less verbose.
Yeah the Raycast is great in how many options it has but it definitely needs a simplified utility function.
Good day! The keys W, A, S, D do not work for me when driving, what could be the problem?
The way you did ITriggerEventsJob, i did ICollisionEventJob but I am getting a memory Leak. Any thoughts?
Try using the attribute [updateAfter(typeof(StepPhysicsWorld))] on your system
@@mathiasjensen2841 Thx
When I put stepPhysicsWorld.Simulation at 17:43 , Unity logs out an error that says:
cannot convert from Unity.Physics.ISimulation to Unity.Entities.EntityQuery.
So what can I do now?
Hello, With Unity 6 coming out and DOTS being a highlight of it, are there any plans on updating any of these tutorials?
Yup! UA-cam doesn't support updating videos but I plan to remake them using Unity 6, I'm currently playing with DOTS Physics right now for my upcoming DOTS RTS course
Aren't there Physics Shape and Physics Body for 2D sprites?
You implemented 'directly adding dots physics' example by adding conversion script to game object (in editor),
then can I make that process fully code-driven by creating object-adding components-adding conversion script?
If not, is there a way to *make dots phsics object by pure-ECS approach* ?
Sure you can make everything straight through code, create an Entity and manually add the Physics components you want like PhysicsVelocity.
Hi, thanks for this tutorial. I wonder why if restitution is 1 it looses velocity on each impact?
it's basically completely different from old system
like learning from different Game Engine
Can you explain why velocity of both EntityA & EntityB would be modified when collision triggered? Isn't A&B refers Ball & Ground? Why only ball jumps up despite of both entity's velocity changed?
The Floor entity does not have a Velocity component, it only has a Collider component so that's why it doesnt move.
If you add a Rigidbody or a Physics Body component then it will end up with a Velocity component which will end up both jumping.
@@CodeMonkeyUnity Oh, so you mean ball can be A or B by collision case, and it's better applying velocity all of them (and nullify v of floor) than taking overhead deciding which one is ball and which one is floor... Is it right?
@@jamesmillerjo Yup the ball can be either A or B. In this simple demo I just tried to modify the PhysicsVelocity or both entities but if you want more specific logic you could add another ComponentDataFromEntity to specifically identify which one of the two is the ball.
@@jamesmillerjo No he is not applying velocity to all of them . He is testing wich one is Ball and wich one is Ground.
can't find the "Physics shape " under DOTS and Physics.why?
Code Monkey. What a great vid man. Side by side comparison of using a gameobject vs DOTS. Brilliant! I hate to request another idea on top of all the others we are suggesting for you, but #Geri mentioned on here of doing a small game in DOTS. I second that idea. Similar to a Flappy Bird style game..? I would love to give you a one-time donation. You have a Paypal, GoFundMe?
Yeah a small complete game is definitely something I'm looking into.
You can get the Game Bundle which really helps and you get some cool games to play!
unitycodemonkey.com/gamebundle.php
Thanks!
Awesome
I am new to unity, I don't know why I give my entity to rigibody. My entities will fall to the bottom of the map, I am sure I have added colliders. Mine is the need to detect the entities near each entity. In addition to using rigibody.index. Is there any other way to get entity? does there have collider.index somthing like that. I check unity.physic, I need to use Overlap query to do that. Thank you. I am not sure what to do, I am not sure do you have these kind of tutorial. if has, please let me know.. Thanks very much.
How would you efficiently handle different collision pairs? For example:
The player and enemies shoot a different projectile type. Each projectile plays a different sound and particle system on impact. Each projectile has their unique sounds / particles for hitting different 'pairs' such as the player, an enemy, the floor, the walls, etc.
Would you write a single system, then depending on the pairs invoke the proper logic using a function pointer?
Identify objects with Tag components and do the logic based on the Tags.
I haven't tested so not sure if it would be better to have a single Job handling all possible interactions or multiple Jobs each handling a specific type of interaction. I'm guessing more Jobs will have some overhead but it's likely worth it to keep your codebase nice and clean.
Why the object is not falling at all? i followed all the steps for DOTS version but it remains still.
The API has changed a lot in this video. Nowadays all you need is to make a subscene and add a Game Object with a Rigidbody, it will automatically be converted into DOTS physics ua-cam.com/video/4ZYn9sR3btg/v-deo.html
In scene start. My objects destroyed, why? I dont see cube and sphere.
Great video. Please, cover the joints topic in next vid.
BTW. What you mean by Havok is not free? Unity don't adds Havok to the free version or what? I have to pay havok's people to make a game with havok in Unity?
Yes Havok is a third-party Physics engine used by many AAA games and yes it has a paid license. Not sure how much it will end up being, it's still available as a free trial.
Unity Physics on the other hand is free included in Unity.
ECS is another level of coding. Extremely hard
JobComponentSystem is depreciated and instead SystemBase is used. What modifications are required in code because if i use SystemBase, i cannot get JobHande inputDeps from anywhere
I have modified the code here a little (it working but giving errors):
protected override void OnUpdate()
{
JobHandle jobHandle = Dependency;
TriggerJob triggerJob = new TriggerJob
{
physicsVelocityEntities = GetComponentDataFromEntity()
};
triggerJob.Schedule(stepPhysicsWorld.Simulation, Dependency);
Dependency = JobHandle.CombineDependencies(Dependency, jobHandle);
}
using Unity.Physics dose not work for me. im not sure why but that extension dosent exsist. i have installed the physics package like stated in the video. PLEASE HELP!!!
also love your videos. a tutorial on making a space game with realistic physics would be awesome. i wanna make spaceships!
Can i used colisions, and dont use phisics simulation?
Where is the documentation shown in the video? God I hate to navigate Unity's online resources
I can't control any car in demo, how did you do it?
Will the DOTS code will become shorter? It looks like a lot of code for really simple mechanics trying to achieve.
And the code seems to repeat for entities as well. Is it because the DOTS is still in development?
It's still very much in development and the amount of code is constantly being simplified so yes I assume it will continue in that direction.
Where do I find the package files? I can't find it in my package manager.
To see preview packages, enable them in the settings inside the Package Manager.
But, with 2020.1 they removed the pre-preview packages, e.g. the hybrid renderer.
They describe a workaround here: docs.unity3d.com/Packages/Installation/manual/index.html
In short, you can click "Add package from git URL" and paste the corresponding unity package name (e.g. com.unity.rendering.hybrid )
idk what to think about dots lol making a gameobject jump when it hits the trigger but its 10x the code length and complexity.
The point is that it's 100x faster. You can have 10000 DOTS balls jumping at 120fps. Or. 100 normal balls jumping at 30fps.
6 months old, but still.
thank you
Thanks for your videos, I have a question. In case you want to control collisions and physical 2D, how would you do it?
Right now DOTS works solely in 3D so there's no dedicated 2D Physics but you can easily just make sure the Z never changes.
thanks, for the answer, I wait for the next chapter of codemonkey :).
Could you make a tutorial on everything needed to start a new project from scratch? I can't seem to figure out why whenever I start a new project, add entities, add physics etc... I get a lot of exceptions and nothing is working.
If you want to work with DOTS then open a completely blank project and install the Entities package, in doing so it will automatically get all the related dependencies like Jobs.
If you add the Physics package afterwards you might get some issues with the Performance API, you need to manually select the correct versions, I'm guessing that's an issue that will be solved soon.
5:21 when i start scene objects destroyed. Why?
Have you done any tests to see what kind of performance difference this gives?
Not yet, I'm planning some torture tests soon, but if the other DOTS tests I've done are any indication that this can be 1000x faster.
Hello Code Monkey :) What are your thoughts on the new HAVOK Physics? Should someone like me use it in my project instead of the Unity Physics?
I haven't fully tested both in order to compare but I believe Havok works faster so if speed is absolutely necessary go with Havok. Although Havok is paid for whereas Unity Physics is free.
Havok physics is free for unity personnel and maybe is free for plus
Would it be possible to use "rigidebody based on assets" in an ECS project just by putting "convert to entity" like you did?
Yes when you add ConvertToEntity it will convert a normal Rigidbody component into a DOTS Physics Body
@@CodeMonkeyUnity great, good to know !
thank you, and amazing video as usual.. :)
@@CodeMonkeyUnityWhere is the ConvertToEntity script?
The ball with rigidbody stops bouncing after a second, losing all energy. :/
+ the raycast is not accurate, looks like the center of sphere collider is 1cm higher than the actual shpere, but its not. So I have to 1cm higher.
Even if you give it perfect bounciness the underlying values are stored in floats so you don't have infinite precision which does mean that eventually it all comes to a stop.
@@CodeMonkeyUnity Thats an answer I didnt expect. Thanks for tutorial, gonna work with dots so I grab anything i can find
Hello,
difficult to use the project on Github: tons of errors ^^. On your video, the InputSystem package does not seem to be installed. Because of namespace errors, I installed it, and I went from 110 to 22 errors : \
The remaining errors are mainly "Assets \ Common \ InputActions.cs (791,39): error CS1061: 'InputActionAsset' does not contain a definition for 'GetActionMap' and no accessible extension method 'GetActionMap' accepting a first argument of type 'InputActionAsset 'could be found (are you missing a using directive or an assembly reference?) "
.
I will watch the video quietly and try again when I can understand these errors...
What version did you open it on? The samples github comes with the entire project so it should already have all the packages installed correctly, open the project folder with 2019.3.0f1
@@CodeMonkeyUnity 2019.3.0f1.
It is nice to want to help me, but I think that I am not yet learned enough on Unity to advance on this subject. I prefer to wait until I have a little more knowledge, in particular on the new input system.
I followed the rest of the video, I almost finished it, it is very interesting (still struggling with the English language, despite the efforts of those who make the subtitles).
I am trying to reproduce your actions, and I will point out very small difficulties:
- when you type the code, you are quite often at the bottom of the screen, where the subtitles are located. So pause, move the subtitle bar, resume reading. It's just boring.
- sometimes you go very quickly with the mouse, without commenting. You must then go back and scan the screen. Nothing insurmountable, it's just boring.
Your videos deserve to have more views, and I find them really very interesting, we always learn something from them. In fact, I watch very few English channels, but the lack of quality French channels is a powerful motivator ... And in addition, I feel that my level of English is improving :).
As I wrote to you (it seems to me that I used the form on your site), I bought your games, and I made comments and proposals. I had a good time with these games, and I still do.
Thank you again for all these videos and happy new year 2020.
我觉得up主很强
Epic Hello World Program.
Great as always. Another inept tutorial?? That's what it sounds like to me for some reason.
Heh it's "in-depth" but yeah I can see how it sounds a bit odd
How well does regular unity physics and DOTS physics play with each other? Like, say DOTS colliders hitting gameobject colliders? Or DOTS rays hitting gameobjects?
They don't interact, they live in completely different worlds. You can mix them in the same scene but they don't collide between systems.
What about a hybrid approach, using only DOTS physics but still referencing the original gameobject with monobehaviors that aren't DOTS friendly.
@@nukulargames6315 Technically you could have an invisible collider in the DOTS World and on every Update move a GameObject to the same position as the Entity but that is a very convoluted way of doing things.
My Sphere does not fall. Without converting them to entities it works! :/
Is it still accurate?
Is unity physics changing constantly at the moment?
It's still in development but I believe everything in the video still works
Hey I am completely new to game development so which video should I see
If you're completely new to Unity start off with the Basics playlist
ua-cam.com/play/PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT.html
After that look through the video list for more beginner tutorials or try following one of the complete simple games I have like Flappy Bird and Snake
ua-cam.com/video/b5Wpni9KPik/v-deo.html
Code Monkey ,thanks a lot
Hi CodeMonkey! What is exactly World.DefaultGameObjectInjectionWorld ?
It's the default world that gets created and what the objects with the ConvertToEntity script get instantiated into.
@@CodeMonkeyUnity got it, thanks so much!
Hi!
Can you do the HAVOK physics as well?
Yes, you can easily swap between the two
@@CodeMonkeyUnity I should of made it clearer ...can you do a video on it..I tried and got weird results lol
The line: return triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps); is showing an issue: the call is ambiguous between the following methods or properties: IBodyPairsJobExtensions.Schedule(T, Simulation, ref PhysicsWorld, JobHandle) and ICollisionEventJobExtensions.Schedule(T, ISimulation, ref PhysicsWorld,JobHandle)
I have posted the issue here: forum.unity.com/threads/itriggereventsjob-schedule-compile-error.877681/ and if you or anyone has the solution, or even a clue....
If I find the solution I will post back.
-------------------------
EDIT 1: I attempted to run the Unity Physics samples, and they too get this error. So it seems it's something to do with my system. I will update again when I find something else.
EDIT 2: Solved. I was using Visual Studio Community 2015 and upgraded to Visual Studio Community 2019 and the conflict was resolved. I have no idea why upgrading the IDE resolved the conflict between two functions... but it worked for me.
-------------------------
Thanks for this video and all of them, they are a great help.
Idk why but 2:18 make me laugh
If Unity started adding this kind of complex features then they will easily lose their users because in the market game engines are coming those make your life more easy day by day.
One name is Buildbox, they will provide big competition in this.
Game Objects and MonoBehaviours aren't going anywhere, if your game has no issues with performance then by all means keep making games as you've always done.
DOTS is simply another option that is extremely performant. There are many (most) games which have limited design due to performance limitations, that is what DOTS is meant to solve.
@@CodeMonkeyUnity Yes I understand your point and you are doing really good :)
I am just talking generally, maybe Unity make this thing compulsory in the future as like they will do LDRP as their default render pipeline.
All i want local wi-fi based multiplayer game.
Doing the networking for games is relatively abstracted from the actual hardware, so learning client/server and p2p architecture will be relevant regardless whether its LAN/WiFi/WAN/p2p - applications dont actually care whether their data is sent via wifi, ethernet cables or some other fake adapter as you might see in a vm. Youd wanna start looking into UDP, bidirectional communication etc
nice one but can we off and on that feature without uninstalling unity dots physics
Is this chinese?
What is chinese?
@@CodeMonkeyUnity dots in general, i didn't understand anything xD
protected override void OnUpdate()
{
CollisionWorld collisionWorld = m_BuildPhysicsWorld.PhysicsWorld.CollisionWorld;
UnityEngine.Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Vector3 rayEnd = ray.origin + ray.direction * 100;
if (Input.GetMouseButtonDown(0))
{
// Vector3 mousePos = Camera.main.Scr
IgnoreTransparentClosestHitCollector collector = new IgnoreTransparentClosestHitCollector(collisionWorld);
var raycastInput = new RaycastInput
{
Start = ray.origin,
End = rayEnd,
Filter = CollisionFilter.Default
};
collisionWorld.CastRay(raycastInput, ref collector);
RaycastHit hit = collector.ClosestHit;
Debug.Log(hit.Entity);
}
}
Too Time consuming,