#archived-code-advanced

1 messages · Page 12 of 1

brave widget
#

time to research

#

:D

#

Also Idk if peeps will know it here, there's no legal issue with using bricks that resemble lego right? I looked into it they can't trademark a shape, but they trademark their logo on it and the minifigure

shadow seal
#

Probably is

brave widget
#

Well I mean in the UK we have tons of fake lego at like stores n stuff

jolly token
#

But there is many fake lego products isn't it

brave widget
#

so not sure

#

yuh

compact ingot
brave widget
#

Sounds good, will check their patents appreciate uit

compact ingot
#

you also can’t use minifigs as they are part of the trademark

shadow seal
#

Pretty sure their mini figures are protected

#

Yeah

brave widget
#

^

#

knew that one :)

#

apparently the 2x4 brick is still too

#

interestingly

shadow seal
#

Maybe the shape is fine to use, but the knock off brands are always somewhat different aren't they

compact ingot
#

You can always release it as a fan product

brave widget
#

yeah, I'll probs switch stud shapes but other than that should be golden

sly grove
#

use triangle studs 😛

shadow seal
#

Hexagons, the bestagons

compact ingot
#

use no studs

jolly token
#

dragons

brave widget
#

forgot how fun Unity is tho, let go of it like 2 years ago just came back and its fun af just messing around

#

HAHA triangle

#

Gotta love github copilot too, have to rewrite some code usuallyt but sometimes it gets it spot on

#

did it compeltely wrong tho

#

so

#

nvm

#

github sucky

jolly token
#

When it looks like spot on but when there is one variable wrong

brave widget
#

HAHA true

jolly token
#

Even AI uses GameObject.tag instead CompareTag

brave widget
#

is CompareTag better?

jolly token
#

But honestly I don't use tag at all. They're too limited. Cannot even have two tags at one time

brisk pasture
#

i often avoid tags, and just use what interfaces are on components

brave widget
#

It's nearly perfect B) just gotta make it so it goes to the highest Y position and make the Overlapbox a little smaller so it doesnt make it touch when its on the outskirts

thanks @sly grove

sly grove
brave widget
#

yeah doing that now :)

jolly token
#

I would save 3d grid or object list somewhere and check if anything overlaps in there
Just to prevent timing mismatch or something causing object overlap

brave widget
#

It's perfect :)

brave widget
#

Anyway to rotate the the OverlapBox with the rotation of the transform too?

jolly token
#

OverlapBox accepts orientation

brave widget
#

oh yeah it does

#

missed that

#

it's so fun to mess around with haha, distracted by my own creation :(

shrewd bear
#

Would this be the best channel to discuss a unity standalone build crash?

undone coral
#

@brave widget do you currently use source control like git or plastic?

#

and are you using Input System / Event System?

uneven blade
#

I know this should be in #💻┃code-beginner, but I don't wanna disturb them.
Hi, everyone! Why is the static Transform::LookAt(Vector3) method rotating my model incorrectly? I've tried messing with the look direction, but that appears to be in world space (it was doing weird stuff)... Thx for the help. I've attached a video.

#

I'm sorry for the terrible quality, but I don't have nitro 😛

#

I mean, the code is extremely self-explanatory, but if I'll be happy to share it.

torn basalt
#

Is there a lattice modifier available for Unity>?

jolly token
uneven blade
#

Well... I've noticed that when I drop in the model, it's automatically rotated -90 degrees to the X axis. Is there a way to add a rotation offset?

sly grove
#

and/or fix your export settings

uneven blade
#

👍 ok, thanks

bronze geyser
#
string bar = "Hello";
public List<SerializableBaseClassWithConstructor> foo = new List<SerializableBaseClassWithConstructor>()

Is there a way for me to pass bar to the constructor of SerializableBaseClassWithConstructor when the object is initialized/added to the list through the inspector?

raw sedge
#

You're constructing a list with that type, so no. You can instance SerializableBaseClassWithConstructor and pass the value there

#

Then add the instance to the list

bronze geyser
#

Figured, maybe Odin has a fast workaround for this =/

shrewd bear
#

So I'm getting a crash in the standalone build when changing scenes and the issue appears to be related to this:
Setting up 8 worker threads for Enlighten. Thread -> id: e7a0 -> priority: 1 Thread -> id: e7a4 -> priority: 1 Thread -> id: e7a8 -> priority: 1 Thread -> id: e7ac -> priority: 1 Thread -> id: e7b0 -> priority: 1 Thread -> id: e7b4 -> priority: 1 Thread -> id: e7b8 -> priority: 1 Thread -> id: e7bc -> priority: 1

#

Any ideas? This is from the player.log that the build produces.

#

It never occurs in the unity editor either.

tribal pivot
#

Hm ive seen these but they never caused crashes

plucky laurel
#

those appear in every log afaik

shrewd bear
plucky laurel
#

no doesnt appear in mine but im not using enlighten at all, but ive seen it before in working builds

shrewd bear
#

I did a test where I built the game 3 times. The two that crash happen after that. The one that worked didn't

plucky laurel
#

so the log from the working build didnt have gi?

shrewd bear
#

Correct

plucky laurel
#

do you use enlighten?

shrewd bear
#

I have no idea what it is

plucky laurel
#

did you bake global illumination?

shrewd bear
#

I haven't baked global illumination

plucky laurel
#

this may be a crutch, but try going through your scenes that go in build, go to lighting tab, and disable all forms of global illumination there

#

i dont know the root cause, if it is enlighten, it can potentially fix it

shrewd bear
#

Okay. So just turn off all lights

plucky laurel
#

not lights

#

lighting window/panel

#

window > rendering >lighting

shrewd bear
#

okay let me check that

plucky laurel
#

it may be a bug in unity, so you could update to latest matching major version

shrewd bear
shrewd bear
plucky laurel
#

press new lighting settings, then set lightmapper to none/disabled

#

on other scenes reference same lighting settings

shrewd bear
plucky laurel
#

ah shit im blind, its disabled anyway

#

no

#

im correct, yes do the same for other scenes

shrewd bear
#

Okay. I'll give it a shot.

shrewd bear
# plucky laurel im correct, yes do the same for other scenes

Wasn't it. Same last line.
`Unloading 5 unused Assets to reduce memory usage. Loaded Objects now: 2047.
Total: 3.543600 ms (FindLiveObjects: 0.137200 ms CreateObjectMapping: 0.072400 ms MarkObjects: 3.290600 ms DeleteObjects: 0.042600 ms)

Setting up 8 worker threads for Enlighten.
Thread -> id: ad44 -> priority: 1
Thread -> id: 7fe8 -> priority: 1
Thread -> id: 6c30 -> priority: 1
Thread -> id: cbd4 -> priority: 1
Thread -> id: 8cf0 -> priority: 1
Thread -> id: 2808 -> priority: 1
Thread -> id: ad68 -> priority: 1
Thread -> id: ddc0 -> priority: 1 `

tired creek
#

Its not possible for a plane to pass a triangle in such a way that it intersects a different number of edges other than 2, right?

sly grove
#

or if they intersect at one of the corners... well you decide what that means

#

other than those degenerate cases your options are 0 and 2

brave widget
lament briar
#

Hi, I'm hard stuck on a problem that's probably over my capabilities. I'm using a thread (task) to load objects from a class used to save the objects in a chunk. Every time I create a chunk in my world it either gets created, or loaded from data, if a chunk had already been created in that position. This works every time, the loading thread here works flawlessy, without crashing. However when I'm loading a world from the menu, all the first loaded chunks crashes and have an infinite loop inside them. Using the debugger I've come to one of the weirdest behaviours of all time, where trying to get a static instance of a singleton restarts the thread. Here's what the debugger sees:

#

It starts from the beginning. Goes on until...

#

it gets there:

#

Here's the calling of a singleton. To be sure that no thread is calling the same singleton at the same time you can see at line 99 that I've added a (static) mutex on this class.

#

When I enter this line, it correctly send me there:

#

Exactly where it should be.

#

But, the problem, is when I execute this line. It send me there:

sly grove
lament briar
#

This is the place where I call the thread

sly grove
#

it's liable to just kill your thread gracelessly

#

you can't really access any unity data from a background thread

lament briar
sly grove
#

e.g. savedObj.position etc. Is that a Transform?

#

What does SpawnObject do?

lament briar
#

No, that's my custom class used to store saved data

#

not a transform

sly grove
#

what is objectContainer?

lament briar
#

it will be turned into a transform in the SpawnObjectsManager singleton, that I guessed it spawns them in the main thread since it's a singleton and I'm using a static instance. At least, I hope it does.

lament briar
sly grove
lament briar
#

Shouldn't a mutex block weird behaviour anyway?

sly grove
#

you can't access unity data from a background thread

#

mutex or no

#

the unity engine doesn't know about your mutex

lament briar
#

How is it working then?

sly grove
#

so I'd guess whatever is happening inside SpawnObject is part of the issue

lament briar
#

It also worked until yesterday

sly grove
#

can you show that code

lament briar
#

This, calls this:

sly grove
#

yaeh there's the bad stuff

lament briar
#

God why is it working and why did it work for so long

#

almost a week without breaking

#

Ok - is there a way to call that singleton and execute it in the main thread?

sly grove
#

not sure 🤔 it shouldn't work at all. Are you sure your code is actually running in a background thread? How are you starting it?

lament briar
#

Oh, hold up

#

hold up

#

I got it

#

I know why it doesn't work (but I don't know why it worked all this time)

compact ingot
#

Did you use Task.Run before?

lament briar
# lament briar This, calls this:

When the world is NOT spawning (the first spawn when you load a game from the menu), it doesn't go to the direct instantiate method, but it goes to spawnManager.addObject above that. This just adds the object to a queue that the main thread process every update (up to a limit per frame, to reduce lag).

#

But when the world is spawning it goes right into the direct instantiate method, crashing

#

could it be this?

lament briar
lament briar
#

Never had to optimize anything, this time the world is pretty big

#

Gotta say that, threads are way less useful than what I thought since I can't use all unity api inside them

compact ingot
#

when it worked ‚last week‘ I mean

lament briar
#

Ah, yes

#

idk what I changed now that broke it o.o

#

and anyway this debugger behaviour is extremely confusing, I guess it's what you get when you work with threads

sly grove
#

the debugger can indeed be incredibly confusing when working with multiple threads

compact ingot
#

threads are not trivial. And they won’t help much making unity load smoother

lament briar
#

never actually used it with Unity in my 2 years experience (as a hobbyist, so not 2 year of work, I'm still a total newibe)

sly grove
#

What's your goal with this code?

#

have you considered using an asynchronously loaded scene?

lament briar
#

My goal is to load a procedural map made of chunks

#

I noticed that when all the code was simply executing, instantiating and loading thousands of objects every time I loaded a single chunk the game froze for seconds

compact ingot
#

What are you actually loading?

lament briar
#

It depends, the biggest load are single chunks

sly grove
lament briar
#

each one has about 5k objects inside

compact ingot
#

how do you load them?

lament briar
#

not voxel

#

more like valheim

#

hold up:

#

That's what it looks like when it works

#

If you focus you can see in the distance chunks spawning, and a very small lag sometimes

#

I basically gave up reducing that lag, gonna admit it, it took me two weeks to decrease the lag from very high to acceptable and I'd just like to go on ahah

plucky laurel
compact ingot
#

Tbh a world like this should spawn all those prefabs dynamically

#

Not store any of the positions in a file. No loading necessary

plucky laurel
#

with unity you can just render same tree using gpu instancing, and use a pooled collider you literally just move around from "tree" to tree when players get near

#

if the tree state changes at any point, it receives damage for example, you swap it for an actual tree object

lament briar
#

Is this that book?

plucky laurel
#

yes

lament briar
#

Yeah i got it

#

lol

#

what are the chances..

plucky laurel
#

big, popular book

compact ingot
#

doesn’t seem to be the issue here

#

(Flyweight that is)

lament briar
plucky laurel
#

do you have profiler results?

lament briar
#

I wasn't talking about normal lag, the lag I had was the chunk loading lag, because in a single frame I was spawning thousands of objects with raycast, instantiate, json serializing, file reading etc

#

btw... it didn't work

#

Now spawnobject only adds the object to the list, and it still causes that weird behaviour

plucky laurel
#

i dont know what can cause the lag without profiler

#

you can try preloading files

#

see if its disk read locking it

#

is it consistent or only first time an object is spawned?

lament briar
#

I'm not talking about the lag now, I mean I'd like to but maybe after I resolve the main problem... an endless thread loop

plucky laurel
#

oh sorry then i got it wrong

compact ingot
#

The world streaming lag you get in unity that you also can’t fix will not show in the profiler. It’s an engine issue caused by internally iterating all the objects that get loaded. It’s what happens between 90 and 100% in an async load

lament briar
#

is still happening even without touching transforms

compact ingot
lament briar
compact ingot
#

Most engines have this issue and there are numerous talks at GDC where object init was a major issue when implementing streaming

#

in unity your only option rn is to hide it or load very small chunks

plucky laurel
#

or not spawn it and just render

compact ingot
#

Or buy a source license

#

That’s the best way

plucky laurel
#

subnautica had the whole world octree on disk

#

so theoretically that should be the "smoothest"

#

you dont need chunk load objects you can grab them directly from octree by proximity

compact ingot
#

yes

#

Preload all assets, spawn prefabs incrementally

#

doesn’t matter where the data to configure them comes from so long as you don’t trigger the internal init for 1000s if things in one frame

lament briar
#

Yeah I'm spawning them incrementally

#

the spawnQueue.Add above is literally that

#

I've made a video of the debugger:

compact ingot
#

InfiniGrass/VegetationStudio help a lot with spawning stuff without storing positions

lament briar
#

The simple get instance is causing a loop...

compact ingot
lament briar
#

I have absolutely no idea on how to do it T.T

compact ingot
#
Task.Run(async () => { 
    // do some synchronous/blocking stuff

    await Task.CompletedTask; 
}
#

better make the method async, pass in a cancel token and make sure you arent actually running ophaned threads still

lament briar
#

Doesn't await waits the task to be completed, blocking the main thread?

compact ingot
#

the await is also not necessary

#

but the Task allows you to reference the thread and check its status

lament briar
#

Translating "There should be a )"

compact ingot
lament briar
#

yeah

#

i missed the )

compact ingot
#

the point of Task is to have access to the thread and inspect it, to be able to await it and to get return types

jolly token
#

You're awaiting CompletedTask? 🤔

compact ingot
lament briar
#

an infinite loop

compact ingot
#

it would not change the bug

#

it would just give you more access to observe whats going on

lament briar
#

How can I do that?

jolly token
lament briar
#

With the debugger?

compact ingot
lament briar
lament briar
compact ingot
#

you can also just make LoadObjectsThread async

fresh salmon
#

Yeah if you need LoadObjectsThread to finish before the lambda completes you should be awaiting it too

compact ingot
#

LoadObjects is blocking

lament briar
compact ingot
#

you made an async lambda that wraps a synchronous method

fresh salmon
#

A simplification would be to not make the lambda async, as it runs on the thread pool, won't block the main thread

compact ingot
fresh salmon
#

Ah alright then

compact ingot
#

anyway, i'm not seeing this going anywhere

#

this is impossible to debug remotely unless someone has had the exact same issue before

lament briar
#

T.T

compact ingot
#

i suspect the debugger actually suggests the wrong thing

lament briar
#

Well... I can move this method on the main thread again... But it will increase a bit the lag 😦

lament briar
compact ingot
#

yes

#

exactly

#

does VS have no thread-debugger?

fresh salmon
#

You can select the thread via the dropdown at the top

lament briar
#

Yeah

#

the point is that it's not even changing

#

like it's always the same thread

fresh salmon
#

Looks like the method that runs the async task is in Update, is this intended (sorry if question seems weird, I just arrived)

fresh salmon
#

It'll spin up a new task each frame

lament briar
#

wonderful

fresh salmon
#

Unity Moment™️

jolly token
compact ingot
#

also there is Task.FromResult()

#

suppose it (the warning) is just meant to help you avoid casual mistakes

compact ingot
lament briar
#

Ok, I resolved the endless loop

#

still not spawning objects, but I'll try to resolve that now, thanks guys

#

if you guessed it it was an incredibly dumb mistake

lament briar
compact ingot
#

like ```cs
if (foo);
DoThing();

lament briar
#

No it was just dumb and I don't know how it worked until now. I mean , I think I know.

#

Basically this method as I mentioned before was made to be executed in the main thread, and I just moved it in a thread... In the update method. It was not a problem before since after executing it it set a boolean variable to true and didn't execute it anymore

#

but when it's a thread, the update loop is faster than the thread, so the variable never actually becomes true, and it simply spawns a thread each time it goes to the update loop

compact ingot
#

i think over time one develops intuition/habits that prevent such things...

lament briar
lament briar
#

really embrassing

compact ingot
#

but you fixed it

#

so no reason to be embarrased

#

its normal to make these silly mistakes

#

i've heard people with decades of exp say, they still frequently make 1-off mistakes

#

and i would say anything involving actual threads/parallelization or of a distributed nature will always have something new to surprise you with

#

especially if you use sync primitives or get into performance code

lament briar
#

Well threading is probably the most complex topic I know.. And my university didn't take it seriously, we just did some threading with C and it was extremely easy

compact ingot
#

yes, thats usually the case

#

have to study it yourself

lament briar
#

That's what I wanted to do, I've got a nice c++ threading book in my bookshelf but I never actually read it

compact ingot
#

but also consider that nobody who studied before 2010 has any formal knowledge of it unless they took an optional course on it

lament briar
#

I used it back in the days when I tried to code a multiplayer game with c++... in 2017.. obviously I didn't make it, but I learnt a lot

compact ingot
#

it was largely irrelevant before multicore CPUs became popular and the cloud (cluster computing) happened

lament briar
#

Mmh. As far as I know the threading course of my university has been introduced during those years

compact ingot
#

same with neural networks... before 2012 or thereabouts they were considered a curiosity

#

its also quite difficult (it seems) to find qualified lecturers on the subject

#

especially distributed systems are very tough to teach well

lament briar
#

Well you usually have to know basic threading to code, no? You need advanced threading knowledge only if you work with big supercomputers

#

as far as i know, at least

compact ingot
#

supercomputers are generally distributed systems (clusters)

#

whether you code for 2 or 200 cpu cores doesn't matter code wise

#

and the concurrency theory is the same independent of how that concurrency is executed

#

its just math

#

usually the concurrency that was discussed before multicode became a thing related to databases

lament briar
#

I thought you had to manually code parallelized code to use 100% of the cores

compact ingot
#

wdym by manually?

#

you can never utilize 100%

lament briar
#

You declare threads, each one does something, then organize their output

compact ingot
#

yes, but thats just TPL

#

you can wrap that in a nicer abstraction

lament briar
#

like computing a whole map made of gps data, if you break it in pieces and give it to different threads then it should be faster no?

compact ingot
#

yes, there is a whole theory around how to break up tasks most effectively

lament briar
#

that's an example some scientists made me some years ago when I was visiting a research centre

compact ingot
#

its not trivial

lament briar
#

probably too advanced for me, I'm still a junior developer 😛

compact ingot
#

there are also multiple ways to parallelize stuff

lament briar
#

I'll probably need it when I'll do my thesis

compact ingot
#

there is branch prediction, vector operations, multi-core, different CPUs, cores that share a cache, CPUs that dont

lament briar
#

I was thinking about simulating a network of biological neurons, and moving the code from CPU to GPU, but it seems really complicated

#

and probably my code would go slower on it, so I still have to consider it

compact ingot
#

that level of thesis is this?

lament briar
#

A bachelor's

compact ingot
#

you wont have to do anything complicated like that

lament briar
#

I know

#

but where's the fun ahah

compact ingot
#

true

lament briar
#

I already used threading to create more simulation of the same neural network, so I could train 15 of them at the same time and speed as one

undone coral
#

is there a pre-existing way to view the state of physics in the near (1-10 frame) past?

lament briar
#

anyway thank you so much for your help, I still learnt something and I would've probably resolved it in a week 😊

compact ingot
#

i think people who take their thesis seriously and want to make something fun become good developers

lament briar
#

I hope so... I'd like to become a good one, and sometimes I do something complex, but then I lose hours and hours on dumb mistakes like the one that you helped me with

#

where I forget a single line and everything breaks

woven kettle
#

hey,

how to make a 3d object act like a slider ... slides from one point to another were one end has a value of "0" and the other has the value of "1" ?

lament briar
#

You want to drag it with the mouse?

woven kettle
#

yes but in 3d space

#

its easier in 2d like some UI objects

fresh salmon
#

With rotation/scale or just position?

woven kettle
#

position only

fresh salmon
#

And is it non-linear, like for a value of 0.5, it's not in the middle of the two points?

woven kettle
#

i have 2 empty game objects , and another cube game object, i want the cube gameobject to be able to slide between the 2 empty gameobject only and cant go anywhere else

fresh salmon
#

Vector3.Lerp(point1, point2, ratio).

woven kettle
#

I'll give it a try 🙂

woven kettle
fresh salmon
#

Value ranged 0-1

#

float

woven kettle
#

yeah but we are in 3d space

#

we have 3 vector3 which defines the position of each object

fresh salmon
#

No, one Vector3

#

It's sufficient to represent a position in 3D space

sly grove
fresh salmon
#

By Lerping between two Vector3s, you definitely can move the object in 3D space

#

Mind you, it's Vector3.Lerp, not Mathf.Lerp

woven kettle
fresh salmon
#

Mhm, Lerp between these positions

sly grove
#

listen to him

fresh salmon
#

cube.position = Vec3.Lerp(start.position, end.position, progress)

woven kettle
fresh salmon
#

You need the inverse now?

#

From start, end, cube positions; get the ratio?

jolly token
#

What value of ratio should be if the cube is not on line?

sly grove
woven kettle
#
public Transform p1;
public Transform p2;
public Transform p3:

Vector3.Lerp(p1,p2, ?? ) 
sly grove
#

do you want to input the ratio and get a position?
Or input a position and get a ratio?

fresh salmon
#

Yeah I understood the question backwards

woven kettle
#

I need the ratio

sly grove
woven kettle
#

the position is given by the player

sly grove
#

although it assumes that the object is on the line between the objects

woven kettle
#

@sly grove that was perfect!!! thank you!

sly grove
brave widget
#

apologies :D

hallow turtle
#

can i get help with my double click on a 3d object function```
void Start()
{
healthBar.SetMaxHealth(enemy.maxHp);
healthBar.SetHealth(enemy.currentHp);
healthBar.SetName(enemy.name);
firstClickTime = 0f;
timeBetweenClicks = 0.2f;
clickCount = 0;

}

private void OnMouseDown()
{

clickCount += 1;
if (clickCount == 1 && allowed)
    {
    healthBarObject.SetActive(true);
    nameText.SetActive(true);
    firstClickTime = Time.deltaTime;
    StartCoroutine(DoubleClickDetection());
    }
}

private IEnumerator DoubleClickDetection()
{
    allowed = false;
    while(Time.deltaTime<firstClickTime+timeBetweenClicks)
    {
        if(clickCount == 2)
        {
            Debug.Log("clicked 2 times");
            break;
        }
        yield return new WaitForEndOfFrame();
    }
    clickCount = 0;
    firstClickTime = 0f;
    allowed = true;
}
#

what i currently have but when i click once it doesnt go back down to zero after 0.2f seconds

novel plinth
#
    void OnMouseDown()
    {
      if(clickCount <= 2)      
          StartCoroutine(MyFunc());
      
      else      
          //Do other things
    }
    private IEnumerator MyFunc()
    {
        yield return new WaitForSeconds(coolDownTime);
        
        //Do other things first

        clickCount++;
        if(clickCount == 2)
          clickCount = 0;
    }
#

I'd not use coroutine for this, but it's up to you

undone coral
#

when can i set QualitySettings.maxQueuedFrames ?

#

it seems setting it in a void Start crashes the game

jolly token
#

Crashes in editor or build?

idle bridge
#

Hi everyone, I have a problem with my game. Actually it's not that bad but really annoying. When I build my game on ios, my fps are really low with freezes while on android, it's running really smoothly. Someone know why it's doing that? I also have a runtime mesh generation but it's not a big performance hit so I really don't know

idle bridge
jolly token
idle bridge
idle bridge
#

I mean where is the profiler going

jolly token
#

It’s on the doc

muted rune
#

i'm trying to design/build an audio solution where you can add an ambient sound to something like a river and depending on where you are in conjunction to a set of points set along the flow of the river it'd reposition a 3d audio source to more accurately represent where the sound might be coming from

#

i got it mostly working, but i'm wondering how to give more weight to points closer to the player position

#

the black points are points on the lines between points closest to player

gray pulsar
muted rune
#

yesss

thin mesa
#

definitely not an advanced topic. but get the difference in position as the offset at the beginning. then object2.position = object1.position + offset and that's literally it

muted rune
#

[redacted]

flat marsh
muted rune
#

my apologies 😄 it seemed somewhat relevant hehe

placid shell
#

im wondering if there is any way to get a struct to show up in the inspector that is not serializable (i cannot make it serializable due to this acting very weird with native arrays, often breaking them for some reason)? I'm happy to use a custom editor script should it be required!

graceful pawn
#

think the custom editor is the only way to go

placid shell
#

i suppose i could create a variable for each thing in the struct, but it would make my code quite messy looking lol (mainly due to the struct having over 30 things inside it lol)

#

something strange is going on, another array in the struct is working fine, despite the first one not

quiet frigate
#

Any particular reason to not turn it into a class instead?

placid shell
#

even worse they are c style arrays

fading musk
#

ScriptableObject with a list of objects of classes that all derive from either an interface or an abstract class. The list doesn't seem to serialise with either. Is there a way to do something like this?

I've tried using all sorts of [Serializable] and [SerialiseField] with no luck. It may be an issue with my ui but the list is not showing up in the json at all so I'm pretty sure it's a serialization problem.

brisk pasture
#

it should work with the abstract class, but keep in mind UI wise it will only show you fields on the abstract class not the extending classes

#

[SerializeReference] can be used with interface types

#

but it will cause things to work quite differently

plucky laurel
#

unity data is stored in yaml variant

brisk pasture
#

he does not say json anywhere

plucky laurel
#

It may be an issue with my ui but the list is not showing up in the json

brisk pasture
#

oh missed that

#

either way if relying on unity's serialization and not something like json.net, it really does not like interfaces or polymoprhic types unless [SerializeReference] is used and i am 90% sure that is not supported by JsonUtility and just yaml

plucky laurel
#

are the objects in the list derived from UObject?

fading musk
fading musk
brisk pasture
#

well like mentioned [SerialiseField] does not care about interfaces at all

#

and am pretty sure with [SerialiseField] it will not save all the data you need just what is on the abstract type used

#

why i suggested [SerializeReference] but if you use that you do not get a editor or inspector support for free. but it does support interfaces and polymorphism

#

in the yaml it will be structured different though more or less everything with [SerializeReference] will end up at the bottom of the file with ids and those ids get referenced where used

fading musk
#

Ah! Wow, that worked wonders, I had no idea [SerializeReference] existed until now. Thank you so much!

#

(and my apologies if I was a bit dense ;-v-)

brisk pasture
#

its newiesh

novel plinth
#

SerializeReference is OP!

brisk pasture
#

think maybe 2019 unity

novel plinth
#

It's my new favorite

brisk pasture
#

i like it, but find it can be fragile to type name changes

#

since it does not have a guid to match it like a component or so gets

placid shell
brisk pasture
# novel plinth SerializeReference is OP!

yeah in my current game our npc behaviour trees use it, so the states for each node can just be a interface type and all be serialized into 1 SO that contains the whole node network with edges and nodes saved with SerializeReference

novel plinth
#

yeah, it's a feature that's been begged since 2016

brisk pasture
#

now what i want, is being able to click and drag in components of a interface type in the inspector

novel plinth
#

it can make your code less bloaty

#

and definitely less inspector spaghetti

brisk pasture
#

but yeah before SerializeReference, something like the behaviour tree i did with a crapton of SO's as subassets. this is cleaner asset wise, and well interfaces are jsut better to work with for stuff like this

placid shell
shadow seal
#

No, not this channel

fresh salmon
#

lmao

split folio
#

Gg

shadow seal
#

You are not even beginner man

split folio
#

Lol

shadow seal
#

To your blank console?

split folio
shadow seal
#

<@&502884371011731486>

fresh salmon
#

You were asked to share code in #💻┃code-beginner. You didn't do so. Go back there and share your code and your question.

humble leaf
#

!warn 976018323957514280 You've been told already not to crosspost. If you continue to be annoying, you'll be muted.

thorn flintBOT
#

dynoSuccess Muhamm3d#9902 has been warned.

fresh salmon
#

That'll calm them down

split folio
jolly token
stuck onyx
#

if we do this...

MyClass.OnActionInvoked += (state)=>
        {
             DoStuff();
        }; ```
#

are we listening to the event just once or do I still need to unsuscribe inside ?

#

like..

sly grove
stuck onyx
#

ok so i need to unsuscribe inside

#

thanks

sly grove
#

yes but that's not possible to do in a lambda like that

stuck onyx
#

agh shit

sly grove
#

You'd have to do it like this:

MyDelegateType listener;
listener = (state)=>
        {
             DoStuff();
             MyClass.OnActionInvoked -= listener;
        }; 
MyClass.OnActionInvoked += listener;
``` for example
#

easier if you use a real method rather than a lambda

stuck onyx
#

yeah ill use a method, thanks a lot

violet ether
#

can someone help me with this?

upbeat path
undone coral
stuck onyx
#

never used it, if i remember correctly... is some framework to adopt some pattern like mvc ?

#

im starting to get crazy with to many events and different listeners, want to do some sort of central class that listens to all those wo send events so my other classes would just have to listen to this one

undone coral
stuck onyx
#

sort of a proxy for listeners 😅

#

not sure if its a good idea though

undone coral
undone coral
undone coral
fading musk
gaunt spoke
#

Hello, I'm trying to understand scripting backends, IL2CPP and Mono, and I have a few questions

Do they both use the Roslyn compiler ?

With Mono, the code is compiled just in time so is it as slow as an interpreted language ?

sly grove
#

JIT compiled languages are not as slow as interpreted languages

#

they are compiled on the fly to machine code - so once the JIT compiler takes a first pass at the code, it should be comparable to a normal compiled language.

#

For Mono you get:
C# -> IL then at runtime IL -> machine code with the JIT
For IL2CPP you get:
C# -> IL -> CPP -> machine code and ad runtime it runs the machine code directly
(hence IL2CPP)

gaunt spoke
#

Thank you ☺️

jolly token
#

I want to have automated documentation system with documentation comments. Which I could generate documentation viewer via some library (e.g. DocFx). Then I want to highlight or generate difference-only document, compare to other version in source control, to share to my colleagues. Is there any tool or use case for this?

sly grove
undone coral
jolly token
undone coral
#

hmm

#

i mostly use docs through the IDE

#

it's hard to say

jolly token
#

Yeah what I wanna do is when I done with feature, just generate diff and share to let people know what has been changed

jolly token
chilly nymph
#

But docs will only ever be used by devs?

jolly token
#

Hmm I do use swagger, but I want to generate doc for internal api changes

chilly nymph
#

I personally update a changelog on push.

jolly token
#

Lazy to do that tbh lol

chilly nymph
#

I also wrote a changelog that pulls push comments but you have to add minor, major, bug values yourself.

#

{0,1,0}

#

That's the best way I've found.

#

Ping me if you do find a good solution.

jolly token
#

Sure I will share if I find something

undone coral
#

or whatever they're called

jolly token
undone coral
#

can i ctx.cmd.Blit between render textures with different graphics formats?

#

what happens?

#

i am seeing white when i blit a cameraColorBuffer into a render texture

rigid dagger
#

I'm wondering if anyone here is familiar with the Unity test runner. I have a handful of play mode tests and I am noticing that each test just adds more things to the single test scene that is generated when the test suite kicks off. I'd like to start with a new scene each time (or open to other suggestions). I have tried SceneManager.LoadScene() for a test scene I made in the Setup method and I have tried destroying all objects on TearDown. Loading a scene seems to not be recognized by the test runner and looping through game objects and destroying them just locks the test runner up.

Any ideas on how to do this properly?

jolly token
#
[TestFixture]
public class TestSceneTests
{
    private bool initialized = false;

    [UnitySetUp]
    public IEnumerator Setup()
    {
        if (!initialized)
        {
            initialized = true;
            SceneManager.LoadScene("TestScene", LoadSceneMode.Single);
            yield return null;
        }
    }
}
#

If you want to load scene for each test in fixture then you won’t need to have initialized flag

rigid dagger
placid shell
placid shell
undone coral
#

i guess what are you actually trying to do?

#

you are using flex?

placid shell
vague sandal
#

yo wsup

#

my lerp isnt working

#

somehow idk why

#

could anyone tell me why

astral sky
#

not sure if it actually matters but is it the fact that theres no space between the ,

long ivy
#

looks like your arguments are in the wrong order to me

vague sandal
#

oh

muted rune
#

@gray pulsar thank you so much, that weight formula worked perfect.

regal olive
astral sky
#

ah really? mustve taught myself that it is then

regal olive
#

Yeah, but when you put a semicolon it spaces them out for you in VS, to make it look better (unless you put it before you changed the comma space)

astral sky
#

ah right okay

hallow turtle
#

is it possible to move one script from a object to a prefab? like i have a object with a few classes for a rpg on it and i want to move the chosen one to my player prefab before it is created

wide bolt
#

@hallow turtle I'm having trouble understanding exactly what you're trying to achieve. Can you give me a more succinct example. what is the object with the classes, what is the script that you want to move and what effect are you hoping to achieve by moving it?

placid shell
low mesa
#

Hello everyone!
Debug - Attach Unity Debugger.
I'm having this weird issue with my editor, when I try to launch my debugger I have 2 port to choose from.
Someday I only got 1 to select, but more than often I have 2 instance.
And as you can imagine, it's quite annoying to keep the port number in head (which changes every day btw), and re-relaunching the project just for this... Anybody have seen this issue? I'm trying to search for this on Google, but no real hit so far...

(please (at)me in your answer)
Many thanks for reading my post!

jolly token
#

Btw what Unity version are you on?

low mesa
jolly token
#

Yeah for me that issue was dissapeared after some version update

maiden turtle
#

Does anyone have a properly configured setup for GRPC communication? It seems to be pretty annoying to set up https://stackoverflow.com/questions/72907696/how-to-get-grpc-working-between-a-unity-game-client-c-net-and-tonic-rust-b

#

Then unity side is what I'm interested in

stuck onyx
#

i have a 3 cameras 1 for world 1 for UI (screen space canvas) and a 3rd one that focuses a 3d object and i render over the other 2. But this object always appears behind the UI. Is there any way to make him appear below the UI whenever I want to? Here is how it looks

#

below blurred is what the main world cam renders... a tile map. the UI you can see, the below buttons and this street menu

#

but this cube, im using a 3D camera

#

and I'd like to be able to put stuff below the UI (as it is) but also in front

raw sedge
#

Shift the UI up?

humble leaf
#

You want the cube to be in front of the UI?

stuck onyx
#

1 way would be with a renderTexture and convert it to UI

#

but id like to know if there's an easier way

humble leaf
#

Yes, that's what you would do. Then move its sibling index.

stuck onyx
#

isnt there any other way than using renderTexture?

humble leaf
#

Or put it on its own canvas and change its render order to be higher or lower than the main UI value.

stuck onyx
#

hmmm i should put the cube inside of a canvas for this?

#

i've been trying that but for some reason the cube stops being rendered

humble leaf
#

If you want to do a special shader/render feature in URP, sure. Seems a lot of work for it though.

#

No, it needs to be a render texture for it to work in UI.

stuck onyx
#

nah, i dont use URP and dont know shit about shaders 😅

humble leaf
#

I mean, if you didn't want to put the RT into the main UI canvas, you can use its own.

humble leaf
#

I don't see why using a RT is an issue though. 🤷‍♂️

stuck onyx
#

no its not an issue...i guess i should use it always

#

yeah

#

thanks

dapper cave
#

how do i profile memory BANDWIDTH? i think there is too much shuffling data but not sure where.

raw sedge
#

you should be able to profile memory usage over time, your memory rw usage is going to be dictated by your allocations

dapper cave
#

no, it can be data copy to a pre allocated variable or parameter, won't show on profile but still kills mem bandwidth

bright geyser
#

can someone remind me how to add code please?

lavish sail
#

like create a script?

bright geyser
#

in VS2019, I have a function with variable, when I right click the fn variable and choose "Create and assign field context" it auto creates a variable for this, ie on context: public AccountController(DataContext context){} it auto creates the variable private readonly DataContext context; how do i change the behaviour to name it _context?

#

as in that code, to make it more readable

ivory prawn
wintry dragon
#

This is the dilemma. I'm working on a greedy mesh algo. but now seem to require the use of multiple materials to allow me to repeat the texture. Idk if anyone has any other solution.

sly grove
#

and texture mapping is as usual done via UV mapping

ivory prawn
#

it's stretching because the UV is going from 0 to 1 down the side of the object. If you're creating the mesh yourself you can just make the UVs for the vertices carry on past 1, and set the wrap mode on the texture to repeat

#

If you're not creating the mesh you could create a simple shader yourself that decides which part of the texture to sample based on world dimensions rather than object space dimensions

plucky laurel
#

yeah you can map UVs to world coords 1 to 1

#

you can also use horizontal/vertical/all axis tiling atlases

sly grove
#

the uv coordinates refer to coordinates in the texture

#

not coordinates on the mesh

#

you assign the appropriate UV values to the appropriate vertices on your mesh (in a process called UV mapping) to get the part of the texture you want on each triangle/face of the mesh

#

long story short - learn about UV mapping

bright geyser
#

@ivory prawnMate, that's exactly what I was after, thank you.

queen geode
#

Does anyone know how can I set the control scheme in code whith the generated C# class rather than the player input component?

exotic gull
#

This good in terms of getting the local Bounds of an object before any transformations? ```cs
private Bounds getLocalBounds(Collider collider)
{
Type colliderType = collider.GetType();
if (colliderType.Equals(typeof(MeshCollider)))
{
return ((MeshCollider) collider).sharedMesh.bounds;
}
else if (colliderType.Equals(typeof(BoxCollider)))
{
BoxCollider box = (BoxCollider) collider;
return new Bounds(box.center, box.size);
}
else if (colliderType.Equals(typeof(SphereCollider)))
{
SphereCollider sphere = (SphereCollider) collider;
float diameter = sphere.radius * 2.0f;
Vector3 localBox = new Vector3(diameter, diameter, diameter);
return new Bounds(sphere.center, localBox);
}
else if (colliderType.Equals(typeof(CapsuleCollider)))
{
CapsuleCollider capsule = (CapsuleCollider) collider;
float diameter = capsule.radius * 2.0f;
Vector3 localBox = new Vector3(diameter, diameter, diameter);
localBox[capsule.direction] = capsule.height;
return new Bounds(capsule.center, localBox);
}

        return new Bounds(new Vector3(0, 0, 0), new Vector3(0, 0, 0));
    }```
fresh salmon
#

Oh god those type checks

fresh salmon
#
if (collider is MeshCollider meshCollider)
{
  // use 'meshCollider' variable
}
jolly token
#

Then you can InverseTransform

upbeat path
fresh salmon
#

Yeah, that was just a design tip though

jolly token
#

Hmm actually it would be little different

#

Since bounds is AABB

fresh salmon
#

You can rotate it with the worldToLocalMatrix or some shit

jolly token
#

You may need to cast, actually 🤔

fresh salmon
#

Forgot the variable name

jolly token
#

No, it doesn't work with AABB

fresh salmon
#

Oh well, ignore me then

rugged radish
#

hello
when windows kills an app for launching a GPU job (compute shader) that takes too long to complete, is it because of the entire execution time is too long, or because some threads took too long to compute ?

I fixed the issue by better parallelization, but would like to know in case I need to write a heavier compute shader

undone coral
#

windows doesn't care what your process is doing

#

what do you really mean?

rugged radish
#

it literally said that

undone coral
#

that you click inside your unity window, and you see "Your app has stopped responding" faded background modal dialog?

#

hmm

#

do you have a screenshot of this?

#

or do you remember the actual words

rugged radish
#

it killed unity and said that a GPU took too long executing

undone coral
#

you would have to remember the actual words, verbatim

#

because i'm not finding anything about such an error message on google

#

you are paraphrasing / interpreting a different error message

rugged radish
#

should've made a screen shot before fixing that issue

#

I'll try googling the error message

undone coral
#

suffice it to say there isn't such a windows error message. Unity might have an error message

#

but it's not windows

#

your process can crash, of course, with a gpu-related error

#

usually running out of memory

#

do you have a log?

#

you might use too much memory*

rugged radish
#

I'm pretty sure it was coming from a graphics driver or windows, but can't be certain 100%

undone coral
#

your logs would say "CRASH"

rugged radish
#

because of how it was worded

undone coral
#

it wasn't windows

#

are you asking if unity prevents you from running runaway compute shaders?

#

probably

#

why wouldn't it?

#

i forget what you are trying to do

fresh salmon
#

"Failed to present D3D swapchain due to device remove/reset" or something?

#

That fits the description

rugged radish
#

that particular shader rasterizes some regions defined by polygons
one of the regions was very big, so one of the thread ran way too long

rugged radish
#

and get the exact message

undone coral
#

so that can happen for a bajillion reasons

#

did that occur in the middle of running your game?

#

you probably ran out of GPU VRAM (horses)

#

did you screen go black?

#

did you see a windows "gpu recovered" message? (zebras)

rugged radish
#

it's a one-off calculation

fresh salmon
#

Usually the error happens when the driver hangs due to an expensive operation, and Windows think it crashed, so it resets it

#

Killing Unity in the process

undone coral
#

windows will tell you if it reset something

#

failure to present d3d swapchain is a unity crash

#

it sounds like you ran out of GPU VRAM

#

knowing nothing else

fresh salmon
#

In the event viewer yes, you'll have a log that it was recovered

undone coral
#

you might have more information in the logs

undone coral
#

on Windows 10 at least

rugged radish
#

only if unity keeps old logs, I ran it multiple times since then

undone coral
#

was this in the editor?

rugged radish
#

it was

undone coral
#

i guess what is your goal?

#

to use more GPU VRAM than you have?

#

you can try to load pieces of your work in batches

#

which is what it sounds like you did

rugged radish
#

I doubt it's a gpu ram issue, because the memory footprint of that algo remained the same

undone coral
#

it really depends

#

i don't remember what you are trying to do

#

with a compute shader

rugged radish
#

that particular shader rasterizes some regions defined by polygons
one of the regions was very big, so one of the thread ran way too long

undone coral
#

in my experience, the most common reason you will see a GPU-related crash is running out of GPU RAM

#

well

#

that isn't very informative

#

what is it really?

rugged radish
#

it would be pretty hard for 10 GBs

undone coral
#

yes, but you are running in the editor

#

and there's a lot of stuff going on that you wouldn't immediately comprehend. for example, if you had both the scene and the game view visible, well it would run the shader twice

#

but i don't know

#

i don't know what it does!

#

you haven't told me yet

rugged radish
#

rasterizes the polygons into a texture, that is literally it

undone coral
#

i don't know what that means

rugged radish
#

a bunch of point-in-polygon checks

undone coral
#

what is the purpose of the shader?

rugged radish
#

for every cell of the output

undone coral
#

like what is its gameplay / logical goal?

#

are we talking about a fluid simulation?

#

like what are you trying to do

rugged radish
#

it will be used by placement algos

#

the map

undone coral
#

okay

rugged radish
#

I'm moving a bunch of rasterization logic from CPU to GPU

undone coral
#

you are generating a map?

rugged radish
#

so immediate goal is to offload calculations

undone coral
#

you are procedurally generating a map, and this shader plays a role in...

#

what exactly? placing props like trees and rocks?

rugged radish
#

that too, basically there's a number of maps that tell which region is where, depth to the water bodies, depth of the biome, etc

undone coral
#

okay

#

so you had working C# code correct?

rugged radish
#

I have it, I have working hlsl code as well

undone coral
#

okay well the simple answer is that probably your compute shader is buggy

#

if the application crashes

rugged radish
#

was buggy, I wanted to know how to organize my other compute shaders, to not run into the same issue again

#

because I still don't know if a long running compute shader caused the crash, or only a long running thread

undone coral
rugged radish
#

sure, knowing limitations would be nice though

rugged radish
#

The default timeout period in Windows Vista and later operating systems is 2 seconds. If the GPU cannot complete or preempt the current task within the TDR timeout period, the OS diagnoses that the GPU is frozen.

#

so it doesn't matter how exactly you cause it to hang

exotic gull
jolly token
#

So you probably needs to cast 😌

exotic gull
#

will do lol

plucky laurel
#

registry edit

jolly token
#

Haven't heard about Vista such a long time

pastel wagon
#

Does anyone know when material properties are pushed to the gpu? I’m trying to alter a material property inside OnPreRender in a vr game but only the left eye seems to be getting the correct value (the right eye ends up with the same value). I’ve verified with the debugger and logging that I’m calling SetVectorProperty with different values for each eye

%^#&@!%#^!&@%$& I don't understand why but using Shader.SetGlobalVector worked instead of setting it directly on the material

undone coral
#

you can probably ticket that as a bug

pastel wagon
#

hrm. unlikely to help me cause this is for a mod for a game using 2019.4 :/ But thanks for confirming I'm not crazy. burned a lot of time on this

#

even a workaround that can force material properties to be pushed would be useful though

#

turns out SetGlobalVector isn't really a great solution because there are situations where I need more than one instance of this effect running with different values...

undone coral
#

well if you're modding a game

queen geode
fresh vortex
queen geode
fresh vortex
#

i have my own input system where i handle stuff, fire evernts on context.started/context.performed etc, whenever i want

queen geode
fresh vortex
#

you can create different maps and do whatever you want with the input asset in your own input system class

#

when you want to controll different object just change the map

queen geode
storm maple
#

lets say i have an ortho camera somewhere and i want to calculate the clip space position of a vertex if the camera was at 0,0,0, how do i go about that? can i somehow "translate" the camera projection matrix in space?

raw sedge
#

Yes

placid jacinth
#

Other channels are being used so will pop this in here-
Just wondered if there was a shortcut to get the Assets folder file-path as a string?
(e.g. Projects/MyProject/Assets)

I don't want to get the path for a specific asset, as in AssetDatabase.GetAssetPath()

I assumed there would be something along the lines of AssetDatabase.ProjectAssetPath() or something but no joy

Any ideas? :)

urban sequoia
placid jacinth
#

The problem? I have no problem with a string

#

I just want to retrieve wherever the current assets folder is

#

The file path to that would be a string

placid jacinth
obsidian glade
#

It's been a while since I was working with VR in Unity now, but the XR Interaction Toolkit (is it still around in preview?) came with a big folder of tests written for all kinds of interaction and input events in VR - worth checking out as you seem interested

lost sequoia
#

I made now a video, I hope this is now more easy to understand what I want and What I got already...
I want to wrote the information's, I collect in my IJob Structs, into a TMP_Text, but the text field doesn't show up in the inspector.

How can I run it in the struct (this would be the best result)
or in worse case, how can I transfer my integer value: "randomNumber" from my IJob Struct, to my MonoBehaviour class?

obsidian glade
#

that's a repo for examples using the toolkit, the toolkit itself contains the tests - you may need to add the package from within Unity

formal lichen
#

I've just been wanting to get the player to move forwards using the joystick 😐

lament salmon
#

Can anyone point me at some good resources for active ragdolls/physical animation?

quartz stratus
lament salmon
quartz stratus
lost sequoia
#

How can I collect my string or integer from a IJob Struct, into my MonoBehaviour class and ask for every external threads information, to put them at this frame all into the TMP_Text?

#

Because it is not possible to put my new information from my IJob struct directly into my TMP_Text, because I heared that structs and especially IJob doesent support that. so I want to use the main thread, to ask for all the external threads (in my case 16 threads) for all his integer or string values to put them one by one into my TMP_Text...

obtuse arch
digital rain
#

Hey! Not sure if this is counted in advanced scripting but I couldn't find anything more suitable, but i need an application to run in the background (kinda like how Spotify runs in the background) on Android, i dont think i can use services here and i have tried to edit the build files too using Android studio, but it throws a bunch of errors for some reason(will send error log if needed) thanks in advance!

digital rain
#

for some reason android studio refuses to build it

orchid marsh
#

Without logs, folks can't help you.

#

If they're Android Studio compilation errors, try asking an Android Studio discord/forums and Unity forums.

crude isle
#

I have an issue and was curious if anyone has experience with this type of problem. I am working on a project with "Passive Item" mechanic similar to games like Risk of Rain & Binding of Isaac and I'm about to revisit their implementation. These Item's effects are triggered in various ways either through a timer or some event. In the case of events I have quite a few, each with their own method signature. My problem stems from these events.

If for example I want to make an Item that spawns an explosion when the player dashes, my first approach would be to make a rather generic/modular SpawnObjectItemEffect script (derived from ItemEffect) and a PlayerDashItemTrigger script (derived from ItemTrigger). The PlayerDashItemTrigger script would subscribe to the player's Dash event (with a signature of Vector3) and holds references to ItemEffect scripts. It would call their "ExecuteEffect" method when the particular event is Triggered... This works fine until I want to Hook up the SpawnObjectItemEffect to a different event with a different method signature. For example if I make a PlayerHitEntityItemTrigger that subs to the player's OnHitEntity event which passes the hit entity and an IHitData instance. The data from the Hit event couldn't be passed to the ItemEffect without a specialization in ItemEffect to account for the Hit event's data (hitEntity and IHit).

What would be an eloquent solution to this "problem"? Should I make a "SpawnObject" script for EACH event type/signature? Should I have a method in the base "ItemEffect" script for EACH event signature that every ItemEffect needs to implement? Should I wrap my events into a unified data structure (PlayerEventArgs for example)? Every solution I come up with feels... extremely sloppy.

jolly token
digital rain
crude isle
#

@jolly token I would still need different methods to accept the PlayerHitEventData and stuff. I was thinking about consolidating all the event signatures into a single struct that just marks what type of event it is when created. I just feel this is still pretty awkward and will require a lot of "hard coding" within my scripts for each event type still. I really don't want my scripts to end up having big switch statement blocks for example.

jolly token
crude isle
#

@regal olive What do you mean about parent objects?

I can't exactly pass this info in any more of a generic form. Like for example the data generated from a particular combat Hit cant be reduced down really. I can pass this data as an Object or GameObjects... but I would need to pass more info with it to describe it's context, event type, etc to know how to cast it properly. My issue isn't the types being passed, it's the variation in method signatures itself. I would still need multiple method signatures to account for the variance in Event data. I guess I could make the data more generic by just packing all of the data from every single event into a single struct like I described in my OP. But like I mentioned in another reply that would cause the same issue that Im having in a way because I would still need some kind of switch statement to "know" what to do with each event's data.

obtuse arch
crude isle
#

@jolly token For sure. I've seen solutions like that before. I'm worried it wont be extensible. I will have to hamfist every type of event into a potentially large object type that is passed around and processed in countless ways, mostly within a single method on each script.

#

@obtuse arch Do you mean I should do the whole PlayerEventArgs thingy except it's a container for concrete typed EventData (like DashEventData, HitEntityEventData, etc). I would access the EventData using a generic <T> method based on the Event type being received in that Item? Wouldn't I still need different bits of code for each Event type within each ItemEffect script in order to actually process the EventData from the PlayerEventArgs container? Honestly I think it could potentially be cleaner to just make a "SpawnObjectX" behavior for each event type and have the single responsibility of processing each events data kept strictly in a single component. It's a lot of components though...

obtuse arch
#

Similar to CollisionHandling pattern where a Collider/Collision is passed and from its GameObject once can retrieve required components, assuming the mapping is correct

jolly token
obtuse arch
jolly token
#

In that case, the problem I see is coming from that Trigger and Effect is decoupled but somewhat dependent. You could make interfaces that constraint them, for example IHitTrigger can only trigger that implements IHitItemEffect and passes IHitEventData. and IGenericTrigger can accept any IItemEffect and passes IGenericEventData, something like that.

quartz stratus
#

I love the idea of interfaces. Maybe I'm just not working on a project that's big enough yet, but every time I start integrating interfaces into a new feature or system I'm building, I seem to always transition it into an an abstract base/inheritance structure. I think I need to read through some code on GitHub or somewhere and get a better understanding of how to use them properly though.

quasi nova
quartz stratus
plucky laurel
#

how would you implement a canonical hexagonal in unity?

#

also what advantages it has over ioc/ddd/ecs and how will it help deliver product in time, are there any examples where a project was using it?

quartz stratus
#

thanks, I may just take a look into that

obtuse arch
hushed moth
#

hey guys, is it possible to play webrtc (i have the working server + url) in an android app? i found the webrtc package but that is not for playing url, more like stream

upbeat path
#

why do you do that, rather than just implementing something and seeing how it functions?

faint terrace
#

How can I sync Instantiated prefabs (like projectiles) in online Photon game?
Do I have to Instantiate them differently?

weary stag
#

Anyone have any idea how to convert this algorithm from a recursive one to an iterative one?

jolly token
weary stag
#

That's the obvious approach.

#

I'm looking for a more-say different approach.

jolly token
weary stag
#

move list being a stackallocated array

jolly token
weary stag
#

yes

#

which is what makes it hard to generate an iterative approach 😅

jolly token
weary stag
#

@jolly token GPU

#

Recursion on GPU is slow.

#

So trying to convert to an iterative version

jolly token
weary stag
#

That doesn't help in converting to an iterative?

undone coral
jolly token
#

It doesn't make it iterative but it was a suggestion to parallelize the process as an alternative. If it doesn't work for you then nevermind 🙂

undone coral
#

you can try the experimental/directrender branch for usable android webrtc receiving

undone coral
obtuse arch
# weary stag So trying to convert to an iterative version

This is a ‘dynamic programming’ category problem where soln for next state is calculated on soln for previous state.
Making it iterative wont help you parallelise since the othercore will have to wait for previous result of any other core anyway.

Better approach would be identify individual non dependent calculations batch (batch meaning a sequence of calculations though dependent but only on result of sequence itself)and run those sequo in parallel.
This way you will achieve multithreading some way but still most of cores will wait anyway.

#

Also i would suggest looking at job system, The overall framework is good and you will find much functionality needed.

weary stag
#

not CPU

obtuse arch
obtuse arch
# weary stag not CPU

Though your problem is more directed towards cpu, even if you manage to run it on gpu im sceptical wether you will see any actual performance boost.

Do profile and scale upon that is what i suggest.

urban trail
#

Hi, does anyone know how to make a custom virtual cursor?

obtuse arch
urban trail
#

kind of like crosshairs

#

I want a crosshair so a cursor locked in the middle of the screen and invisible but to have it also be able to click buttons in world canvases

#

Well yeah i guess

#

Hmm

#

Ill try that, thanks

#

That might be too advanced for a simple thing such as this

hushed moth
crude isle
#

@regal olive Sorry. I didn't think I explained my problem well enough initially

#

no reason to be rude about it

flint sage
#

You're trying to over generalize your behaviours, even if they can't really be generalized

#

You'll spend ages trying to fix bug in specific combinations and likely introducing new bugs in other combinations

#

There's no way to reasonable do that

crude isle
#

@regal olive ahh okay, thought you were being sarcastic haha.

flint sage
#

Take a good look at your passive items that you designed and go figure out what 5 are common enough to share an implementation

crude isle
#

@hollow rapids Yeah seems to be the issue. No reasonable way to structure this how I've been structuring all my other systems.

flint sage
#

Also, if you don't have passive items designed yet. You should do that first, trying to make a system that encapsulates all possible passives items you might ever want is an easy way to shoot yourself in the foot

#

??

crude isle
#

@hollow rapids I have a few in my brain that are very different from each other that i've been using to inform the code.

flint sage
#

Unique behaviours like that don't tend to generalize either way, so you might still have a custom behaviour for that in both systems

crude isle
#

@flint sage im not even sure what it would look like to code something like this in a less generalized way.

#

@regal olive I guess you could describe it as a combo between Risk of Rain and Vampire Surviver... kinda. When the player levels up they get to choose 1 out of 5 randomized Passive Items. The same item can be stacked multiple times to give additional bonuses.

#

@regal olive I have an implementation of this working but the Passive Items are just Stat Modifiers atm. I want them to have more interesting functionality.

weary stag
#

I already have a CPU parallel algorithm

#

But GPU one seems out of reach

flint sage
#

Really depends what you're making tbh, porting a cpu algorithm won't work very well obviously but some things are very well suited

zinc aurora
#

I am putting this here, not because this is particularly "advanced" but because i have been debugging for ages, have asked tons of developers for advice with no avail and have been searching online to see if anyone else has had any issue like this.

#

I have created a asynchronous loading screen to build the game scene, track it's progress on the slider and wait for the min load time if it loads too fast. Pretty simple. It works perfectly the first time around but if i return back to the main menu and press play again, it activates the loadingBackground for .3 of a sec, runs up to line 57, the says progress is 100%, fails to run any of the other lines then deactivates the loadingBackground. I have no idea what is happening, any advice or tips would be awesome, thanks in advance !

silent dagger
#

Hello there, I'm not sure if it could be written better than this.
I have this GetAllPopluatedSlots which is an IEnumerable, but I can't convert it into an array on the fly, so I've been forced to make a new foreach loop

List<EquipLocation> equippedItems = new List<EquipLocation>();
foreach (EquipLocation itemLocation in equipment.GetAllPopulatedSlots())
    equippedItems.Add(itemLocation);

for (int index = equippedItems.Count - 1; index >= 0; index--)
{
    items.Add(equipment.GetItemInSlot(equippedItems[index]));
    equipment.RemoveItem(equippedItems[index]);
}```

Can I spare a for-each in some way? 🤔
Or maybe in performance meaning it's a non-problem?
#
public IEnumerable<EquipLocation> GetAllPopulatedSlots()
{
       return equippedItems.Keys;
}```

equippedItems is a Dictionary
jolly token
obtuse arch
jolly token
weary stag
#

the method is called Move Generation

#

It uses parallelism when depth > 4

#

for all depths <= 4, it does it synchronous as moving data to other threads is more expensive then the actual operation

crude isle
#

@jolly token Could you give me an example of how that would work? I'm struggling to figure out how I would use the interface to get around the extensibility issues. Wouldn't I end up with the same type of problem compared to using the abstract base class or just wrapping Event Data into an object?

jolly token
undone coral
#

well what's your objective @hushed moth ?

#

what is the game?

undone coral
undone coral
undone coral
#

how many items do you actually have?

#

that you have written?

hushed moth
zinc aurora
# undone coral > loading screen to build the game scene hmm why?

As soon as the user clicks play in the Main Menu, this script throws up a loading screen, tracks and displays the progress of the next scene to the user using the slider then disables the loading screen when the minLoadTime is met. It's works perfectly fine the first go round but if i go back to the main menu and press play again in the same session, it's fails.

undone coral
#

not very experienced in all of this and it's very very hard

undone coral
#

and then beam back positional information? what is the idea?

#

what is the game / application

undone coral
#

i can tell you how i would write it

#

based on the code snippet you shared things are in kind of bad shape

zinc aurora
undone coral
#

Right before you transition scenes

#

In your old screen throw up a UI image that says loading

#

Then synchronously load the next scene

#

What kind of game is it? The right answer is don’t use scenes but I’m tired of saying that

zinc aurora
# undone coral What kind of game is it? The right answer is don’t use scenes but I’m tired of s...

Interesting approach but i just find it would be a lot more cluttered and unorganized to put every GameObject in a parent and keep 1 main scene alive throughout my entire games lifecycle, and just set it to active/not active when using or not using so i create scenes for major sectors of the game.

And using 1 scene for the entirety of the game may not be an issue for you depending on your memory requirements, and performance requirements but may cause issues for others.

So nobody can realistically avoid load times. They are going to occur. Objects take time to load so i do need to make a reliable loading screen.

jolly token
# crude isle <@307360612403642370> Could you give me an example of how that would work? I'm s...

https://gist.github.com/cathei/ed8ea7f088237b681a43db2dfec256ea
Here I made an example script how you could apply interfaces to your Trigger/Effect system

The point of the system is you can put IItemEffect<IEventParam> to any trigger that has more specific event parameter. So you don't have to create multiple overloads for same ItemEffect.

If your ItemEffect requires more specific event param like IPositionEventParam, you can only add to the EventTrigger supports the params that extends IPositionEventParam. (and it's correct behaviour because otherwise it wouldn't make sense).

queen stirrup
#

Anybody able to help with a Serialization issue? I'm trying to create a dropdown for a custom class. It works, but when I actually select the class from the dropdown, nothing happens. Here's the problematic line: "property.managedReferenceValue = Activator.CreateInstance((Type)obj);"

#

Anybody know why that wouldn't instantiate the obj type within the property?

hardy nymph
#

Hi I need some help

#

I'm trying to use this package

hushed moth
hardy nymph
#

I tried using the exact code that is on the documentation (the example code) but it doesn't work

#

Can someone confirm running the package on their pc ? I just want to know if it's only my problem.

  • Yes I have set unity API compatibility to 4.x
chilly nymph
hushed moth
chilly nymph
#

In unity?

hushed moth
chilly nymph
#

And that would be MaterialOverride or RenderTexture

#

So you're not receiving data?

hushed moth
chilly nymph
regal olive
#

im having problems with my code (not technically my code) its the unity fp movement code but after c/p it, there are eroors with the code, I dont really know why... but there are 3 ; errors and 1 } error, and when i go to the line of code there are ; and on the other 1 there is a {

#

ill send the code momentaraly along with the errors

chilly nymph
hushed moth
chilly nymph
#

But right now you need to focus on receiving data.

regal olive
#

Assets/universal player scripts/movement/player movement.cs(139,75): error CS1002: ; expected

Assets/universal player scripts/movement/player movement.cs(139,80): error CS1002: ; expected

Assets/universal player scripts/movement/player movement.cs(139,80): error CS1513: } expected

chilly nymph
#

error CS1002: ; expected

regal olive
#

Assets/universal player scripts/movement/player movement.cs(139,102): error CS1002: ; expected

chilly nymph
#

error CS1002: ; expected

regal olive
#

ik

chilly nymph
#

What does that mean?

regal olive
#

i checked and its missing a ; somewhere but either im blind or there is no ; missing

regal olive
chilly nymph
regal olive
#

it means im missing a ;

chilly nymph
#

Check your lines: player movement.cs(139,75

#

Also you should not have spaces in your file names.

regal olive
#

i did

jolly token
#

What is the question if you know?

#

float targetSpeed = _input.sprint ? SprintSpeed : MoveSpeed;oint error prone, and is cheaper than magnitude;

regal olive
#

i cant find where the missing 1 is

#

;*

jolly token
#

What is oint error prone, and is cheaper than magnitude

#

That doesn't look like c# to me

regal olive
#

its a temp code 4 movement out of the fps unity example

#

ima change it out later to fit my game

jolly token
regal olive
#

sry 😦

jolly token
# regal olive sry 😦

Not to be mean but that oint error.. part isn't a code. It suppose to be a comment but seems to be cut off from somewhere.
Also you may want to configure your IDE to show where is the error. #854851968446365696 IDE Configuration

chilly nymph
#

Unity is an abstracted way of displaying components (classes) to have everything in one class is possible but it's like "why".

#

It's very hard to handle references or pass around data that way as well, and it would make it harder in the long run to write and update your code.

regal olive
chilly nymph
#

I don't really understand what you're trying to say.

Having classes is not complexity, it's abstracting your code out in component like objects that you can reuse.

#

Classes (if anything) make your job easier.

#

How would you have dynamic systems if it was all one class?

#

How can you have 10 or 20 enemies?

#

How many years do you have?

jolly token
#

Most development pattern and techniques are for teams not for single developer. To make a big project maintainable.

chilly nymph
#

To put your question into perspective, you're asking something like.

When I go camping I bring my entire house with me.

#

Any book on the topic explains when and why they should be used.

#

Yes, but it's not your entire house.

#

You don't bring a fridge (network code) in a tent (enemy)

#

"Can you justify the complexity of breaking apart your game software into a whole zoo-ology of different classes when a single component could suffice?"

This depends on what game you're making and the complexity, you could make pong technically in one class without any issues, but if you ever wanted to extend it you would have to do 2x more work. (this is just looking at practical's of development) iterating on design and development.

#

To answer your question, there's no truths in programming, you will never make the best possible script and even if you do then there's so many factors as to what is a good script, is it speed? Dev time? Compact? etc.

But in terms of asking "Is something complex" is that asking from a new developer standpoint or general terms?

Breaking your properties apart is the easy thing to do, it adds readability as well as keeps your code compartmentalized. So in terms of complexity I believe having one class would expand that exponentially. Imaging having to have render code in the same scope as player movement.

#

Also debugging, teams, networking, generics, dynamic systems, iterating, tasks / threads. Would all be nightmares to do.

#

Sure, and 90% of tuts are done by juniors.

#

You can shoot your foot however you want to when programming.

#

How can I answer that?

#

I try and make my systems least complex as I can.

#

But literally how can anyone answer that?

#

With classes 😄

#

My classes are done in a way that they do one thing.

#

Or act on one object.

#

When I started programming, I believe everyone does.

#

But you learn.