#archived-dots
1 messages ยท Page 35 of 1
yeah, it's sample you make in manual
ok
Has anyone had any troubles with queries shared component filters?
query.SetSharedComponentFilter(new StarShared() { systemID = ind });
Basically I do this, I get 0 entities
meanwhile
without it I get tons
and also meanwhile
that same entity
ind is confirmed by debug log = 0
is BRG for mainly static objects?
so all you need is constantly update InstanceDateBuffer?
to be honest I don't see much improvements over my Graphics.DrawMeshInstancedProcedural solution
Are you not allowed to write to a NativeStream in parallel without disabling safety?
you are allowed I think, use thread id as a "stream batch id" (I don't remember what's the proper name)
BeginForIndex?
oh yeah it was a function
thread id won't work for that, since you can only write to each index once
yeah I checked it now, I'm using int indexOfFirstEntityInQuery as it's still a IJobEntityBatchWithIndex
How many buffers are you creating on the stream?
buffers? do you mean streamWriter.BeginForEachIndex(index); calls?
No, when you create the native stream you need to set the amount of buffers it uses
Which is what BeginForEachIndex refers to
ah then it's unit count in my case, I'm using stream in my AI so as many as agent count
How to make it change to a different place when the button is clicked ?
You're gonna have to be a little more specific
how to make click button and this button change position
Ask in #๐ปโcode-beginner , this is the wrong channel for your question
ok ty
If I schedule my job in parallel I get this error:
ArgumentException: Index 1 is out of restricted IJobParallelFor range [0...-1] in NativeStream.
It works fine if it is normally scheduled
do you start with 0? are you create stream with actual value in bufferCount?
Yes, I set the stream count to ChunkCount for the schedule IJobChunk
then I use unfilteredChunkIndex to set the foreach index
strange
Sirs. Can anyone test whether unmanaged shared component filter works for entity query on your end?
It doesn't for me and I'm going crazy figuring whether it's me or unity bug
I use them a ton, it works for me
e.g.
๐ฅด
What's not working?
When no filter: this entity matches query
When I add filter: query is empty
Meanwhile shared comp matches entity 100%
Are you sure the value set in the filter is correct?
Can you show the whole query?
And the query also includes the shared component?
Yeah
Are you just calculating entity count to check?
I do calculate, and I then use it in a job
And the calculated number is 0?
Odd
Now that WorldUpdateAllocator is a thing, is it faster to use that and just let the rewind handle it, or to schedule explicit Dispose jobs?
my guess is that WorldUpdateAllocator is faster
Maybe I misunderstood your question, but I'm not even sure it is possible to dispose allocations from WorldUpdateAllocator
Can someone help me understand what this means: Returns a uniformly random float2 value with all components in the interval [0, 1) when calling Random.NextFloat2 vs NextFloat2Direction.
Direction should be normalised
Ah, I get it now
A BatchDrawCommand is using the pass "Sprite Unlit" from the shader "ShaderGraph/Procedural Bullet" which does not define a DOTS_INSTANCING_ON variant.
This is not supported when rendering with a BatchRendererGroup (or Hybrid Renderer). MaterialID (0x4) MeshID (0x1) BatchID (0x2)
How to define DOTS_INSTANCING_ON?
Wait it works on non-sprite SG Shaders
Sprite Unlit can't be drawn by dots graphics?
๐ญ
Ok it worked when its not sprite
Suppose there is no way to check if the non-indexed entity has a SharedComponent equivalent to a ComponentLookup<T> inside a IJobEntity.ScheduleParallel()?
I think you need ijobchunk
Can you give me a quickie? Currently I am using query.AddSharedComponentFilter then ToEntityListAsync and then gonna pass that list of entities into IJobEntity job to verify if the entity exists.
Oh IJobChunk will let me use a SharedComponentTypeHandle right?
๐ค that's interesting. I will try that route first, feels cleaner and more optimal.
Use shared comp type handle
And use it with chunk
To check your optional component
Thx
Why is clipping weird when using Entity Graphics?
GameObject counterpart looks fine
Looks 2d? How are you rendering it with graphics?
quad mesh + any unlit transparent shader
sprite is attached to Base map property
can you Reinterpret something like:
DynamicBuffer<Foo> foos;
foos.Reinterpret<Bar>();
public struct Foo : IBufferElementData
{
public Bar Value;
}
project currently doesn't compile so cant' test it
or do i have to reinterpret it like for like:
DynamicBuffer<Foo> foos;
foos.Reinterpret<Bar>();
public struct Foo : IBufferElementData
{
public FooBar Value;
}
public struct Bar : IBufferElementData
{
public FooBar Value;
}
Both works
essentially having a struct inside another struct with nothing else does not change the layout at all, just the type.
yeah i was hoping that was true
my previous problem got more complicated
.>;
now it have something like
3 element buffers on a singleton entity that two of them hold positional data
another holds a mapping between that, and an intermediate mapping entity
Quad Mesh + unlit opaque (Alpha Clip cutout)
that maps to another entity that holds pathing data
#sadge
aka List<List<Vector2Int>>
this is what it feels like to create a joining table in sql
1 > Many <> Many > 1
Unlit Transparent looks fine, but Opaque + Alpha Clip doesn't work like its GO rendering
yay
I fixed selection tool finally
actually made it extremely fast through burst
if I only could find a way to read pixel faster
it'd be as good as instant
trying to understand this error: ArgumentException: All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -1).
it seems to be pointing at me trying to get a buffer
atleast according to the stack trace
when you create entity through ECB
you get invalid entity
with index -1
which is only valid for buffer
it will be actually created and get normal index when PlayedBack
i understand that about ecb
but why would it throw that error when trying to get a buffer
maybe you're trying to get a buffer from deferred entity?
i'll try to write some pesudo code
its abit too large
hmm let me check
i dont' think i am
yeah i'm not
yeah gimme a sec
can't just copy paste this its way too large
// in protected override void OnUpdate()
var buffer = EntityManager.GetBuffer<FooElement>(this.cachedEntity);
var ecb = new ECB();
var entities = fooEntityQuery.ToEntityArray(Allocator.TempJob);
foreach (var entity in entities)
{
for (int i = 0; i < someLength; i++)
{
var fooComponent = EntityManager.GetComponent<FooComponent>(entity);
if (!this.FooCheck(ref ecb, buffer[i]))
{
continue;
}
}
}
ecb.Playback(em);
ecb.Dispose();
private bool FooCheck(ref ECB ecb, FooElement fooElement)
{
var someBuffer = EntityManager.GetBuffer<BarElement>(fooElement.Value);
var entity = ecb.CreateEntity();
var buffer = ecb.AddBuffer<Foo2Element>(entity);
buffer.Add(new());
}```
so its erroring in the method
when i try to get someBuffer
ecb doesn't need ref btw
hmm k
well
I'd attach a breakpoint
and take a look
at values
of entities
you are trying to get buffer from
thats weird...
hmm
so it must be because i added it to a buffer
okay i need to ecb adding data to buffers to
let me do that...
entityCommandBuffer.AppendToBuffer( i'm assuming its just that
๐ค
didn't know that method exists
good to know
hmmm
feels so bad I can't add any abstract data to world without assembly modification
how do you guys keep track of how systems work?
like i had to literally diagram out my data structure just to remember wtf is going on
Haha I've done this for 1 library
But generally not that complicated
A lot of my libraries are only 1 system
I was going to write a sequence diagram for another soon though
But system groups can help as well
To group behaviour
sir, do you have any idea how to store NativeReference untyped and then retrieve it by type?
public static NativeReference<T> GetSingletonStructReference<T>(this EntityManager em) where T : unmanaged
I want to have this utility method
that lets you store and obtain signleton struct per world
okay this was the problem had to replace all my buffer modifications with ecb
which makes sense
is there burstable way to get Type hash?
just any unmanaged data unique per type
doubt it's burstable
Why bother with native reference then, just store the pointer?
I want it to be NativeReference
with safety handle
void* is fixed size of 4 bytes, right?
Technically depends on platform
IntPtr.Size will give you size of pointer
is to store untyped memory sizeof(NativeReference)
4 bytes for 32 bit and 8 bytes for 64 bit
There's a burst hash function
Burst util or something I can't remember
Gives you Hash<T>
Ah you want to make a typed singleton storage?
just use Typemanager to go from type to index
but it only works with IComponentData
I don't want it to use comps
just add the attribute and never use than as comps
Getting a hash with burst method is not guaranteed to be unique, is it?
should be
its never guaranteed to be unique
with 64 bit
why would burst change it?
Therefore I don't think it will be possible using that method, and you can't check if it was a collision, since you can't use the type
if you care about collisions you wouldn't even use hashing in the first place
but i doubt collisions matter here
its not like it randoms a hash
it generates it against your input
are you confusing this with GUID?
only thing i can think of
if type "PlayerMoveInput" and type "PlayerAttackButton" hashes to same value, he can't check if there was a collision, and will use same data for both
why would it be the same?
There is a tiny chance it will be
you are referring to the infinitely small chance there is a collision right?
that happens with normal hashing
yes
But at 64 bit it's low enough I don't think it'd be an issue
On the rare chance it fails it should be obvious in your app
You just have to remember why
well according to simple stats
you have about 40% chance of collision
after 4billion hashes
on 64bit
But is it guaranteed that the hash will be same across all different kinds of hardware/computers?
my guess is there is a static formula
in the backend that allows it to be burstable
otherwise i can't see this working
but would have to see source
ok
would suck if It would cause a crash for some random player
but even if it changes per computer basis
the chance of it happening usually isn't a consideration
great
how many unique things is he gonna hash anyway
unless its over 4 billion
i doubt it matters
modders might use over hundred
still feels scary, idk. But maybe I'm exaggerating. Probably the chance for a galactic cosmic ray flipping a bit is higher lol
perfomance is not at issue here so
yeah pretty much
it's one time operation to get pointer, that's it
He can detect it in a tryadd
Anyway
But modders make it a bit more problematic
You can't fix that easily
big doubt
like even at 1million unique items to hash
its like 1/1million chance
of failing
I know unitys animator hash is 1/300000
Collision
32bit
Which is much higher than you'd expect
But 64bit is magnitudes less likely
yeah
(birthday paradox always gets you though )
but i think there is a limit on how many keys you can map anyway
true true
but stats already calculated for that
(still not sure why you can't just have a string id)
is there a way to loop over all buffers of a certain type?
using entity queries
and ToComponentData?
welp doesn't look like it
why not?
doesn't seem to like it
myQuery.ToComponentData<DynamicBuffer<MyElement>>(Allocator.TempJob);```
didn't like that
O.o?
or iterate chunks manually
i was just gonna grab all the entities then iterate over their buffers after getting them manually
That's how you do it
just use BufferHandle for it
would be way faster
rather than EntityManager
hmm
how can I create a pointer reference to abstract memory?
I guess I need to allocate memory
copy to it
and then save pointer
btw @rustic rain isn't what you are doing already accomplished by sharedstatic in burst?
no static
I need it per world
but you can have two keys, maybe one can be world the other type?
no, that is not it
why?
World is one type
I don't want and shouldn't do hacking by inheriting from it
besides
I need it for unmanaged world
sooo
Looks like AllocatorHandle
is a ready solution for my custom allocation
google doesn't show up with anything on this
buffer type handle
hmm i'll keep it in mind will have to see what their use cases are
unity docs on this sucks
typaHandles are for iterating over chunks
whats a "chunk"
Let's start with tihs ๐
https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/concepts-entities.html
fair enough
I haven't dived that deep into unity's ecs that much, just taking what i know from other ecs libraries and trying to apply it here lol
ahh okay so chunking is just unity's term for their cache of objects with similar components
ok, think I made it
[UpdateInGroup(typeof(InitializationSystemGroup))]
public struct SingletonNativeReferenceStore : ISystem
{
public NativeHashMap<long, IntPtr> ptrMap;
public NativeList<int> sizeList;
public void OnCreate(ref SystemState state) { state.Enabled = false; }
public void OnDestroy(ref SystemState state) { }
public void OnUpdate(ref SystemState state) { }
}
public static class NativeReferenceUtility
{
public static unsafe NativeReference<T> GetSingletonStructReference<T>(this EntityManager em)
where T : unmanaged
{
var hash = BurstRuntime.GetHashCode64<NativeReference<T>>();
var handle = em.WorldUnmanaged.GetOrCreateUnmanagedSystem<SingletonNativeReferenceStore>();
ref var store = ref em.WorldUnmanaged.GetUnsafeSystemRef<SingletonNativeReferenceStore>(handle);
if (store.ptrMap.TryGetValue(hash, out var ptr))
{
UnsafeUtility.CopyPtrToStructure((void*)ptr, out NativeReference<T> output);
return output;
}
var value = Memory.Unmanaged.Allocate<NativeReference<T>>(Allocator.Persistent);
var instance = new NativeReference<T>(Allocator.Persistent);
UnsafeUtility.CopyStructureToPtr(ref instance, value);
var size = sizeof(NativeReference<T>);
store.sizeList.Add(size);
store.ptrMap.Add(hash, (IntPtr)value);
return instance;
}
}
oh wait, forgot to allocate collections
Does anyone know how to get Unity's new input system to work with ECS? I want to be able to support multiple players with multiple input devices.
๐ What kind of selection tool?
shader based
renders meshes
without physics
to select them
with mouse
I thought default dots ady have tat?
I found out that somehow I render things twice. Is HR/EG making that second camera? or is it SceneView camera? In second case I assume that it will go away in build?
should go away if you close/hide scene view
hmm
any idea how I can deallocate specific amount of bytes
allocated by Memory.Unmanaged.Allocate<NativeReference<T>>(Allocator.Persistent);
it's still there
pog
my NativeReference implementation works
If anyone interested
allows you to create singleton struct per world
with only access to Manager
by storing it you get direct access to whatever value you want
perfect for storing input per world I think
or other things that don't really need Entity
I have a parallel job that needs to do a physics distance query. However upon running it it's giving me that "previously schedule job" error about conflicting with Broadphase and other physics stuff. I'm assuming I didn't add the physics system as job dep. But I can't find where to get it. Back on 0.50 it was a simple method from the StepPhysicsWorld. But now I don't see that or the class. Where do I get this?
try adding query to RequireForUpdate
do I need add new blob asset in the baker?
I found: AddBlobAsset(ref blob, out var hash); but do I need to store that hash?
Was that response to me?
yes, dependency should be autamatically figured out if you properly add your queries to it
I found out that in 0.51 it was more automatically than in 1.0?
bunch of my systems suddenly needed that additional RequireForUpdate to work
In this particular case, I am not using the source gen methods. So I donโt think that will work for me. When I get back I will try it, but I donโt think that will do it.
Will OnStopRunning be called
on next update
where OnUpdate won't?
I have a reactive system that updates data to smth
and I need to set a boolean here, whether data is valid (was updated this frame)
or not (was not updated this frame)
all right, I checked source and seems like it
I don't get it, the hasmpa is still stored in a chunk. 1 random access and a random lookup. And then another random access to get the value.
how is this better than just storing the value in a singleton icomp?
hey im wrapping my head around baking right now. quick question: how do i sort the baking systems? e.g. if i want to set the transform of the resulting entity how do i make sure it runs after the system that just copies the gameobjects transform?
Or even better: how do i skip the copying of the transform?
lookup is only done once in OnCreate
after that it's direct pointer
same thing as normal systems
Baking systems are SystemBase now
and they are literally same thing as runtime
you query over entities only
so you have to implement temporary baking types
there are attributes for temporary types that get removed automatically
or attached to all entities
ah great! so i guess this will do : [WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)] [UpdateInGroup(typeof(PostBakingSystemGroup))] [UpdateAfter(typeof(TransformBakingSystemGroup))]
why do you need transform group?
i want to override transforms for some Prototype instances
hmm there might be now. Prefabs dont cut it in my usecase but maybe ill find some decent solution later on. for now id be happy to just convert everything to 1.0 as soon as possible without breaking everything
Your not building mobile are you?
no im not. would that have consequences?
Can't build mobile with 1.0 and IL2CPP right now...
Or at least it crashes on startup
good to know but i guess that will be fixed soon
possibly 2022.2.0b11...
ah even better if the error isnt in entities package itself
Not sure if it is or isn't
But I believe ECS is being built-in to Unity now so it still could be an error in ECS
i got the selected entity for editor tools like this: ```public static class EntitySelection
{
public static Entity selectedEntity
{
get
{
var proxy = Selection.activeObject as EntitySelectionProxy;
if (proxy && proxy.Entity != Entity.Null)
return proxy.Entity;
return Entity.Null;
}
}
}```
is there a new official way?
EntitySelectionProxy is now internal
Isn't there a component that is needed so that modifying LocalToWorld updates the entity or am I mis-remembering?
it's now built in
scene view selection works
sry i dont know what you mean. I need a working solution for this:
var selectedEntity = Selection.activeObject as Entity;
Compiler complains that entity is a non nullable type
try direct cast?
"cannot cast Object to Entity"
basically a system needs to know which entity is selected in the editor
no, LTW is the low level matrix
every change applies
ok thanks, just checking. I must be doing something in another place
a little confusion ๐
๐ค
Assets\Runtime\SelectionSystem\SelectionTool\EntitySelectionTool.cs(156,25): error SGQC001: WithAll<SelectionRenderAspect>() is not supported. WithAll<T>() may only be invoked on types that 1) implement IComponentData, ISharedComponentData, IAspect<SelectionRenderAspect> or IBufferElementData, or 2) are UnityEngine.Object types.
query = SystemAPI.QueryBuilder()
.WithAll<Selectable>()
.WithAll<SelectionRenderAspect>()
.WithAll<StarIndex>()
.Build();
IAspect<SelectionRenderAspect>
It's not even a thing
wtf
I'm so done
๐ฅด
What does star index look like
public struct StarIndex : ISharedComponentData
{
public int systemID;
public static implicit operator StarIndex(int x) => new() { systemID = x };
public static implicit operator int(StarIndex x) => x.systemID;
}
the icons don't match, tag vs sharedComp
Hmm try implement IEquatible
Hmm maybe that's not needed anymore
But it was earlier I thought
How are you adding this shared component to things
during baking
You haven't accidentally added via the managed path?
no I use default
Hmm
I'm on a tropical island so can't really check atm
But I definitely upgraded and tested my save library in 1.0
Which requires filters on subscene shared components which was working
Error: The previously scheduled job Broadphase:PrepareStaticBodyDataJob writes to the UNKNOWN_OBJECT_TYPE PrepareStaticBodyDataJob.FiltersOut. You are trying to schedule a new job EnergyReplenishDirectiveJob, which reads from the same UNKNOWN_OBJECT_TYPE (via EnergyReplenishDirectiveJob.JobData.CollisionWorld.Broadphase.m_StaticTree.BodyFilters). To guarantee safety, you must include Broadphase:PrepareStaticBodyDataJob as a dependency of the newly scheduled job.
Where can I get this so-called Broadphase:PrepareStaticBodyDataJob dependency to add to my job dep?
Nope, onlly thing I'm doing is var physicsWorld = GetSingleton<PhysicsWorldSingleton>(); passing it into IJobEntity and there all I do is just this call if (CollisionWorld.CalculateDistance(queryInput, ref hits))
I think it's because of the way I prepared for the job. Can I post some code?
It's also attributed with Unity.Collections.ReadOnlyAttribute in the job struct
You don't have a secondary exception right?
one sec, I think I made it go away. Gonna do a quick test here...
My jobs in this system need to be chained to avoid race conditions. And the first job in the chain I put default as it's inputDeps. But then when I changed it to Dependency prop, the errors went away.
Does that sounds right for a dependency chain to look like this Dependency->JobHandle1->JobHandle2 & 3->Dependency because at the end of the chain, I do Dependency = JobHandle.CombineDependencies(lastHandleInChain, Dependency).
Like for job handle one to depend on the Dependency and then have the Dependency at the end depend on all the chained jobs.
Unless your job doesn't run on any entities data, you need to pass Dependency
It contains all dependencies on all type handles or comp lookups
Oh thank you for explaining that. Now it makes sense. Yeah as soon as I did that, everything started to work as intended. thx again man.
where did the option to rebuild entity cache go in 2022.2?
my subscene conversion fails without producing a useful log ๐ฆ
All settings moved to preferences
wondering does float3 have a function similar to Vector3.distance()?
math.distance
thanks!
trying to figure out the best way to optimize this: I have to do a for loop through an array of around 30 thousand length, i have to do that for loop a lot of times though in another for loop, so I'm wondering what the best combination of job types would be to get this being performant?
am i using this incorrectly?
this.tileFinishTileQuery = EntityManager.CreateEntityQuery(ComponentType.ReadOnly<TileFinishComponent>());
var tileFinishComponents = tileFinishTileQuery.ToComponentDataArray<TileFinishComponent>(Allocator.TempJob);
foreach (var tileSpawnComponent in tileSpawnComponents)
{
// do stuff
}
seems to be returning nothing
data definitely exists
getting this mysterious message, the array is definitely 100 thousand in length though...
and even if the error message is telling the truth, you still should be able to get index 0 of something that is 1 in length, right?
found this post by Tertle, wondering does this still apply to 2021.3.11f1?
ignoring the error results in visual anomalies like particle's positions suddenly teleporting when they touch an object
could also potentially be an issue with Nvidia Flex somehow messing up the arrays, all of the demo scenes are capped to 99 thousand fluid particles at highest... (also sidenote: it is kinda insane that my gtx 750 Ti can handle that many fluid particles while still running 60fps lol)
No
This is a bug from 0. 17 lul
ah, do you have any clue what could be causing my issue then?
managed to work out it is either an issue with Vector4* or NativeArray<Color32>, those are the only arrays i use in the location i am getting that error from, still both should be length 100 thousand...
aha, how do i do that, im a bit of a noob im afraid lol
What device are you on?
windows 10 64bit, desktop computer
found a simple solution, instead of attatching a debugger, i just removed [BurstCompile]
this is the real error message
Cool.
But you may want to learn how to connect the debugger anyhow... It's a VERY POWERFUL debugging tool...
ye, ill learn eventually, ill probably google it sometime during lunch lol
ah turns out i accidentally set my max particels to 100 thousand instead of a million, whoops
ok
I resolved my problem with query
it seems like
ECB in baking system
added component the wrong way
I cached entities and comp values myself and added through EntityManager
that fixed the issue
Details?
in my case:
I added unmanaged shared component through ECB
Filters didn't work
I added unmanaged shared component through EM
Filters work
doing test in new project rn
๐ค
new project works
Here's what I had
var ecb = new EntityCommandBuffer(Allocator.Temp, PlaybackPolicy.SinglePlayback);
foreach (var (kek, e) in SystemAPI.Query<BakingTempTest>().WithEntityAccess())
{
ecb.AddSharedComponent(e, new SharedTest { value = 0 });
}
ecb.Playback(EntityManager);
ecb.Dispose();
Here's what I have now
var query = SystemAPI.QueryBuilder()
.WithAll<StarIndexTemporary>()
.Build();
var hashSet = new NativeHashSet<EntityId>(
query.CalculateEntityCount(),
Allocator.TempJob);
foreach (var (starRef, e) in SystemAPI.Query<RefRO<StarIndexTemporary>>().WithEntityAccess())
{
var star = starRef.ValueRO;
var ind = math.select(default, star.index, star.initialized);
hashSet.Add(new EntityId { e = e, ind = ind });
}
foreach (var entity in hashSet)
{
using var hierarchy = em.GetAllEntitiesInHierarchy(entity.e);
em.AddSharedComponent(hierarchy, new StarIndex { systemID = entity.ind });
}
hashSet.Dispose();
Odd
whats the new way to do RequireSingletonForUpdate? just create a query and require that and ignore the fact that its not checked at this point that there might be multiples?
RequireForUpdate
and yeah, it creates new
with size of 1
afaik
Does the safety system not handle writing to different indices on a NativeStream in parallel?
It keeps giving me an obscure error
Bumping this: Does anyone know how to get Unity's new input system to work with ECS? I want to be able to support multiple players with multiple input devices.
What issue related to ECS do you have?
Read the required input(s) in a system and make the required modifications to your world state
If I want to have a coop compatible system, won't I have to make an entity per "player" and then somehow store the InputDevice that player is using in a component?
Well the point of the InputSystem is to abstract away what device is being used, so I probably wouldn't do that
You could just have a component per player with all the input for that frame, but there are lots of different ways to do it
how would I set the values of the component?
in a system
yeah I get that, I just don't know how to read input values of multiple users. I've never used the input system for projects with coop
Lets move this to #๐ฑ๏ธโinput-system , since this isn't an ECS related topic
ok
do you have set amount of players
or any?
not a set amount, it should be between 1 to 4
well, what you can do
is to keep around a singleton array
size of 4
type would be struct of inputs
that your game need
smth like
yeah I don't like that
struct Input{
bool rmb;
bool lmb;
bool jump;
}
It'd feel better if it were a component per player
since I'm planning to have multiple character types that can be controlled, and each type has a different input strucure... and players can change their type during the game
I don't get why have singleton component per player
though
it's as good as hardcoding stuff
Ah, nevermind then
Why singleton? Each player has an entity with the component on it
is that all meant to be coop on same PC?
yes
then
it's easy
just have an entity with input component that controls all character related systems
and separated by SharedComponent
but I want to make a structure that would work with lan/multiplayer. Kind of like unreal's framework
That's a lot more complicated than local coop
struct PlayerIndex : ISharedComponent{
public int playerIndex;
}
no idea how multiplayer works at all, so no help from me in this area ๐
What you want to do usually works the way that the local coop client "owns" all local players, and everything else works as normal
Since you have the possibility of multiplayer though, and want to play local only, you need to start a local gameplay server (with 1 client, the local coop session, which could have e.g. 4 players)
I'll explain the framework that I have in mind (heavily taken from unreal):
- Every real player has an entity
- The scene is filled with entities that represent characters. Those characters may be fundamentally different (for example, a snail character and a rabbit character with different controls and movesets).
- The player entity can "possess" one or multiple characters. The player will feed its possessed characters with input every frame.
What makes this powerful is that the "player entity" doesn't have to be a local player. It can be a player from another computer or even a CPU with programmed logic.
I somehow want to integrate unity's input system into this
By "every real player", do you mean a single client could have e.g. 4 if you have a local coop session with 4 players connected to a remote server
ngl, feels like the most simple solution: just run another client for another hotseat player xD
and just code normal network multiplayer
yes. You can play with coop players and with online players at the same time.
I remember that feature from castle crashers I think
You can either run multiple clients on the same machine or a single one that manages all local coop sessions
I'm planning to have a single client that'll be responsible for all of the local players.
Then you probably just want multiple owned "player" entities for a single client session, and that session collects input for all players and sends it to the server
exactly
So with what exactly are you having issues?
Since there are a lot of design decisions that need to be made here
getting the inputs... I've never done local coop before
Then look in #๐ฑ๏ธโinput-system , I explained it there
yeah I'm trying out what you wrote there
it looks like it'll work. The only thing that I'm not getting is how to associate a User with an entity
Do InputUsers have Ids? And if so, would it be a good idea to store that in a component?
I mean you can just associate an integer with each player
But it seems it does have a uint id
So just use that I guess
What networking solution are you using?
not sure yet. I might make my own. I don't want to worry about networking for now, I just want to make sure that I have a framework that'll make it easy to implement networking in the future.
I know ECS has a networking solution but I haven't looked into it yet
The reason I'm asking is that depending on how you implement it, you may need to send your input to the server, so something to maybe keep in mind
You should worry about networking right now if you know you'll have it in the future
I agree
e.g. Unity's solution will require some architectural decisions in regards to input handling
I have a general idea of how my networking will work so I am designing a system that'll work with that.
I'm just prototyping for now and I'm going to tackle the networking issues before I start finalizing the project so I'm not to worried about that.
If you build it yourself you can do what you want, but like I mentioned, unity's netcode will require some special stuff for inputs
I'll read about it
The gist is since it's fully authoritive, you send your inputs to the server instead of updating the clients position
sounds a bit too ambitious. for coop an authoritive server is overkill. p2p and a relayserver is what most use with host migration. steam relay works great for this.
I guess it depends on the game, if you require cheating prevention you may still need to do it
Also afaik there is no p2p multiplayer solution for ecs, so you'd have to roll your own
i don't think a couch coop with online multiplayer has any right to invest into cheat prevention unless enough people play it. cheat prevention isn't just a coding problem, it costs money and requires lots of server structure
I don't really find fully authoritive server models very complicated to work with, netcode for entities has been really nice on that front imo
The hard part there is reducing the effects of ping
yeah, you need at least 3-4 servers minimum
Well, you can just let people host them, you'd need a NAT punchthrough service though if you don't want people to forward ports
might as well go through steam relay
I've never used it so I can't comment, I only know the "usual" struggles with these things
I'm assuming it also locks you to steam
there's a community project for unity.transport to go through steam relay
sure. when on pc you have to be on steam anyway
if you follow any figures, no there aren't ^^
A lot of people are hobbyists not making games for money ๐
well then don't make a multiplayer game
Why not?
because it costs money
No it doesn't
Let people host the server
Ever played minecraft? Terraria? Factorio?
none of those games have statically hosted servers
yeah true ๐ those games are the best of the best so people put up with anything
people don't put up servers for a couch coop that has 5 minutes round (i think)
Who said it lasts for 5 minutes?
noone, i made up a strawman ๐
point is, better worded, the game has to be worth it.
I wouldn't even say that, some people just want to make multiplayer games, even as a hobby
even if there aren't millions of people playing it
afaik those are mostly p2p games
None of the ones I mentioned earlier are
There are also AAA games that are P2P, so I don't think there is a huge generalization you can make
i don't know any p2p game that doesn't use a relay server. the security concern of seeing ips over others was just too big
A P2P game using a relay server is still a P2P game
true but only because we have no better abbreviation for it. technically there's nothing p2p going on when all peers connect to one node
I'm specifically talking about P2P vs an authoritive server. Technically speaking you are right, if I host a client and server on my machine, we are just two "peers", but it's still server authoritive
what's among us using for networking? do you know?
I'm guessing mirror, but I have no idea. It uses steam's API for networking though since iirc you didn't need to forward anything
Or they may have their own NAT punch through service, but I doubt that
But the Unity.Transport integration for steam relay sounds cool. Especially since unity now finally has a unified networking system that is (hopefully) here to stay
Tbh, I'd like to make a talk/big blog post about this because it was a really nice way to scale and grow from "I want to host this on a free cloud instance" to "I now am popular enough to have to deal with hackers" to "whatever Among Us is now".```
I use https://github.com/willardf/Hazel-Networking on Linode. Tbh, it's extremely cost-effective for me(ymmv), but I generally suggest people use Photon until they have some success.
There's another recent big game that attempted this, the "P2P authoritive" system, but they had issues with hackers aswell iirc
Ah alright, so not mirror after all
Never heard of that one
I'm not sure if the souls games do any authoritive calculations, hackers have always been an issue there too
the point i want to make, for a long persistent game like Minecraft, Terrario, Factorio -> authorative server. anything else, short 30min rounds, non persistent world -> p2p with relay servers
Definitely, like I said, it depends on the project
I was only saying that just because you are a hobby dev / small project doesn't mean you can't work on an authoritive multiplayer game ๐
DS has relay servers too but yeah, their anti cheat sucks. i think it's p2p in the classic sense. no authority or shared authority that suppresses hacks/cheats
They have a dedicated matchmaking server but after that it's all P2P
I can't remember the name of the project I'm thinking of...
iirc it is also fully P2P but they somehow attempt to check for cheating, I have no idea how it works though
Elite Dangerous is also P2P from what I can remember
agreed. i didn't account for self hosting tbh. that's really the outlier that makes this work.
Yep, servers are expensive after all
uhm, I have a (probably) stupid question -- what is "ScheduleParallel" equivalent in Entities 1.0 foreach?
IJobEntity's scheduleParallel
or codegen free IJobChunk
i really like the new bakers but man it is annoying to replace 100+ conversions :S
100+? damn. i had exactly 64 to update. took me 4-5 hours
not counting when i moved all bakers to a seperate namespace ๐
i didnt expect to have so many myself. they built up over the years. i do have a lot of small modular components. when i find the time i should combine them to more useful authoring components.
Any ideas why this is failing code gen?
Already tried restarting the editor, same issue
Weird, if I put it above the job struct creation, it works
Are there special cases where this isn't allowed @proud jackal ? otherwise I'll try and write a bug report, it works in another job for me for some reason
Look at the front page for known issues ๐
Front page? Of the entities forums?
https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/index.html
This is one of em, I fixed it a week after exp-1.0 release, so next release :3
Ah, I saw it. My bad
Yeahh.. This one ๐
The job where it works is an IJobParallelFor so I'm guessing that's why it works
Yup, if you look at the sourcegened result for the system, it's because we have to do nested replacements for IJobEntity (which is what caused the error)
Also something else I was wondering, is it required to put [NativeDisableParallelForRestriction] when writing to a NativeStream in parallel or is this somehow related to the memory leak issue?
Good question, this is outside my area, but I guess the docs don't say a thing about it?
Yeah that's why I was confused. Disabling the safety stops throwing the error and everything works fine, otherwise I get a bunch of these cryptic error messages:
ArgumentException: Index 4 is out of restricted IJobParallelFor range [2...2] in NativeStream.
ArgumentException: Index 12 is out of restricted IJobParallelFor range [6...6] in NativeStream.
ArgumentException: Index 10 is out of restricted IJobParallelFor range [5...5] in NativeStream.
etc
@misty wedge My guess is that ActiveChunkTrackingComponent contains a NativeContainer (in this case a native stream perhaps?). We are working on improving the messaging around this error as it's non-obvious but ComponentLookup is a NativeContainer itself, so when a ComponentLookup is used to fetch a component with a NativeContainer in it, this not allowed by the safety system currently. Since the NativeContainer inside the component isn't seen by the safety system at schedule time, it looks like you're accessing a native container that was never prepared for access on job threads and you start getting less helpful/misleading safety errors. Disabling the safety system is fien to do in this case but you do also accept all the extra care needed to ensure you do not access the NativeStreamin in your component in parallel in a non-readonly manner
From memory native stream range nearly always breaks safety from how it's setup and needs parallel safety turned off unfortunately.
I think there's a method public void PatchMinMaxRange(int foreEachIndex)
On the writer you can use if you want to keep the rest of safety enabled while overriding the min/max range
Does [RequireMatchingQueriesForUpdate] includes [WithAll(typeof(SomeTag))]?
What is the equivalent to ConvertToEntity component in ECS 1.0?
I'm trying to convert and inject go outside a subscene
None. Unity decided to not support converting outside subscenes. Spawn the GO at runtime and link it to an entity
Entities 0.51 Raycasting
I see. Thx
Can't I just duplicate it and put the copy inside sub scene? That way on load, I will have both legacy and ecs versions?
๐ค
do you need a hybrid object or why do you need that?
yeah I do.
consider this way. convert what the entity representation should be in a subscene. either give it some tag or put it in an IComp container so you can query it and get the prefab entity of it. the GO, which is then just a graphical representation, on awake can then instantiate the prefab entity. it also works the other way around.
How expensive is entityManager.GetComponentData<CompData>(entity) to use in Update loop? is it as bad as go.GetComponent<Comp>()?
Oh that's so simple. Thanks!
As fast as hashMap lookup
Or array indexing
Ok thanks!
What it does under the hood:
- array access by entity index to get chunk of entity
- little calculation of chunk offset (also includes array access)
Where in the samples can I see how to use EndCommandBuffer in systems?
If anyone ever come across one
Bc all tutorials about it is outdated.
Need to destroy entity, and I heard its better to do it at end simulation buffer
But getting this error when using with jobs ```the type Unity.Entities.EndSimulationEntityCommandBufferSystem is a managed type and is not supported``
But I can use normal ECB with jobs properly
What do you want again?
I read that destroying entities should be done in end simulation command buffer, not the regular one? Idk I'm confused about the whole concept so I'm looking for the usage.
The NativeStream is passed to the job in this case, not in a component
is there a nice way to force a gameobject to bake? I have an editor script that procedurally adds a child to a gameobject but it's not baking it until I close/open the subscene
it's not meant to be baked until subscene is closed
baking is done in one run
close subscene, look at hierarchy
I don't get it ๐
I have Live Baking enabled, so it does run through the bakers without waiting to close the subscene
only during run
Importing com.unity.physics gave all of my systems error SGJE0010: IJobEntity.Execute() parameter 'transform' of type LocalToWorldTransform is not supported.
Anyone knows why?
physics only supports old transform
So I just have to wait till it supports it?
or use old transforms
to use the old one add "ENABLE_TRANSFORM_V1" to scripting define symbols
If physics is imported, this is not needed, it will enable transforms v1 automatically.
oh it didnt do it for me
Okay got it all sorted out, thanks!
For anyone interested in this info: Unity 2022.2.0.b10 + Entities 1.0.0-exp8. If you compile a game in ILCPP2 and you have a subscene in your scene the game will crash. There is a workaround though, instead of using a subscene to instantiate entities use the EntityManager.CreateEntity() function.
This links shows how to instatiate Rigidbodies at runtime for example without a subscene
I hope this helps somebody
(Specially considering that my game runs at 40 FPS when compiled with Mono and it runs at 70+ FPS with ILCPP2)
(I have configured ILCPP2 to only compile for ARM 64 on Android)
How do i move a package to the asset folder without breaking Components on Prefabs?
2DAnimation package has an error with entities 1.0. When i move the package to my project all bone setups on my prefabs are gone...
Hello, i was wondering how in DOTS you would design things differently?
Like for example you have a pickup class that get's inherited by classes doing specific logic for their pickup.
Like if you picked up health it gives the player a certain amount of health or if you picked up Ammo the player gets some ammo.
Is it still possible to have some kind of inheritance like that where you have 1 main class having the basic logic and then the inherited classes doing specific logic?
@radiant berry you would probably split it into multiple systems. 1 system doing the "basic logic" for pickup like e.g. destroying the pickable item and another System operating on a other component that adds health. Composition over inheritance
There is no inheritance in DOTS. it's not an OOP style
sure you can use inheritance. You could have a BaseSystem handling the PickupLogic and some item specific systems that inherit from the BaseSystem. its just not the best practice.
What would be the point of that? Wouldn't you have one system handling all pickuplogic, not just for specific items
DOTS isn't an object-oriented approach; it's a data-oriented approach... hence DOTS - Data-oriented technology stack
so OOP principles such as inheritance are going to be of limited use, or even harmful
I would probably have a System per specific item logic and 1 System for the shared item logic.
one system that handles something like a PickUpItem Component.
another specific system queries for WithAll<PickUpItem>() and HealOnPickUp Component for example
inheritance is just a tool. use it in the right places. even in OOP composition beats inheritance. its all about using the right tools for the job.
Perhaps, but only by coincidence. A system conceptually isn't an object. It's just because DOTS is written on top of C# that means you're still technically using objects. You have to design in a different way. Everything is composition because you're working from the data up
not really, hee
ISysteem is not even an object
just a tiny bit of allocated cache
technically, Unity invented c++ inside C#
think it was deprecated
SystemBase is base system class
and yeah, it is a class
but deeper we dive into Entities
the less SystemBases we need
some seniors in this channel reported converting most of their systems to ISystem
is there actually anything that cant be done with ISystem atm?
didnt have the time yet to convert everything but its one of the next things ill attempt
custom graphics
BRG usage is way too low-level
besides
you still have to store it somewhere
I have an incremental baker that traverses a graph of scriptable objects that might try to add the same component multiple times based on the individual scriptable object settings. Its giving me this Error:
"Baking error: Attempt to add duplicate component VectorizablePosition for Baker Baker with authoring component UtilityDecisionAgent. Previous component added by Baker Baker"
Id like to have a TryAddComponent...
Is there any way to check whether a component was already added by a previous baker?
Baker is not meant to have any access to anything else
use Baker to add temporary data
and then loop over it in BakingSystem
but the temporary data would also be the same component
not really
the only way i see right now is to traverse the whole graph first to gather a list of all Components to add and then filter out duplicates before adding all those components.
you can any
?
add temporary tags that are meant for your workflow
okay ill try but i doubt it works
@rustic rain how do i declare temporary components? i cant find it in the docs yet
[TemporaryBakingType]
or smth like that
ah thx
using Unity.Entities;
using UnityEngine;
public class BakingTest : MonoBehaviour
{
}
public class Baker1 : Baker<BakingTest>
{
public override void Bake(BakingTest authoring)
{
AddComponent<TempComponent>();
}
}
public class Baker2 : Baker<BakingTest>
{
public override void Bake(BakingTest authoring)
{
AddComponent<TempComponent>();
}
}
[TemporaryBakingType]
public struct TempComponent : IComponentData
{
}```
temporary types still throw the duplicate error
my actual case is this: ```public class Baker : Baker<BakingTest>
{
public override void Bake(BakingTest authoring)
{
AddComponent<TempComponent>();
//go down in Scriptable Object Graph...
AddComponent<TempComponent>();
}
}```
generic systems
will they ever be? i was thinking about replacing my generic systems through codegen. but i might as well wait
yeah, that seems like the only way right now. it can be coded so the compiler doesn't complain but at the end the system can't be instantiated.
hmm why is that? cant you make an instance with MakeGenericType and add it to the PlayerLoop?
Burst compilation wouldn't work with it
because youd need to register the actually used generic components in the assembly?
not really
generic components are fine registered in runtime
unless it's IL2CPP
but Burst won't compile it
I mean generic jobs
huh. my jobs scheduled from generic Systembases run with burst
Generic system bases are fine
it's generic jobs that aren't
also depending on complexity of how generic it is
it might just be useless
Indeed. This is why there are attributes such as RegisterGenericJobType and RegisterGenericComponentType We can statically determine some closed forms of generic types by scanning all assemblies (not cheap to do but makes things more convenient) however you can't always resolve generics this way such as scheduling a generic job from a generic method where the T closing the generic job comes from the generic method's T GenericArgument.
The specialized attributes allow us to know what special cases you have so we can generate the IL and/or pass the correct context to Burst for AOT code generation
they work fine. just need to register
and there goes the whole point of generics ๐
not totally, you have to implement them anyway.
and i prefer 2-3 lines of implementation than copy pasting a whole system + jobs
Yes, my 'indeed' is specific to that generics are complex, not that they are useless (far from it!) Many cases for generics we can indeed deduce, but you do certainly run into issues with heavy generic library code that is intended to work out of box for end users. Usually they need to opt-in to a closed form using on of the "registerxxx" attributes
i'm okay with registering or some other code overhead. are there plans to make generic ISystems work at some point? this is my current SystemBase which I wanted to convert to ISystem public unsafe partial class StatChangeSystem<TStatsConfig, TStatBuffer_Base, TStatBuffer_Final, TStatEntityReference> : SystemBase where TStatsConfig : struct, IStatsConfig where TStatBuffer_Base : unmanaged, IComponentData where TStatBuffer_Final : unmanaged, IComponentData where TStatEntityReference : unmanaged, IStatEntityReference
There are not immediate plans to do so but that could change. The complicating factor is that ISystem is meant to be burst compilable and that ultimately means burst compiling instance methods which is something Burst does not support. To do so, we need to provide some custom wrapping/trampolining, assembly scanning and more RegisterGenericSystem attributes to make it work. We are very aware of the iteration loop slowness that source generators, IL Post Processing and Burst have today so we want take some care to ensure features added don't add too much more pain in this space. There are a few things going on to make improvements to iteration and once we make some more ground there we will likely have some more leeway to add support for generic ISystem support
thanks for the answer! sounds very complicated! ๐ as long as SystemBase works i'm okay with it. having some class based systems is not too bad and the the expensive code is burstable anyway
I've just resorted to generic implementation structs for isystem
With default generic job field to get it to schedule fine from burst
Works well enough
Is what I mean by default generic job field
Little gross but good enough to trick burst into being able to handle it
Where possible I also replaced a few generic systems with dynamic type handles (again via implemention structs and extension methods)
Yeah anything that ends up being a generic job should be fine (provided you might need one of the RequireGenericJobType attribute escape hatches). The main issue is really the instance methods when it comes to bursting generic systems as Burst needs to know what T is when you refer to it as a generic field on your system etc... That part we sort out for jobs already so any shenanigans you can do to rejig your problem into "how can I make this into a generic job" should get you most of the way to bursting generic things. We certainly don't want all this hoop jumping for you though and aim to improve this area
If anyone is really craving generic ISystem bursted OnUpdate calls the process could be implemented in one's own ILPostProcessor cloning some of the logic we already do for handling bursting shared components with IRefCount methods but it will be fiddly and will certainly add a tax to your iteration time today
(I don't advise it though and would encourage moving important hot paths to bursted static functions when you can, and call them from SystemBase<T>)
I instantiate some generic systems like this:
sysType = typeof(BaseScoringSys<,>);
constructedClass = sysType.MakeGenericType(outputBufferComponentType, readComponentType.GetComponentType);
object sysInstance = Activator.CreateInstance(constructedClass);
sys = (BaseScoringSys)sysInstance;
currentworld.AddSystemManaged(sys);
var updateGroup = currentworld.GetOrCreateSystemManaged<ConsiderationUpdateGroup>();
updateGroup.AddSystemToUpdateList(sys);
worked in entities 0.51 but it somehow broke in 1.0
The Error happens in line "currentworld.AddSystemManaged(sys);"
The Error:
ArgumentException: The passed-in Type is not a type that derives from SystemBase or ISystem
__
BaseScoringSys Inherits from Systembase
try using default world init static method
to add systems from system list
sry not sure what you mean.
DefaultWorldIniti...
smth like this
it contains static method
to add systems to world
".AddSystemsToRootLevelSystemGroups();"
yeah
thanks! seems to work. still a strange error. id expect both ways to work
someone on the forum figured it out how to serialize the enabled state of comps. close the subscene ๐
... ๐
I keep getting surprised that everyone leaves their subscenes open
Had a script in 0.51 that would force quit play mode if a subscene was open because it just broke netcode ghosts
This seemed fixed in 1.0 so removed the script but habit just has me always closing them
So I've just avoided so many random issues people seem to have
Considering these issues though, sounds like I need to bring the script back!
tbh, i was under the impression it doesn't even make a difference ^^
It's what causes the physics to fall through floor a lot of people have issues with
From a brief guess / look I'm not sure the baker systems run in this state
oh that's also related to subscene open. hm
Though I have not investigated enough to say for certain
But if you look at live baking state it doesn't include changes from systems
Does ComponentLookup heavily pollute the cache with each access?
Feel like it's inevitable to use ComponentLookup to basically pass data between entities
I avoid using Component/BufferLookup in constant-frame operations, and try to make most interactions event-based, but with thousands of actors, there's going to be dozens if not hundreds of Lookups every frame
and try to make most interactions event-based
What's that? Creating entities?
It's totally fine to use random access
Shouldn't make it a way too big of a deal
hard to say, not every lookup is equal. i've profiled a lot and some lookups were absolutely destroying performance and some were really fast. it's really dependent on the memory layout, memory locality and internal cpu optimizations. there's no strict rule other than avoid them were possible but don't feel bad if you can't and never write additional data just to prevent a random access. unless the write is used for a persistent acceleration structure no write will ever be worth it.
are you sure? i've finally been able to get to work on it and, while unity doesn't throw me any errors and visual studio correctly shows me the generated code, unity itself does not seem to find the generated code.
i've tried importing my old generators, those work immediately without problems.
maybe i'm just missing something ๐ค
thanks in advance
Please, I want to change the parameters in the _schedulepremovejobs_b7_0 method. It is a method in the internal class.
Its position is classAIMOVESYSTEM_SERVER.CLASSC._SCHEDULEMOVEJOBSB7_0
My mistake, can you help me point out? thank you
How do I get TransformAspect.Lookup's Entity?
is it cheaper to destroy an entity
or remove a component
i'm assuming its to destroy an entity
also can't find how to rate limit one of my systems any advice?
depends. in most use cases removing a component, but it will incur a structural change. but it's definitely the better choice when you want to keep the remaining entity around and in working state. if you just want to temporarily get rid of a component, you can also just disable it, and later easily reenable it, both of which will not incur any structural changes
wait you can disable components
wtf.
since 1.0 you can
just use a quad
i'm not sure what 2d support in pre 1.0 you're referring to anyway
Perhaps Tiny's 2D Physics
tilemaps just dont' work
2d physics needs a hack to work
don't think tilemaps work with native pre 1.0 either
yeah it didn't natively work
but atleast the editor was okay with the it and it still loaded if you monob'd the changes
in the new unity
it just doesn't recognize any of the rule tiles
non of the editor features work
its just a blank file (rule tiles etc...)
and doesn't render at all
so i'm waiting for it to update to support it
2025
maybe it just messed up the migration for you cause that doesn't seem like something that slips through
yeah i kr
don't think so
others have tried
and couldn't get it to work either
if you figure out something let me know
sure. am not really working with 2d, but i might take a look at it
Think back the times before Unity get 2D Physics and other 2D Features.
You lock an axis constraints
And call it 2D
lol yeah
like worse case scenario
i create my own tile grid stuff
and fake 2d in 3d like unity does
but reinventing the wheel just sucks
either way, you'll have to change a loooot of code when you'll be upgrading
you cannot
What's the equivalent of TransformAspect.Lookup's .HasComponent(e)?
equivalent in what context
I need to get the lookup's entity
Or even other components it has
Previously I can do ComponentLookup<LocalToWorldTransform>.HasComponent(e)
there's SystemAPI.[lookup something]
yeah i read the changes its interesting...
but anyway how do i deal with simulation speed?
like trying to figure out lets say i want to spawn something every 60 frames/so trying to target 60fps 1/s - but the fps is like 200 - you cant clamp the fps easily and you shouldn't
cause technically you can do that in monob
you just wait at the end of every frame to try delay rendering
and aim for a targeted fps
main reason is for multiplayer games the only way i'm considering to keep sync is via lockstep
i mean you can always just keep track of a float and increment it by SystemAPI.Time.DeltaTime and return if float < [number]
that doesn't work thou
it would desync
best you could do it something like
currDelta - 1f
but that would still make the spawner
spawn late
Can't you use Systemgroup rate manager ?
for multiplayer you should def use the multiplayer packages e.g. unity.transport
that's either dumb or foolish
Transport is fanatic
+1
then look at transport and just copy what you need
got an example for this, trying to google it
anyway that doesn't make sense. the server is the only one keeping the timer
do NOT do p2p
that's just bad design
but there is a "host"
that determines desync
its lockstep so everything is simulated client side
via data
states aren't passed across
== cheating infested
that would just desync
if lets say you try to buy an item that you can't
and you send data that you attempted to buy item id 1
and your hash of your inventory is now whatever
and it gets compared with the host sides hash
it now no longer matches
and clients desync
but lets not divert this discussion as to why you want me to use unity networking
and if you do a legit action and have package loss, you just lost whatever you have been doing
You just have 2 friends join a game and hijack it from host
host is the auth in hash comparison
tcp is majorly unsuitable for most game actions
you can also do that in udp
but its more flaky i guess
tcp isn't that slow that it matters anyway
So it's server authorative then
yeah
but not in the traditional sense where clients send actions
and server sends states
ahemm.....'tcp' and 'not slow' in one sentence is straight from hell XD
Therefore the server is keeping the timer
Then what should I do? I hope you can help me, thank you
not do whatever you were doing
How does that work with a lock step
yeah, my question
your data sent across for "current action" has a timer of -1
your client will try its best to keep up with simulation
but that doesn't matter if you are behind or not
(as long as you aren't in front)
seems majorly wonky
you just have buffered things to simulate/process
What is the benefit over just having a single host
less data sent across the wire
who cares
