#archived-dots

1 messages Β· Page 172 of 1

dusky wind
#

Luckily, if you need to manipulate Transforms

#

TransformAccess, TransformAccessArray, and IJobParallelForTransform still are around

#

and give you direct access to the transform data

violet cosmos
#

I saw that. I wish there was more of those kind of Jobs that are tightly coupled to the engine

dusky wind
#

They're.. around

#

Animation Jobs are there

#

and I think there's an audio job somewhere

#

but that's about the extent to which you have non-main thread access

#

You'll otherwise need to manually copy data in and out yourself

violet cosmos
#

Yah, I really need to look at how many resulting "commands" I'd have, and the cost to back resolve reference data

violet cosmos
#

OK, another noob question before I dig into this...

Lets say I have MyTransA: IJobParallelForTransform and MyTransB : IJobParallelForTransform

I can just make hundreds of A and B, and intermix them into the same JobHandle?

#

Or, can I just intermix anything in that JobHandle in general, irrelevant of it's interface

safe lintel
#

if you mean combine dependencies, use JobHandle.CombineDependencies(dep1, dep2)

violet cosmos
#

Well, no. Dependencies are something separate. I'm just trying to get an idea of how to layout my data and calls

#

I think I know how I should lay it out. Maybe...

deft stump
#

you want two jobs to do a write operation on the same list of tranforms?

safe lintel
#

what do you mean by MyTransA: IJobParallelForTransform, a native array being used in two jobs?

#

oh transform access array?

violet cosmos
#

Here's my idea for the current work flow:

I'll have a container MyThing, that specifies four jobs, each depending on each other TransA > B > C > D. That container will return a JobHandle for the dependency chain with each precise Job implementation.

Once a frame, a manager will loop over all the MyThing in the game. Maybe a dozen, maybe hundreds, and schedule the MyThing jobs under one JobHandle as Schedule (each MyThing are self-contained)

Each Job MyThing may result in zero or more CommandThing. The manager then iterates over the CommandThing when the whole schebang is complete.

Any CommandThings that are Transform, will get batched under IJobParallelForTransform, but others may be relegated to the main thread due to referencing issues

#

I'm going to try to schedule this early frame, so it's definitely complete before Update(), and use LateUpdate or my own PlayerLoop injection

dusky wind
#

@violet cosmos generally speaking they will allow you to do so

#

But it likely aren't going to be what you expect

#

If both run at the same time

#

The application order or values may not be guaranteed

#

Orrr Unity might have a safety check for it

deft stump
#

unity has a safety check for it

violet cosmos
#

Sorry, what "both" run at the same time?

#

I'm not going to run the CommandThing on Update, fwiw. That needs to be on the main thread, or through IJobParallelForTransform whenever that can be slotted

#

Timing is something that is a big ? in my mind though

#

But if the data gets completed earlier than Update finishing, then it's a win, because then I can apply it when the thread is free

fossil obsidian
#

Is this a good place to ask a question regarding Animation rigging? Since it's running in Jobs?

dusky wind
#

@violet cosmos you can schedule both but not Complete them until all of them are already scheduled

#

This means they will both run at the same time

#

Instead you might want to Schedule one, Complete it, then schedule the second, wait for the frame to be over via Update, complete the second job, and repeat

#

This introduces a sync point

#

And is generally undesirable

#

So pass the JobHandle of the first job into the Schedule of the second instead of calling Complete

#

This schedules the second to run only after the first is done

wheat stump
#

Say some good ways to learn DOTS style codong

#

Coding*

deft stump
#

what you mean dots style coding?

wheat stump
#

I have experience with Gameobject style. I need to know a good starting point to DOTS way

deft stump
#

think database.
entities are indexes,
components are your columns,
systems are your sql statements

wheat stump
#

Okay @deft stump

#

It's as simple as thatπŸ₯°

#

I was thinking wrong the whole time

#

Thanks

stone osprey
#

Im using "event-entities" for the communication between systems... but there something i cant find a solution for... the destruction, each system fires those events on their own, but they should not get destroyed at the end of the frame, instead they should get destroyed after one frame in total... [SystemA, SystemB, SystemC] -> [SystemB spawns Event-Entity] -> [Event Entity travels to System C, SystemA and SystemB] -> [Once it reaches the System it was created by, it should get destroyed]

#

Any idea how we could implement this ?

opaque ledge
#

idk but there is already a 3rd party package for that

mint iron
#

@stone osprey you just need a way to track them. eg. instead of creating the events straight away, queue them into a system that runs at the end of the frame/group. That event system keeps track of the things it has created and therefore can remove them straight away next update before creating new ones.

By having one system that handles it start/end frame, you don't have to worry about the update order on each system using events, that x must be after y so the event still exists etc that would be a nightmare.

The only downside is that a simple implementation would have most events becoming visible in the next frame rather than the current frame. Which should be fine if everything you've written is designed to be async. But it could be done per-group if you really wanted it.

mint iron
#

its also worth pointing out that Tertle's new implementation doesn't use Unity ECS; doesn't create entities or components. Which is probably good if you want super fast performance (if you're doing thousands of events per frame for example for input or something). But if you wanted systems to be able to be reactive / ForEach on the existence of that event data, not gonna work.

stone osprey
#

@mint iron Thanks a lot ! πŸ™‚ That should do the trick... i looked at it, and i actually asked myself how hes able to create those "event-entities" multithreaded πŸ˜„ makes sense now... those arent entities

violet cosmos
#

@mint iron Can that be used outside of ECS, for example in just pure Jobs?

dusky wind
#

@violet cosmos seems like it

#

It's a wrapper around NativeStreams

#

Which is a typical native container for CSP style communication

violet cosmos
#

That might solve one of my issues that we discussed yesterday, about building a queue of commands

dusky wind
#

Depends on the context of what those commands need to be used in

#

If latency is critical, I don't suggest using NativeStreams and overlapping concurrent systems

#

As it may break the cache coherency of your CPU

violet cosmos
#

Yah, still need to tighten up that design... Was kind of hoping it would become apparent later

dusky wind
#

Also if those commands need to be used on the main thread, it's better to build a buffer of commands

#

Copy out the buffer and run the commands in the main thread while the worker threads continue on simulating

#

For which, a NativeList or Queue may be sufficient

violet cosmos
#

Yah, that's what I was thinking too. Keeping it simple, but it's nice to have a tool like that should the need arise

dusky wind
#

NativeStreams really are only useful when you have multiple jobs running concurrently and need to have some streaming communication between them

#

Netcode is a good example of this use case

#

If you've ever written concurrent Go or Rust code, they're the functional equivalents of channels

violet cosmos
#

NativeList is thread safe for writes?

dusky wind
#

I don't think it has a concurrent version no

amber flicker
#

Pretty sure it does - NativeList<>.ParallelWriter?

dusky wind
#

Oh it does

violet cosmos
#

Nice, good to know

dusky wind
#

I just tend not to use it since order can't be guaranteed without sorting

amber flicker
vagrant surge
#
NetCode 0.3.0 is a significant change to the authoring workflows for ghosts. We now automatically generate code per component and no longer do any code generation per ghost prefab. 
#

this sounds very nice

amber flicker
#

Btw do people have ideas about clean ways to do Example scenes & Systems? i.e. I want examples systems to only run for particular scenes and never touch another part of a project. So far I'm thinking [DisableAutoCreation] on the system and ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList in Awake() on a monobehaviour in the scene?

vagrant surge
#

when i looked at netcode and saw that its basically creating a heavily hyper-hardcoded codegen per each archetype that you have networked, i inmediately dismissed it

violet cosmos
#

@amber flicker In ECS?

amber flicker
#

? An example ECS System yes.

violet cosmos
#

If you're doing it in ECS, then there's a tag (I forget which) that you can set on the system that Unity will skip automatically adding it. Then you can inject it only when you need

amber flicker
#

[DisableAutoCreation] - yes sorry, that was my suggestion above - will edit it in.

violet cosmos
#

That's what I would try first, for simplicity sake

amber flicker
#

well one issue is you also need to remove it from the player loop on destroy. Not a big deal just wondered if there were any other approaches I haven't considered.

violet cosmos
#

If it's just ECS, you don't need to worry about that... Inject it through the World

#

If it's in PlayerLoop, then yes... You need to worry about that

amber flicker
#

sure

#

actually does anyone know the api for removing a system from a player loop?

stiff skiff
#

Which version? This has changed a lot since the last few releases

amber flicker
#

0.14 - latest

stiff skiff
#

From what I know, systems arn't in the playerloop, EXCEPT for the root systems

#

which are the init, simul, render groups

#

So if you want to remove a normal system, just remove it from it's parent

#

So someGroup.RemoveSystemFromUpdateList(systemToRemove)

amber flicker
#

Sweet, thanks... I may have been overcomplicating it. Just trying it now

radiant sentinel
#

Hello, can i write to DynamicBuffer from IJobChunk buffer acessor ?

safe lintel
#

yes

radiant sentinel
#

How, with command buffer or i have direct acess to write

#

@safe lintel ?

radiant sentinel
#

@mint iron example just reading value

#

Where is write? I have a problem here to write buffer

mint iron
#

mmm thats a good point, youd have to check to see if making a copy in those methods or giving you access to the source

radiant sentinel
#

yes, do u know, about source access of dynamic buffers accessor? i dose not know is it possible or not.

#

i want refactor arch and i need this information

mint iron
#

looks like it gives you a DynamicBuffer instance so you can just set the value normally.

minor sapphire
#

Hello, I'm wondering if anyone can help me understand pointers a little better.
I found this very interesting code on the dots forum here:
https://forum.unity.com/threads/confusion-about-behaviortree-in-dots.955875/#post-6231711

enum State : ulong 
{
    WALKING,
    TALKING,
    CHEWING_GUM 
}

unsafe struct Node 
{
    State state;
    ulong paddingSoThatDataIsAlignedOn16Bytes;
    fixed byte data[240];
    
    void update(ref Blackboard e) 
    {
        switch(me.state) 
        {
            case WALKING: ((WalkingState*) (void*) data)->update(ref e); break;
            case TALKING: ((TalkingState*) (void*) data)->update(ref e); break;
            case CHEWING_GUM: ((ChewingState*) (void*) data)->update(ref e); break; 
        }
    }
}

struct WalkingState 
{
    float3 targetPosition;

    void update(ref Blackboard e) 
    { /* ... */ }
}
#

It appears to be an example of how to do a behaviour tree with structs.

#

I get that we want to cast the byte array to a WalkingState struct pointer, but why do we need to cast to void* first?
((WalkingState*) (void*) data)->update(ref e)

dusky wind
#

@minor sapphire without knowing the actual return type of Update it's difficult to explain

#

void* is nothing but a fixed memory address

#

It can be casted from and to any pointer type

#

But dereferencing it is a compiler error

#

And holds no type information so you can't do pointer arithmetic on it

#

If update returns a pointer

#

The void* cast may be necessary

#

But if it already returns a void pointer, that's sort of redundant

minor sapphire
#

it looks to me like update returns void, all it does it interact with the blackboard passed in by ref

#

the switch is just casting the byte array to a struct instance, it already knows what type to cast to, but is going through (void*) before casting to its final type

trail burrow
#

@minor sapphire you shouldn't need to cast to (void*) first, but maybe the compiler gets confused cos data is a fixed expression

#

so you need to insert to void* cast to make the compiler happy

#

also this thing

#
unsafe struct Node 
{
    State state;
    ulong paddingSoThatDataIsAlignedOn16Bytes;
    fixed byte data[240];

isn't safe for alignment

minor sapphire
#

Today has been one of those days where you think you know c# pretty well but then see how much you still don't know lol

trail burrow
#
[StructLayout(LayoutKind.Explicit)]
unsafe struct Node 
{
    [FieldOffset(0)]
    State state;

    [FieldOffset(16)]
    fixed byte data[240];

@minor sapphire this is how you align properly

minor sapphire
#

interesting. this is just so when we fetch data we are minimising the amount of memory words we're accessing or something?

trail burrow
#

aligning on 16 byte boundry is fairly odd tho unless you are doing SIMD operations, etc. normally you'll align on 8 byte boundry on a 674 bit machine

#

@minor sapphire depends a bit on exact use case, it's so you don't do un-aligned reads or writes, which are more expensive

#

now, the compiler will usually align thing properly for you, so u dont need to think about it

#

but there are cases where it's needs to be done by hand

minor sapphire
#

right

trail burrow
#

we have built fairly complex AI graphs that all rely on native memory only

#

i can't say i agree with the way it's done in that blog post

minor sapphire
#

Does it use unsafe?

#

After seeing what people are accomplishing with pointers it seems like it's a tool one really should know, so I'm trying to wrap my head around these techniques now

trail burrow
#

yes entire code base is nothing but unsafe code

minor sapphire
#

lol

trail burrow
#

we have our own C# memory allocator, all collections implemented in native memory, etc.

minor sapphire
#

just mark whole solution as unsafe

trail burrow
#

yes πŸ˜›

dusky wind
#

Does anyone know how to get the children entities while using IConvertGameObjectToEntity?

#

I need to add some components to all of the children in the hierarchy

coarse turtle
#

Try this?

// In the Convert method
for (int i = 0; i < transform.childCount; i++) {
  var child = transform.GetChild(i);
  var e = conversionSystem.GetPrimaryEntity(child);
  // Do something with e
}
dusky wind
#

GetPrimaryEntity returns the root...

#

Does GameObjectConversionUtility build it leaf first or root first?

coarse turtle
#

hmm I don't remember πŸ€”

#

You can try a conversion system in GameObjectAfterConversionGroup to try and post process the children

dusky wind
#

I'm actually manually using GameObjectConversionUtility for this

#

@coarse turtle hmmm

#

your method worked

amber flicker
#

I think one alternative (not that you need it by the sounds of it) would be to have a system that runs in the after conversion group that uses the LinkedEntityGroup buffer

coarse turtle
#

oh cool - didn't know a buffer like that existed

dusky wind
#

No longer using the Hybrid renderer, but I got some ECS powered animations in now

#

The fresnel hitboxes are pure ECS

minor sluice
#

sweet. how do the hitboxes follow the transforms at the moment? are the relevant transforms preserved as ecs entities with hierarchical relations (LocalToParent etc)?

dusky wind
#
  • Construct a Playable
  • Copy Player transform from ECS to GameObjects via CopyTransformToGameObject
  • Evaluate the playable for the gameobjects given data in ECS
  • Copy bone transforms into ECS via CopyTransformFromGameObject
  • Use bone locations to drive hitboxes
#

All of which runs in a manually run loop

#

I need to verify whether this is Burst-style deterministic

#

since it leaves ECS to sample animation right now

#

And I need to confirm this doesn't break existing rollback

minor sluice
#

oh, that's neat!
can't say anything about determinism, think fholm mentioned that everything animation related in unity's internal systems is probably not deterministic, but it would be great if this approach works.

dusky wind
#

It's a holdover until the new DOTS Animation system is more stable

#

and I'm not too worried about determinism of hitbox placement all that much

#

realistically the inaccuracies may break determinism much less than if physics were non-deterministic

minor sluice
#

I see,
it is still surprising to me that say gamecube emulator games on dolphin can work deterministically with lockstep netcode (different topic but was just surprised that the approach works, since it works across so many different hardware)

trail burrow
#

@minor sluice because its an emulator

#

makes it easy to make it deterministic

#

you have 100% control over every instruction that executes

#

and yes, correct - none of the unity DOTS stuff is deterministic except for a very specific condition: Burst running on the same architecture + platform, that is deterministic

minor sluice
#

is that a given that that the instructions are translated in a way that they behave the same when translated to different hardware architectures when emulating, or is that more a choice of how the programmers handle the mapping (I guess it's this one?) - with sometimes accepting less accurate but faster emulation

trail burrow
#

@minor sluice well, depends i suppose - you can have have full control in the translation ofc

#

something like a snes/nes emulator is just something that reads a binary file (the game) and mapes it to "something" the current architecture understands

#

and with how fast toadys computers are vs old gaming systems, etc. you have A LOT of leeway

#

"is just something that reads a binary file ..." is a gross simplification ofc

minor sluice
#

Ah I see. haven't ever looked into emulation, but the more modern ones seem highly complex.

trail burrow
#

oh yes it is complex

#

but like... you have full control

tardy spoke
#

Anyone try out Svelto.ECS ? Looking into it, looks pretty cool. Also he has a demo project where he uses it and just does the rendering on Hybrid Renderer using Unity ECS as a simple API layer. Neato.

dark cypress
#

Thanks for sharing, alex. That project seems pretty crazy to take on as a solo dev.

tardy spoke
#

Haha, yeah it's actually really cool, and the example projects have well documented code. Some of the concepts are slightly different than Unity ECS, so there's definitely some learning curve again, but in my mind it could be worth learning as even though the guy built it for Unity game dev for his own studio, it's completely platform agnostic so you could apply it to any C# project. He has a concept called "implementors" that he demonstrates a lot which are basically a service layer between whatever program you're interacting with and SveltoECS, so he uses those to access the components (Transform, Animator, etc) on Monobehaviours, etc.

#

Unity should follow this guys approach. He said (paraphrasing) "It's impossible to keep my blog updated and write about all the details of new functionality because it becomes outdated, but I will keep the core mini samples always updated to the current release, demonstrating the current best practices".

That seems like a reasonable and really good approach when it's impossible to make full docs all the time.

violet cosmos
#

@tardy spoke The best thing you could do for them is to document the code while you're working on it, and let the autogen docs be more complete

trail burrow
#

tbh i never saw the benefit of any of the ECSes which are just systems to structure

#

like they dont provide anything

#

and at that point you might aswell use unitys or build a bespoke system

#

they still rely on unity for anything complex

#

like rendering, path finding, physics, etc.

violet cosmos
#

There is a sense of enforced memory optimization, and structure for multi threaded code. Those kinds of designs are useful

#

Also, Unity is inching towards making things ECS. Unity Physics package for example is full ECS

trail burrow
#

yes, but then just use unitys ecs with all its flaws

#

im talking about third party ECSes like svelto, entitas, etc.

violet cosmos
#

Svetlo has memory layout and "Tasks" for multi-threading, it seems

I'm not one to knock that there's different options

trail burrow
#

I think you're missunderstanding me slightly

#

If you use some third party ecs

#

which still has to hook in unity

#

to perform any complex task

#

what's the point?

#

you're just shoveling data between unity and some unsupported third party ecs for no reason at all

#

like you cant really DO anything with the ecs, so yeah multi threading and such is great

#

but when the physics engine, path finding, etc. that it hooks into

#

doesnt support threaded queries, etc.

#

or any threading at all basically

#

what's the point

violet cosmos
#

Those APIs that Unity provides aren't just trash because you've structured your application code differently

#

It really depends on the application you're developing. Some have a distinct benefit for using an ECS system, others it might actually be a detriment

#

I could see how a Civ like game could benefit greatly from ECS, where a Match Three type game would be more difficult

#

So, if you have the bulk of your work per frame in application logic, CPU side...

trail burrow
#

But then just use unitys ecs? because it can actually benefit from the threading for real as it can perform queries and interact with the rest of the parts of the engine on threads

violet cosmos
#

Unity ECS isn't so... complete. It feels like it's mixed visions. At least something like Svetlo was developed with a clear vision in mind from someone who's out there making games. Unity, honestly should really make games like Epic. Not tech demos, real production games with a the most talented workflow oriented people they can afford

trail burrow
#

idk, i just don't get the point - unless you have some very specific requirements for w/e reason

violet cosmos
#

Trust me, I have a great use case for ECS, but it doesn't work with Unity's system, at least not now

#

But, I'm moving that system into Jobs because.

#

I don't fault anyone for organizing their code in a way that makes their life easier and more matches their desired workflow. That's why we have options πŸ˜„

trail burrow
#

like i see the point of ecs in general ofc, i just don't see the point of these ECSes which dont actually provide anything, other than an architectural pattern which sure is a benefit, but not enough imho

#

we use an ECS, and unitys ecs im sure will be good in the end also

violet cosmos
#

Enforcing structure is what API does

trail burrow
#

The ECS craze just reminds me of the MVC craze around 2005 in the web world, everyone and their cat builds an ECS lol.

#

and maybe 1/100 of them are actually usefull

violet cosmos
#

Possibly, yah. But here's another angle to look at. We have people here who are very new into programming, and yes you could make the argument that they should learn how to organize their code so it's laid out in a memory efficient way.... if a structure provides that through pattern, then it's a win. Said people can get on to making games

Look at any good framework at all, not just ECS. They enforce patterns and structure upon the developer that optimizes the workflow to the needs

#

I'm sure even a quality netcode library does that, enforces a structure that reflects best practices πŸ˜‰

#

Sometimes though, that structure doesn't work. The exceptions break the rule. For example, for me. I can't use Unity ECS or Hybrid in the way it's "designed efficiency", unless I make some serious changes to the application design

trail burrow
#

There is nothing bad with having well architected solutions to problems.

#

I never claimed that either :p

#

But this thing where, i mean i lost track of the amount of ecs:es there are just for unity

#

And they all provide.. basically nothing

#

And most people using them don't need the "performance" they can deliver

#

I say "performance" because most of them don't perform that well tbh

violet cosmos
#

ECS is old as dirt in games... My first experience with ECS was using libGDX in Java years and years ago: https://github.com/libgdx/ashley

#

For libGDX, it added a lot, because that's just a graphics library at it's core

trail burrow
#

Yeah, its the same with MVC is old as shit way before the web craze about it

#

Just people picked it up around than

#

and it became the "in" thing

#

and yeah sure, if you just have a thin rendering api

#

i'm not saying it's wrong to structure your code well

violet cosmos
#

For Unity, ECS adds a way to manage large homogeneous pieces of data

For Svelto, I think the goal for ECS was to make a more maintainable pattern for data/threading

trail burrow
#

i'm saying that this influx of ECS:es, which essentially don't do anything other than bind you to someone elses architecture - they are just not needed

violet cosmos
#

True, but if you're not interesting in writing that, and want to get onto the work of making games, what's wrong? Unity "soft enforces" a pattern too, with MonoBehaviour, GO, and Components

trail burrow
#

What im saying is just, we don't need all the ecs:es and most of them are shit anyway. I have no idea if svelto is good or not, or how it performs or anything like that. I just think they are utterly pointless.

tardy spoke
#

@trail burrow A few potential reasons could be 1. Don't like OOP. 2. Don't need performance of Unity ECS and would rather use GO's. 3. Don't want to wait for equivalent DOTS functionality. 4. Almost every third party package has documentation and is designed to work with GO's.

violet cosmos
#

The guys in the functional side of programming think classes, interfaces and inheritance is pointless too πŸ˜†

trail burrow
#

I use FP every day fwiw, for game dev

tardy spoke
#

They're just a framework... OOP is also a framework, haha.

violet cosmos
#

That's the thing: It's the flavors and options that work for the person/studio. If you forced functional programming on everyone, then someone who would rather work in OOP wouldn't feel like they're working in their most comfortable workflow

tardy spoke
#

A tool to get a job done. For me my own concern is with code architecture at scale since I don't have enough experience to do it properly, I would need to rely on a framework that handles that aspect for me for any type of success, haha.

#

The benefit of ECS would have the same affect as React had on web dev stuff. It will create a form of standardization which, even if the approach is imperfect, helps unify efforts between devs because at least there are some standard practices.

#

If I was running a game studio, I would enforce the usage of ECS simply to keep everyone on the same "page" without needing a ton of lengthy discussions because there are literally limitless options to architecture. Some limitations are great, especially when it comes to actually getting things finished.

trail burrow
#

ECS is a pattern, React is an implementation of MVVM isnt it?

#

And again, im not against ECS.... we use a custom linear memory ecs ourselves

tardy spoke
#

You could also write a program in binary, but you have to draw a line somewhere, right? I feel there is a continiuum of abstraction and the appropriate tool for the job at hand, and the most appropriate tool will definitely vary from person to person.

trail burrow
#

You are missing the point im trying to make, I'm just saying this influx of random ECSes is not needed, not saying we don't need a good architectural pattern to deal with game-dev in general.

#

I'm not convinced ECS is "it", but it offers some clear benefits in terms of structure so for now that's what we're doing

tardy spoke
#

Oh, if you're telling me everything has already been invented and programming trends just cycle, yeah totally agree.

trail burrow
#

GitHub has like 30-40 unique ECSes just for unity

tardy spoke
#

No, it definitely won't be the last trend and something else trendy will come along, haha. Or technology will change and make it's approach irrelevant, haha.

violet cosmos
#

I think a lot of those ECS systems for Unity are really just fighting against the MonoBehaviour.Start/Update paradigm, that fits their own flavor

tardy spoke
#

However, for me, I much prefer the ECS approach because I find it easier to learn things when the structure is more ridgid. OOP has evolved quite a bit over time and there are a lot of "exceptions" to it that I find make it difficult to really learn "well". It would take a long time.

It's almost like learning the English language (exceptions and "magic" everywhere) compared to learning something like Spanish (extremely few exceptions to grammar rules across the entire language).

trail burrow
#

What people call 'OOP' now a days isn't really how it was originally intended, but tbh that's another discussion

tardy spoke
#

Yeah, I agree, totally.

trail burrow
#

the whole inheritance-chain-interface-etc. thing is just stupid

amber flicker
#

I basically agree with @trail burrow - I'm glad those projects exist and I wouldn't be surprised if Sebs Svelto has some better ideas in it. I'm not going to install any of them though.

tardy spoke
#

But to me I feel that since OOP keeps bending it's own rules to basically implement functional programming practices... why not just do functional programming, haha.

dusky wind
#

Haha, if y'all think that level of fuckery is bad

trail burrow
#

@amber flicker They are, essentially - useless. They give a slightly different way to structure your code... ugh so what is all i'm saying.

dusky wind
#

Y'all should see the hoops people go through to get mutability in Haskell

trail burrow
#

They serve 0 purpose

#

@dusky wind I think ur missing the point of the discussion we're having :p

tardy spoke
#

Well, the thing I like about Svelto is the platform agnostic nature of it means it could be reused, so you're not just learning a bunch of custom syntax for a "one off" necessarily. I would prefer to learn Unity ECS as it will evolve and increase in value, but I feel right now svelto may be a good train off to learn because you learn a lot of the concepts, and you're not restricted by waiting months/years for DOTS functionality to catch up. Realistically you could make a full featured game in Svelto today, but not with DOTS yet.

trail burrow
#

@tardy spoke you dont really make a 'game' in svelto tho, you strap svelto on top of unity and make your game in unity go/mb system

tardy spoke
#

Yeah, totally

trail burrow
#

its just structured differently vs how it would be in normal unity

#

which is why i think it's basically useless

dusky wind
#

No it makes plenty of sense, structurally ECS doesn't necessitate better code.

#

Which is why it's called DOTS

tardy spoke
#

But that's actually what I'm looking for. Ever since I tried putting a DOTS animation in a subscene, I realized it would be quicker to learn an entire new system that uses GO's than for me to figure out how to "hack" DOTS into working for my needs. Massive chances I'll run into other issues as well that have already been solved in GO world.

dusky wind
#

ECS for unity and many other engines is really just a way to more generically apply data oriented design

dusky wind
#

Though you can have ECS without it

trail burrow
#

@dusky wind we're talking about all these third party ECS:es for unity, which basically serve no purpose IMHO.

#

not unity ecs

#

at least me alex/benjamin were

#

anyhow, convo derailing fast and i think i said all i had to say πŸ™‚

#

or feels like it will derail

dusky wind
#

Ehhh, I've messed around with Entitas and several other codegen based ECSes

trail burrow
#

They serve no purpose imho

dusky wind
#

They definitely don't immediately show good results when there's a lot of global behavior.

tardy spoke
#

They allow people familiar with ECS systems to implement their knowledge in Unity. Isn't that valuable enough? Even if they have no performance benefit?

dusky wind
#

But to say they have no purpose is a overly broad statement

tardy spoke
#

They may not be valuable to a lot of people, but to some people they would be extremely valuable. Like in my case - I can't really make the game without it.

trail burrow
#

my POV more comes from the fact that they are just strapped on top of unitys default systems and offer basically nothing other than locking u into some architecture that you dont have control over

#

but anyway said that like 10 times now so

#

Β―_(ツ)_/Β―

tardy spoke
#

So you just don't like frameworks in general?

#

That's cool. I understand both sides of that.

trail burrow
#

@tardy spoke if they provide something of value sure

rancid geode
#

I don't quite understand why to use a third-party ECS due lack of features in Unity's ECS, if in the end you will need to find a way to communicate the GOs with that third-party api just like you would with missing Unity ECS features in hybrid

dusky wind
#

Some of them are divorced entirely from Unity's default systems

trail burrow
#

@rancid geode bingo.

dusky wind
#

And some run entirely outside of Unity

trail burrow
#

yes, ours can do that also

coarse turtle
#

yea you'd probably just get a frankenstein like system architecture which gets difficult to follow along with third party systems sometimes

trail burrow
#

but it actually PROVIDES something you cant get with unity

#

not just a fancy archicetural pattern

dusky wind
#

So some do have some added benefit of running completely independently of the engine

trail burrow
#

that someone obessed about over and over

rancid geode
#

If you intent is to not stick to Unity, then it is a valid point @dusky wind, but for someone who alredy settled the engine to be used, why then?

dusky wind
#

The idea is mostly for using Unity as a frontend

trail burrow
#

@rancid geode running outside of unity has massive scalability benefits when dealing with server hosting/networking

#

@dusky wind this what quantum does, client side frontend

tardy spoke
#

Svelto ECS system is designed to interact with GO's. Unity ECS seems like it really isn't designed well for that, though you could "hack" it into working.

dusky wind
#

Yes, and that has a provides a decent common structure.

tardy spoke
#

Well, actually

trail burrow
#

but the benefit of most of these ECS to be able to run outside of unity

#

is useless

dusky wind
#

Like you admit that these frameworks can be used to isolate game logic from the actual engine

trail burrow
#

because they cant make a game

#

without unity anyway

dusky wind
#

But see no purpose in them?

violet cosmos
#

Dunno, having worked on quite a few large projects across teams, I feel architectural patterns are important

trail burrow
#

@dusky wind no you missunderstood

tardy spoke
#

@violet cosmos totally agree

trail burrow
#

@dusky wind it is a benefit to be able to run outside of Unity, if the framework can handle that and allow you to lift your entire game outside of Unity. But none of these third party ECSes can do that because they are bound to unity because they use all of unitys features for physics, navigation, etc.

#

Yes sure some games you can build without that, but not a lot

#

So then there's no point again.

dusky wind
#

I do agree that these frameworks do need to provide a significant win over vanilla Unity other than just structure

trail burrow
#

Because sure they CAN run outside of unity, but if you want to make a game... they cant

tardy spoke
#

My question is if you feel that the solution of learning a third party ECS is not good, what would your solution be? And would your solution change if you were bad at OOP? Haha.

dusky wind
#

But to say that they inherently have no value is an oversimplification

trail burrow
#

@dusky wind yeah sure, it is - but not too far off from the truth

tardy spoke
#

I understand if I was godly at OOP I would definitely not go this route, but that's not the case.

violet cosmos
#

As someone trying to limit my use of MonoBehaviours.... There's a benefit. I'm sure we've all read the "10000 Updates" article

trail burrow
#

@tardy spoke well i have my own ECS i build all my games in, but its actually a standalone system which doesnt depend on unity for ANY game logic.

tardy spoke
#

So your solution for me is to become you and build my own ECS?

#

That may be difficult

trail burrow
#

that's not what i said πŸ˜„

tardy spoke
#

I will start with mimicking your movements and speech patterns and we'll go from there. Seems like learning an ECS may be easier though.

trail burrow
#

Β―_(ツ)_/Β―

rancid geode
#

@rancid geode running outside of unity has massive scalability benefits when dealing with server hosting/networking
@trail burrow well, yeah, this is a valid reason, but this is due your project needs that, not due "Unity ECS is lacking too much"

dusky wind
#

I'd always say evaluate the project requirements before deciding on a solution.

trail burrow
#

@rancid geode not talking about a specific project here or anything, just said thats a proper benefit.

dusky wind
#

In this industry, there really is no one size fits all

trail burrow
#

not just "oh i can structure my code a bit differently but still nailed down to gameobjects old ball and chain" πŸ˜„

tardy spoke
#

@dusky wind yeah, agree. You also have to evaluate your own skill levels and weaknesses, haha.

rancid geode
#

Svelto ECS system is designed to interact with GO's. Unity ECS seems like it really isn't designed well for that, though you could "hack" it into working.
@tardy spoke I find it quite the opposite, Svelto ECS is designed to interact with any engine, Unity ECS is designed to interact with GO

the work you will have to integrate GOs with Svelto ECS will not be that different (if not bigger) than with Unity's ECS

tardy spoke
#

GameObjects aren't really a ball and chain, I mean zillions of games were made with them hahah

#

I don't really need the performance. What I need is a finished game.

#

I can have a really fast nothing, or a slower, but hopefully playable something.

#

@rancid geode yeah, it is designed to be agnostic, that's true. UECS can definitely interact with GO's, but I feel you'd have to build a bit of additional tooling unless I'm missing something about a clean direct way to interface with a GO right from a System.

rancid geode
#

Currently, it is possible to do a full ECS game using only existing GO stuff (without Hybrid Renderer and Unity Physics, for example). You probably won't have performance gain, neither multi-threading, but your code would be well structured already (and once the missing features lands, you could migrate little by little too)

trail burrow
#

you're just creating more work for yourself strapping some third party thing on top which provides almost nothing

#

making most of your code and workflows

#

incompatible with various assets, etc.

rancid geode
#

I think the problem is when we try to do UECS stuff with GO stuff with performance in mind, which is when we start to hack the system to try to fit them together

#

Fitting UECS with GO is as easy as using Convert & Inject and using AddComponentObject when needed

dusky wind
#

There are... A few more quirks

tardy spoke
#

Hmm, maybe my best approach would just be UECS with GO's and then adding in the DOTS functionality as it's released

trail burrow
#

if there was one word i would descrive the unity ecs with it's "quirks" yes @dusky wind lol

rancid geode
#

And the bonus part is that it works with existing Asset Store assets too without (much) additional work

tardy spoke
#

The only problem is that you have to use GO's until basically ALL the entities DOTS shit is done lol

dusky wind
#

But yes it's not as hard as it is in most other GO-wrapping frameworks

rancid geode
#

If you are used to event-driven architecture it is even easier to join those two "worlds"

#

Hmm, maybe my best approach would just be UECS with GO's and then adding in the DOTS functionality as it's released
@tardy spoke this is what I have been doing to be precise

dusky wind
#

I'm not sure how well they've standardized the use of Disabled wrt linked GOs

tardy spoke
#

@rancid geode do you have an example of on of your Systems accessing a GO directly?

#

Or as "easily" as you could?

#

What was your solution for that? Is it fairly clean?

rancid geode
#

I can see to provide some for you, yes, most of my stuff is under NDA so it is hard to just pull something right away haha

tardy spoke
#

Yeah, no worries, just curious haha

dusky wind
#

I don't remember exactly how to do it, but I distinctly remember it involves IManagedJob

#

Or something along those lines

#

And just fetching the GO/components via AddComponentObject and ComponentDataFromEntity

#

Might have changed in later versions of Entities

tardy spoke
#

if someone has a clean solution I'll do it, but my thinking is I always seem to just run into weird stuff with DOTS / hybrid, and I think in terms of actually trying to get something "done" it may not be the best approach at the moment.

I also won't even be able to use subscenes for my main world with GO's which was pretty much 70% of the reason I wanted to use DOTS in the first place, haha.

dusky wind
#

Tbf

#

I stopped using Hybrid Renderer

tardy spoke
#

Yeah, that's what I'm talking about

dusky wind
#

And am just using the GOs to render

tardy spoke
#

Like you have to go full GO or full DOTS, and DOTS simply isn't complete, so it just makes things pretty awkward for development.

dusky wind
#

But other than that and animation sampling

#

Everything I am doing is in ECS now

rancid geode
#

@tardy spoke here for example would be an GO -> Entity interaction

    public sealed class FpsCounterSystem : SystemBase
    {
        public delegate void FpsUpdateHandler(int fps);

        public event FpsUpdateHandler OnFpsUpdated;

        private int _elapsedFrameCount;
        private float _elapsedTime;

        protected override void OnUpdate()
        {
            _elapsedTime += Time.DeltaTime;

            while (_elapsedTime > 1)
            {
                _elapsedTime--;
                OnFpsUpdated?.Invoke(_elapsedFrameCount);
                _elapsedFrameCount = 0;
            }

            _elapsedFrameCount++;
        }
    }

    public sealed class FpsText : MonoBehaviour
    {
        public string FpsTextFormat = "FPS: {0}";

        private Text _text;

        private void Awake()
        {
            FpsCounterSystem fpsCounterSystem = World.DefaultGameObjectInjectionWorld.GetExistingSystem<FpsCounterSystem>();
            fpsCounterSystem.OnFpsUpdated += HandleFpsUpdated;
        }

        private void Start()
        {
            if (TryGetComponent(out _text))
            {
                _text.enabled = false;
            }
        }

        private void HandleFpsUpdated(int fps)
        {
            if (_text == null)
            {
                return;
            }

            _text.enabled = true;
            _text.text = string.Format(FpsTextFormat, fps);
        }
    }
tardy spoke
#

It's almost like the best approach right now is "learn ECS, but make your stuff in GOs with ECS in mind, and plan to migrate it over in a year or so", haha.

dusky wind
#

I just have a simple few systems that import/export between GO and ECS state

violet cosmos
#

Yah, that's my plan for the systems that I'll use Unity ECS for

dusky wind
#

For me, ECS is the real game simulation

violet cosmos
#

They will just be organization systems, with many inputs and few outputs

dusky wind
#

GOs just display the view of the data in that simulation

violet cosmos
#

But, depending on how my learning with Jobs goes, may not be necessary, because I feel like you have more control over pure Jobs in the frame lifecycle

hollow sorrel
#

@dusky wind you were able to check the size of your world, right? how'd you do that?

dusky wind
#

@hollow sorrel SerializzeUtility

hollow sorrel
#

ah

#

makes sense

dusky wind
#

Then just record the size of the buffer

#

Realistically it's bounded by 16KB * the number of chunks in the world

#

Not a particularly good solution when you have a lot of singleton archetypes

hollow sorrel
#

seems serializeworld also serializes blobassets tho, dunno how i feel about holding a copy of each static blobasset for every rollback frame

trail burrow
#

does it serialize the entire chunk no matter what?

tardy spoke
#

@rancid geode thanks for the example, I'm studying it, haha

hollow sorrel
#

would it be better to just hold an int pointing to a blobasset? thonking

dusky wind
#

@hollow sorrel oh for rollback

hollow sorrel
#

seems kinda roundabout

dusky wind
#

I just make dummy Worlds

hollow sorrel
#

since a blobassetref already basically is a pointer

dusky wind
#

And use EntityManager.CopyAndReplaceEntitiesFrom

hollow sorrel
#

ah

#

so for rollback you don't serialize

dusky wind
#

Nope

trail burrow
#

how expensive is that

#

?

#

CopyAndReplace...

#

thing

dusky wind
#

It's a MemCpy

hollow sorrel
#

gotcha

trail burrow
#

well its several

#

plus some additional logic i assume

dusky wind
#

Takes max 0.1ms on my machine for a small 220kb world

#

I havent tried scaling it

#

It's negligible compared to full serialization or the simulation latency

trail burrow
#

you do this how many times per frame? or only on rollbacks when you reset to a verified state?

dusky wind
#

I do it once per game tick

#

To save multiple copies of the world, one for every game tick

#

Then once again when rolling back

trail burrow
#

you do it once for every predicted frame also?

dusky wind
#

Yes

trail burrow
#

basically a ringbuffer of worlds

dusky wind
#

Yep

#

128 game ticks is about 27MB of memory

#

Less than a 1024x1024 uncompressed texture

#

So I don't particularly worry about the memory usage

trail burrow
#

nah thats usually fine no matter

#

because u will have porlbems with rollback perf before u run out of memory

#

on any modern machine

#

i.e. its too much data to copy

dusky wind
#

I haven't tried this yet with managed components

#

But it worked perfectly when in Pure ECS

trail burrow
#

we moved away from the ring-buffer model

#

it's too slow for more complex games with a large game state

#

but for fighting/brawler/etc absolutely it's a good way of doing it

#

easy to implement, rock solid

dusky wind
#

@hollow sorrel I'm not sure if I showed you this already

#

I'm under an anti-NDA

#

So here's the code for my world pool and rollback world save/load

hollow sorrel
#

lol anti-NDA

#

oo you actually have a bunch of worlds, didn't know if they were lightweight enough

dusky wind
#

They allocate GC

#

It's a class not a struct

#

So I pool them

#

For what it's worth

hollow sorrel
#

ah makes sense

dusky wind
#

And when you make them, they come without any systems

#

So it doesn't simulate, ideal for a snapshot

trail burrow
#

how do you deal with reconnects or late joiners?

#

just full re-sim?

dusky wind
#

Late joiners are not a problem for my game genre

trail burrow
#

reconnect is the same problem-ish

dusky wind
#

Reconnects I'm considering sending them a replay file

#

I just implemented replays

#

Assuming determinism

#

They're less than 100KB for a minute of gameplay

trail burrow
#

that seems like a lot

dusky wind
#

So I don't think it's unreasonable to just sent them the full input history after a certain frame

hollow sorrel
#

why not just latest snapshot + inputs in between

dusky wind
#

Most of these games is less than 5 minutes

trail burrow
#

4 players 100kb for 60 sec?

#

but yeah still

dusky wind
#

Yeah

trail burrow
#

not a lot of data

dusky wind
#

Includes checksums for each frame

#

But realistically any long term disconnect is likely just going to boot the player's back to the lobby

#

It's fast paced enough that I don't expect players to get hung up on disconnect issues

#

Only when it happens repeatedly

#

Which I think is mitigatable outside of the core game

violet cosmos
#

Crap, well ran into my first problem with generalizing a scheduling system...

If I have a class that has a method like public IJob CreateJob(foo,bar); I can't schedule it because the Jobs API complains it doesn't have a type

dusky wind
#

@hollow sorrel haha, the game state is already 200+kb

#

A snapshot is worth 2 minutes of gameplay

violet cosmos
#

I feel like there's some way I can mark the struct to do this....

hollow sorrel
#

true but i imagine loading would be faster than resimulating the game

dusky wind
#

Also the snapshot includes local information like pointers

#

Which will probably segfault if I loaded it elsewhere

hollow sorrel
#

ah

#

yea i'm trying to avoid any local info like pointers in sim world

#

and if there is then it should be rebuildable

dusky wind
#

@violet cosmos back when jobs came out I figured out how to make my own custom jobs

violet cosmos
hollow sorrel
#

@trail burrow what is the alternative to ringbuffer

trail burrow
#

@hollow sorrel internal pointers was a huge issue

dusky wind
#

But it may take me some time to dig it up

trail burrow
#

until we solved it once and for all with the allocator

#

i mean not an issu eas it would break the games, but having to deisgn everything w/o internal pointers is a PITA

#

rollback netcode and simulation for figthing game is easy because their structure is clean without too much internal complexity

#

but for more complex games, it becomes a PITA

hollow sorrel
#

yea i'm designing with indirection everywhere and it is kinda a pita

dusky wind
#

I'm assuming y'all just used integer IDs that were universally consistent

trail burrow
#

before the custom allocator yes we used that

#

but its just a pain to deal with on a large complex codebase

dusky wind
#

I can see why, haha

hollow sorrel
#

what's the alternative to ringbuffer that is somehow faster

trail burrow
#

just using 2 states, one verified and one predicted

#

and dont save any inbetween states

#

say im on Frame40 verified and Frame50 predicted

dusky wind
#

Your simulation needs to be pretty darn fast for this though

trail burrow
#

when i get all input for Frame 41, i simulate that on the verified state

#

and then copy it over to predicted, and re-run the sim

#

to catch up again

#

its faster than saving a ring buffer

#

cos theres a lot less memory to shovel around

dusky wind
#

For large worlds, I can see that yeah

hollow sorrel
#

ah i see, so result is you're always resimulating max frames right

trail burrow
#

no

#

i re-sim whatever is incorrectly predicted

#

or rather to whatever tick is incorrectly predicted

#

its much faster for large worlds, as you will get to a point where the actual shoveling of memory around is a substantial part of ur frame time

#

espc on mobile

hollow sorrel
#

ahh

trail burrow
#

but its a more complex setup

#

the ring buffer solution is what we used originally

#

because its a clean, clear system

#

very easy to reason about

#

but it has drawbacks when u start getting into larger game states

dusky wind
#

Do you know at what threshold did it start overtaking the other parts of the loop?

#

Size wise?

trail burrow
#

and we have people building 64 player games on quantum, with tons of NPCs, players, etc.

#

@dusky wind on mobile its already around the size ur at now

#

on pc its at around 1mb iirc

dusky wind
#

Interesting

trail burrow
#

maybe 2mb

#

im working on another idea, which is just a prototype, which uses copy-on-write semantics and immutable memory to not ever have to copy any memory at all... but that's just a... hobby prototype for now

#

nothing thats considered for quantum itself

dusky wind
#

Yeah that was my first thought

#

When you mentioned high write volume

trail burrow
#

it also gives "automagic" safe threading

dusky wind
#

LMDB does something similar for it's storage engine

trail burrow
#

yeah, but we operate on such tight timings that a lot of the traditional 'best practices' to scale systems like this goes out the window

#

i've read more whitepapers on this stuff than i'd like to admit lol

dusky wind
#

I'm not sure if the immutable memory will work well with data oriented systems though

trail burrow
#

i have a twist on it :p

#

which allows me to keep linear memory

#

dod-style

dusky wind
#

It definitely seems like a fast way to invalidate your cache lines

trail burrow
#

it does work, i used it for a prototype mmo backend

#

it performs very well, but it imposes a bunch of annoying architectural restrictions

#

on how you design the game

#

so i dont think its generally applicable for "any game"

#

but some types of games could benefit from it

#

if i ever get to finishing it into something useable

#

@hollow sorrel are you designing ur own predict-rollback thing?

#

or just curious

#

this is the third or 4th day we've discussed stuff like this

hollow sorrel
#

yea would like rollback multiplayer in the future for my lil metroidvania
but also i think determinism would help with doing time shenanigans
e.g. time rewinding/forwarding as a mechanic

trail burrow
#

yeah there's a few fun benefits

#

like how you can do perfectly slow motion stuff even in MP, etc.

#

and mess with time and all kinds of fun shit

hollow sorrel
#

which is something we used to do in regular unity but it basically the most inefficient game you could imagine
idk if i ever showed you phased but it's a project from like 4 years ago that i was making with skarik
am rebuilding it now with actual proper architecture instead of gamejam architecture

dusky wind
#

Haha

violet cosmos
#

Uff, that's super annoying.... .Schedule isn't part of the IJob interface, it's an extension method. Not sure how that solves anything, because Execute is part of the interface and obviously doesn't suffer from unboxing issues but the things you run on the main thread, Run and Schedule aren't

dusky wind
#

That was is exactly what I was designing for too

#

One of my characters is supposed to have a time stop on their kit

trail burrow
#

im fiddling on a little card game on the side, which uses fully immutable data structure for entire game (doesnt need to be efficient or rollback ofc) so i have a full history on entire game and can go back in time and mess with things, etc.

dusky wind
#

Well, for everyone except thrm

trail burrow
#

it's fun - not in quantum tho, just built that on the side standalone

dusky wind
#

@trail burrow played 5D chess?

trail burrow
#

i have not

dusky wind
#

It's cheap on Steam

#

Does a lot of that, but with chess

trail burrow
#

i dont have much time to play now a days, but will check it out

dusky wind
#

Time travelling chess game

trail burrow
#

(company to run/wife/two kids/renovating house)

#

busy busy πŸ˜„

#

but yeah

dusky wind
#

Close to the same idea as your card game

trail burrow
#

will check it out

hollow sorrel
#

yea we basically had a full history as well but that was a time when i had no clue about memory management and it was just piling up
we built our own 3D tilemap solution as level builder, think sorta like minecraft
but each single tile would take like 100+ bytes memory lmao

dusky wind
#

Sounds like it could accrue fast

hollow sorrel
#

main problem was we're storing all 6 faces of each voxel since could be a different sprite for front than back/top etc

#

thought of a more efficient solution for that now still gotta implement tho

trail burrow
#

god we dont have any recent videos of anything made with quantum that shows the time-fuckery stuff

#

but yeah its absolutely a benefit

#

i usually say that building a predic/rollback deterministic game is like building a couch co-op game that automatically works online

#

and it's a HUGE benefit not having to really think about networking, we have a lot of studios which might not have a dedicated network programmer on staff and they can still pull of insanely good games, with tight AF mp

#

just because... u dont need to do shit to get mp

hollow sorrel
#

yeah i don't want to bother with making sure each seperate action has seperate networking code for it to make sure the other player sees it.. i just want to make game and have other person see the same thing

trail burrow
#

yup

hollow sorrel
#

one other massive benefit i been thinking about

#

is for testing you can just play your game once, store all the inputs of that playthrough and next time you just hit play on your robot and check if end position/win condition is still achieved
need to redo that if main stuff changes ofc but still

#

should save a lot of time making sure level still works as intended

trail burrow
#

yes

#

we have people doing that

#

espc once they get pretty far into dev of the game

#

to be able to verify everything still works properly

#

they have huge piles of replays

#

with pre-recorded start state, input and end state

#

this can also run outside of unity

#

so easily hooked into a test runner, tooling, etc.

hollow sorrel
#

yeah

trail burrow
#

the largest benefit is not having to think about MP at all in the gamelogic

#

i could never go back to doing it the old way

hollow sorrel
#

i feel like even if a game is fully singleplayer i'd prob still try to make it deterministic tho, at least if you already have basics like deterministic physics etc built once
the costs aren't that big compared to the benefits of debugging, being able to use it in game mechanics, is nice for speedrunners too since it's always same result, etc

#

and having a seperate render/sim loop is also huge

trail burrow
#

    public override void Update(Frame f, ref Filter filter) {
      var input = f.GetPlayerInput(filter.PlayerLink->PlayerRef);
      var thrust = (FP) input->Thrust / 100;
      
      var rotation = default(FPVector3);
      rotation.X = -input->Pitch;
      rotation.Y = input->Yaw;

      thrust = FPMath.Max(thrust, rotation.Magnitude / 10);
      
      var fwd = filter.Ship->Engine.EngineThrust = FPMath.Lerp(filter.Ship->Engine.EngineThrust, thrust, f.DeltaTime * 5);
      filter.PhysicsBody3D->Velocity += filter.Transform3D->Forward * filter.Ship->Engine.EnginePower * fwd * f.DeltaTime;
      filter.PhysicsBody3D->Velocity += filter.Transform3D->Right * filter.Ship->Engine.RollPower * input->Roll * f.DeltaTime;

this is some code from some random space ship prototype i made

#

and that's... it right

#

there's no replication of state, no manual prediction, no nothing

#

@hollow sorrel tbh making something deterministic, espc if you need like physics and navigation and shit is a huge task

hollow sorrel
#

yeah but that's stuff you only have to do once right
i'd prob do that anyway because i try not to use unity stuff

trail burrow
#

depending on what game ur trying to build

#

making like a deterministic 3d physics engine

#

is SO. MUCH. WORK.

hollow sorrel
#

hah i guess so

#

hole in the market there tho
0 CCU quantum package aimed at singleplayer games

trail burrow
#

we have one person on each part now a days

#

of the engine

#

they had to, legitmately, come up with custom algorithms for various collision checks because of the lack of precision in fixed point

#

so at least 2 completely new ways of doing collisions checks for some volumes had to be developed

hollow sorrel
#

yea i imagine there's a lot of cool tech in there

trail burrow
#

one of them was sphere<>ray, where the classic techniques you can read about online dont work when distance between sphere and ray origin is too large

#

or basically the "way" to do that check, does not work in fixed point

#

i know there was another one but it slipped my mind which it was

hollow sorrel
#

if you started to make a singleplayer game today tho

#

would you go the normal route

#

unity way

#

or use quantum

trail burrow
#

depends on what it is

#

the card game im making i did not use quantum for

#

i wrote a new framework for that

#

but card game doesnt need any fancy physics or shit

hollow sorrel
#

tru

trail burrow
#

thats also mp, co-op at least

#

but yeah idk tbh

#

depends on the game

#

if i could make it in quantum i would

#

because it gives me 'free' mp

#

when/if i want it

hollow sorrel
#

yea makes sense

trail burrow
#

we plan to build a PC multiplayer fps

#

in quantum

hollow sorrel
#

wow a competitor to FPSSample

trail burrow
#

ye

hollow sorrel
#

that's pretty cool tho, a lot of advantages to building full games with your own tools

#

assuming it's more than a sample

trail burrow
#

we'll see what it ends up as

hollow sorrel
#

do you have a seperate team for it or is it same quantum engine ppl

#

could just have a buncha teams for seperate games

#

infinite growth

trail burrow
#

separate team doing fps stuff

hollow sorrel
#

nice

#

but yea just to steer it back to DOTS talk i don't think i'd bother with determinism if it wasn't for DOTS, even though a lot of it isn't deterministic
making deterministic tools with ecs architecture is a lot easier than the monobehaviour mess we had before

trail burrow
#

yes agreed

#

the memory layout u get from dod

#

makes it a lot easier

hollow sorrel
#

still not happy with my current render/sim seperation tho
right now i'm just querying components that i want to copy data from in the sim world and copy it into render world
but that's a lotta boilerplate and not sure if efficient either

#

dunno what alternative would be tho

trail burrow
#

Yeah idk how to set that up

#

With dots ecs

median mesa
#

Hey there. Anyone knows why the Unity Physics doesn't appear in my package list?

#

I enabled preview packages in advanced settings

median mesa
#

Thanks @tardy spoke I thought I was going mad

proven minnow
#

If I have ConvertAndDestroy and OnDrawGizmos on an object, it doesn't draw after a play-stop cycle until I select it in the hierarchy - does this happen to anyone else?

safe lintel
#

convert and destroy wont work with ondrawgizmos during runtime, ondrawgizmos is a monobehaviour function(which gets destroyed when you convert and destroy the gameobject into an entity)

proven minnow
#

@safe lintel Sure, but once I stop the game, the gameObjects come back, right? When they do, they don't draw.

#

I just want them to draw when the game is stopped, (impostors for where enemies are supposed to be summoned)

safe lintel
#

oh, well not sure in that case, you are definitely using OnDrawGizmos and not OnDrawGizmosSelected?

amber flicker
#

I saw in the other channel @proven minnow 's sure about that - main other thing I can think of is it's some static array and you have domain reload disabled?

#

otherwise it could well be a Unity bug

violet cosmos
#

Soo.... What's the way to pass data from one job to another?

I thought I saw that jobs that are in a dependent chain could do that, but maybe I just imagined it. All the examples I see are using the main thread

trail burrow
#

@violet cosmos assign them both the same collection and put a dependancy between them

#

job 1 put data into collection, job 2 consumes it

violet cosmos
#

I'm not seeing any good examples how to reference Job1 from Job2, outside of the main thread

trail burrow
#

no i mean give them accces to the same block of memory frmo the main thead

#

before u schedule them

#

job1 writes to it, job2 reads from it

violet cosmos
#

Ahh, so....

var data = new NativeArray<int>();

var job1 = new Job1 {
   Fill = data;
};
job1.Schedule();

var job2 = new Job2 {
    Use = data;
};

job2.Schedule(job1);

??

trail burrow
#

ye

violet cosmos
#

Gotcha, didn't realize it had back references to Unity.Collections types declared on the main thread

tardy spoke
#

Do you think it's worth throwing this code snippet up in the wiki?

#

Just a simple test of what @rancid geode said about controlling GO's

hollow sorrel
#

that'd only let you rotate 1 GO?

tardy spoke
#

Yeah, really what I'm trying to get across would be how to access a System from a monobehaviour.

#

I actually didn't even think of that and know you could do that, haha.

amber flicker
#

slightly cleaner imo to do Entities.WithAll<Test>().ForEach((ref Rotation... if you're just using it as a tag

#

in fact I don't know if let's you use in for a tag

tardy spoke
#

Yeah, I can clean it up. Really it just needs the rotation component to get the idea across.

safe lintel
#

why dont you add the monobehaviour as a param to the foreach?

tardy spoke
#

@safe lintel show an example :O

I'm looking for the most efficient way to do that.

#

Then I'll toss a wiki page up with the different ways.

safe lintel
#
var deltaTime =  Time.DeltaTime;
Entities.ForEach((Entity entity, MyMonobehaviour myMonobehaviour, ref  Rotation rotation, in RotationSpeed rotationSpeed, in Test test)=>{
myMonobehaviour.transform.rotation = math.mul(rotation.Value, quaternion.AxisAngle(math.up(), rotationSpeed.value * deltaTime ));
})
#

this assumes you have added inject to your monobehaviour or added it somewhere via AddComponentObject

tardy spoke
#

Awesome! I'll fiddle around with it and throw an example of that up as well.

#

I could see this becoming spaghetti pretty quickly though because for it to actually rotate you have to run the same math on the actual components as well, haha.

#

Otherwise the component values don't change so the rotation doesn't happen.

#

Would be handy for some small things like a GUI, but I'm not certain architecting with GO's is actually that straight forward with ECS

safe lintel
#

if you have added the transform directly on your monobehaviour you could also just directly modify the transform the lambda

//convert interface on monobehaviour
dstManager.AddComponentObject(transform);

// foreach
Entities.ForEach((Entity entity, MyMonobehaviour myMonobehaviour, Transform transform, ref  Rotation rotation, in RotationSpeed rotationSpeed, in Test test)=>{
transform.rotation = math.mul(rotation.Value, quaternion.AxisAngle(math.up(), rotationSpeed.value * deltaTime ));
})
safe lintel
#

page can probably be expanded to include the variations between hybridcomponent, companion gameobjects and just addcomponentobject

tardy spoke
#

That's awesome!

#

What happens if you use that and convert and inject or whatever? Is it possible to keep entire games in GO's with ECS that way, or are there weird side effects/it doesn't work? Haha

safe lintel
#

yeah you keep the gameobject around. its what I do, I dont use AddHybridComponent because theres still a big old warning that its not for production use and I have no idea how its gonna change in the future

tardy spoke
#

@safe lintel I wonder if they would prefer the use of ManagedICD's over AddHybridComponent? It's pretty much the same thing, isn't it?

safe lintel
#

afaik addhybridcomponent makes use of the companion gameobject system where it hides your resulting gameobject for the sake of tidiness and you kinda work with it but its just invisible, also if you create or destroy the entity, the gameobject follows the same, ie created or destroyed

violet cosmos
#

RayCastCommand seems kind of jank... It just takes a NativeArray, what if you don't know the number of results? Could be 0, could be 100?

tardy spoke
#

Hmmm, strangeness

safe lintel
#

the number of results is what you input

violet cosmos
#

@safe lintel I don't understand that. If I cast a ray through the world... I can cast one ray that has a number of hits, correct?

safe lintel
#

but for the hybrid companion gameobject workflow, theres still a warning that its not recommended for use outside of experimenting, so that on top of them not recommending using entities for production has me just ignoring it for the moment entirely, addcomponentobject and just manually managing everything is my own strategy until theres more stability or declaration of intent on what unity intend for hybrid workflows

violet cosmos
#

So, the intention is to allocate an array that is larger than what I expect, and loop through that until Collider is null? That's what the API seems to indicate

safe lintel
#

i think there was a bug with the number of hits with raycastcommand, its kinda finicky

#

like it only recorded the first hit? its been a long time since ive used it

violet cosmos
#

"If maxHits is larger than the actual number of results for the command the result buffer will contain some invalid results which did not hit anything. The first invalid result is identified by the collider being null. The second and later invalid results are not written to by the raycast command so their colliders are not guaranteed to be null. When iterating over the results the loop should stop when the first invalid result is found."

Some API there, Unity πŸ˜›

violet cosmos
#

Double you tee eff

#

How do they anticipate people actually using that?

#

That's another "might as well not even have made it" type of thing

tardy spoke
#

lmao

hollow sorrel
#

seems like another something they wrote on a friday afternoon and then never looked at it again

#

are you still using physx?

manic aurora
#

sometimes i feel like unity wields this weird power over me, like, i'll shamelessly eat what they dogfood me because the alternative is write my own physics, renderer, whatever

violet cosmos
#

@safe lintel A link would have sufficed

#

Fuck, well... Here I was getting my thing ported to Jobs and now this. Like, how do I get all the targets in a sphere?

hollow sorrel
#

physics.overlapsphere

violet cosmos
#

Yup, on the main thread

safe lintel
#

how many things are you running in your scene?

hollow sorrel
#

eh there's spherecastcommand but dunno if it has same issue as the raycast one

violet cosmos
#

@safe lintel This system is a light test, many things have raycasts/under/within/etc... But I have a Weapons System that is raycasting hell that I want to put on threads. But, if I can't tell all the things it crossed through, then it's pointless

hollow sorrel
#

unity's physx implementation just doesn't really support jobs very well

#

if you're doing things on large scale consider moving to ecs physics

#

if small scale then it doesn't matter, overlapspherenonalloc is pretty performant

violet cosmos
#

Then I have to convert everything, it forces me into Hybrid

#

The thing is... if some use ray casts, and some use sphere overlap, etc etc... and Raycast is broken, then I can't just generalize it as a fully jobified system

hollow sorrel
#

yeah

violet cosmos
#

Considering that SphereCastCommand uses the same interface, I'm willing to bet it's the same restriction. One sphere cast, one result

hollow sorrel
#

would imagine so

violet cosmos
#

Welp, another few days of my life wasted on DOTS

tardy spoke
#

Except this is really all just ... kind of pointless since subscenes can't store this shit anyway (can't convert and inject a GO in a subscene) so it's useless for my game and I'll have to wait for DOTS animation, but could be useful for other things... maybe audio?

#

Wait... nothing will work in this way in a subscene haha

#

because it all has to reference a GO... lolol

#

Subscenes = life ruiners

#

The original terminology was Life Ruiners but they changed it last minute. "Throw all your game objects under the Life Ruiner".

safe lintel
#

technically there is camera conversion for subscenes, if you enable some scripting define with the hybridrenderer

tardy spoke
#

πŸ€¦β€β™‚οΈ

safe lintel
#

but for everything else yeah antiquated unity stuff wont work with em

tardy spoke
#

The only thing in my game not under a subscene is the character with the camera hahaha

#

I guess I could switch to world streamer

#

and give ECS the finger

#

but like... one of the BIGGEST benefits of DOTS is the subscene loading times lol

safe lintel
#

could always scale back your idea 😩

tardy spoke
#

I think I'd run into the same issues with any idea really

hollow sorrel
#

could consider reversing your dependency
add a component that you read at runtime to spawn a GO and link it
then your subscene is 100% entities

tardy spoke
#

They all have unique challenges, etc

#

Hmmm... I like what you're saying Scorr.

#

IoC that shit

#

Actually, yeah, that could work

hollow sorrel
#

kinda like how a healthbar doesn't spawn health, health spawns a healthbar

tardy spoke
#

Yeah good thinking to with just a simple component or something and some sort of system that just figures out what to spawn... hmm...

#

Does loading GO's like that cause a lag spike? Do they async at all? I heard they are pretty heavy to instantiate, but I would only be instantiating I think maybe 20 per tile (subscene)

#

probably usually 4 or 5 kinda thing.

hollow sorrel
#

i used to do similar thing but all i needed is sprites
i would just have an entity with a 'sprite' component, then a spritesystem would spawn a gameobject with a spriterenderer for the actual representation
and a systemstatecomponent to track if the original entity is alive, and if it gets destroyed then destroy the rendering GO too
if your gameobjects are only used for rendering it's pretty simple
if you need more stuff i guess maybe you could link an actual prefab on the component

tardy spoke
#

It might get a bit greasy with my "world moves around player" solution as I'll have to also move the translations of the spawned GO's.

violet cosmos
#

And if you have complex hierarchies, you're hosed

hollow sorrel
#

loading GO's is pretty heavy, yeah
you prob wanna look into gameobject pooling

tardy spoke
#

Yeah, could pool 'em

#

with the open world though there will likely be a couple hundred discrete NPC's at the end or more though... quite a bit to keep instantiated.

#

I'm thinking maybe switch to world streamer and use the AddComponentObject method and use ECS paradigms while basically creating a GO game. Just use ECS for heavy logic systems or systems that can be optimized... maybe switch some systems over when the tech comes out...

violet cosmos
#

Systems that don't require Hybrid

tardy spoke
#

I forsee multiplayer and VR interaction being a huge issue with entities

#

Yea exactly @violet cosmos

violet cosmos
#

I'd definitely use Unity.Physics if I could get away from GameObject conversion and they gave me the option to just inject the entity part

tardy spoke
#

Hybrid is like... terrifying, haha. It could change at any moment, you pretty much know all the code you write will have to be re-done later.

hollow sorrel
#

if you go full seperation between simulation and rendering, where simulation = your ecs and rendering = your GO's, you could despawn GO's that aren't in view, but keep their entity representation ticking for AI behaviour and whatnot

violet cosmos
#

Hybrid is going to have to change. What they have now: There's no way this is "the way", SubScene is teh suck

tardy spoke
#

Subscenes ... don't work.

#

They work for what they're kinda supposed to do, but what they do isn't very conducive to making games, hahah.

hollow sorrel
#

they're great if you don't use GO's πŸ˜„

tardy spoke
#

@hollow sorrel yeah I think that's the idea. The server will be keeping track of all locations of enemies

#

Client will be mainly rendering I believe

hollow sorrel
#

oh in that case you want full rendering seperation anyway

#

it's a win win

tardy spoke
#

Yeah, totally

#

Exactly

#

And SpatialOS has it's manual written for integration with GO's, so that could potentially be a rabbit hole to try to get it working with entities

#

Between implementing SpatialOS and some VR framework, the thought of having to convert them to work with entities is pretty concerning, hahah. Could easily take me months of work, if I could even get it to work at all.

hollow sorrel
#

yeah

#

good thing you chose a project with a small scope eyes5

tardy spoke
#

I'm not a big fan of world streamers approach to world streaming (I loathe build times), but at least it's tried and true.

#

Haha, yeah, I always have a huge project on the go for some reason. I must just prefer the journey. πŸ€·β€β™‚οΈ

violet cosmos
#

@tardy spoke When you work on a large project like World Streamer, you just work on sections at a time. You have the build machine do it's thing overnight

You can just organize your areas to be hidden and out of view under a parent

#

I really wish Unity had a more detailed road map.... Like, if I knew that they'd implement some basic physics calls in Jobs next month, I could keep working on this thing with it's limitations

#

But, as it stands I can't plan... anything. I can only plan that things will be broken until they're fixed, which may be never

proven minnow
#

NativeMultiHashMap is really awkward to use, isn't it

#

(and in regards to the ongoing conversation, I went full-bore dots, no gameobjects for my project, and except for not having particles or a UI, I'm pretty satisfied so far)

violet cosmos
#

@proven minnow How do you deal with nested hierarchies? With my experimentation, if I use EntityManager.Instantiate() or Destroy() on an entity with a hierarchy, it just destroys the top level Entity, and ignores the children exist

What's your way of loading/unloading entities from the disk into memory? Like, prefabs and things?

Do you have any integration with skeletal animation? Mecanim? IK solvers?

dusky wind
#

@proven minnow in what way?

#

I haven't had any issue with it

tardy spoke
#

@violet cosmos yeah I get it, but subscenes were nice because they actually totally unloaded the sections. Not sure if hiding stuff or disabling GO does a true unload?

dusky wind
#

@violet cosmos you need a LinkedEntityGroup for the hierarchy

#

If you delete the root, the children will be deleted too

tardy spoke
#

World streamer does let you only rebuild one target section though, which could really keep those build times down

violet cosmos
#

@dusky wind This is with entities converted by Hybrid. If I load them from a SubScene, and then call Instantiate() it only instantiates the parent

dusky wind
#

If the entity has the linkedentitygroup in the Subscene it should be saved

#

Also IIRC unity physics is decoupled from ECS

#

You can manually make your own PhysicsWorld and query it

violet cosmos
#

Nope, Unity Physics requires IConvertToEntity

dusky wind
#

It does? The samples don't seem to use it

manic aurora
#

requires is strong wording, you can construct the physics components manually

dusky wind
#

Yes, but you can manually create your own colliders

#

And add it to a physics world without entities

violet cosmos
#

Yes, believe me I've thought of that. But it's kind of all or nothing.... I don't want to pay the penalty for two physics sims running

dusky wind
#

Btw, you can disable the default one via PlayerLoop

#

If you are so inclined

violet cosmos
#

Yes, but I have tons of code on the existing. Even then, I'm not entirely sure the benefit if the game isn't Hybrid

dusky wind
#

If you don't need the determinism

#

Yes there isn't much use for it beyond

#

Maybe using Havok

violet cosmos
#

PhysX is fast enough. That's not the problem. The problem currently is that I can't call squat usefully from Jobs into PhysX

dusky wind
#

Ah yeah

violet cosmos
#

*CastCommand is some of the most useless API I've ever seen

dusky wind
#

The Collider/Ray Cast APIs in Unity physics goes wide pretty easily

violet cosmos
#

Yah, I like how Unity Physics does some things. I don't like the workflow to get there

dusky wind
#

I fit around 512 spherecasts in under half a millisecond

violet cosmos
#

I really wish they would have packaged tools that didn't do the whole GO conversion, but just the physics side

dusky wind
#

I mean the only other option is rolling your own conversion

violet cosmos
#

Yah, which... Now I have to maintain that. Again, it's not an API, without that it's feeling like a toy

#

Like... where's the real world consideration on any of this stuff? Are they making it purposefully difficult?

dusky wind
#

Odd

#

These don't implement IConvertGameObjectToEntity

violet cosmos
#

No, but in my quick tests, the GO's didn't do anything until I added ConvertToEntity

#

There's also a lot going on when I look at the Entity, that isn't quite apparent how it's getting injected

dusky wind
#

I mean if you aren't using ECS

#

It makes sense that it doesn't do anything without the system to build the physics world?

#

You will need to do that manually

#

If outside of ECS

#

Likewise you'll need to make your own exporter for the physics world data

violet cosmos
#

I just want to convert the few things that are just required for physics, not all or nothing. I'm honestly really surprised they didn't build that

#

I should make a project and take out Hybrid and see if it behaves differently

dusky wind
#

For my use cases, I have just been using ECS

#

And exporting the data to GameObjects

#

The core ECS is actually pretty solid

violet cosmos
#

Yes, I agree

#

(on core)

hollow sorrel
#

they don't implement convert because it uses a conversion system to convert them

dusky wind
#

Oh that explains it

violet cosmos
hollow sorrel
#

yeah creating new projects is a pain, not just because packages but also project settings etc
i've just started copying my main ecs project and deleting everything in assets then using that

#

to save setup time

violet cosmos
#

I really need to get back to making a game. DOTS has been a huge waste of my time

#

Yup, Unity Physics doesn't seem to work without Hybrid

dusky wind
#

I just uninstalled hybrid yesterday/this morning

#

and my physics hasn't broken

#

What error are you getting?

violet cosmos
#

If I use Convert and Inject, it renders, but no physics sim

If I use Convert and Destroy, it doesn't render

hollow sorrel
#

oh by hybrid you mean hybrid renderer? wasn't sure what you were talking about earlier

#

Unity Physics doesn't have any dependencies on hybrid renderer, that'd be weird

dusky wind
#

What components are you adding? because if you don't add the correct ones, it won't simulate as expected.

violet cosmos
#

Physics Shape, Physics Body, Convert to Entity

#

Removed the PhysX stuff

dusky wind
#

Make sure the motion type in the body is not set to kinematic

#

and double check the entity debugger to see if the physics related systems are both there and enabled

violet cosmos
#

The Plane is Static and the Cubes are Dynamic

#

I also have the Physics Step component, and Convert to Entity on it in the root of the scene

dusky wind
#

yeah that should be sufficient, odd

#

Again, check the Entity debugger?

violet cosmos
#

They're there

dusky wind
violet cosmos
#

That's with "Convert and Inject". If I use Convert and Destroy, the scene is empty

#

Maybe I need to use an SRP?

dusky wind
#

if the intention is to use Hybrid as a renderer, yes

#

I think the new one is SRP only

violet cosmos
#

Right now this is just a new project with the built in renderer

dusky wind
#

Mine doesn't use the hybrid renderer at all

violet cosmos
#

I'm installing URP to see

hollow sorrel
#

does convert and inject actually sync transforms?

dusky wind
#

I don't think so

coarse turtle
#

By itself no

dusky wind
#

you'll need to add CopyTransformToGameObject and CopyTransformFromGameObject manually to the entities.

#

it's likely because it can't automatically tell what the authoritative source of transform information is

#

you'll need to inform it

hollow sorrel
#

then sounds like that's the issue, with inject transform doesn't sync and with destroy it doesn't render because not using hybrid renderer

#

URP isn't gonna fix it

dusky wind
#

@violet cosmos double check the position/transform values for the entities?

#

if the ydon't match up with their original gameobjects, they're likely not copying the values over

violet cosmos
#

Even with URP, Convert and Destroy results in an empty scene

dusky wind
#

You don't have the Hybrid Renderer installed yes?

#

What Scorr says is probably accurate if that's the case

violet cosmos
#

So, that validates what I said earlier: Unity Physics requires Hybrid to work

#

sure I can simulate stuff there, but it's completely disjointed from the game

dusky wind
#

That's if and only if you are using Hybrid to render your entities

violet cosmos
#

So, brings me back to not having nice hierarchies

hollow sorrel
#

no

dusky wind
#

If you don't need the performance of ECS, you can still back your rendering with GameObjects.

hollow sorrel
#

unity physics has nothing to do with hybrid renderer

#

how were you rendering your entities before?

violet cosmos
#

So, if I was using Convert and Inject, I need to link back the transforms?

hollow sorrel
#

you can use gameobjects, you just gotta add a copy component james mentioned

dusky wind
#

Yes, you'll likely need to make a few authoring scripts to add CopyTransformToGameObject and CopyTransformFromGameObject components to the entities.

#

Which, all things considered, isn't too bad

violet cosmos
#

Gotcha, didn't knows those existed. That works, with Convert and Inject

dusky wind
#

The real issue comes when GameObjects no longer scale to what you need.

#

but if your game remains small scale enough

#

it's not really an issue.

violet cosmos
#

I get a warning that "Copy Transform to Game Object Proxy has been deprecated"

dusky wind
#

Did you add the Proxy or the non-proxy version?

#

This might be true in newer versions of Entities

#

I am still on v0.11 and 2019.4

violet cosmos
#

I only have a proxy verson

#

I'm on the latest, and 2020.1

coarse turtle
#

You need the non proxy version and just put it in an IConvertGameObjectToEntity

dstManager.AddComponent<CopyTransformToGameObject>(entity);
dusky wind
#

Seems fine to me

#

Be sure to have a using Unity.Transforms; for the type

violet cosmos
#
{
    /// <summary>
    /// Copy Transform to GameObject associated with Entity from TransformMatrix.
    /// </summary>
    public struct CopyTransformToGameObject : IComponentData {}

    [UnityEngine.DisallowMultipleComponent]
    [Obsolete("CopyTransformToGameObjectProxy has been deprecated. Please use the new GameObject-to-entity conversion workflows instead. (RemovedAfter 2020-07-03).")]
    public class CopyTransformToGameObjectProxy : ComponentDataProxy<CopyTransformToGameObject> {}
}```
dusky wind
#

Yes, use the first one

violet cosmos
#

That's the class you just told me to use. Note the [Obsolete] tag now

hollow sorrel
#

yea proxy is the monobehaviour, they deprecated the authoring component but the ecs component still works so you gotta add it manually with your own authoring component

dusky wind
#

The class is deprecated

violet cosmos
#

I don't have any that aren't labled "proxy"

dusky wind
#

the component is not

#
    /// <summary>
    /// Copy Transform to GameObject associated with Entity from TransformMatrix.
    /// </summary>
    public struct CopyTransformToGameObject : IComponentData {}
violet cosmos
#

So I custom inject that on conversion?

dusky wind
#
using Unity.Entities;
using Unity.Transforms;
using UnityEngine;

public class CopyTransformOut : MonoBehaviour, IConvertGameObjectToEntity {
   public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem system) {
      entityManager.AddComponent<CopyTransformToGameObject>(entity);
      entityManager.AddComponentObject(entity, transform);
   }
}
#

add that to your codebase, and attach it your objects

#

Edited, forgot that you also need the Transform as a component object

violet cosmos
#

OK, this conversion process that doesn't involve Hybrid actually happens rapidly

#

especially once a prefab is converted... Subsquent conversions/injections are as fast as I'd expect for a regular GO

#

So, now to figure out how to query the physics worlds with Jobs πŸ˜†

dusky wind
#

this is basically it, get the PhysicsWorld from BuildPhysicsWorld, pass it readonly into a job, and run queries against it

#

it should be able to go as wide as you want, I have it running in parallel there

violet cosmos
#

Giving that a shot right now

#

Thanks!

violet cosmos
#

In the Job struct, getting an error like "pointers and fixed sized buffers may only be used in an unsafe context, on trying to assign the Collider to ColliderCastInput

dusky wind
#

@violet cosmos you'll need to mark the function unsafe

#

this is unavoidable for Unity Physics in it's current state

coarse turtle
#

or wrap it in an unsafe context

void Foo() {
  unsafe {
     // Do some unsafe fun stuff here :)
  }
}
violet cosmos
#

Yah, it's not added to project right now. I'm also looking into scoping

#

The question is: Why is this not just API?

#

Everyone's out here making calls like Unity.Physics.Collider* sphereCollider = (Unity.Physics.Collider*)Unity.Physics.SphereCollider.Create(sphereGeometry, filter).GetUnsafePtr();

dusky wind
#

In a way it is

#

And it's much more powerful than your original SphereCast

#

since it can take ANY collider, including convex hulls,and (maybe?) meshes

hollow sorrel
#

yea and it is a way to have sorta subclasses while still using structs without boxing

#
  • burst compatible
dusky wind
#

the burst part is amazing when it comes to performance, it took me almost 10ms to do full 1000 sphere casts in the past

#

now it's under half a millisecond on a release build

hollow sorrel
#

damn

#

have you figured out a way to reduce the base cost? like make it less wide

dusky wind
#

oh that was a worst case benchmark

hollow sorrel
#

seems reducing solver iteration count is a massive difference, dunno how much it impacts stability tho

#

yea i mean base cost with low collider count

#

different scenario

violet cosmos
#

But, if I have to put in unsafe in almost every physics Job, will Burst just be negated?

dusky wind
#

Nope

#

it works just fine being unsafe

hollow sorrel
#

seems with solver count set to 1 it only takes ~0.2ms base cost which is pretty good, but dunno if that's a good setting to fiddle with

dusky wind
#

Just be sure to never alias your pointers

#

it negates a lot of the compiler optimization that can be done

#

@violet cosmos you can wrap the unsafe parts into your own API if it feels like too much tedium

#

@hollow sorrel the bigger cost is from building/stepping the physics world

#

which you can get around by using Havok if you don't mind the licensing requirements and don't need determinism

hollow sorrel
#

havok isn't deterministic?

#

i think they mentioned it should be in the forums

dusky wind
#

due it's caching, no

violet cosmos
#

@dusky wind I'm definitely going to wrapping this into an API. Because I have a feeling Unity will change the implementation

#
{
    public PhysicsWorld World;
    public float3 Position;
    public float Radius;

    bool haveHit;
    NativeList<ColliderCastHit> hits;

    public void Execute()
    {
        CollisionFilter filter = new CollisionFilter()
        {
            BelongsTo = ~0u,
            CollidesWith = ~0u, // all 1s, so all layers, collide with everything
            GroupIndex = 0
        };
        
        SphereGeometry sphereGeometry = new SphereGeometry() { Center = float3.zero, Radius = Radius };
        hits = new NativeList<ColliderCastHit>();

        unsafe
        {
            
            Unity.Physics.Collider* sphereCollider = (Unity.Physics.Collider*)Unity.Physics.SphereCollider.Create(sphereGeometry, filter).GetUnsafePtr();

            ColliderCastInput jobInput = new ColliderCastInput()
            {
                Collider = sphereCollider,
                Orientation = float4.zero,
                Start = Position,
                End = Position
            };

            haveHit = World.CastCollider(jobInput, ref hits);
        }
    }
}

vs Physics.SphereCast()

Imagine that in a tutorial πŸ˜›

dusky wind
#

Haha

violet cosmos
#

I mean, com'on

dusky wind
#

To be fair, there are about 20-30 different things you can customize with the query

violet cosmos
#

They couldn't have abstracted that out in the PhysicsWorld?

hollow sorrel
#
Havok Physics for Unity is a deterministic but stateful engine. This implies that a copy of a physics world will not simulate identically to the original world unless all of the internal simulation caches are also copied. Therefore, for networking use cases that depend on deterministic simulation of a "rolled back" physics world, you should rather use the Unity Physics simulation since it is stateless.

oh, so technically deterministic but still not suited for rollback

dusky wind
#

it'd be one hell of a method call if it weren't this complex

#

Oh I must have misread then

violet cosmos
#

Most people don't need that. Radius. Center. Flags.

That's 98% of a SphereCast, and how people use it. If you need more, then cool. But most people, myself included in this case, don't

dusky wind
#

@violet cosmos all of them pertain to that specific query.

#

Yes but the idea is that it generalizes to any geometry

#

not just spheres

#

BoxCasts, ColliderCasts, etc. all depend on those additional parameters.

#

I agree it's not beginner friendly

#

but it gives full access to all of the tunable parameters.

violet cosmos
#

Yes, even if it was

PhysQuery q = PhysicsWorld.CreateSphereCastQuery(new float3(0f,0f,0f), 5f, layerFlags);
PhysicsWorld.Query(q, ref hits);

That's far more acceptable from a general point of view, correct?

#

I know, that's not my point. Fringe cases shouldn't define the norm

dusky wind
#

I'm sure they'll eventually provide simpler wrappers

violet cosmos
#

Agreed, which is why I'm going to wrap it first haha

dusky wind
#

but while the API is in flux, that's likely not going to be available.

violet cosmos
#

I'm not doing this shit each time I need a sphere cast. That's going to be so much more code to maintain

#

Shit, I might even just make them extensions of PhysicsWorld

hollow sorrel
#

i wonder if you could still use havok for rollback if you can copy the internal cache tho thonking