#archived-dots

1 messages Β· Page 67 of 1

storm ravine
#

it’s deterministic vodka

urban rivet
#

True I think I could predict exactly what happens

safe lintel
#

haha

gusty comet
#

Gosh I want to generate gameobject from entities because I need to move them in the scene. I gave up and just spawn GameObject and then create the entity. But the transform position and the position component won't syncronize 😦

solar ridge
#

Isnt a vodka logo of a goose

#

Geese are aquatic buoyant animals so it shall float

#

You'll need to add the copy from (which ever one you are changing) component

coarse turtle
#

@gusty comet use the CopyTransformToGameObject component so you can sync the position to the actual game object

#

also lol to all the vodka stuff πŸ˜‰

solar ridge
#

Im curious if I can edit the layout of the components in the inspector when selected in the entity debugger

#

Recipient:Id length and buffer are of an array. It would be nice if I could make that use the tostring

gusty comet
#

@coarse turtle but I also want to be able to move it inside the scene. Seems like using both components broke stuff, the position isn't right

coarse turtle
#

And you wouldn't want to manipulate both the original transform and the position component at the same time πŸ€” sounds like a recipe for a race condition disaster

old atlas
#

Hi, does anybody know about any example/resource that explains how to use the new GameObjectConversionSystem, GameObjectConversionUtility and WorldDiff features?

coarse turtle
#

ah sorry I haven't touched those yet :c

safe lintel
#

was meaning to try it out but havent gotten around to it yet

gusty comet
#

@coarse turtle No I need to use the gameobject transform because it's to move 3d objects in the scene. Or maybe I should just do another build for this because it's temporary anyway ^^"

coarse turtle
#

So In that gif, I put a PositionComponent and CopyTransformToGameObjectComponent on a camera and if you want to move the "gameObject" you would manipulate the Position associated with that entity

#

Unless you're talking about being able to move the gameObject with scene tools

gusty comet
#

yeah but you can't use the basic tools which manipualte the transform

old atlas
#

@safe lintel I will check it out, thanks

gusty comet
#

well I'm going t make two build in the end. I don't know why I didn't think about it before x)

#

Moving the transform is just to correct some data we have

coarse turtle
#

You can try to write a scene tool which writes to the PositionComponent if you need a perma solution

gusty comet
#

Could be interresting, I'll keep that in mind thanks ^^

sharp nacelle
#

I know this is technically a JobSystem question and less of an ECS question, but does anyone know how to actually enable "Full StackTraces" on native collection leaks? Apparently I am missing a few disposes and I don't know where.

manic aurora
#

huh does it not give you the full trace in the console detail window when you click a specific error?

sharp nacelle
#

not on the "memory leak" errors of NativeArrays. It only says one should enable Full Stacktraces.

#

It says something about enabling a define, but well, we don't really have access to the C++ part of the engine, so I hope there's another way.

silk basin
#

Theres a dropdown menu in the toolbar that has options for the job system including the full stack trace i believe @sharp nacelle

frosty siren
#

Is it ok to use interfaces with ComponentData?
I understand that the design of ECS and DOD in general tells me that I have to separate the logic and data, but I have a case where I have the same data structures with the same update logic, but with a different interaction logic. And I want to put it in one system.

green lynx
#

how do you guys deal with race conditions in a hybrid system? ex. initialization
like I spawn a bunch of entities using a MonoBehaviour, but then when I try to GetComponentGroup in OnCreateManager() the entities don't exist yet

frosty siren
#

@green lynx do u mean that your OnCreateManager() executed earlier than your MonoBehaviour?

green lynx
#

@frosty siren bingo

frosty siren
#

@green lynx i thought about call Mono's Start() in OnCreatManager() but you should come up with how to cache your Mono in system.
Also when we need to get EntityManager we use GetOrCreateManager(Type), may be u can use CreateManager(Type) in your Mono to create system manually and be ensure that it's already created.

green lynx
#

@frosty siren Thanks! I'll try CreateManager in the MonoBehaviour script

untold night
#

@frosty siren - if the data behavior is similar enough, you might be able to work around it with jobs that implement the interface and operate on the data instead. Combine this with a system that has generic paramters to slot in the necessary Job types, that should make it possible to do what you want.

Two possible issues might crop up:

  1. Generic systems don't hook themselves up when you use the default world bootstrap, you'll have to add them manually and update the playerloop after you do so.
  • I don't know how well this would play with burst jobs. as long as the types are blittable it probably should. Since you'd just be defining a struct that fulfills a interaface requirement, and the job system works just fine, that shouldn't be part of any burst issues you run up against.
#

something along these lines:


public interface IMyCustomAdd<T,U>
{
    T Value { get; set; }
    NativeArray<U> Results { get; set; }
}

[BurstCompile]
struct AddOnesInt2 : IJobParallelFor, IMyCustomAdd<int,int2>
{
    int _value;
    NativeArray<int2> _results;

    public T Value
    {
        get => _value;
        set => _value = value;
    }

    public NativeArray<int2> Results 
    {
        get => _results;
        set => _results = value;
    }

    public void Execute(int index)
    {
        _results[index] = _results[index] + int2(_value);
    }
}

public class MyParallelForCustomAdder<T, U, V> : JobComponentSystem
    where T : struct, IMyCustomAdd<U, V>, IJobParallelFor
{
    //....

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        T addJob = new T();
        addJob.Value = 42;
        addJob.Results = _MyCustomResultsArray;

        JobHandle addJobHandle = addJob.Schedule(_MyCustomResultsArray.Length, 64);
        return addJobHandle;
    }
}

This obviously wouldn't be in ONE system, but a bunch of similar systems could be updated as part of a single group and potentially all be working in parallel if they don't touch the same component types.

green lynx
#

yoo I just figured out GetComponentGroup wasn't working because I was trying to get the component wrapper instead of the actual component. OTL I'm an idiot

manic aurora
#

if i have multiple worlds and have a sync point in one of them (for example, i need to run a command buffer to create or modify some entities before starting the next job), does that always mean i have to block for all worlds until that's complete? i can't see how the answer isn't yes, but it's a bummer when some of my worlds do not depend on one another whatsoever

sharp nacelle
#

@silk basin wow thank you, I must have been too blind to see that πŸ˜„ I only remember turning the thing on, but I didn't see the Full Stack Traces entry. Thanks!

solar ridge
#

Is there anyway to iterate over all sharedcomponentdata in a job?

#

Trying to create a spawnjob with a prefab, and while there are likely other ways, I feel knowing how to iterate over sharedcomponents in a job would be handy regardless

solar ridge
lime dome
#

cube cubed

tawdry tree
#

Abstract art? Or is this actually supposed to do something useful?
EDIT: I mean, it's pretty and all, but I'm wonder a bit WTH I'm looking at

lime dome
#

or cubed cube

#

take your pick

solar ridge
#

Spawns around points determined in editor

#

Just lots of cubes to determine scalability

#

Longest running system is 5ms and that is the renderer they have atm

#

Though I still need to try to get the spawner to be in a job to not block main thread while spawning.

#

Buffer.Instantiate(Gameobject) would be nice

solar ridge
#

Alternatively how would one pass a shareddata to a job to use for setting data for a new entity?

#

I was thinking readonly worked but apparently not

untold night
#

that is some nice rock salt, at least

solar ridge
#

XD

#

Trying to pass a RenderMesh to a job and it is proving more difficult than I anticipated

#

Unless there is a way I am missing how to use Buffer.Instantiate(entity) with preloaded data

#

Update: Was infact missing how Instatiate worked: Also Prefab component is pretty neat

#
var gameObject = Resources.Load<GameObject>("Cube");
_template = EntityManager.Instantiate(gameObject);
EntityManager.AddComponentData(_template, new Prefab());
#

Would be nice if a PrefabComponent came with an existing wrapper

lime dome
solar ridge
#

LOoooool I hadnt thought about it

manic aurora
#

does EntityArchetypeQuery work for yall? when i call GetComponentGroup with my query it won't select the correct overload...

solar ridge
#
_query = GetComponentGroup(new EntityArchetypeQuery {
    All = new[] {ComponentType.Create<Desired>()},
    Any = Array.Empty<ComponentType>(),
    None = new[] {ComponentType.Create<Undesired>()}
});
manic aurora
#

oh...my error was in a dumb place, i had a type wrong, thank you

rugged wagon
#

I'm wanting to learn more about ECS. I can easily find some tutorials on youtube, but I'm curious what people who are using ECS regularly recommend

untold night
#

I'd say grab the source packages in 2018.3 or 2019.1b and look at a lot of the scripts themselves. The current tutorials are good for the overall theory, but some of the specifics are out of date.

That being said, they've hinted at massive update circa GDC In march and I wouldn't be suprised if they push a bunch of the talks up asap like they did last time.

Since one of the goals is to have a lot of the core bits done between 2019.1 - 2019.2 expect to see better/more tutorials and more stable samples during or after that time.

A good book to get your hands on to really understand the mindset is the data oriented design book: https://smile.amazon.com/dp/1916478700

A sampling of the contents (but not the whole thing) is here: http://www.dataorienteddesign.com/dodbook/
The formatting is hard to read on the website.

vivid relic
#

Hey all. Im returning to ECS after a while to fiddle around with it again. I see a lot has changed, and I'm even having trouble just spawning a thing with a RenderMesh on it. Am I understanding correctly that EntityManager.Instantiate(prefab) should grab all the ECS components I have on my prefab? I'm getting "Invalid AABB Result". This is with the new Hybrid Renderer

tawdry tree
#

The prefab is a hybrid GO/entity, right?

vivid relic
tawdry tree
vivid relic
#

I just started the project today, so MeshInstanceRenderer doesnt exist anymore

tawdry tree
#

That said, I'm using preview21, not the current 23

vivid relic
#

in the newest versions, that is. Its been moved to Hybrid Renderer package and renamed RenderMesh

#

hmm... Perhaps I should just try and roll back

tawdry tree
#

I updated to see if my code still works, getting Assembly has reference to non-existent assembly 'Unity.PerformanceTesting' (Packages/com.unity.entities/Unity.Entities.PerformanceTests/Unity.Entities.PerformanceTests.asmdef)
Which is great because I can't actually edit that to fix it

vivid relic
#

You need to add something to the manifest

#

"com.unity.test-framework.performance": "0.1.49-preview",

#

I think its that one

tawdry tree
#

So I actually need to edit the manifest now? Didn't do it the first time, though I noticed it was listed in the getting started guides

vivid relic
#

Apparently for this version you do. Its under Project_Folder/Packages/Manifest.json

tawdry tree
#

Now it's Could not load file or assembly 'Smash, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. but it does render the thing, at least

vivid relic
#

Strange. Does the MeshInstanceRenderer component still exist?

tawdry tree
#

Nope, I changed from that

#

So my system grabs the renderer on initialization (AfterSceneLoad)

_boidRenderer = ECSUtilities.GetLookFromPrototype("GameobjectInSceneName");

The method looks like this

using Unity.Rendering; 
using UnityEngine;

public static class ECSUtilities {
  public static RenderMesh GetLookFromPrototype(string protoName) {
    var proto = GameObject.Find(protoName);
    var result = proto.GetComponent<RenderMeshComponent>().Value;
    return result;
  }
}
#

But I forgot why I do that. I think I instantiate things different from you

vivid relic
#

Yeah, I do it differently

#
        {
            foreach (var spawner in spawners)
            {
                var prefab = EntityManager.GetSharedComponentData<ShipSpawner>(spawner).prefab;
                var entity = EntityManager.Instantiate(prefab);
                var position = EntityManager.GetComponentData<Position>(spawner);

                EntityManager.SetComponentData(entity, position);
                EntityManager.DestroyEntity(spawner);
            }
        }```
tawdry tree
#

Hmm, yeah, I use entityManager.CreateEntity(archetype) and set the renderer as a sharedcomponent

vivid relic
#

I must have misunderstood how its meant to work. I thought you could make prefabs, set all your stuff on them, and then instantiate with EntityManager, and it would copy over all the components into "pure" world

tawdry tree
#

Tip: When using triple backtick code blocks, write 'csharp' directly after the first backticks(and then add a newline) to get code highlighting

vivid relic
#

ty

tawdry tree
#

Also, it's a bit of a bother, but you might wanna consider converting all tabs to double spaces, just for sharing, since Discord makes the tabs really big

#

Hmm, yeah, without further testing, it looks to me like the instantiate method should work

vivid relic
#

it instantiates just fine if I remove RenderMeshComponent, and LocalToWorldComponent. I can even tell that my thrust system works on this entity (it has a thrust component), in the entity debugger. But if I put rendering components back on, it freaks out with AABB errors.

tawdry tree
#

Yeah, I remember having AABB errors at some point, but don't remember how I fixed it. A quick search suggest there might be an issue with the rotation quaternion? At least some matrix shit (the math kind, not movie).
EDIT: The thread suggests to check for NaN in your code to see where it breaks

vivid relic
#

Good call!

#

There was NaNs in the position component, so I'm doing something wrong there

tawdry tree
#

great!

vivid relic
#

But now it renders

#

Thanks a lot

tawdry tree
#

But I really just googled 'unity ecs AABB error' and chose the tops result, so shame on you for not getting there before me.

vivid relic
#

All I got was old old posts where they were emitting those errors from physics, particles etc

#

But I guess I could have reasoned my way to it

#

oh, I see now. I left out "ECS". Shame on me indeed

old atlas
#

Is there any way to run the animators after the entity-gameObject synchronization?

#

By default, if I have a gameObject with game object entity component, a IComponentData wrapped with ComponentDataWrapper and an animator, I can create an animation curve using Unity's built-in animation window and run it thanks to the animator component.

#

However, the value that the animator sets every frame gets overriden by the value that the entity currently stores, and so the animation curve has no effect.

#

If one disables the game object entity component, the animation runs as expected.

#

My first idea has been to take a look into the PlayerLoop api and try to run the animator after the ecs systems, but no luck so far. Any ideas?

urban rivet
#

You should absorb the ECS forum, there's weeks of data there, followed by the updated samples from github (fixed for api changes)

tawdry tree
#

Hoo? When were the samples updated?

old atlas
#

They get updated quite often, last update seems like it was a month ago

tawdry tree
#

Hmm, maybe I just stumbled on an outdated version or just got unlucky with some of those I looked up, then

green lynx
#

anyone had any luck with modifying vertices on a rendermesh component? My mesh kinda just... disappears

tawdry tree
#

That sounds odd, like it loses reference to the mesh(which should nullref) or maybe it just can't make sense of it. I remember that when procedurally making meshes I had to make sure to set/update both vertices and triangles (and normals, but messing up those just made weird lighting).

manic aurora
#

make sure your tris are oriented correctly too, or they're invisible. im still using MeshInstanceRenderer in my project that works with meshes, but manipulating the mesh directly without reassigning MeshInstanceRenderer .mesh works fine

rugged wagon
#

@untold night Thanks a bunch, these are some great resources!

gusty comet
#

Hi guys, someone know how to properly delete/reset a world? or maybe just the entity manager. Because I tried to dispose the world or delete the manager but Unity crash whitout even the error display ^^

light sage
#

Migrated my 2d sprite based project with ~200 GameObjects over to close to pure ECS using quads and unlit/cutout materials. Two days of scanning the limited API (apparently most of the examples are gone), and had a hard time until I figured out the meshinstancerenderer is now rendermesh, and those kind of changes that aren't documented anywhere that I could find. But, with il2cpp working thanks to an xml file linker I found to prevent stripping, I'm now getting a stable and beautiful 120+ frames/sec. Once you start to pick up on ECS from an OOP trained mindset, it's hard to go back. There are still hundred of ways to optimize my build, and I don't even need them. @gusty comet an EntityManager can make batch calls to destroy, there are a few examples of scene swapping still on the Github API.

#

@gusty comet This is what I'm refering too

var instances = new NativeArray<Entity>(500, Allocator.Temp);
EntityManager.Instantiate(entity, instances);

// Destroy all 500 entities
EntityManager.DestroyEntity(instances);```
#

Way to learn that I find the quickest is just look at all the properties/methods/structs while messing around in Visual Studios. They are mostly named quite self-explanatory, and when you find one that sounds interesting open up google and learn learn learn

gusty comet
#

@light sage Yeah thanks I know ^^ I was just wondering how I could delete the whole active world and set a new one.

#

Btw I'm going to dig a bit into Buffers, could they be the answer to array linked to entities?

light sage
#

I 'm actually digging more into chunk iteration and buffers today myself also.

#

interesting questions really

#

since World is an object, wondering if maybe possible to copy default world and use the copy to populate, the default being more of an archetype (lightweight so you can keep it around to reset). That or JIT to compile on demand at reset, haden't gone down that thought pathway before bc not really applicable to my game, but the concepts are actually thought provoking in terms of future implementation

gusty comet
#

I guess I could also have a native array inside a system and inject this one

#

I wonder how I could choose between those solution

light sage
#

Injection getting reworked , but the way I would think is starting with the template and just dropping the extra at reset would be more efficient for multiple resets

#

unless there are persistent changes you want carried over on resent, then I think your method

#

@gusty comet Are you doing pure ECS? Do you know a good method to hook a reference to the main camera's transform's position property into an Icomponent, entity, etc? or if there is a good not so hacky way to control the main camera's position inside the pure system? (right now I am just updating in the updata() of the bootstrapping monobehavior. It's working, but I would like to be able to manage internally, outside of the systems monobehavior kickstart class with native ECS methods?

#

prefab it, and grab it that way through gameobject entity?

gusty comet
#

@light sage I still use some gameobject for the camera and the colliders, but you can do it like the rendering system and directly save UnityEngine.Camera.main inside your custom system and then just get your component groups.

light sage
#

true, I just didn't want to worry about synchronization issues later

gusty comet
#

that's why I stayed safe (especially to switching camera) and still use gameobjectentity to synchronize the gameobject camera to my camera entity

light sage
#

that a good scalable plan

#

just annoying because I would rather avoid the Update method entirely, and my camera moves at the same velocity as my playerentity, although I do need to have access to it outside of the system at the same time

gusty comet
#

well you can simply make your own camera system like I said earlier, can be really quick depending of the features you need

light sage
#

did that for input, made it very low level

#

just when I think I understand ECS it's another revelation

gusty comet
#

things are pretty natural for me so it's hard to tell ^^

#

Btw this one is more about the memory layout that unity use than ECS

light sage
#

I started 2 days agao >_<

gusty comet
#

I work with that mindset since... sometime x)

light sage
#

started c# 2 weeks ago, but it's a java clone so same thing

#

ECS reminds me of when I worked with JCL (job control language)

gusty comet
#

c# is really annoying though, give me back my C++ 😒

light sage
#

or java control language, I g\forget

#

but working with spooler and all that

#

IBM mainframes

#

since I had to install the cpp libs to compile to il2cpp it gives me a good time to write some plugins

gusty comet
#

I'm working a bit too much for this right now :/

tawdry tree
#

Ooh, a lot of people would get mad at you calling C# a java clone. Same general style though, they're both mid-level C family languages

#

And I would say C++ is a lot more annoying than C#. Then again I haven't worked much with C++, and not getting used to things makes it more bothersome to do, and I did it in school, so follow ALL the conventions. Header file for a class with one method! Header file for class with TWO methods! Oh, and did you fuck up memory again?

#

having low-level control is nice and all, but most of the time I don't care and just want my code to work.

light sage
#

they can retort with the fact that one of Javas first design implementations was to create a streamlined way to program VCR chips

#

true, I want low level where there are clear bottle necks though

#

like having a need to constantly check for input flags even though it's a 90% waste, and especially doing so on main thread

#

that kind of stuff screams for a more efficient solution

#

but given the choose between embedded ifs or less efficient code, I'd take the slightly less efficient, more elegant readable

#

at compile time, depending on compilation method, it's all mostly negligible anyway

gusty comet
#

hum someone know if the transform system does support serialization? I mean how does it know that I just loaded a bunch of entities that are parents/childs (because the entity reference serialization is managed)

tawdry tree
#

I don't think it is serialized by default, but the datatypes definitely are, so you should be able to trick your serializer of choice to include it

gusty comet
#

? Entities references are serialized

#

they just recompute their new value when load the world

tawdry tree
#

Actually, rereading your comment, you're speaking about transform relationships, now locRotScale

gusty comet
#

just the transform system which does have a map of the relationship between parents and childs

#

I'm wondering how does it behave when you serialize/deserialize the world

tawdry tree
#

I can't help you there, but it shouldn't be too hard to test?

gusty comet
#

I'm afraid it's just not supported because the Add only appear in the attach function. But I'm going to test it yeah ^^

gusty comet
#

Okay I said nothing, transform system update itself if the hierarchy changed even whitout the event, and the nativehashmap can even extend is capacity. Good enough for me ^^

gusty comet
#

Still I'm not sure how it does trigger attach chunks :/

dull copper
#

oh

#

new entities and hybrid rendering packages out now

#

EntityDebugger and Entity inspector API are no longer public

#

wonder why they did that, sounds like that would seriously limit custom inspectors

gusty comet
#

In fact the transform system doesn't update itself... I just did serialize the entity event by error xD

coarse turtle
#

tertle provided a work around soln to the thread

lilac ermine
#

but you can do it like the rendering system and directly save UnityEngine.Camera.main inside your custom system @gusty comet the rendering system uses Camera.main? πŸ€”

#

i'm surprised unity still even let's you do this, and without throwing warnings like "hey did you know you've probably been unknowingly abusing this for years?"

#

the first time i learned it does FindGameObjectsWithTag every time you call it was from some random unite video and my jaw nearly hit the floor

full stirrup
#

I figured that out from the simple Camera.main property, it flops if there isnt a camera with the MainCamera tag so you kind of put the pieces together

#

Pay some mind to the easy access properties for anything like that happening

light sage
#

In this clip you can see I'm using quads for tiles and just pure ecs, and everything is very efficient (40,000 quads in the video clip example), but I have an issue finding a way to get the "ship" entity's position into the class and job that deals with calculating adding/removing/repositioning quads along the edges dynamically (quad fits in a 1x1 Unit, ship position x/y increases by 1 a new row/col of quads to transform). What is the best way to get the ship position (which is set to a float3 "pos" in ships componentdata) to the other system without ghosting the ship, etc?

#

since the camera is already ghosting, I would like to be able to just grab the coords directly from inside the system, with no other overhead. I have other plans for the camera also, which make that a bad route

light sage
#

Would bringing the ship in with the tiles through a mutual float3 data type, updating that data type to match the ship's position, and using a separate job just to bring all those tiles back with a different filter and use that float3 for the transform? Ugh, feel like I'm missing something simple

#

had no success with getcomponentdatafromentity or those methods, they never seem to work, I guess I'm just implementing them wrong

tawdry tree
#

Well, I assume you already have a way to find the player ship, so can't you just, in your system, grab that, and use the ship's position as an argument to the system?

lilac ermine
#

were most of the examples removed from the sample project? or we're supposed to find them elsewhere?

tawdry tree
#

They drastically stripped down the amount of samples, yeah. Prolly cus some of them got a bit outdated, or used patterns they decided weren't so good

lilac ermine
#

are there any good examples of dealing with ui? also curious how people do more reactive / OnPropertyChanged style

#

for example, i do a lot of like this in my own little ecs framework (i'm transitioning some smaller stuff to unity's)

#
healthComponent.CurrentHealth.DistinctUntilChanged ().Where (value => value <= 0).Subscribe (_ =>
{
  animator.SetTrigger ("Die");
});
#

this might be like a reactive DeathAnimationSystem

#

using UniRx for reactive properties

#
animatedButtons.OnAdd().Subscribe(entity =>
{
  var button = entity.GetComponent<Button>();
  var animator = entity.GetComponent<Animator>();

  button.OnPointerDownAsObservable().Subscribe(_ =>
  {
    animator.SetInteger("State", 1);
  });
})
#

this could be an AnimatedButtonSystem

#

i'm already thinking how to do the OnAdd stuff for the group according to the brief bit joachim discussed this at one of the unite's, using SystemStateComponentData for reactive systems (unless they've added something else recently i've missed that allows a nicer built in way of doing this)

#

it's the reactiveProperty.UntilChanged() and myClickable.OnPointerClickAsObservable() type of stuff i'm still really missing though

tawdry tree
#

So while(not changed) and on mouse clicked something something as observable? Without the context for those method names I don't know what they actually do

lilac ermine
#

yeah sorry i'm trying not to flood the channel with code but still be communicating clearly

tawdry tree
#

Could always make a pastebin or something to put your code online and shar eit with a link instead of actually writing it all here.
I think some services let you edit them later, too

lilac ermine
#
public class HealthComponent
{
  public int StartingHealth;
  public IntReactiveProperty CurrentHealth;
}
tawdry tree
#

I take it you are specifying a bit more which specific features you need? (if not, please do)

lilac ermine
#

my systems are then almost all reactive and mostly do some processing or setup when entities are added

#

for example healthComponent.CurrentHealth.DistinctUntilChanged ().Where (value => value <= 0).Subscribe would then just respond to when it changes and is less than 0

#

the specific feature i need here is in my update loop i just want to be processing entities that meet some query

#

in this example it would be give me all the health components where the value has just changed to less than or equal to 0

tawdry tree
#

So you're the Observer pattern to activate systems when entities change? That doesn't sound very ECS...

#

In that specific example, it sounds to me like the 'proper' ECS way to do it is to get all entities with Health, without DeathTag
Then to do death stuff and add the tag.

#

Possibly swapping the DeathTag with a blittable bool/state variable in health to see if change has been processed

lilac ermine
#

ehh i was hoping to avoid like this. i'm pretty sure i saw some way of doing this with queries but i can't find it now

#

it's very ecs, with observables we can still split data and logic πŸ˜‰

tawdry tree
#

You could also just make a Reactive component with a bool/state 'changed'.
So stuff would (usually) have Health and Reactive, and you'd query for both, then filter out everything where Reactive.changed is false. In that case I'd have a system running after everything else to set all changed bools back to false (so that all systems using it would run, not just the first

lilac ermine
#

we're just not thinking in a polling / update mindset

#

hmm, that could work too πŸ€”

#

i was hoping this was something i could nicely do with queries though

#

but most of the examples + tutorials i was seeing for those were outdated some time ago

tawdry tree
#

Well, it would use queries, just not the way you originally envisioned?
It should be mentioned that, having not really worked much with ECS, I'm a bit of an armchair theorist here.
I think queries are one of the things that have changed quite a lot, and I might have read somewhere that they are being dropped? At least in their current form? It might have referred to something else or already have happened, too.
...I really should wring my brain for an idea I find sufficient to actually bother sitting down and putting in more than a token effort in learning Unity ECS...

#

Only thing I've made is this beginning of what should've become a boid simulation, with the most literal examples of corner cases I've ever had in my code.

#

I did consider getting a nice shot of that and posting to r/ProgrammerHumor tho

lilac ermine
#

yeah i dove in pretty hard for a couple of weeks but there was a lot of old stuff and new stuff i never quite sussed out. the Filter bits i think were removed but chunk iteration via archetype queries is very much part of the core

tawdry tree
#

Oh yeah, archetype queries and chunk iteration is quite core, I meant queries in the LINQ kinda query meaning

#

Wait, can you append where statements to those queries?

lilac ermine
#

Β―_(ツ)_/Β―

#

i remember something like 'only getting the entities whose componentdata has changed' but maybe i dreamt it

tawdry tree
#

That sounds vaguely familiar, something about chunks changing...

lilac ermine
#

well, i'm also very interested in any good up-to-date ui examples out there

#

my instinct is to create wrappers (proxies...) now that fire off ECS style events for other systems to consume

tawdry tree
#

Hybrid UI elements, where the UI events would create UIEvent (ButtonClicked, ButtonHover, etc) entities, which would in turn be used by systems?
For now I think you shouldn't be too picky in that particular department, as changes will probably soon give you a 'proper' way to do it or just break your existing code if you make it too complex/clever

lilac ermine
#

basically yeah. monobehaviours that create entities as events. quick and dirty and like you said it's probably going to be seeing some changes in the near term anyway

tawdry tree
#

Could even use actual events for extra dirty, but I'm not sure how good of an idea it is to have Systems listen for events

light sage
#

honestly I'm just hacking at it, I was just adding more component data and a new system anytime I needed to enterface with the ship in a new way, or add a feature

#

without an api, and verything in flux, it's a confusing time to learn

tawdry tree
#

Well, if you learn the principles, that's valuable in itself. And if you just check the changelog when things change, you should eventually get an understanding not of how things are in the moment, but what major changes has been made over time.

light sage
#
{
    [BurstCompile]
    struct ShipMovementSystem : IJobProcessComponentDataWithEntity<ShipData, Position>
    {
        [ReadOnly] public float dT;

        public void Execute(Entity Player, int index, ref ShipData data, ref Position pos) {

            pos.Value += new float3((data.velocityX)*dT, (data.velocityY)*dT, 0);        
        }
    }
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var job = new ShipMovementSystem()
        {
            dT = Time.fixedDeltaTime
        };     
        return job.Schedule(this, inputDependencies);
    }
}```
#

this I use to manage the ships acceleration, but even it's redundant and the "with entity" unnecessary

tawdry tree
#

Add csharp after the first triple backticks (and a newline, if you don't have one) to get code highlighting. Also consider replacing tabs with two spaces for more discord-friendly indentation.

light sage
#

I guess a basic question then. Should I keep most of my classes in different files? Right now I have a file for each class and one for each entity archetype

#

or is it irrelevant on compilation?

#

I love and support ECS, this black box scenario atm is just really frustrating

tawdry tree
#

In general it's considered good practice to separate types into separate files, but in the end it's a style choice.
With ECS there are a lot of types involved, though, and I would for example put the hybrid wrapper class in the same file as the ECS component struct

#

Unless you made assembly definition files, i don't think the compiler cares.

light sage
#

that's what I have right now, archetype declarations in the bootstrap/monobehavior, and everything else seperate. I guess I'll just pick up what I can, and when the reposiory get's fixed I can make changes

tawdry tree
#

That sounds like a reasonable setup. And it's not like it's hard to extract a class/struct to its own file. While watching a video it struck me that in some cases it might be useful to have one file with a bunch of related archetypes. Like for different NPC types or something.

light sage
#

yea, like items, or ship types, that's smart, I just want it clean and organized for when I comment it out in case of collab/ etcetera

#

I just know that if things aren't put together that get called in batches, and burst compiled, and if they are bringing in a bunch of unrelated stuff with them it kindaof defeats the purpose

#

plus I'm pedantic about not using the main thread at all, since I can't inject

#

leave room for GUI

tawdry tree
#

The batches are based on chunks, which are determined by the components on entities, I think? The key part there is to have like stuff be actually like, and not have different components if you can help it.
As for optimization, someone else wrote something nice, along the lines of "I'm not too worried about optimization for now, since things change so much. I can optimize later when the effects of each system is more clear."
Aka the first rule of optimization: Don't optimize.
2nd: If you need to optimize, profile first.
3rd: When you optimize, do it where you get the greatest effect.

light sage
#

I'm profiling, and I hvae a stead 60 fps fixed and 120+ fps unstable, CPU halfway to bottlenockeing due to endframe and rendering. My philosophy is build the strongest and most efficient foundation possible, that way it's scalable and will give an idea of where the game can go limitation-wise

#

bottom up approach, I used to use a top down, and my programs would always end up hard to maintain at some point

tawdry tree
#

Making a strong foundation is great and all, but at some point you just end up spending a whole lot of effort that would ultimately not have much effect. It's a tradeoff, I suppose.

light sage
#

on native il2cpp build it's incredibly solid, it's just the syntax, I'm at a roadblock with how to do what I need to do using ECS

#

I understand what you mean though, I just stuck an entity to ghost the player to get the positional data and dropped a comment to fix it when I know how

tawdry tree
#

The player moves via a system, right? Where you need their position, do whatever you do to grab their position and stuff there, then input that into a job or whatever in is required for. Something roughly like

JobHandle Onupdate(object IDontRememberWhatGoesHere){
  var playerpos = entitymanager.GetPlayerSomeHow().Position;
  var actualJob = ActualJobThatNeedsPlayerPos(playerPos);
  actualjob.Schedule();
}
light sage
#

This video shows my problem, I'm having really good performance with ECS, but when I reach the bounds of the tiles, I can't figure out how to best keep replacing them, and also how to get the universal coords back to 0,0,0 without any hitches when the floats get too large. All this I know how to do with OOP easily, it's just that I can't progress until I go through example after example ignoring the fact that all the examples online (98%) use inject consistently

tawdry tree
#

Hmm, if you have issues with floats not being large enough, go for doubles or split things into sectors. Ie, first (arbitrary large, but not too large) units is sector one, then the position float starts over from 0 while the sector increases.

light sage
#

considering something along the lines of a transition with visual effects

tawdry tree
#

Or look up how other people have solved floating point issues, i know Kerbal Space Program have some solution to it, and the game is big enough that I reckon they've stated how they do it somewhere

light sage
#

KSP I don't knwo how it was made, it's a marvel

#

but eh, I could map the tiles to a sphere, or reset an menu screens, lots of options, just the syntax

tawdry tree
#

Oof, you would wanna jobify and/or ECS that one, but yeah, one way to do it. Possibly THE way to do it (not necessarily that specific script, but in general)

light sage
#

yea, that one would be too much overhead, but interesting concept

#

I just hope that ECS doesn't get stuck underneath the framework where we can't access it directly anym,ore so that I'm not wasting my time learning it

lime dome
#

HDRP natively supports Camera-Relative rendering now, so the problem with models looking odd is eliminated.

#

but the physics issue would still be a factor

light sage
#

not much collision intended

#

so worth looking into

#

might just zone things and rotate all the quads inside the frustrum and drop the rendering amount beforehand

tawdry tree
#

Well, ECS is still in experimental/preview, and while you could make something production-ready, it's explicitly not supported, and in massive flux. Chances are some form of ECS will stay with unity for the foreseeable future, though.

dull copper
#

afaik, KSP used floats in local sims and doubles in larger scale

#

making custom physics integrator isn't hard, doing everything else around it on physics engine is harder (but you don't really need collisions for everything)

light sage
#

Squad proabbably had a whole team devoted to C++ or other lowlevel plugins I would imagine

dull copper
#

you can do their scope sims on pure c# just fine

#

in fact, I think they have their physics stuff publicly available somewhere

light sage
#

I try not to actually simulate where I don't have to, life for acceleration, and velocity, I'm not grabbing square roots every loop

#

I know they have an api, I have it on steam, I could look, I more need to know how to do inject without inject though, lol

tawdry tree
#

but... but... that's exactly what inject is for, why can't you use that?

light sage
dull copper
#

"Download the beta build required here" πŸ˜„

#

those docs could benefit for a full check now

light sage
#

I have 2019 beta, I'm going to try doing what I need with IJobChunk

dull copper
#

also the injection page links for ForEach goes somewhere else

light sage
#

yea, that repo is screwed up

dull copper
#

afaik, 2018.3 is still fine for ECS but new ECS renderer will require 2019.1

#

mainly missing things from engine API side on 2018.3 for that

tawdry tree
#

Oh yeah, the way to do things now is to use the object initializer, isn't it

var jobStruct = new SomethingJob(){
  VariableToSet1 = something,
  VariableToSet2 = somethingElse
};
light sage
#

I'm doing it in a strange way lol

#

but it's coming along somewhat

tawdry tree
#

I think all ways are strange right now, due to it changing so much and documentation being, uh, of variable usefulness

coarse turtle
#

Yea, most information I get from the forums lol

light sage
#
[BurstCompile]
    [RequireComponentTag(typeof(BackgroundData))]
    public struct SetQuad : IJobChunk
    {
        public ArchetypeChunkComponentType<Position> Pos;

        public void Execute(ArchetypeChunk tileChunk, int chunkSize)
        {
            var chunkPos = tileChunk.GetNativeArray(Pos);
            var howManyPos = tileChunk.Count;

            for (int e = 0; e < howManyPos; e++) 
            {

            }
        }
    }```
#

well, they added a new required param to the Execute method for ArchetypeChunkComponent, but once I find it I think this should do ok

#

besides the fact we can't have nativearrays as components

tawdry tree
#

Need a newline after the csharp part

light sage
#

since typeof is slow, I could just grab all the tiles to this system with a throwaway tag and strip that tag once I have them I guess

#

move them to persistent nativearrays

tawdry tree
#

As long as you don't repeatedly add and/or remove the components, that should be fine, but it might be better to just have an AddedToCollection variable you set to true?

light sage
#

I mean, I could filter them without that "I think"

#

never sure without a decent api lol

tawdry tree
#

Try and see if it works? At this point I'm pretty sure just trying whatever to see if it works is the proper way to handle things

light sage
#

unity crashes restart and try again lol

#

soon as I find this new int param

#

assuming its either the size (32 - 128) or the instances wanted?

tawdry tree
#

What's the context?

light sage
#

I'm rewriting the whole code, probably tore down 400 line so far, I'm understanding better (sortof)

#

only way to learn it right now is through an IDE

manic aurora
#

is BufferArray being deprecated along with ComponentDataArray? for certain workloads that would actually completely eliminate my ability to parallelize buffer writes on a per-entity basis, since there is no IJobProcessBufferData

untold night
#

I believe there is a BufferFromEntity<T> lookup, and chunks can get you a BufferAccessor<T> that you can access in IJobChunk

manic aurora
#

hah i had one of those - "it works!"... "it doesn't work!" ... "it works!!!" moments with that. BufferFromEntity was great once i figured it out πŸ‘

lilac ermine
#

suuuuuper brain block atm: what are some reasons a component system doesn't run?

#

i have a very basic system i am trying to change over from my own ecs framework to unity's - i thought i was pretty comfortable with their system at this point but i guess not

#

i've tested the code and setup in a fresh project and it works fine

#

and i can see my system showing up in the entity debugger as if it should be updating (in the existing older project)

#

but when i Debug.Log in OnUpdate() it seems to never actually be called

manic aurora
#

does it get called if you use [AlwaysUpdateSystem]? is it in the default world, or a world you've otherwise configured to update with ScriptBehaviourUpdateOrder? and iirc systems won't run if the component groups you inject all have length zero, but i don't know if i've seen that being true in practice...

lilac ermine
#

default world and should not be zero

#

at the moment i am testing a gameobject with: GameObjectEntity, Animator, and Button

#

this is the system

#
using Unity.Entities;
using UnityEngine;
using UnityEngine.UI;

public class AnimatedButtonComponentSystem : ComponentSystem
{
    ComponentGroup animatedButtons;

    protected override void OnCreateManager()
    {
        base.OnCreateManager();

        var query = new EntityArchetypeQuery
        {
            All = new ComponentType[] { typeof(Animator), typeof(Button) }
        };
        animatedButtons = GetComponentGroup(query);
    }

    protected override void OnUpdate()
    {
        Debug.Log("running with " + animatedButtons.CalculateLength() + " animated buttons");
    }
}
manic aurora
#

i am a little foggy on handling hybrid stuff, but i'm willing to bet that entity archetype query doesn't know what to do with the unity engine components (which are not "components types" like it expects, i.e. ones that fulfill the IComponentData interface)

lilac ermine
#

i thought this too, but it works fine in a "clean" project

manic aurora
#

oh interesting...

lilac ermine
#

i can see the entities like this in the debugger in both projects

#

hmm, i have some ideas, but it's mostly a game at this point of "spot the difference"

#

yeah it's one of these plugins silently conflicting πŸ€”

#

hmm, yeah, for some reason having UniRx in the project causes this behaviour

lilac ermine
light sage
#

I couldn't put my project back together, I got carried away making huge alterations, lol

#

trying to hook into the main camera, meshes and textures, and then delete the bootstrap gameobject so it's just the camera,

gusty comet
#

Hi guys, I just updated my project entities package and got a some errors on the transform system :
Library\PackageCache\com.unity.entities@0.0.12-preview.24\Unity.Transforms.Editor\TransformComponentEditors.cs(41,26): error CS0246: The type or namespace name 'PositionProxy' could not be found (are you missing a using directive or an assembly reference?)

#

Anyone have a clue of what I missed?

light sage
#

I've noticed a few few things seemed not to work like they did before, but I thought it was just me

#

I'm comparing cpu usage between using two worlds, one for simulating and one dedicated to rendering, so it's further refining the logic then render loop

#
public World sys = new World("sys");
    var job = new BGenJob()
    {
        sys = Unity.Entities.World.Active,'
    other variables = whatever}```
#

nice feature to experiment with

#

eh, that's redundant though, just setting it back to active lol nvm

#

WorldDiffer looks interesting, can't find any documentation at all

light sage
#
DiffUtil.GetAllChunks(EntityManager m_entityManger)```
#

if that works the way it sounds that the most useful bit of code I've found yet

#

or are their differed chunks of entities not visible in the debugger used to render?

light sage
#

Yea, I'm finally finding the fun apis. So Unity will autoupdate, and nerf a lot of these loopholes to the lower level hidden functionality, right?

elder wharf
gusty comet
#

@elder wharf Oups I deleted the wrong message, yeah I did delete it that's fine now ^^ thanks

gusty comet
#

Can someone explain me ArchetypeQuery? can't find what Any,None and All mean exactly 😦

knotty radish
gusty comet
#

or maybe I should have read the code...

knotty radish
#

"All = All components in the array must exist in the Archetype
Any = Any of the components in the array must exist in the Archetype (at least one)
None = None of the components in the array can exist in the Archetype"

gusty comet
#

Yeah thanks I don't know why I asked that xD

knotty radish
#

It's not always the first thing I think about when I'm wondering about something in ECS but sometimes this wiki does have the answer

gusty comet
#

Yeah just didn't read the right page, but I could have simply looked at that :

/// <summary>
    ///     Define a query to find archetypes with specific component(s).
    ///     Any - Gets archetypes that have one or more of the given components
    ///     None - Gets archetypes that do not have the given components
    ///     All - Gets archetypes that have all the given components
    ///     Example:
    ///     Player has components: Position, Rotation, Player
    ///     Enemy1 has components: Position, Rotation, Melee
    ///     Enemy2 has components: Position, Rotation, Ranger
    ///     The query below would give you all of the archetypes that:
    ///         have any of [Melee or Ranger], AND have none of [Player], AND have all of [Position and Rotation]
    ///     new EntityArchetypeQuery {
    ///     Any = new ComponentType[] {typeof(Melee), typeof(Ranger)},
    ///     None = new ComponentType[] {typeof(Player)},
    ///     All = new ComponentType[] {typeof(Position), typeof(Rotation)} }
    /// </summary>
    public class EntityArchetypeQuery
#

Btw is there some utilities to serialize Native Containers?

knotty radish
#

Not sure, I don't think it exists yet

#

But they are working on editor tools for ECS so I guess that during the GDC something will come out or be announced (well UTiny editor tools were already announced for C# ECS but no ETA at this point)

muted flare
#

hey hey guys ! anyone knows when LA megacity samples will be avaiable ? or maybe they are already somewhere ?

gusty comet
#

Well I'm going to do it. I need it right now ^^

#

@muted flare this year πŸ˜‰

untold night
#

I think they said megacity would possibly be as soon as gdc

muted flare
#

hahaa πŸ˜ƒ so noone knows =). I was curious how the code looks like with this new invention called IJobProcessComponentDataWithEntity

knotty radish
#

Well they need the scene streaming feature if I'm not wrong so whenever that is out, Megacity will follow

full stirrup
#

think theres samples of IJobProcessComponentDataWithEntity

dull copper
#

I don't think there was any official statement on MegaCity release other than during 2019

#

but it's probably going to get out sooner than later (I'd guess if not on GDC then on next Unite late this spring)

urban rivet
#

I'm curious about how this will solve open world rendering. In megacity they're not using hierarchical lod are they?

#

it's just brute forced

gusty comet
#
public static void WriteArray<T>(this BinaryWriter writer, NativeArray<T> data) where T: struct
        {
            writer.WriteBytes(data.GetUnsafeReadOnlyPtr(), data.Length * UnsafeUtility.SizeOf<T>());
        }

It was there πŸ˜ƒ Still need to update Entity reference

#

@urban rivet they are. Using HLOD because they have part of buildings that they want to switch LODs with the same worldreference

urban rivet
#

I see, details are hard to come by

#

Does unity generate these merged lods for us?

tawdry tree
#

Pretty sure they made (procGenned?) different levels of actual detail, from plain stretched cubes, then adding on slightly larger details, all the way to the finest details (like AC units). Relevant 45min talk:
https://www.youtube.com/watch?v=758hd52A_RE
There's also they keynote, which is 12min long but not as technical, more a showcase. There are some technical tidbits, but more at the concept/pattern level.
https://www.youtube.com/watch?v=j4rWfPyf-hk

Learn how we built the Megacity demo in this Unite LA session. Get an introduction to the editing tools developed for streaming worlds and how we utilized ne...

β–Ά Play video

Megacity is a project built on our data-oriented design tech alongside tons of optimizations we're aiming to bring to Unity in 2019. The results are jaw-drop...

β–Ά Play video
dull copper
#

HDRP got DOTS instancing on github now

toxic walrus
#

wait... DOTS is already available?

untold night
#

ECS + Jobs + BURST is DOTS

#

twas called Capsaicin or Capsaicum once upon a time

toxic walrus
#

ah, i thought it was their visual scripting coming for ECS

lime dome
#

yeah DOTS = visual scripting was my understanding too

#

so if it's not, then what is the Visual Scripting called? DIPPIN? πŸ˜›

untold night
#

speaking of instancing and DOTS, is that PR just for HDRP or will it work for LWRP as well? I'm kinda stalled on something because the only sane performance alternative right now is creating a bunch of prefabs in all possible configurations, whereas with instancing the code would be much simpler for a data view UI i'm working on

urban rivet
#

Huh, DOTS instancing is a strange call, I guess I thought it would be automatic

#

what is different between DOTS instancing and DMII ?

#

I figured the shader part would be consistent between them even if submission wasn't

untold night
#

at the moment there's no real support for material property blocks, so even if you want to, say, make your own bespoke sprite atlas system, you're up a creek without a paddle.

My current work around is different prefabs with different RenderMesh components per material input combination, but that doesn't scale in the slightest.

#

whereas if we had material property block / instancing support, it would be a cakewalk and all the input data I'm trying to diagnose would batch under a single material object

#

for perspective, I'm trying to diagnose the output of my input buffer by making one of those fighting game UIs that show the individual moves you inputted

dull copper
#

@urban rivet I'd guess it's all tied in with this Added new batched renderer for MegaCity sample (Requires API in 19.1 and is disabled by default)

light sage
#

code was working last night, I changed it a bit, and ran it this morning, now I'm getting batch jobs only can be run on main thread errors, even when I try to revert the code, was there a change or am I just not remembering how I had is coded?

#

batching seems faster on the main thread also

dull copper
#

@lime dome and yeah, can confirm: DOTS != the visual scripting thing (although new VS will be under DOTS), it's umbrella term for these things like recursive mentioned (Unity started using it only recently)

urban rivet
#

That's for subscenes

light sage
#

why are for loops not working in my jobs today...

storm ravine
#

@fringe dew you should ask them better, be kind with them πŸ€”

light sage
#

was rhetorical, it's what I get for putting a bunch of code I don't fully understand in my project

#

I should divide this system up anyway, it was serving too many purposes

solar ridge
#

Data Oriented Tech Stack for those wondering what it stands for. It just a tech stack and not any one thing

gusty comet
#

Okay I'm completely lost with that one. What does activate this option mean?

light sage
#

do the volatile attribute and ecs/burst conflict? also, how does stackalloc tie-in?

gusty comet
#

What's the preferred method of iterating pure entities and changing data in their components in a regular ComponentSystem(not JobComponentSystem)?

gusty comet
#

But I can't use IComponentData in ForEach parameters, it doesn't compile. @dull copper

#

Hmm, actually it has a generic overload that mentions IComponentData in the source.

#

Okay, nvm. I just had to also take entity as an arg in the lambda. Wooo.

solar ridge
#

Ref may also be required

#

Not for the entity though

#

Just for the components

gusty comet
#

Yes, I didn't mention that but it was.

light sage
#

1,000,000 entities (quads, with sprite textures) covering, each 1 unit^2 in size ran in editor at a sketchy but playable 40+ fps lol, new benchmark

tawdry tree
#

How many systems were running, and how complex are they?

light sage
#

I can drop it on codepile or something

#

just three systems, a lot of it was due to occlusion settings I think

#

(when I switch to scene view it quickly locks up (after 3ish seconds), but otherwise it's good. My specs aren't great either

tawdry tree
#

Well, my point was more that entities in themselves shouldn't drop that much FPS unless you have GPU intensive stuff on them (and single, presumably render-instanced quads are not), so I was wondering if it's in a more complete environment with several systems of varying complexity or more like a 'how many entities can I spawn' test
Sounds like the answer in the format I was looking for is not many, and not particularly complex

light sage
#

no, it was simple, but 1,00,000 was just pretty ispiring, quads > sprite, with no ecs and sprite I couldn't lods more than 60,000 tiles without threadlock

#

I'll just pm if that's cool, show you a few snippets

#

looking for a second opinion on something, I have everything very commented out

tawdry tree
#

Sure, and I think you dropped a 0 in that million

light sage
#

HodHandr is extremely generous with his time, I feel like I solidified my csharp and ecs knowledge tenfold, just publically announcing his helpfulness, no better way to thank you right now

light sage
#
            Data.right = (int)(pos.Value.x);
            Data.left = - Data.right;
            Data.up = (int)(pos.Value.y);
            Data.down = - Data.up;

            if (Data.right > ZERO)
            {
                Data.off_Loops_Right += ONE;
                Data.off_Loops_Left = ZERO;
              
            }
            else if(-Data.left < ZERO)
            { 
                Data.off_Loops_Left -= ONE;
                Data.off_Loops_Right = ZERO;

            }
            if (Data.up > ZERO)
            {
                Data.off_Loops_Up += ONE;
                Data.off_Loops_Down = ZERO;
            }
            else if (-Data.down < ZERO)
            {
                Data.off_Loops_Down -= ONE;
                Data.off_Loops_Up = ZERO;

            }
        }```

XY vector specific, background loop based, inverse delta time
             job performance logging, lightweight interger component thingamagig
**EDIT--fixed, after taking the modulus and absolute value stuff out, the solution sseemed a little counter intuitive at first
#

But could it be useful, hopefully I can find out before I decide it's causing overhead and evict it

hexed pumice
#

Hi, With Unity 2019.1.0a10 I got this error Library\PackageCache\com.unity.jobs@0.0.7-preview.6\Editor\JobsMenu.cs(43,60): error CS0117: 'NativeLeakDetectionMode' does not contain a definition for 'EnabledWithStackTrace' Do I need to revert to Unity 2018 ?

dull copper
#

why on a10?

#

we are now at beta 4

hexed pumice
#

Hum... no real reason. I will try.

#

The latest is 2019.2.0a4

dull copper
#

if you want 2019.2, sure πŸ˜ƒ

#

a4 is bit old, 2019.1 has been getting few updates more

#

but 2019.2.0a6 will release next week at least (a5 was skipped)

urban rivet
#

I am a slut for latest alphas but sometimes the alpha takes you to a place you regret

#

b4 atm

hexed pumice
#

Cool... Fresh install of 2019.2.0a4 and the latest boid sample will crash the editor on loading the scene.... 😩 The other samples work...Will I need to go back to b4.

light sage
#

I never used inject because I started ECS only recently and read the deprecation notice, but why is it being depricated? inefficiency or unsafeness? or just a stylistic choice?

tawdry tree
#

Pretty sure you still have some form of injection (like in jobs...?), they're just deprecating the [Inject] decorator? Haven't really read much about that particular feature, but injection has a bit of overhead

light sage
#

that makes sense , ECS is a closed loop without it, I guess it kinda throws a small halt bottlenecking a bit at the barrier like that

#

makes sense then why they say use the buffer now

thick carbon
#

because [Inject] was a pretty big code smell

#

hard to see what's going on if you don't know exactly what the Inject attribute does

urban rivet
#

chunk replace need for inject

gusty comet
#

I have exactly 4 meshes that will persist for all of the game level. What's the best way to get them into a ComponentSystem and manipulate the shader properties every frame? I read all relevant Unity forum threads about it and I'm still not clear on how to do that except for forking the instanced renderer system and performing dark magic on material blocks.

#

I'll also need to spawn hundrends of differently colored instanced blocks so I need to set material properties for that as well.

tawdry tree
#

So when rendering stuff you have both a material and mesh in the RenderMesh component. The material should be set to instancing on for performance. The RenderMesh component should be a shared component for everything with the same settings (so one shared between all yellow, one between all red, etc.)

#

Not entirely sure what the best way to keep track of the various instances are, though. Maybe spawning entities with no position and a component, something like

struct RenderMeshStorage : Component {
  public  int Identifier; //Could be team, faction, whatever. 
}

RenderMeshStorageArchetype : Archetype {
  RenderMeshStorage,
  SharedComponent(Rendermesh)
}
gusty comet
#

@tawdry tree what you suggest, does that work only for properties you set once? I need to update a property every frame.

tawdry tree
#

Uh, if the update is supposed to update EVERYTHING using that same color to a new color, maybe. if everything needs to be able to change material info separately, you might lose out on instanced rendering, but either way using shared components would probably be bad, as whenever a value changed the entity would need to switch chunk, if i understand correctly.
That said, I haven't played around with that, and it depends on what you need to do. Why does the material's settings need to be able to change every update? What are you trying to accomplish?

gusty comet
#

@tawdry tree well it's going to be a rhythm game. I have the track buttons press animation controlled by a shader property of press progress of [0,1].

#

I'll also need to light up note blocks that are being correctly held. That means changin the shader's glow float.

tawdry tree
#

Hmm, in this case I think the 'proper' way to do it is to bake the color into the shader, but that'd require shader work.
Not to mess around with the material itself

gusty comet
#

The color is not the issue. I need to set the float for press progress.

tawdry tree
gusty comet
#

And a bool for the block shaders.

#

I know how.

#

It's just that instanced renderer ECS system ignores material properties.

#

And material blocks are classes, not structs.

tawdry tree
#

That sounds odd, but unfortunately I can't help you, sounds like you'll need someone with more nitty-gritty experience

soft nova
gusty comet
#

Yes, I've seen this.

#

I've explicitly mentioned that I don't want to fork the current rendering component system.

soft nova
#

Well you didn't say you don't want to fork it, but is either that or you re set the Shared component every frame with a modified material, which will be way slower since those will be constantly moving between chunks.

gusty comet
#

I guess I'll just sync the properties back to the regular renderer with a component mono since all of this is non jobified anyway Β―_(ツ)_/Β―

#

Any idea why this doesn't add components at all? cs protected override void OnCreateManager() { ForEach((Entity entity, ButtonComponent button) => { EntityManager.AddComponentData(entity, new TrackIndex { Value = button.Index }); EntityManager.AddComponentData(entity, new TrackInput()); }); }

tawdry tree
#

What exactly is that supposed to iterate over? If you put a breakpoint, I believe you will find that it never enters the loop?

gusty comet
#

You mean the world's entity list isn't formed until all managers are created?

#

The entity with a ButtonComponent is in the scene from the start. @tawdry tree

tawdry tree
#

Try setting a breakpoint and see what happens

gusty comet
#

I understand that it doesn't run, I'm asking why.

tawdry tree
#

Because it has nothing to iterate over? I haven't actually used that ForEach method

gusty comet
#

It works in OnUpdate.

#

It takes components you want to match as its args.

blazing pagoda
#

As far as I know, there's no entities yet when all managers are created ?

gusty comet
#

Hm, so I can only create them but not check existing ones in OnCreate. Okay.

blazing pagoda
#

Where's that ForEach thing from by the way ? I don't seem to have it in my ComponentSystems

gusty comet
#

It's the recommended way of iterating in non job component systems.

#

Lets you get IComponentData as well as MonoBehaviours if you want.

blazing pagoda
#

Ah, I'm in a JobComponentSystem

#

probably why its not there

blazing pagoda
#

Does the latest version of Entities let you use CreateArchetypeChunkArray() with SetFilter() ? If so, how do I go about doing it ? Do I just SetFilter, start the job, set it again, start next job, then wait for all of em to complete, or ?

soft nova
#

Is there anything specific that needs to be done to have pure entities work on the editor (not in play mode)? I can see that they are added, but they just don't do anything

#

Wait nvm, it works on non created worlds. So the issue is my new world

ebon narwhal
#

Do we have any news as for when we will be able to test UI features and Unity's 2D features with the ECS and Burst compiler ?

#

I am mostly interested for the sprite renderers

tawdry tree
#

You can already make 2d stuff with quad meshes, but I suppose it doesn't have quite the same simplicity of use

ebon narwhal
#

I have already done that ( I have been doing that in the past when we did not have sprite renderers available ). But indeed it does not feel right at the moment to reverse completely what i have invested time into.

near gulch
#

is there networking support for ECS yet

tawdry tree
#

There isn't not ECS support? If you're wondering if you can use those convenient 'just slap em on and play' scripts, then the answer is no; you'll need to use lower level code and/or hybrid, I believe.

near gulch
#

i don't think so

manic aurora
#

the new unity.networking supports jobs, but it passes around some native arrays under the hood that make it impossible for the ECS dependency-resolution to detect that said native array is still being accessed

mystic mountain
#

Hey! Trying to get a hang on the unity ECS concepts. Currently looking on archetypes. So from what I kind of get is that they are a composition of ComponentData like A=[positions][rotation] B=[position][rotation][velocity] etc. But mixing SharedComponentData into this, will each unique value of ShareComponentData create a new archetype?

#

i.e. C=[position][rotation][mesh = "human"] D=[position][rotation][mesh = "bird"] (where mesh is SharedComponentData)?

tawdry tree
#

No, an archetype just defines which components are/should be attached.
If differently valued shared components made separate archetypes, then what about differently valued components? As you can imagine, there are more than a few issues with separating things like that. I like to think of archetypes as an interface/recipe for components.

mystic mountain
#

Hmm, ok. I thought it was more like a "prefab" kind of thinking. But its like each Archetype represents a collection of chunks, and further what I understand entities with same SharedComponentData are grouped in the same chunks.

manic aurora
#

i mean, in practice, you will just use archetypes to instantiate entities with fixed initial components. there will of course, also be conditionally added components, but if they aren't known at the time of instantiation, you wont' have any "in-code" archetype for them. you could REFER TO an entity with a particular set of components as "having a certain archetype", but even when you are working with chunks, you won't ask for "give me chunks of this archetype", you will ask for specific component(s) that could be on multiple different archetypes (that will all be iterated).

yes, shared component will split up your chunks for the same archetype. would i refer to each combination of components + shared component value a new archetype? nah

mystic mountain
#

I see, well when reading the docs and listening to talks its good if everyone has the same definition, then you can argue that their definition is bad x)

light sage
#

oof, I restructured my folders and namespace, and got things working again, but now I'm getting "Saved by batching: 0" when I was getting around 9 for that value before. I made a few other minor changes, but can't quite seem to get that value back from 0, and I didn't save a mirror of what I had. Anyone have even a clue what I may have done to prevent the batching?

#

With what I had before, the only difference I can conclude for sure is that I was using fields to declare specific entity managers for seperate tasks, and what I have now just "gets or creates" one when I need

soft nova
#

Does your material has GPU instancing enabled?

light sage
#

Ah, good call, I changed my material up eartlier

#

let me check if that's it

#

how do I give karma

soft nova
#

I believe that this server doesn't have anything for karma, glad to know that the issue was easily fixed

light sage
#

yea, me too, I honestly never would have thought of that since I change the scripts so much, glad someone had the insight

mystic mountain
tawdry tree
#

There was a discussion about how to handle/do that earlier, but I believe the conclusion was basically 🀷 unless you already know you might wanna wait until they make that easier/make a good example.
The first step would be that each world can only have one entityManager, so if you manage to get multiple different entityManagers, you have different worlds.
The goal with separating simulation from rendering is that you can render at glorious (insert fastest commercial screen update rate here) FPS even if your simulation stutters or just runs like shit at like 1-5 FPS.

mystic mountain
#

Hmm ok, not sure I follow the reasonining. You could also just make the simulation systems togglable and break them from the rendering systems, which is kind of basic and what you usually do?

light sage
#

Yea Jaws, that's how it's supposed to work, but how it is now, unity does it's own stuff with the "WorldDiffer" and we do stuff with the world. It should be that there is a ghost world that just calculates, and another world in charge of transforming and rendering

#

my question is with the new hybrid rendering module, why can't we see the outlines of out entities meshes in scene view? I just got my infinite universe simulation "pretty much" working, but there are some issues I really need a visual to work out.

light sage
#

NotImplementedException: The method or operation is not implemented.
Unity.Rendering.InstancedRenderMeshBatchGroup.OnPerformCulling (UnityEngine.Rendering.BatchRendererGroup rendererGroup, UnityEngine.Rendering.BatchCullingContext cullingContext)

This error, and the the address in the scripts

light sage
sharp nacelle
#

do we have a sticky or a page with the latest and greatest ECS samples and resources? the official samples github got a bit empty in the recent updates and many other projects are from last year and don't reflect the latest changes anymore.

Sorry if this gets asked a lot πŸ˜ƒ

dull copper
#

it's a common issue really

#

ECS evolves a lot

#

and almost nobody who shares examples bothers to keep the up-to-date with latest conventions

#
#

neither of them cover ForEach but official samples do

light sage
#

https://gametorrahod.com/@5argon this is indespensible

#

kinda provides an insightful timeline for us newcomers

dull copper
#

there's some weird stuff too though

#

like comparison between ue4 and unity when he's only used Unreal for few weeks πŸ˜„

#

you can't objectively compare the two with that little experience on UE4

#

but yeah, this is offtopic, sorry about that πŸ˜ƒ

light sage
#

yea, I take the meat lol

dull copper
#

it's funny though, as people who move from Unity to Unreal have some urge to immediately praise how much better the UE4 is based on their early impressions, you don't see these people coming back when their expectations have been readjusted to reality

full stirrup
#

ive used both for about 7 years and still continue to use both

dull copper
#

yeah, they both have their own good things and painpoints for sure

sharp nacelle
#

@dull copper thanks, that should help me get up to speed. Last time I played around with ECS was in November or December I think, and a lot of stuff has changed already πŸ˜„

dull copper
#

GDC is really close now though

#

expect to see new fancy ECS stuff there

sharp nacelle
#

while I'm at it: does anyone have experiences with creating managers in the ECS worlds? I'm trying to extend ScriptBehaviourManager, but the InternalUpdate function is internal and abstract, thus preventing me from using the class at all.

#

Basically I need to implement the function to compile, but can't because it's internal. Maybe I'm misunderstanding the new Managers system.

light sage
#

I've tried reflection with the assemblies, but from looking through stuff it seems they either haven't gotten to implementation yet, or (more likely, from the names of the assembly definiotns and todo: commentary), they're going to decrease what we can actually do in scripts in favor of bringing that functionality to GUI elements in the unity editor. But I hope it's the former. The noise library in the new math package works amazing with ecs in burst, having fun with that atm and not getting anything concrete done

lime dome
#

this blog post just dropped and I'm trying to understand something

#

when he says "We will slowly but surely port every piece of performance critical code that we have in C++ to HPC#." does he mean just ECS stuff, or the whole engine in it's entirety?

#

later he says "By writing Unity’s runtime code in HPC#, the engine and the game are written in the same language. "

#

which makes it sound like he means everything

#

that would be a huge shift to rewrite everything in their stripped down C# instead of C++

untold night
#

that's pretty much what I expected would happen.

Outside of platform-specific and/or licensed integrations, there will eventually be no reason to have so much of the engine be a black box C++ thing that's harder to maintain for feature teams

#

especially when so many of their issues are likely down to how data is marshalled back and forth between C# and C++

it's basically a game of don't break the garbage collector when you're dealing with that much interop

lime dome
#

I guess that does make sense

light sage
#

what's a good approach for GUI elements atm? bring the component data over to the Monobehavior in an OnGUI, or is it worth is to try to setup a GUI system in ECS? I can't think of a good way to deal with strings, but strings are generally going to be consistent for my nrrds with numerical data being the major fluxuation in that regard

soft nova
#

Depending on what you want to do with the UI, but for just showing data. IMO is not worth it

light sage
#

true, it's just bothersome to have the monbehaviour holding up the other threads from accessing my components, I'm going to have to implement a unversal timer at some point anyway to manage things. I altered the timestep for testing and some of my jobs were outpacing others because I didn't have my dependencies setuup correctly. ECS atm feels like writing an engine from scratch

dull copper
#

@lime dome that's what Unity has messaged since last year now

#

they can't port like everything to c# side

#

you still need c++ for accessing the hw

#

but for most engine components, they can do that

#

there will still be some things on c++ but they can keep that side slim if they want to

lime dome
#

I see

dull copper
#

it's good though

#

as it mean we'll get more source access to unity code than now

#

I hope some day they get the core so slim they don't need licensed 3rd party content there and they can open it to all users as well :p

#

but that's me being hopeful

#

competition gives you full source code access already so this is one big limitation for Unity right now

lime dome
#

yes, that's true

urban rivet
#

@lime dome eventually all of unity will be C#

#

Well, C# authored but compiled to better than standard C++ machine code

#

It's higher performance in the end for them to do this because there's no bottleneck between C++ and C# worlds then

#

managed memory etc

#

I think it'll take a few years so really, I would say it'll be a good time to start after GDC for your own stuff. At least I think it'll be less wild west by this point.

lime dome
#

yeah I guess I have a hard time believing C# is faster than C++. goes against decades of conventional wisdom πŸ˜›

#

but if they have pulled that off, awesome

urban rivet
#

It's not really C# or C++ that's faster anyway

#

the language has always been irrelivant

#

the compiler is king

#

Of course we're not allowed to use it all, but you know what I mean!

#

Tron knows best

lime dome
#

yeah I know, but usually C#'s compiler wasn't the best.

#

I guess it was just a matter of time until they reached parity

urban rivet
#

C# compiler will remain poo I think

#

just not this bit

#

it does stand to reason though, there is plenty in C++ land we can do to kill our perf that we don't even need to touch really

lime dome
#

oh absolutely.

dull copper
#

@urban rivet I honestly doubt everything will be c# in Unity

#

that would be madness

urban rivet
#

Anything we touch in our games that has something to do with perf will likely end up in C#

dull copper
#

yeah but I now talk about hw interfacing, that's traditionally been c++

#

altho it would be fancy if they could get that done too

#

but looking at current development it doesn't seem it's going that way, a lot of upcoming new systems still rely on slim c++ counterparts

#

and I don't think Unity has ever tried to hide that

#

I know Joachim mentioned it still being there on their goal for this

safe lintel
#

i hope blittable bools are introduced at gdc, alongside something meaty like physics πŸ˜ƒ

dull copper
#

heh

#

pretty sure everyone has worked around it but it's still weird it got removed before any alternative

knotty radish
#

I can live with a byte as a bool

#

We won't have outofthebox physics any time this year I think, there is just too much to do before that

safe lintel
#

noo dont crush my dreams

knotty radish
#

Hey but UTiny editor tools coming to ECS is already something

#

I just hope they will change the file extension name

#

".ut*" 😫

dull copper
#

unreal tournament

knotty radish
#

Yes exactly I can only see that

dull copper
#

I'm more hopeful on the HPC# physics

#

Unity has been clear that it's not going to be full blown physics engine but simpler setup

untold night
#

I doubt a whole physics stack will be at GDC, but I'd like at least a good basic collision / spatial query solution that's not the current weird physx hack for raycasts

just a "here's an octree, capsule, sphere, box and mesh collider alternative, along with all of the *Casts alternatives"

dull copper
#

so there are real chances on seeing the first iteration this year

untold night
#

and also compute penetration alternative

knotty radish
#

"compute penetration alternative"
Yes this

safe lintel
#

where did they mention its not going to be a full blown thing? always thought it was going to eventually replace physx

dull copper
#

maybe eventually

urban rivet
#

@untold night I'd be happy with raycast vs static mesh plus basic support for box, sphere and capsule colliders, I don't even need anything fancy

dull copper
#

of course that was almost year ago

#

so plans could have evolved

#

(and probably have)

urban rivet
#

Hopefully because unoptimised ECS physics are still ECS physics that are wasting perf...

dull copper
#

I'd want convex collisions, overlap and cast queries

safe lintel
#

nothing there strikes me as cut down in any way

dull copper
#

and doing those would require a broadphase πŸ˜„

urban rivet
#

yeah just convex+primitives vs mesh and themselves

dull copper
#

yeah, I guess it doesn't, I just read it so πŸ˜„

urban rivet
#

dont need to worry about special stuff or joints

dull copper
#

"brute force simple readable code" is usually meaning it doesn't do dozen things with all the bells and whistles tho

urban rivet
#

or it means no broadphase :P

dull copper
#

they definitely do broadphase in some form

#

it would be silly not to

urban rivet
#

a physics engine without broadphase wouldn't really be that useful imo

#

I guess for simple games then... why use ECS?

dull copper
#

it can be simple AABB thing even

#

but I bet they figure out some fancy setup for it

#

like they did with the static object culling on ECS

urban rivet
#

physx is pretty nice peformance at the moment but suffers some bottlenecks with the oncollision stuff, even with GC alloc removed, there's a lot of overhead still happening

untold night
#

I mean I'm making a 2.5D action platformer on 3D rails with small to large-ish levels. My use case is the following:

  • Character vs Static World Geo
  • Character vs Moving World Geo
  • Hitbox vs Hurtbox
  • Some rays for platforming/AI
  • the actual "physics" will need to be hand-rolled like my earlier prototypes

@urban rivet - agreed, I'll expound for some folks:

I like physx but the main problem it, Box2D, and a few other middleware bits Unity uses is it's still kind of it's own thing with its own conventions and you have to map Unity conventions to PhysX conventions. They also don't expose everything due to opportunity cost + shifts in an API they don't control.

Honestly Unreal ditching almost every out-of-the-box 3rd-party integration makes total sense, you have to bend over backwards to meet both the licensing and API restrictions and you may not legally be able to expose as much as some users need without jumping through hoops.

This is less of an issue now that PhysX is open source, and it's not a problem with Box2D given that it was always (I think?) open source, but for stuff like Beast/Enlighten/Substance it's been very apparent.

dull copper
#

tbh, Unreal exposes so little of the physics mainly because Epic's own games work with the setup they have

#

I'm sure they could expose everything there without issues if they wanted to

#

but there you at least have source access so you can expose what you need (like I did with physx contact modifications and fixed timestepping for physics which UE4 doesn't support out of the box)

#

the main issue in Unity is that we have no control over the integration

#

and if you need some niche feat, it's going to stay low on internal priorities

#

as majority will not benefit from it

#

this is one big reason why I'm excited about DOTS

#

as it finally gives more power to users by giving more source code access due to the new things being (mostly) on c# side

untold night
#

also Unity feature engineers can work more effectively with less WTF bugs caused by weird C++ compiler behaviors.

dull copper
#

I'm not totally convinced on that one yet

light sage
#

the compiler is going to be c++ either way

#

il2cpp is what burst works with

dull copper
#

but on the bright side, they'll be WTF:ing on DOTS bugs

#

so it's definitely win for us

#

as they will without a doubt make it more robust because of it

untold night
#

it's less bugs with C++ itself and more the Marshalling between C++ <-> C#

like they've said in the past if you don't do the translation for certain calls and data structures it will break the GC

dull copper
#

afaik, burst works without il2cpp, they convert IL to LLVM and from there to machine code

untold night
#

yeah, for burst code at least, it's just machine code the C++ is talking to

light sage
#

my il2cpp standalone windows builds have been noticeably the smoothest

dull copper
#

Burst is a compiler, it translates from IL/.NET bytecode to highly optimized native code using LLVM.

untold night
#

I have worked with C++/CLI exactly once and never again.

I'm sure Unity probably has their own bindings and not that hybrid monstrosity but yikes. I still had to write custom marshalling code and that was half the headache.

One of the reasons I dislike Objective-C is the syntax discontinuity

light sage
#

I was considering doing some work w/ pointers and marshalling with ECS, but it was leading to more trouble than it was worth

#

being as the editor supports this at 10x this scale with my poorly optimized ecs mess, I don't really see the need for lower level access until I get around to serverside implementation

#

I just have to learn to settle fights between the threads, the reder queue, layers and the z-axis

#

the new math library may have it's basis even lower than C++...I can't see how they could have the hardware access to generate that kind of entropy with c#...c# is user-friendly,, but also very limited in compasrison to C++

urban rivet
#

@untold night Another major (essential TBH) reason for inhouse physics over physx regardless of licensing, is that in this case, a properly deterministic physics engine will perform best, and of course make it a game changer for networking...

#

Quite a literal game changer with what it'd empower you with.

#

This also saves money in server upkeep obviously, so it's beyond a performance issue

#

Latency on opposite sides of the world would be almost similar to local for a lot of games too...

dull copper
#

I don't really see how you could fight latency with that at all

#

sure you don't have to wait for corrections from server (as deterministic physics don't drift) but other users actions still can only happen on the other client after the messages get there

#

but when you have pvp collisions in real-time online game, latency will always be an issue and no determinism can help that

light sage
#

and tailor made in-house compensation system is going to outperform a non-costom tailored one

#

but, yea, optic fiber can't be programmed

#

only contracted out by ajit pai or whoever

lime dome
#

ijit pie sounds about right

urban rivet
#

@trail burrow will explain how deterministic physics can help fight latency :P

dull copper
#

You can send smaller packets I suppose

urban rivet
#

you can escape doing anything for a large amount of things and fix all sorts of rollback or prediction

#

also box landing in australia will happen same time as a box landing in america

#

See gaffer's articles on it for a bit more, he simmed a few hundred physics things on network

dull copper
#

But you also cant quantize all the values so you end up sending full resolution data

#

I think I've read most of his articles

#

My core issue regarding latency is still player vs player collisions.. Only thing that can dramatically help on that is lower ping

#

On nonphysics heavy games, you can hide that better

urban rivet
#

but with determinism the idea is that when anything collides, both can be adjusted instantly and perfectly locally and correctly

dull copper
#

Nope

urban rivet
#

it allows you to rewind

#

it allows you to predict

dull copper
#

That cant happen as your clients dont have realtime data on moment of impact

urban rivet
#

in practise it doesn't matter much

dull copper
#

They can guess where other player was or what it was doing

#

But that guess will not be deterministic

urban rivet
#

in typical games the characters haven't even moved far for half a second's latency

dull copper
#

In physics sims, even last digit from float value can throw collisions in seemingly different direction on some cases

urban rivet
#

how if it's deterministic?

trail burrow
#

hey

urban rivet
#

yo

dull copper
#

Doesnt matter. Your input data never is

urban rivet
#

please teach us master fholm

trail burrow
#

lol

dull copper
#

Due to the latency

trail burrow
#

in a fully deterministic and predicted enviroment

#

player collisions resolve perfectly

#

every time

untold night
#

Determinism is also good for replay/journalling/automated testing/AI training

trail burrow
#

@untold night yup

#

@untold night also makes spectating games easy, just send the input stream

#

so little bandwidth

dull copper
#

Only way you can guarantee you feed the simulation with exact same data is to stall the simulation, basically lag everything

trail burrow
#

@dull copper no there isn't

#

quantum literally does what you say is impossible :p

dull copper
#

You can guess and then correct with real data

#

If you do that. I believe you

trail burrow
#

yes, predict/rollback

#

we predict remote players inputs, then rollback the entire world

#

on mispredictions

dull copper
#

Yeah. Thats fine, but you still do get the initial error

urban rivet
#

If unity isn't planning to do that I might as well just make it email turn based

trail burrow
#

@dull copper yeah but that initial error is usually fairly minor, especially when dealing with something that's even remotely not instant acc/deacc

#

@urban rivet i doubt they are tbh, quantum is a dedicated setup because the chance of miss-predictions (and thus rollbacks you perform) scales with player count

#

so it requires a custom setup to be fast enough

urban rivet
#

right

trail burrow
#

@dull copper this last one is the most important for our convo

#

that is two players, both with 250 ping

#

one watching the other player move around

#

this is all built in quantum

urban rivet
#

for smaller games you don't need ecs at all, just a deterministic physics network engine

#

I guess you started with that?

trail burrow
#

well quantum has its own ecs, state definition language (compiles to c#), own physics engines, etc.

dull copper
#

I'd debate most smaller games dont "need" determinism

urban rivet
#

there can't really be a separation between physics and networking IMHO.

trail burrow
#

@urban rivet nope

dull copper
#

It helps but people have managed without

trail burrow
#

@dull copper well the benefit of something like quantum is that you can have people basically write a single player game that works in multiplayer, since you dont need to do anything other than your game logic/ui/etc.

#

there's no MP code

#

that is the 100% big win

#

plus it handles shitty network conditions better than regular networking

#

so really good for mobile games, etc.

urban rivet
#

actually the shitty network quality is a point I hadn't thought about

#

so games will just feel great mostly

dull copper
#

But then you have to deal with exit games who get so pissed off when you discuss their own licensing that they just boot people off their support discord :p

urban rivet
#

I guess I'm not going to get this from Unity within 2 years.

dull copper
#

I have huge respect for @fholm. Just cant see doing any further business with a company that cant openly discuss their public terms

urban rivet
#

Yeah well that's offtopic lol

#

lets change subject

dull copper
#

ik, still bummed that they booted me tho :D

trail burrow
#

i mean the ECS is ... it's good, but i don't see most games needing the performancea

#

and the job system is generally not usable for dedicated servers anyway

urban rivet
#

truth is I'm likely to go with photon for networking becuse I am not experienced enough to deal with shit (tm) and I am utterly clueless at running servers.

unless unity has a hot networking thing lined up, I can't be blamed, right?

#

look, if I was stupid, I would be trying to do all that myself

#

I think indies are best off upping their single player game, or even couch co op

trail burrow
#

@urban rivet yeah for sure, but like in the case with quantum we have a lot of teams that have never done MP before, even smaller indie teams (3-4 ppl)

#

and they couldn't find/didn't want to get a networking guy

#

and quantum basically just lets them write gameplay

#

as they would normally

#

but quantum isnt for every game, it's a specific product built for one purpose, it's not a one-size-fits-all silver bullet for MP at all

urban rivet
#

it seems to me it's for games that are mp centric, rather than sp games with optional mp

trail burrow
#

ye

#

for sure

urban rivet
#

it's battle royale friendly :P

trail burrow
#

haha

#

we have a few mobile BR games in dev i think

light sage
#

my game would probably function fine relyaing network data through telnet

#

or even an irc channel lol

#

my "cluster" could literally probably be a freenode server on a unix box running on dsl

safe lintel
#

i just noticed you can rename entities in the debugger, is it possible to assign an entity a name via script?

knotty radish
#

Are you working on Quantum (like at Photon enterprise)?

light sage
#

@safe lintel yea, it's setName, a property set with EntityManager. It's helpful for finding the entities easier in the debugger

#

possibly a method, I forgot

safe lintel
#

thanks @light sage !

dull copper
#

@safe lintel just be aware that entity naming is editor only thing

#

That stuff helps a lot in debugger and in forthcoming ecs editor but there is no reason to waste memory on it in actual builds so it gets wiped from builds

#

Btw. Hybrid Renderers gameobject scene conversion tool also does this: once scene is converted to ecs world, new entities hold their old gameobject names

gusty comet
#

How do systems run without being attached anywhere in the scene?

lime dome
#

magic of The Cloudβ„’

#

πŸ˜› (j/k)

gusty comet
safe lintel
#

Yeah I figured as much, thats all I need it for. Trying to figure out which entity is what without names is enough to drive one to the edge of madness

gusty comet
#

Ughh, I'll have to think of how to jobify random generation that syncs to a Unity tilemap. The pain is I don't even have chunks, it's all a queue of position snapshots with some info about previous steps and some querying the tilemap for taken tiles.

gusty comet
#

Anybody know how to imitate tilemap structure in a native container?

gusty comet
#

Specifically position lookup, I need to check if a tile is empty or not.

#

Using its x and y coordinates of course.

tawdry tree
#

If you can access the container, then you just need to have it structured in a way that helps with that, but I don't know how to do the access part

gusty comet
#

I suppose I can use NativeHashmap that uses a position struct with x & y as the map's key.

tawdry tree
#

The easiest is a 2D collection, but you'd get better performance from flattering it, such that instead of
[[1,1 2,1 3,1]
[1,2 2,2 3,2]
[1,3 2,3 3,3]]
you have
[1,1 2,1 3,1 1,2 2,2 3,2 1,3 2,3 3,3]
That requires known sizes, though. You could achieve that by chunking the map up, but that adds further complexity...

gusty comet
#

No known size, also infinite upwards πŸ˜„

#

I'll have a death level rising destroying the lower tiles though.

tawdry tree
#

A mentioned, you could chunk it, so for every, say, 10x10 tiles you make a chunk. But then you need to potentially chunk those...

#

Really, having a proper way to lookup a given Entity (tile) by struct (coords) would be ideal, but I'm scratching my head as to how

gusty comet
#

That'd be a cache miss so there probably isn't a way to do that.

tawdry tree
#

Keep in mind that while performance is great, sometimes you just need tot get shit done, and worry about it later. Someone more experienced with ECS might have a better answer, tho

gusty comet
#

Yeah, my non threaded implementation takes 1 second for 10000 iterations, so it's more about keeping stuff async as player moves upwards.

tawdry tree
#

Hmm, a descent search using linked entities might work. Ie. you have an origin chunk available, then you just consistently move towards the chunk you need. The issue is that everything needs to be in memory, though.

#

Google-fu tells me that the NativeHashmap structure might help you do what you're looking for

gusty comet
#

Yeah, I already mentioned that.

tawdry tree
#

Ah, i missed that message while writing mine

#

But as far as I can tell, hashmap with the the index coming from the position sounds close to ideal

gusty comet
#

Actually, looking at my original implementation, all I need is a hashset of vector3s.

#

But there's only a hashmap, hmmm.

#

Oh, I guess I could hash the position and use it as a chunk id in a multihashmap and then just do a linear search in values with that key since it allows doing this.

#

Does that sound good?

#

Are concurrent writes to the same native container atomic btw? I kinda need generation jobs to always have the latest data when there are multiple of them cause otherwise they'll get old data and put things where they overlap.

#

@tawdry tree

tawdry tree
#

Sounds good, your position is something like this?

struct Vector2Int {
  int X;
  int Y;
}

No clue about how atomic the operations are.

gusty comet
#

Yeah.

#

I have another question then.

#

I need to query that a tile was marked as taken or marked as must be unoccupied.

#

What's better, 2 multihashmaps of chunk id to int2 or a single map of chunk id to a struct of int2 and a taken or forced free flag for these 2 types of special tiles?

tawdry tree
#

Uh, not sure I understand the question

gusty comet
#

I need to query 2 types: if a tile was marked as "do not block" or was taken by a block. I can either make a single hashmap for them and have a flag of their kind with each of them or just make separate maps.

#
NativeMultiHashMap<int, int2> taken;
NativeMultiHashMap<int, int2> doNotBlock;
#

vs

#
enum Kind
{ Taken, DoNotBlock }
stuct SpecialTile
{
    int2 Postion;
    Kind Kind;
}
NativeMultiHashMap<int, SpecialTile> specialTiles;
#

I'll need to query both but which one is theoretically friendlier to cache?

tawdry tree
#

I don't know about the gritty specifics. Also keep in mind the danger of premature (over)optimization. (which of course depends on what you're trying to accomplish and for what platform, etc.)
On the maintenance side, though, it seems to me like one method might be a lot easier to code and maintain/understand than the other, depending on the context and use and such.

gusty comet
#

@tawdry tree okay. I'll go with a unified map for now. Also there's apparently an IJob interface for iterating mutlimap, which is pretty neat. I'm going to need to destroy some of them when they go below a certain height.

#

How can I return no job in JobComponentSystem's OnUpdate? Let's say some condition isn't met so I don't want to schedule any jobs.

safe lintel
#

return the original jobhandle in OnUpdate?

#
        {
            return inputDeps;
        }``` I would assume it would still make sense to schedule the jobs and keep the dependencies and have them not work rather than not scheduling but idk
gusty comet
#

That works, I just wasn't sure if I was doing it correctly @safe lintel

#

Managed to recreate my structure in the job, now I just need to port over the actual generator and then make a system to sync tile entities to Unity tilemap, yay.

#
private struct GenerationJob : IJob
{
    [ReadOnly]
    public GenerationState State;
    public NativeMultiHashMap<uint, SpecialTile> SpecialTiles;
    public NativeQueue<GenerationState> States;
#

I wonder if I'm doing something wrong, but the job actually needs all of this shared state with write access to work in a connected path generation. I wonder if it even threads.

#

Cause I just do this to keep the latest data ```cs
if(states.Count == 0)
{
Enabled = false;
return inputDeps;
}

GenerationJob job = new GenerationJob
{
State = states.Dequeue(),
SpecialTiles = specialTiles,
States = states
};```

safe lintel
#

tbh i havent messed around with enabling or disabling a system but does the system give errors if there arent states for it to process?

#

I personally have a bunch of systems where if there isnt stuff for it to do, I dont really do anything different than if there was, they just always run. Im sure someone more advanced can interject but I personally dont see the value in going out of my way to disable a system if there isnt data for it to process

gusty comet
#

@safe lintel if there are no more states, that'd mean the generator fucked up. Right now I'm just testing if my chunk tile search works so I disable it to avoid getting my console flooded with the same debug messages of marked positions.

#

I just removed the debug log calls from the snippet.

light sage
#

yea, a lot of this paradigm is so foriegn to me, and inaccesble without a lot of trial and error. I have lots of jobs that need the postional data from my "player" (almost all of my jobs need this atm) , but I don't won't to bring my "player" entity's positional component into every single job. Firstly, it seems they would have to filter to see if there is another "LocalShipPositionalComponent", which would never be the case,(does the DissallowMultipleComponents attribute let the jobs know to not search all about? I doubt it) and also, I can't figure out the proper way to bring components from multiple entities into a job. That's my major issue.

TL;DR; how do I bring in two or more distinct component types into a job so that I can work with those two or more components? If I include them in the IJobProcessComponentData type filter, I don't get any components. Is this what inject was for, or am I (I wouldn't be surprised) missing something blatantly obvious. The only way I know to do this is with GetSingleton<WhataverCompoentStruct>().whateverproperty stuck in the jobs OnUpdate constructor/loop, and I know this isn't the correct way

light sage
#

I mean I guess it's a structural flaw in my planning also, a lot of what goes on in my jobs could be reduced to functions (methods, not used to c#). And some of the positional data could be handled with a separate data structure (sql or smth) since it's not as frequently needed. Btw, I'm not complaining, lol, I went into this with the knowledge that this was experimental and not well documented, it's just so difficult to make dynamic expansions as opposed to standard run-of-the-mill OOP. I.E. I'm trying to incorporate a purely simulatory zed axis that's locally irrelavent (the skybox just rotates, no real positioanl change, but does become relevant when "warping", and it's basically looking like it's going to either not be a feature or require a complete restructuring of well, pretty much everything. maybe I need more than one GameObject, or maybe less in my monobehavior that I do have. not even sure

#

honestly probably just feeling stupid about spending all my spare overhead on reinventing what I realize now is just an ECS particle system

lime dome
#

looks like a job for visual effects graph

light sage
#

yep, that's a week wasted, sounds about identical to what I created without any of the overhead clogging my game loop

lime dome
#

well, it was still a good exercise to learn about the ECS

#

i still haven't touched ECS myself

#

so you're ahead of me hehe

light sage
#

I wanted multithreading, but now I want my gameobjects back

dull copper
#

nobody is forcing you to ECS if you only want jobs + burst

#

πŸ˜ƒ

#

even unity does that for some of their systems

light sage
#

I like to learn things the hard way, I'll probably end up with my own engine on top of the Unity engine. But I think that's a good suggestion, try to take what I have and translate it back to a hybrid approach

dull copper
#

my main annoyance is that you can't handle jobs + burst outside of the main thread

#

that pretty much ruins my plans on running custom physics on separate thread and getting burst gains there

#

I actually did a prototype where I ran my own threading on c++ native dll that handled netcode, physics and input

light sage
#

yea exactly, I wanted the simulation world vs. presentation world thing going on

gusty comet
#

Run them inside a job πŸ€”

dull copper
#

that's not the solution to my issue

light sage
#

with the cpu taking all that load

dull copper
#

I want to run things async to rendering

#

jobs finish on main loop and thread

light sage
#

OnUpdate doesn't wait for Update so it's async in a way

#

or more likely I'm still not understanding. I just know when I changed the timestep I got some funny things happening

#

it's a ridiculous timestep, but the homeade particle system (two seperate jobs, working on that), just can't keep up with a different set of jobs, which is actually locked to the main thread like you said due to the camera adjustment being in the monobehaviors update method.

#

which grabs it's data from an entity that ghosts the ships positional data so as to not lock the ships's positional entity to the main thread

#

And actually that just made me realize what's happening here. The camera can't keep up with the ships movement because the ships movement isn't locked to the main thread. The ghost, which grabs positional data directly from the ship, is also locked to the main thread, but it's missing steps exposing a hole in the entire concept behind my idea for keeping the ship stationary in respect to the particles (given a riduculous timestep). But this kind of "bad" async just want fly, because it could easily be abused if it's applied to more than purely aesthetic data

#

but the only solution is dependencies, which would result in what you were saying with everything locked to the monobehavior's update method. Or we get rid of the monobehavior altogether. I don't thinks that's possible right now. And I was going to build a "kernel" system, as a sort of proxy between things, and a way to maintime syncronization between asyncronous processes, but that flopped because it would litterally need to take in every single entity the way I had it figured. Or I add an irrelevent component to the entities it needs

spiral holly
#

I want to learn ECS

light sage
#

@spiral holly GmanGavin, it's hard to learn ECS right now, a lot of stuff just got deprecated and the normal "google my way to a Master's Degree in a few weeks" approach isn't possible. there's very little relevant information out there. But you should still learn it if you have the spare time to waste. I can answer questions here about the common roadblocks you may have starting learning it now, since I started a week ago

#

A lot of method names changed for instance, and they apparently stripped 90% of the examples from the github repository

gusty comet
#

It's hard trying to learn from the FPS sample when it uses ECS and it's changing

light sage
#

The boids sample is almost completely irrelevant to me,indeed

#

and the link to the "twin stick shooter" demo is dead, so I haven't even viewed it. But for large projects, there's literally no references to use. Maybe one or two youtube videos that use injection which is deprecated

#

I mean....I wrote this in 12 hours one day, that's when I decided to download Unity and do game dev. I was tired of web dev. But to produce the same result in unity has taked aroudn 144 hours https://vincible-whip.000webhostapp.com/ Edit: unity ECS. Using gameobjects it would be like 30 minutes

lime dome
#

yeah i was going to say, the web version just looks like some transparent textures side-scrolling πŸ˜›

#

which is very simple to do

light sage
#

yea, the web version was going to grow, but I didn't think javascript would be able to handle my master vision

#

It didn't even reuse the old symmetrical backgrounds, it created a new one each time. Game Dev has a lot of trade secrets I'm having to learn

#

@lime dome it was simple, but the first time doing something like that is was a fun challenge, I just want to fly my artwork really fast inside a skybox of my astrophotography in Eve Online/ksp style in all honestly

lime dome
#

yeah i just meant in terms of taking 144 hours πŸ˜›

light sage
#

oh lol

#

I have a launcher with smtp and boxes and inpus and password, with a sqllite data mockup, and stuff like that

#

so no, not 144 just for the ecs skybox/homeade particlesystem

lime dome
#

yeah, i saw your elaboration to 30 minutes and that's why i was like "that's more like it" haha

light sage
#

yea, I was just referencing the translating everything to ECS with no knowledge of ECS difficulties

lime dome
#

yep learning new systems and methodologies always takes a lot of time

light sage
#

very true! I quit college Junior year to do art, because the CS program at my uni was a joke

#

I had a hard time only in one class called JCL. It stands for Job Control Language, and is actually like IBM's zOS' own version of ECS with a spooler, it's a nasty paradigm for those of us who are more inclined to hollistic, abstract thought patterns

untold night
#

coming from C/C++, ECS feels more right and my biggest issue is having to unlearn the intense desire to build excess scaffolding like OOP trains you to do.

light sage
#

@untold night with OOP though, I like having that scaffolding, i.e. all my spaceships are going to have all of these engines, so when I need one I just use a constructor from an abstract spaceship class. I was really disapointed when I learned unity GO c# classes inhereted*spelledworng from monobehaviors and they didn't use constructors

untold night
#

Yeah that was pretty disappointing as well. I kind of understand with the whole "MonoBehaviours live in both C++ and C#" and by the time they realized it was an issue it was already too deeply ingrained into everything.

light sage
#

I'm trying to use entities like objects, but that's just not ok, it doesn't work lol

lime dome
#

monobehavior never really bothered me

untold night
#

You have to think of them as handles or keys

#

it's basically a database

lime dome
#

you can just stick the monobehavior on a Gameobject as a prefab, and 'construct' one whenever you want by instantiating.

light sage
#

right, but I like passing the params in the constructor

lime dome
#

or you can even just apply the component to a Gameobject you create at runtime and do it that way

#

but I prefer to use prefabs myself

#

well you can send 'params' to the class once it's instantiated

#

or at any time really

dull copper
#

afaik, there's no official world if ECS editor will get prefabs or not

#

I know Tiny Mode lets you make those from the scene hierarchy but they don't really work πŸ˜„

untold night
#

the best solution for you might be to write static helpers that construct different configurations of entities.

also, you can put whatever constructors on component structs that you want

light sage
#

yea, it's just all new I guess, it's hard to learn to do things differently, syntax is somewhat new, first rodeo with C#, only limited Java before and a ton of python, js, and php

dull copper
#

prefabs are great for world building though, I would be surprised if there wouldn't be something similar for ECS

#

you need some way to preset things

#

(without coding it)

light sage
#

so if I add constructors to my components is that goin to mess with the efficiency concept of ECS

untold night
#

ah that explains it. If you're not as used to the lower-level processing it can be a bit of a 180-degree head turn

I was looking at ECS type frameworks for unity years before the official announcement, after a friend of mine and I were basically moving in that direction instinctively anyway

we made a crappy ECS framework entirely by accident, as we were basically moving towards managers and simpler components to deal with perf / org issues on a project

#

nope

#

if well optimized, the perf cost can be negligible or optimized away completely

#

and I mean the compiler

light sage
#

yea, when I read the ECS concept it sounded so appealing/intuitive/and logically appropriate, a "living database" so to speak. I felt I had the solution to database problems, and could have item compoents, ship components, engine compoents, etc, with my systems being a neural network of worker bees

#

all in a muti-threaded and threadsafe environ, meaning no more trying to trick unity into allowing me to multithread. or settling for subroutines.And then reality hit, with actual syntax restrictions and implementation using types as filters, and not having direct access to my entities and basically just being backwards in my thinking

#

I suppose I need to learn the alternative to injection, that's probably the puzzle piece that's preventing the lightbulb from turning on

#
    protected override JobHandle OnUpdate (JobHandle job1)
                {
                        float3 b = new float3( 1.8f , 2.2f , 10.4f );

                        int DataX = GetSingleton<OverlordData>().localX;
                        int DataY = GetSingleton<OverlordData>().localY;

                        int moving_right = GetSingleton<OverlordData>().off_Loops_Right;
                        int moving_up = GetSingleton<OverlordData>().off_Loops_Up;
                        int moving_left = GetSingleton<OverlordData>().off_Loops_Left;
                        int moving_down = GetSingleton<OverlordData>().off_Loops_Down;

                        var job = new TileShifter()
                        {
                                a1 = new float2(noise.cellular(b)),
                                a2 = new float2(noise.cellular(b)),
                                dataX = DataX,
                                dataY = DataY,
                                m_right = moving_right,
                                m_left = moving_left,
                                m_up = moving_up,
                                m_down = moving_down
                };

                        return job.Schedule( this , job1 );```
#

I mean, this has to be a terrible way to get this entities data into this job

#

componentgroups or something I think I need those

knotty radish
#

What type is OverlordData ?

untold night
#

yeah, that wall can be tough. You can DI into systems if you want, I believe there's already experimental Zenject bindings for that.

Have you read this book?

https://smile.amazon.com/Data-oriented-design-engineering-resources-schedules/dp/1916478700/

(parts of it are online but the formatting is terrible here): http://www.dataorienteddesign.com/dodbook/

It was greatly helpful in understanding the way Unity's ECS works vs the general concept of ECS. There's

I kinda feel stuff like Entitas and some other ECS-like frameworks get the general idea right, but they fall into the trap of doing the organizational part but still dealing with OOP thinking so you can't get all the benefits.

light sage
#

it grabs the players positional data and determines which directions it's moving,

knotty radish
#

What I meant was what exactly is the type of OverlordData, you could keep your data as a struct and just give that struct to your job

untold night
#

Yeah

light sage
#

@untold night I'm going to add that to my notes I'm taking, I plan to take a break from coding, for learning, I'm just hitting walls like you say

untold night
#

you could also get OverlordData once at the beginning of the function, you don't need to access it for each field

light sage
#

overlord day is the struct

knotty radish
#

Then why are you not giving OverlordData to your job ?

untold night
#

yeah, you could just pass that to the job itself

light sage
#

but the job uses ShipData

knotty radish
#

insert wat meme gif

light sage
#

so if I IJobProcessCompoentData<ShipData, OverlordData> they filter each other out

#

or no?

untold night
#

Not that

light sage
#

they're mutually exclusive types

knotty radish
#

OverlordData is an IComponentData ?

untold night
#

You can just add a normal field on the job struct itself for the singular OverlordData instance

light sage
#

if I I drop it in codepile can you show me rq?

#

that may answer all my questions actually

untold night
#
struct OverlordData: IComponentData
{
//...
}

struct ShipData: IComponentData
{
//...
}

struct MyJob : IJobProcessComponentData<ShipData>
{
    public OverlordData Overlord;

// execute etc.

}

That's perfect legal

knotty radish
#

You should use the bare minimum for attributes

#

Like "BurstCompile" is only needed on top of your JobStruct

light sage
#

right, I knwo that @knotty radish I'm meaning to fix that

#

and I stuck burst compile everywhere a while back bc I wasn't sure lol, and wanted a fair idea of performance

#

less attributes means less components beings locked up from other threads

#

only the attributes needed for that job, no extra ones, also, makes filtering more maleable

knotty radish
#

From what I understand of your code, you only need to add an OverlordData field to your job, set that field, schedule and that's it

light sage
#

what about the entity that derives from the component though?

untold night
#

some points for the code you linked:

  1. You can have OverlordData be in a field on the job struct, and make this way less complicated. Will also make it less error prone.

  2. You could potentially convert the right/left/up/down stuff into an int2 vector for direction, or even just a single int that represents the direciton, with 0 being "nothing" 1 being "left", 2 being right, etc.

  3. Since this function would do nothing if there's no movement, if the overlord data has no movement vector, IE, 0, you can just return the job handle for updates where there's no movement.

safe lintel
#

@light sage was that your art? if so cool stuff

untold night
#
  1. I think [ExecuteAlways] mostly applies to system declarations themselves
light sage
#

@safe lintel thanks, I wish I could code as well :p

#

I swapped the code on codepile for the overlors System

safe lintel
#

my background is art too, I do love the logic of programming but im really bad at stuff that requires math as i avoided it all my life until now

untold night
#

you're doing surprisingly well, don't get discouraged too badly.

light sage
#

I have about 40,000 (give or take a few thousand) lines of commented out code

#

and like 100 being used

#

I love algebra, discrete math, and algebraic calc, but I always sucks at geometry/trig kinda stuff @safe lintel

untold night
#

on the overlord stuff:

  1. For this system at least, I'd replace off_Loops* with an int2, can do the same thing with less complications.

  2. You may be able to use the new math.select(a, b, condition) to get better perf boosts with burst, since it can optimize it natively

light sage
#

right, I can work those thigns out recursive

knotty radish
#

I need to run, good luck with your project, you are on the right track!

light sage
#

I can always make those more efficient, but back to the iComponent inhereted struct being in the class for my job

#

how do I create the overlord entity itself that's linked to the data in the Icomponent struct

#

@knotty radish thanks. great community here, much appreciated

#

Also, the overlord like's to hang out in the monobehavior lol, to relay the positional data to the camera

#

so if he's in that class it's going to defeat that whole idea

#

or no?

#

the monobehavior is where the entity "overlord" is created right now, and his positional data is grabbed ine Mono's update to feed to the camera

safe lintel
#

you could use the ComponentSystem to process the OverlordData and Camera with the ForEach without necessarily having logic in your monobehaviour

light sage
#

If it wasn't for the camera I wouldn't even need the monobehavior after bootstrapping

#

tried to use pointers, couldn't get it to work

untold night
#

yeah, my break is almost over as well. You're on the right path.

Focus mainly on seeing what you can do to simplify the structures involved, and I think you'll have less issue with ECS.

You can put an Entity key inside another struct and that's fine.

struct MyOverlord : IComponentData
{
    public Entity Value;
}

//elsewhere...

struct MoveTowardsTheOverlord IJobProcessComponentData<MyOverlord, Position>
{
      [ReadOnly] public ComponentDataFromEntity<Position> OverlordPositions;
      [ReadOnly] public ComponentDataFromEntity<OverlordData> OverlordData;    

      //etc, can use *FromEntity to check for existence, etc
}

You should look into GameObjectEntity and component proxies.
You can leave the part of the Overlord that needs a regular transform and such in MonoBehaviour land while migrating other components to ECS

safe lintel
#

I spent a ton of time myself trying to figure out ways to not use a monobehaviour for things in my transition to ecs but figured ah well might as well embrace it as its likely gonna be necessary for quite a while still

light sage
#

ok, how do I grab the key to reference an entity

#

I don't know how to reference the entities

untold night
#

yeah, just embrace the Hybrid. I tried to go full ECS and ran into the lack-of-Features wall

light sage
#

I know they have internal version and Index, but I need an example of using a key to grab them

#

thanks though

#

@safe lintel true, ended up settling with the same determined

untold night
#

that is exactly what I just showed you

alternatively you can do build/update your own mapping in a systemwith a NativeHashMap for something specific, then have things that need that data grab it later in the job chain of the same system

light sage
#

oh snap

#

so I can put an entity in a component type?

untold night
#

yes

#

that works

light sage
#

O

#

I think I'm a lot closer now to understanding, last minute epiphany

untold night
#

It's just a handle to a table row

It may or may not be there, but that's all an Entity is. Just a key struct.

#

This means it can be part of the payload of any other structure just fine.

light sage
#

lightbulb is close, thanks a ton, that last bit especially was helpful

untold night
#

I think they disallow it from ISharedComponentData, since that could cause a lot of fragmentation issues, but it can go in IComponentData structs, it can go in IBufferElementData, it can be a field or property on a C# class or monobehavior

#

so if you want an entity that tracks it's children you can make a IBufferElementData and have a buffer of tracked children Entities

if you want an entity that knows it's parent, put an IComponentData struct that has that parent Entity

light sage
#

also the nomenclature and stronly typed stuff is way off from python, my long time go to, so a method to me is a function and so on

untold night
#

anyway I do have to go off the grid for a bit to catch up on some work, good luck!

light sage
#

I'm going to try this stuff out, and I'm going to familiarize myself with things like "let" and lambda functions, etc, this is a good itenerary

safe lintel
#

anyone know how to use *FromEntity? if I have a job```
struct TestJob : IJob
{
[ReadOnly] public ComponentDataFromEntity<Projectile> ProjectileData;

     public void Execute() { }

}
var job = new TestJob
{
ProjectileData = m_ProjectilesGroup.<what goes here?>
};```

safe lintel
#

wait but injection is on its way out right?

light sage
#

injection is already out in the latest packages/beta

#

I think that's why I can't grasp it, I never used injection

#

and apparently the alternative is like harder to understand, so I don't have that stepping stone

untold night
#

you can just grab it from EntityManager directly now

light sage
#

disregard that, it's still there, I read something that it wasn't or they limited it a lot, but I won't use something that's got death stamp on it

safe lintel
#

sorry im slow but whats the syntax for grabbing it from the entitymanager? EntityManager.GetComponentData<Projectile>(entity) doesnt appear to be correct

light sage
#

I tried something similar with default in place of entity

#
m_monopropellant = World.Active.GetOrCreateManager<EntityManager>( ).GetComponentData<ShipData>( ship ).monopropellant```