Wait...Why was that so simple?! I thought it was so hard!!!! Thank you so much!!! You actually saved me life 😅🎉
@hightidesed6 күн бұрын
never optimize without measuring
@ivankramarenko16 күн бұрын
нарешті хтось помітив цю величезну діру))
@dragoons_net24 күн бұрын
Very useful! Never realized that FIXED was a way to keep memory call safe, and bringing the possibility to use it all. Thanks a lot
@KiranPurushothaman28 күн бұрын
Fun times. I had to do very similar things for a console game way back in Unity 4.5. Memory management has always been the weakest part of Unity despite being critical for high performance games. What I found (on memory constrained hardware at least) is that you have to avoid using managed memory as much as possible if you’re expecting to have a long running game. Every once in a while, the GC will expand its heap instead of doing a collect, to potentially avoid a GC hitch. However, that heap never shrinks so you eventually end up with a massive managed heap. This means future GC.Collect() runs will take longer and less memory for stuff like textures (managed natively by engine) to be loaded. The solution is to pool your frequently used objects and reuse them. More extreme cases may require you to just write a C lib to manage your memory and just use pointers in C#.
@thodorisevangelakos28 күн бұрын
insanely underrated channel, glad I ran into you
@yuhangli2964Ай бұрын
@21:00 in Set<T>(), why do you need to use foreach to invoke the Action for every type?
@dvsdevАй бұрын
OH WOW. thats a good catch. I posted a bug. :D Should be Listeners[typeof(T)]?.Value(val); // unless this is another bug.
@morglodАй бұрын
you probably got alignment problem in EngineStruct.Thrusters because you should have +1 byte padding It may work slower that AntiGravThruster.Size*8 or even not work on some platforms
@dvsdev29 күн бұрын
For clarity, this example works. Its part of the code I'm actively using. Its possible I have some glitch in the memory because of it, so I'm not ruling that out. Can you give some more detail please? I'm not sure why I need a 1 byte padding on the arrays. I've needed things like that for low level external C APIs, For instance putting the buffer between data elements so it locks a 3 byte structure into 4 bytes because it was compiled that way. But I'm not aware of an actual limitation even on performance for this in C#. I'm not saying there isn't, but I haven't read anything detailing that. Only the offsets I occasionally need are for interacting with external libraries. And for me, I wrap that up under the concept of protocol. When reading the data from cache ram to a CPU register, I'm under the assumption that an exact byte position is used at no extra cost over a 4 or 8 byte chunk of memory. Again, this could be mistaken. AntiGraviThruster is only 40 bytes in size and so only 280 bytes for the thruster byte array. I'm not aware of that being an issue on any system. I believe the modern CPU/Cache RAM setup is loading 64 to 128 byte chunks into cache ram at a time, and so we would exceed a single RAM read, but it will still load the content over all. I'm generally trusting of Unity ECS's 16K chunk size, that it would work on most any hardware that Unity supports. I.e. I'm not planning to exceed 16k for a single memory block. But don't see a reason why I shouldn't go right up to 16384 bytes at a time. Now, I'm not an expert in this either. This is some 30 years of programming knowledge, down to bits, baud, 7400x ICs, minor assembly, and lots of managed code, but no formal education. I have a lot to learn but have done heavy studies into this. I gladly welcome more knowledge. Perhaps something in my response is incorrect, and I would love to get more detail on how I can improve my understanding. If I'm wrong, I'm wrong.
@morglod29 күн бұрын
@@dvsdev usually to get some data into CPU register, it should be word size (4 or 8 bytes). Otherwise OS will copy memory to a temporary buffer. With other things you are right. CPUs have 64bytes L0 cache, so whole object should fit inside for best performance. Also fields should be ordered in their access order, so CPU could walk with small offsets in one direction on data
@dvsdev29 күн бұрын
@@morglod So in that case, since the thrusters are 40 bytes each, and are largely self-contained (- the engine offset), I could put those in a single array of 28 thrusters. I would also move the engine data, which is just a offset for each of 7 thrusters, into an extra variable in each thruster. Going up to 52 bytes. It would take more memory, but each 64b chunk would contain that engine offset, and not need to load it from two different chunks. Thank you for this insight. I'll research this some more.
@morglod28 күн бұрын
@@dvsdev yep; I missed the thing that you have Size*7 bytes so there is no need in padding actually. So I was actually a bit wrong in my first comment. May be I missed and you said it, but this is called SOA (Structure Of Arrays). In some languages there are special decorators/codegeneration that may make from array of structures -> structure of arrays. array of structs: Object objs[10] structure of arrays: struct ObjectsChunk { objField1[10]; objField2[10]; // .. etc } I think all ECS should have codegeneration that will generate optimal structs instead of trying pack it in runtime. Thats the main problem
@dvsdev28 күн бұрын
@@morglod Agreed. everything I'm doing could likely be done faster in ECS, but the goal I'm pushing for is to cut out Unity physics and replace it with my own. By taking control of the memory in the process at the same time, I *should* get more perf out of this. And not have to worry about staying up to date on ECS API changes. This is the latest test from the current physics system. I haven't fully replaced Unity physics in it yet. kzbin.info/www/bejne/b6SVmImperKgp80 - but I've still got plenty to learn and apply. Looking forward to the journey.
@DanVioletSagmiller-xv3fsАй бұрын
Around 33:01 I failed to show how to get the thruster. The problem being that you can't do a fixed inside another fixed. The method to get a thruster from within the fixed engine pointer, is this AntiGravThruster* thruster = (AntiGravThruster*)(engine->Thrusters + (thrusterIndex * AntiGravThruster.Size)); We didn't need to get a pointer, as we were already in one; making "->Thrusters" act as the thruster's pointer offset directly.
@Tymon0000Ай бұрын
That's unfortunate
@eugenschabenberger5772Ай бұрын
This is great, I somehow missed that this is possible. Back in the good old C days. Makes some things so much easier. Thanks.
@Tymon0000Ай бұрын
Do you use CollectionsMarshal and Spans?
@DanVioletSagmiller-xv3fsАй бұрын
I didn't figure out how to get Span<T> and Memory<T> to work in Unity until after this. (Kept trying to import name spaces and library references, but C# couldn't see it) Then I finally found the reference that said turn on Unsafe and it just shows up. :facepalm: However, this is generally how Span and Memory works, to the stack and heap. So I can still achieve all the same things. For instance: List<int> numbers = new List<int>() { 1, 2, 3, 4, 5 }; Span<int> numbersSpan = CollectionsMarshal.AsSpan(numbers); This is similar to fixed(int* iPtr = &numbers[0]) where in this case I'm getting an int pointer. Incrementing an int instead of a byte, you increment by 1 and it moves the length of the type. so if iPtr is address 1000, and you say iPtr + 1, you would move to address 1004.
@Tymon0000Ай бұрын
It would be nice to see an example with game logic and a simple benchmark comparison with DOTS.
@DanVioletSagmiller-xv3fsАй бұрын
At present, ECS would probably be the same speed, because my current code only takes on the index a single car. I need to run a collection of these replace rigid body, and collider physics, specifically, I need to control the memory structure of the environment. And I'm not aware of a way to replace what RigidBody looks at, so I'll be recreating it. This is what I'm writing the Vigilante Racer code to do, and I will run a comparison on performance after. In FPS per car count in the same test environment most likely.
@Tymon0000Ай бұрын
I used it in the past to pack animations into an AnimationController, but now I just make a folder and store my things in tons of folders. :D
@EmanX140Ай бұрын
Very cool stuff! We need more)
@unityproАй бұрын
Interesting insights as always :)
@DVagSagsmellerАй бұрын
Thanks dan, that was great
@TheSudoАй бұрын
These videos are gold!
@adamodimattia2 ай бұрын
What is `MorphAssetFile` exactly? It inherits from ScriptableObject? Thanks
@dvsdev2 ай бұрын
Just my own class. Its part of a design tool to allow me to morph/deform the car into other shapes. It doesn't hold any real meaning to this video. Though once I have the morphing working how I want, I'll probably do a video on that as well.
@zeiksz2 ай бұрын
This info helped me, thank you!
@lanha33852 ай бұрын
walter white but he is cooking game
@vitalypanda96902 ай бұрын
Omg amazing! I didn't know about that
@KavinduDharmasiri2 ай бұрын
Thanks
@dvsdev2 ай бұрын
In this overly shortened version, I missed including where the shake everything concept came from that was in the first draft. Back somewhere between 2005 and 2007, I was teaching game development at a college in Illinois. (Hartland Community College) and had taught the first simple camera shake as a response to losing a life in a galaxian clone. two of the students were working together that excelled, and came up with a different approach, which involved shaking the stars, the ships and the UI all distinctly. It was awesome. From what I had used and taught up to that point, this was a major upgrade, and with a background of black, it had a moment of shock seeing it. (I hadn't even seen a game do that at that point.) After that point, that became the standard of what I taught in following classes.
@dvsdev2 ай бұрын
Just realized, I said "Crazed is one of the members on my discord server", but I didn't mention that the first video clip was from his game. (bad edit, sorry Crazed!)
@kickassets64142 ай бұрын
Thank u good sirm u have saved me from premature aging with frustration
@MikeCore2 ай бұрын
Is this morph script avalible on a github somewhere or something??? looks extremely handy to me
@DVagSagsmeller3 ай бұрын
This isn't Vigilante Racer, where is Vigilante Racer I want Vigilante Racer
@user-mc8ju5tj5g3 ай бұрын
thank for your vidéo
@sanatdeveloper3 ай бұрын
This video deserves hundreds thousands view!
@dvsdev3 ай бұрын
Thank you! I appreciate that.
@helmmmmm3 ай бұрын
Appreciate your lessons! Solid educational content and it helps me as a fairly new developer 👍
@MeshStudio13 ай бұрын
subscribing for this tutorial Thanks
@guicas20014 ай бұрын
Hi, great series. Really enjoying it, would the edge reduction functionality still be needed if we aim for an infinite terrain as you are doing here instead of an island? Thanks!
@nikefootbag4 ай бұрын
Didn’t know about pixabay, some nice music which I assume you can add to a game royalty free too?
@nanxek4 ай бұрын
This channel is a hidden gem! Thanks for your effort. 🎉
@dvsdev4 ай бұрын
Thank you. That means a lot to hear. :)
@user-cx9ti9hv4f5 ай бұрын
The effect are all very cool. But i'am worry about performance on mobile. Do you test it?
@GameDzDev6 ай бұрын
We miss you
@GameDzDev6 ай бұрын
Thanks man
@sadbuttrue6666 ай бұрын
Hey, thank you so much for your video(s). You cover things I need to know and get the information to the point without making hour long videos. However, I also have to say that I find the AI generated images completely distracting. A simple screen capture while typing and explaining would be perfectly adequate and more appealing to me. Thank you and have a nice day :)
@dvsdev3 ай бұрын
That is a good point. I will keep that in mind. Its also good to get these comments on this one. I'm looking back at this one and finding it useful. It was a different style of editing and takes more effort to prepare. But, it worked out much better in the end as well.
@jethrow15146 ай бұрын
you could also expand this and add a normal of the car to it so it looks more realistic with edges etc, but good quick tutorial overall :D
@2pingu9376 ай бұрын
its pretty pathetic watching peoples mob mentalities these days. you truly have no reputation in the community anymore.
@DanSagmiller6 ай бұрын
That's fine. I don't do this for the reputation. It's a nice perk when it somehow helps with something. But I teach to learn. By going through the practice of generating videos to share with others I have to ask myself new questions. I need to validate assumptions. Sometimes to the point of spreadsheets when comparing a variety of affects/results. I used to be a Unity evangelist (unpaid), but now just about any presentation I do gives warnings about Unity as well. My stances have changed. I didn't switch back to Unity on a whim. If you think it damages my reputation and that somehow negates the value of my videos, that is your choice. I'm glad you were able to find value here in the past.
@NadjibBait6 ай бұрын
Guy's trying to finish his game. He says he cannot do it (with the quality and/or time period he wants) in Unreal, and went back to Unity (the tool he masters) to finish the work. There's no "Community", "mob" or "reputation" to uphold here. Just a professional guy using the right tool for the job. Maybe you're still young, but I assure you, with a few years of experience, both in game dev, and in life in general, you'll totally understand his choice.
@adamodimattia6 ай бұрын
I would like to see once announced video about why Zenject isn't always great, you teased that topic in one of your older videos.
@dvsdev6 ай бұрын
That is a good call out. I'm not actually opposed to it, when the team as a whole is comfortable with it. It is a good system. However, Dependency Injection in general is an invisible architecture. Which means that unless a developer already knows what's going on, it is impossible to just open a project with Zenject and understand how references are set. It means any new developer joining will need to learn a new architecture while also learning the domain of the game logic itself. I say this, because Dependency Injection is not a common skillset for Unity Developers, and Zenject/containers even less so. This can be a painful introduction to a project or Zenject, and generally I would want a company to pay for a few weeks of time for the new developer to just get comfortable with Zenject. before having to figure out the project's domain. Now Zenject can be replaced with observables and locators, with the key difference being that the reference information becomes determinable without needing any knowledge beyond basic Unity usage, and a comfortable knowledge of C#. I.e. as long as they have a history developing in any Unity project, they can figure out how the architecture works with little (if any) additional training. Additionally, if this person is junior, then understanding architectures at a level that will make Zenject's purpose comfortable to understand may be a complete blocker to become productive before getting overwhelmed and easily assuming their own abilities are at fault. --- So, Zenject is great, but imposes a team growth challenge that can be painful, especially when teams/companies don't allocate reasonable training time for learning it. I tend to find that most companies do not. My preference is for architectures to be solvable with only Unity and C# knowledge.
@adamodimattia6 ай бұрын
In a company I worked there was an extesive use of Zenject for all the dependencies. At some point we needed to rewrite a vast part of the game to accomodate different backend support and while doing so we totally substituted Zenject with our own plugin based on service locators. Other smaller stuff with more limited scope was handled with observables mostly. The game almost seamlessly transitioned to "Zenject-less". I appreciate Zenject but I am not sure if I had a lot o use for it if it hadn't been for the hiring companies often demand you to know it. @@dvsdev
@Cloud-Yo6 ай бұрын
I agree with you 100% about Unity, but glad to have you back making content w the engine!
@user-dd9is6iy9m6 ай бұрын
I'm confident Unity will be bought out in the next few years.
@jodjadien7 ай бұрын
the W and S keys arent working for me. the W erases the scene and the S brings it back. Do you know how I can fix it?
@dvsdev7 ай бұрын
That is really weird, no, unfortunately I don't. It sounds like something else is going on, like maybe function lock is on and those have different purposes? It appears W/S are both working as is to type the message here, so the problem must be localized to Unity. Maybe you move to far into something, and the scene goes black because you've move past all your scene objects?
@dvsdev7 ай бұрын
Though unlikely, you might want to check your short cut manager to see if anything is overriding these shortcuts. (not sure if its possible, I usually keep things with default settings)
@jodjadien7 ай бұрын
@@dvsdev I think the problem may have been the amount of elements in my scene it had a lot of LOD trees and lighting. It only started happening after I had filled the scene with them. thanks for the reply.
@SnipshotMedia7 ай бұрын
You should probably delete all your old Unity videos then and stop making money off them if you dont believe in what they are doing as a company. Some morals dude...
@DanSagmiller7 ай бұрын
I'm not monetized. I don't make any money from this.