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.
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.
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.
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)
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.
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
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?
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+
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.
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
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?
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.
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* ?
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?
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4ZYn9sR3btg.html
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.
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.
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
Yup! RU-vid 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
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!
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); }
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!
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.
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?
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.
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 )
If you're completely new to Unity start off with the Basics playlist ru-vid.com/group/PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT 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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-b5Wpni9KPik.html
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.
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.
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.
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.
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
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.