#archived-code-advanced

1 messages · Page 32 of 1

undone coral
#

you should be using IJobParallelFor to achieve this

#

then you have to use the API correctly

#

then you have to use the profiler to see if any of this stuff makes an impact

tired fog
#

I've been doing this so far, so good

undone coral
#

you can use the burst debugger to ensure burst compilation did indeed work, or why it didn't

tired fog
tired fog
tired fog
undone coral
tired fog
#

So, The jobs work with mesh data, and it's parallelized through vectorization of the vertices

undone coral
#

if i were you, i would generate an image, and then use unity native terrains

#

since it looks like you are generating a heightmap

#

and use the unity terrain tiling techniques that e.g. Gaia Pro does

#

you can also use the runtime terrain assets

tired fog
undone coral
#

for designing procedurally generated infinite terrains

#

using built in unity terrain as the rendering / rules backend

#

which helps a lot

#

it's hard to say what your goals are

tired fog
#

I see, my goal is to do most of it myself, too learn mainly, and see what can I do

merry kernel
#

Hi all! I have a few questions regarding Unity's asset bundle system (particularly for Unity 4). Heart
Firstly, what happens during the process of an asset bundle being cached to disk? Also, what are the differences (in detail) between an asset bundle and its cache? And how is the name of the cached file generated?
This is to try get an old game from 2014 that got shut down back up and running, as such I suppose the crux of this question is - what would I need to do to turn these caches back into bundles that can be downloaded from a server pleasedcat
(putting this in advanced as it's rather niche. thanks for any help!! Pink_Hearts )

undone coral
#

you can try using many tools on github to unpack these files

#

and try to repack it using the editor

undone coral
#

you're really close it's going to be like 1 or 2 api calls to tie it all together

merry kernel
#

A game called Monkey Quest by Nickelodeon. I would like to have a way to repack it automatically as we can't redistribute the assets themselves due to copyright

#

hence why I'm looking into the process itself - surely if you can decompile and repack it, the cached form isn't too different from its original?

undone coral
merry kernel
#

I'm unaware of ones that can directly convert these or, to be honest, what the differences are

#

what actually happens during the caching process

undone coral
#

i don't remember there being anything notable about caching in unity 4. caching meant saving the asset bundle to a well known place, and rolling your own way of keeping track of which are newest

#

there's prior work on this game, i'm sure you can find it

#

the earliest version of unity i used was 3.5

merry kernel
# undone coral there's prior work on this game, i'm sure you can find it

the prior work was by me Blonde_Neko_Giggle, we used to decompile and recompile in the editor, but that takes a long time to do, so I'd rather automate it and streamline the process by sticking as close as we can to the original files

if there's nothing different in it being cached, would it not be the case that a simple rename would work? am I just overthinking things?

I haven't a clue what happens behind the scenes tbh as the Unity API calls the internal C++ dlls when it reaches that step

undone coral
#

it will be more valuable to learn to do that in the long run than something specific about the file format or whatever

#

automation is useful

tired fog
atomic pendant
#

I am learning the Single Responsibilty Principle with coding. I am following a long this tutorial: https://www.youtube.com/watch?v=f5zJ4D2E0dI He creates a script that is purely for OnTriggerEnter. So he can put that script on an object and define a UnityEvent in the inspector that should run after the trigger enter is called. How would this apply to Visual Scripting? Is this possible? I can not seem to find it

tender light
tired fog
#

I have a readonly nativearray that I would like to be accessible at all of the jobs that are called parallelaly and have it inside, however im getting this error

#
System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length.
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffd18ca5c93 (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.FailOutOfRangeError 
0x00007ffd18ca5bda (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.CheckElementReadAccess 
0x00007ffd18ca5cd8 (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.get_Item 
#

How can I make it sharable?

rancid swift
real blaze
#

Hey. is Unity's physics system dependent on the global space of a piece ? like, when I move my whole scene to some y += 20 position, can I expect the exact same results as before?

real blaze
compact ingot
real blaze
sturdy trail
#

I'm trying to capture steering wheel X value when window is out of focus. I have set runInBackground and IgnoreFocus in settings. Am I missing something for it to work?

I am just reading now that Device layout can override canRunInBackground but I am not sure if this will work and how do override wheel layout

From what I see now Its not possible at all to do this. Im trying to figure out a way to do this with windows api. Any tips appreciated

sturdy trail
sage radish
sturdy trail
#

Gotcha I'll try this and update later if I manage to do this. Ty @sage radish ❤️

sturdy trail
teal bobcat
undone coral
merry kernel
merry kernel
#

how would you achieve that?

undone coral
#

it's in the docs

#

command line editor batch scripts or similar will get google results

undone coral
#

it looks like you are working in xy space for an xz game

lyric raptor
misty glade
#

I'm getting unity assertion exceptions on some code of mine (well, a library I'm using). I've narrowed it down to one line of code but the unity code doesn't "fail" per se, it just throws an assertion exception which is spamming up my console.

Is there a way to break on unity assertion exceptions? I'm not sure if this is a me-bug or a unity-bug, and googling hasn't been super helpful.

#

(the stack trace on the exception isn't super helpful but I can post it as well)

#

something's failing in the unity mesh bake on particle trails

merry kernel
# undone coral you should decompile and recompile in the editor headlessly

the only problem that I have with this is that many programs have the tendency to introduce weird bugs during decompile - even DevXUnpacker, which we have a license for, seems to have issues. Hence why I'm interested in the process of caching, it's differences, and possible reversion, as this seems more friendly for the end user

#

I'll definitely look into headless decompiling though fuwwycat

undone coral
#

and for education

merry kernel
#

I really don't see why it wouldn't be possible to revert the conversion though

#

the only problem is that it's not documented

untold moth
#

It would be impossible because unity doesn't disclose their packing process. It's not an open source engine you see.

#

At least the implementation. Things that you don't need to know as a developer that abides their user agreement.

merry kernel
#

People seem to have reverse engineered the unpacking process, so I'm just looking around to see if people have information about the differences

untold moth
untold moth
merry kernel
#

That's why I was simply asking about the differences between bundles on servers and 'archives' stored on disk, as well as how the names of caches are generated etc

#

more general questions than direct

#

although I do see what you mean, I apologize - I didn't give the guidelines too much of a read, just didn't want to create an XY problem

untold moth
#

Probably not much difference.🤷‍♂️
If the docs don't cover that I'd assume there's none. At least as far as a regular dev should be conserned.

regal olive
#

Does anyone know if theres anything faster then AnimationUtility.SetEditorCurve
It seems creating a animation pragmatically takes quite a while. Im having to split the workload in a coroutine only calling it < 30 times per frame

golden saddle
#

Is there a dictionary/key-value type that requires both the key and the value be unique?

compact ingot
golden saddle
compact ingot
#

but could be that you need to make your own data struct (depending on the types you want to have in there) and implement a hash function that reliable hashes both values... not sure

golden saddle
#

word. nothing built in tho?

compact ingot
#

ofc not

#

but its also really simple to build that in a custom structure on top of two hashsets

undone coral
jagged vigil
#

Do you guys know how I can get the values from an array on a ScriptableObject to a property drawer field within that Scriptable Object? I need to fill a dropdown with the values of the "Object Events".

solemn walrus
#

What are the minimum specs for a Unity Headless Game Server? I setup one up on Ubuntu 20.04 LTS, but as soon as clients join and game starts, I get 100% CPU spikes, and game gets laggy.

I was on a GCP (Google Cloud) e2-small at first which is (2) .25 w/ burstable to 1.0 VCPUs, 2GB RAM. I have since upgraded to a e2-standard-2 and I am still pegging the CPU at 100% with 8GB RAM and 2 dedicated VCPUs.

This wasn't an issue when I tested locally on both Windows and Linux at my house.

Any ideas?

compact ingot
real blaze
#

I mean since they use soft floats, the results of a subtraction should be the same if in real math it is

real blaze
teal bobcat
real blaze
#

(which I'm not super sure what they are, but the special name makes me think it works like Real numbers)

teal bobcat
#

And that's not what "deterministic" means. Deterministic means that for a given input, you will always get the same output.
This is often useful in multiplayer games where you need to "replay" the player inputs server-side while being consistent with the client-side results.

#

And even scientific/engineering physics software (at least those that I know of) work with limited precision numbers.

smoky kite
#

can I install unity 2022.2.0b8 on Ubuntu OS? Im only seeing downloads for windows/mac on the page

teal bobcat
#

which affects the local transform in the end
There is no concept of local transforms or object hierarchy at the physics engine level, it operate on each object final world position.
Beside, the only way to get more precision out of the hierarchy would be to traverse the whole hierarchy between two transforms to discover the shortest path, every time a position is queried.
This wouldn't solve anything, as you would still get non-coherent behavior between similar setups (you just reduce the error, you don't eliminate it), and you would tank performance.

upbeat path
smoky kite
upbeat path
smoky kite
#

O wait i found a Linux download for 2022.2.0b8

upbeat path
#

tbh if you are using beta releases latest is best

real blaze
real blaze
smoky kite
solemn walrus
keen plaza
#

which is more performant - Physics.OverlapBox or Physics.OverlapBoxNonAlloc?

keen plaza
#

what factors should be considered?

compact ingot
#

NonAlloc is faster in aggregate if there are more than a few calls to the same method

#

The allocating version is quicker for a single use, but creates garbage

keen plaza
#

perfect, thank you. How come alloc one is faster?

#

because it doesn't need to copy anything?

compact ingot
#

i have forgotten the details of why. Might be internal stuff, fewer transitions to native code etc.

keen plaza
#

fair enough, I'll take your word for it 😛

compact ingot
#

the info is somewhere, you can Google it

keen plaza
#

I read the same thing before somewhere on unity answers or google but I couldn't find it anywhere

#

probably searched the wrong terms

#

oh, another question about the OverlapBox I just got - it doesn't need to be a perfectly square box?

#

like it could be a rectangular box?

#

I just saw that you need to provide halfExtents which is a Vector3... but I remember explicitly that somewhere it said it needs to be a equal-sided box

compact ingot
keen plaza
#

that's exactly my thoughts... this means that I had wasted approximately 12 hours of my time a few weeks ago trying to get it to work with combinations of cubes

compact ingot
#

Computationally checking a cube and a box shape have identical cost

keen plaza
#

yeah, I did it by having multiple checks

compact ingot
#

but you can in theory optimize a cube version further since it is a more constrained shape, the difference however would be marginal

keen plaza
#

instead of checking a box of (1,2,1) I did two cubes of (1,1,1) and (1,1,1)

#

thought I was being super smart solving a problem when there was no problem to begin with

compact ingot
#

Fewer checks is always better than a hyper optimized shape when the original shape was already super optimized

#

Not the least because it saves development time 🙂

undone coral
undone coral
undone coral
#

it's distinct from 3d physics

#

i think there is a lot of noise on google about this so it's hard to find knowledge about it

#

the user has some other problems going on in his scene but it will work

#

the reason physics 2d determinism is a priority is not because of networked games though, it's because people design puzzle games with it

teal bobcat
#

Good to know. I'm not actually familiar with the Unity 2D physics implementation, was mainly talking in the context of the PhysX (3D) implementation.
But yeah, maybe is something more than just FP precision related variance due to varying inputs going in the @real blaze case.

undone coral
#

even their own knowledgebase article seems a little wack

smoky kite
#

I'm in a high performance research

undone coral
smoky kite
#

I'm trying to compare performance with multithred jobs and variations (sorting, one thread, multi thread, no jobs)

#

Actually the lab is entirely on Ubuntu due to better performance

undone coral
#

what is the big picture purpose of this?

undone coral
undone coral
#

because the stuff in your parenthetical doesn't sound right to me, as categories of stuff you are trying to compare

#

what are you actually trying to do?

#

unity editor only works well on Windows and macOS, and the players work best on Windows, macOS / iOS, consoles and Android

smoky kite
#

The machines I use in the laboratory uses Ubuntu as OS

undone coral
#

or to like, futz about a bunch and not get much done

#

i rank "dealing with linux desktops" very very low on my personal, subjective list of things worth doing for any reason, even intellectual reasons

smoky kite
#

I already have this implemented and working. Just will have to figure out now why the plastic SCM option doesn't shows up anymore

sterile snow
#

So I have an interesting challenge on my hands, I'm trying to develop some functionality for objects in my game (namely NPCs and the player) to accept callbacks that may modify or add onto existing functionality. (i.e. a callback that may run a second attack when the player attacks)
While I have gotten most of the way there, I am stumped on how to let the callbacks take contextual information in their parameters and be able to change it, like say, taking a reference to a damage value and being able to increase it before an attack happens. A delegate for every possible context seems like the solution (I was already planning on enums to define what exactly a callback is supposed to be applied to), but that complicates storage and the adding of these callbacks. Any thoughts?

#

The intention behind this is to allow the nondestructive addition (and removal) of powers from an external source.

severe topaz
sterile snow
#

Aight I'll take a looksee

undone coral
#

can you give a concrete example

undone coral
smoky kite
sterile snow
# undone coral can you give a concrete example

Well I'm developing a text adventure, but it uses a complex D&D like architecture in the background, so use cases would include passive effects such as "doubling any attack sent, increasing damage dealt by a fixed amount, allowing entirely new abilities, having a 50% chance to block an attack" etc. And these are all effects I need to be capable of extending the base player class, with no need to have the effect built-in in some way (although the checking for and running of the effects must still be built-in of course).

#

An implementation would ideally look like "player is told to attack thru text input, player class checks for callbacks before attacking, runs those callbacks if they exist, accepts any modifications to the attack made by the callback, and then proceeds"

#

At least that's what I'm seeking to do. It's a very big inclusion evidently so what I'm looking for is probably more so examples of what other games have tried to do to solve this problem.

sage radish
#

So in this case, some player script would listen to the AttackEvent/Message to do the attack with whatever data that is in that event/message, but another ability script could also listen to that event with a higher priority and modify it however it wants.

sterile snow
#

That's an interesting idea, actually. I'll think on that.

sage radish
# sterile snow That's an interesting idea, actually. I'll think on that.

Here's a library I wrote with that concept. I can't recommend using it directly, because I've kind of abandoned it, but you can maybe borrow some concepts from it.
https://github.com/PeturDarriPeturs/GenericEventBus

GitHub

A synchronous event bus for Unity, using strictly typed events and generics to reduce runtime overhead. - GitHub - PeturDarriPeturs/GenericEventBus: A synchronous event bus for Unity, using strictl...

sterile snow
#

Oh, no intention to use that directly, I'll take a look though and see if I can get inspired by it for my own implementation. So far what I've wrote is an "aura" object that carries the callbacks (and also stat mods to allow for nondestructive transformations to stats), with which my entities can implement for their own needs. The only questionable area right now is the actual storage of those callbacks and their execution though. Deliberating on it.

undone coral
#

i hear what you are trying to do. it is essentially the same for any kind of game like this, including what it sounds like you are doing

#

it's really useful to think of these things as strategy card game cards, and to describe their effects with short text. D&D already does this.

#

so don't get too hung up on the genre differences here

#

it is really challenging to try to do this if you already have some decoupled architecture in your game. for example, if you are representing monsters and items with scriptable objects, and if game objects have references to each other, and game objects represent monsters and items, etc.

#

since you are making a text adventure, you might already be doing something very tightly coupled

#

which is usually good

#

you can't really do this in a decoupled way

#

an "event bus" is just one piece of a much bigger puzzle

#

there are a lot of architectural insights that make these sorts of things way more realistic to program.

#

i don't know how else to put it, it's really hard

sterile snow
#

Hm

undone coral
#

for example, imagine all the spells that can be associated with an item, like casting a fireball, healing someone, conjuring a creature, combining two effects together, applying and de-applying an aura, etc., were functions with exactly the same signature, but simply chose to use (or not use) certain arguments in the signature

#

so instead of

void Heal(int healingAmount);
void Damage(int damageAmount);
void Conjure(string nameOfCreature);

you'd have

void Heal(int? value=null, string nameOfObject=null);
void Damage(int? value=null, string nameOfObject=null);
void Conjure(int? value=null, string nameOfObject=null);
#

this for example is an essential feature of architecting this kind of game

#

it is so tremendously important that pretty much every version of this whose source code you get to see in real life, like xmage and spellsource, do this, and 100% of the other things that never ship and no one plays and don't work and are too buggy do not

#

because this lets you do

void CastSpell(string nameOfSpell, int? value=null, string nameOfObject=null);

and now, you have a way to simply do

void ModifyEffect(CastSpellInvocation myInvocation) {
 var targetInvocation = myInvocation.targetInvocation;
 var algebraicOperator = myInvocation.algebraicOperator;
 var appliesTo = myInvocation.nameOfObject;
 ...
 case AlgebraicOperators.MULTIPLY:
  targetInvocation.value *= myInvocation.value;
  break;
}

and

var doubleDamageSpell = new CastSpellInvocation("ModifyEffect", value: 2, algebraicOperator: AlgebraicOperators.MULTIPLY, nameOfObject: "Damage")
#

and now, CastSpellInvocation can be [Serializable], you can design it in the editor (Spellsource), or simply write the code - you can, after all, just call ModifyEffect with the right arguments (Xmage)

#

@sterile snow this is like 1 big part of a big big puzzle

#

for the examples you gave, you don't necessarily need a ton of implementation. but you do need the bones

#

🫡

sterile snow
#

Well. I'd say you've given me a lot to think about, never really thought about all this.

undone coral
sterile snow
#

I'ma take a looksee

undone coral
#

in which case you end up with class DamageSpell : AbstractSpell

#

but the fields in abstract spell are the arguments to the spell function i described

#

it's two sides of the same coin

#

observe AbstractPower has amount and source for all powers

#

@sterile snow is this helpful?

sterile snow
#

Yes, I believe it is

#

I really appreciate it

undone coral
sterile snow
# undone coral okay feel free to ping me on this journey!

I've decided to implement a container object with properties like "attack", "value", and so on to give information on the contexts I was concerned about for the meantime. So a callback that extends attacks can just look to see if this object has an attack it can apply a change to.

#

I've been doing something similar already with the payloads the parser sends after it figures out the player's intention.

#

The container won't necessarily have its properties filled out but it doesn't need to, and it can have additional ones added later if I see the need to.

sterile snow
#

As an aside: decided to make a pretty rudimentary global event system (add listeners, fire events, and extend with new events super easily) and wow this is making things a lot nicer.

undone coral
#

don't actually make your own event system

sterile snow
#

Aight I'll do that

real blaze
# undone coral i didn't really watch the video, but the answer to your question is that if you ...

ah, yes that's exactly what I expected the 2D physics to do. but in the video, I duplicated the whole board to different positions and applied the same force to the same object to all of them. the results were different... perhaps my board had a little problem, although I had removed all the custom components that change the Transform in any way.

  • also if I may ask, what's the source for this? is there any articles or official page on it? because I searched a lot and didn't find a single thing.
real blaze
glass lily
#

This is a very specific question, but does anyone happen to know if NativeQueues work with Burst? (I could do some work to verify this myself, but just wondering if anyone has experience with it already)

sage radish
glass lily
glass lily
# sterile snow So I have an interesting challenge on my hands, I'm trying to develop some funct...

Just an idea, but I’d consider a sort of “tagging” system, where you have values (that represent healing, damage, armor, etc) and these values can be tagged, eg. They have a list of strings attached to them. It can just be a class { float value, List<string> tags }. Then they can be stored in a dictionary, and modifiers can look in the dictionary for the type of values that they modify, if they exist. So when a character attacks, they put the attack value in a holding area, and any character can look in that area to modify relevant values (by reference). I can explain more if you like. But generally I’d try using dictionaries and having any modifier/effect search the dictionaries for relevant values (string keys), if they exist. That keeps the system flexible imo. Or that could be the wrong approach. Just an idea.

cerulean scaffold
#

I'm having an issue building my project from a gitlab runner (elevated powershell).
I don't have any issues when I run the commands manually but once the runner executes same commands it gets stuck :(

undone coral
cerulean scaffold
undone coral
#

for starters, you should never run unity with an elevated shell on an ordinary desktop

#

on windows, unity does not print anything to console

#

you have to tail the log file

#

so | Out-Default doesn't do what you think it does

#

it does nothing, because it never prints to the console

#

i think you must have seen that

cerulean scaffold
#

yea I saw that

undone coral
#

so then it will appear to hang while it is building

cerulean scaffold
#

yea but it never stops building

undone coral
#

did you tail the log

#

and watch it do its thing

cerulean scaffold
#

what do you mean by 'tail the log'? I don't know that term

undone coral
#

hmm

#

before i continue, do you want to be a devops engineer? is that something you want to learn?

cerulean scaffold
#

no

undone coral
#

why are you doing this gitlab runner thing?

#

okay.

cerulean scaffold
#

but I need automated builds

undone coral
#

what do you do with the automated build?

cerulean scaffold
#

I run it the next day to see if everything still works after I merged something into master

undone coral
#

by still works, you mean, you want to know if the project builds?

#

but you merge locally on your machine

#

help me understand the purpose of all this

cerulean scaffold
#

I have a gitlab repositories set up on my old laptop and my old pc is functioning as a runner, to run tests and build

undone coral
#

okay, when you say run tests

#

do you mean run automated tests?

#

or do you mean, you as a human being QA a build of your game?

cerulean scaffold
#

I run automated tests but also build the project so I can do some manual playtesting

undone coral
cerulean scaffold
#

yea

undone coral
#

so far everything you've told me is 100% supported by Unity Cloud Build

#

it also isnt' clear to me why you are not using GitHub

cerulean scaffold
#

GitLab lets me do all this self-hosted

undone coral
#

that's true

#

do you want to be a devops engineer?

cerulean scaffold
#

As an means to an end I suppose, but not primarily

undone coral
#

i've authored a unity building automation solution. this takes months of product development

#

you're not going to get this to work

#

in a reasonable amount of time

#

you're already doing a few things totally wrong

#

that you will have to scrap

#

so i really think you should use unity cloud build

#

as soon as you didn't know what tailing logs meant

#

this isn't going to happen

#

do you see what i am saying?

cerulean scaffold
undone coral
#

well you're using gitlab, and you're using gitlab runner, and you're using gitlab runner on windows

cerulean scaffold
undone coral
#

you're trying to run a CI runner on a desktop, with desktop security model and desktop crud

#

like i said

#

there are a thousand "tailing logs" between here and there

#

not 1

#

you can certainly run your builds headlessly on your own local computer. that's what i recommend you do

#

and like, use github

#

i don't know what the purpose of all of this is really

#

running your own source control is as reckless as running your own database

#

it would make anyone, not just me, seriously doubt all your other decisions

cerulean scaffold
undone coral
#

hmm

#

well i think you can keep going down this path of learning how to be a devops engineer

cerulean scaffold
#

It all used to work perfectly before I upgraded to Unity 2022 btw

undone coral
#

that's okay with me, lyou can also say "yes" to that question

#

hmm

cerulean scaffold
cerulean scaffold
undone coral
cerulean scaffold
modern storm
#

When writing a custom generic class, is there a way to have a static method that doesn't require the T parameter?

undone coral
#

but if you are trying to do this, you are probably doing something wrong, like making a "singleton class" or similar

lament briar
#

Hello! I want to create a custom animator that uses an external time variable as a time multiplier. I can't however create a script that extends an animator and use that, since it needs to be a monobehaviour. How can I do that?

undone coral
#

so you would copy the state machine and modify it in a separate script maybe

#

not sure

lament briar
#

For all the animators? I have no idea on how to do that

modern storm
#

@undone coral im writting a wrapper for flattening a 2D array into NativeArray and when I schedule the job I cant pass the class cause its just a wrapper, I'm not ready to write my own collections. So instead I pass the internal nativeArray but once in the job I want to use a method from the type to read/write to it https://pastebin.com/09Tc8jwR

undone coral
#

like 3?

#

you can author the 3 methods

#

and move on with life

#

you can't do what you want to do. you can't make a struct a class

modern storm
#

its a class that contains a struct

undone coral
#

i see that now, well it' snot burst compilable then

#

in which case you moot the point of using jobs

#

most of it anyway

lament briar
undone coral
#

you can subclass FlatNativeArray2D for the 3 types you will use it with

modern storm
#

I pass the struct to the job though not the class

undone coral
#

and in the method

#

DoThing() or whateve rit is

#

call the right thing

lament briar
#

I can't create a script and modify all the states and parameters each time, it's a lot of work

#

I was trying to find a better solution

#

like creating my animator component extending the unity's animator and then, in that script, accessing states of the state machine and multiplying all of them by a timeSpeed variable (found in the game manager, universal to every custom animator)

undone coral
modern storm
#

yes the struct is a nativearray

#

are you saying I could pass the class?... mmm the thought never occured to me. lol

#

no you have to pass value types if I remember right

undone coral
#

no

#

i'm saying

#

do public class FlatNativeFloatArray2D : public class FlatNativeArray2D<float> {}

#

and move on with life

#

now in that class, you know it's a float, make the method you need

#

you will literally only have floats and vector3s

#

or whatever

#

then you are done

#

does that make sense?

#

i don't know what you are trying to do yet

#

like what is the job? where do you want to use a static? it doesn't make sense yet

modern storm
#

@undone coral oh i see what you mean there is no need for a generic type

#

I need to store data per charater and LODLevel

undone coral
#

i think you can figure this one out

#

you're almost there

modern storm
#

thats what I'm doing now and I need to change it to add a level

#

Its been functional for months, I was trying to add a method

prisma spoke
#

Hi! How does Unity know which mesh to load from an fbx into a mesh filter's mesh?
I have the GUID for the asset (the fbx file) from the meshFilter, there is also a fileId provided there that should tell Unity which mesh to load from the asset. The problem is I can't find anything that would tell Unity that that ID should correspond to that mesh
The metadata of the FBX file has no mention of this ID and I can't find this ID listed in any node of the FBX file either. Anyone has any experience with how this works?

nevermind I found it, I was searching incorrectly, here is the answer for anyone interested: Unity hashes the mesh's name: https://forum.unity.com/threads/fbx-submesh-fileids.948882/

spring zenith
#

hi devs! question some of you suffer the crash issue related with libc.so and firebase recently? if yes you solve it? some walkaround idea to that problem?

long ivy
#

on what platform and firebase version? I always see a few from libc.so

pulsar owl
#

Very confused by this error. Wanting to have a simple Unity build pipeline in TeamCity. This doesn't occur on developers machines. Only on the team city machine.

misty glade
#

I've had a lot of trouble personally getting CICD pipelines to build packages properly.. so much so that I generally default to just tossing the source directly in my project instead of using packages when possible. I've done this 3 times in my current project (for Ruffles rUDP, UIParticle, and Telepathy networking) - all of which claim to have easy package support with unity but then failing in build pipelines.

I'd start with making sure your packages json files are in the repo, and that the packages themselves are as well. I don't know the nitty grity of how unity resolves those packages but .. it's not always trivial to get them working for command line builds.

#

@pulsar owl

flint geyser
#

How not to repeat code stored in supposedly protected/private (access modifier) methods when using composition over inheritance? (decorators)
Let's say I am making a state machine for movement. I am trying to create states by creating the base class and then building decorators around it. But there's supposed to be an event in interface IState. How to trigger the event from a decorator when IState interface's client doesn't need a method like TriggerEvent in interface IState?

#

So far I've come to only two solutions:

  1. make IStateChanger and then pass it to the states, but then there would be circular dependency between state machine and states
  2. making an interface which would inherit from IState and then implement the new interface in the most basic state, not a decorator, but it would also mean that the most basic state has to know about an interface made especially for decorators
#

pleading for your comments

flint geyser
#

So I ended up inheriting from StateBase with StateBaseExposedForDecorators implementing IStateExposedForDecorators. Tho looks like over-engineering

sturdy trail
sage radish
# sturdy trail So I was trying on friends pc and SharpDX.DirectInput is not finding his wheel. ...

After some googling, it looks like DirectInput is actually an old API that has been replaced by XInput, so that might explain why it's not working. Sorry about that. Here's an XInput C# API, but I haven't used it before.
https://github.com/speps/XInputDotNet

GitHub

C# wrapper around XInput, works with any Mono or .NET application (eg. Unity3D) - GitHub - speps/XInputDotNet: C# wrapper around XInput, works with any Mono or .NET application (eg. Unity3D)

sturdy trail
midnight violet
sturdy trail
midnight violet
#

And there should be remote devices or so, and there unsupported devices, you can I think right click or similar and enable unspported devices

#

Sorry, can't test right now, unity is loading a huge project right now 😄

sturdy trail
midnight violet
#

Ah okay, was not sure if this is just fir inputsystem or the whole input detection inside unity

silver lark
#

Hey guys, I am not sure if anyone has done this before, but here we go 🙂
I am trying to compile a rust plugin in unity using webassembly (rust compiled to wasm). We are running into some issues regarding pointers...
Right now we got something working using a lot of copying:
We allocate a buffer in unity, associate this with a javascript array in the jslib, allocate a native buffer in rust, use that native buffer to call our rust function, copy the result to our javascript array (and therefor the unity buffer) and then deallocate stuff.
This is not really feasible as this would be very slow.

I cannot imagine unity being able to work with web assembly but not being able to pass heap allocation somehow, is there anyone who knows a sollutions to this issue or anyone who worked with this technology before.

Thanks every, sorry for the long post

sturdy trail
#

Any ideas how to get racing wheel input out of window focus? Im running out of ideas

sturdy trail
# tawny bear Elaborate?

I want to receive Steering wheel X axis data while the game window is out of focus. I've tried unity way of getting input but its only working while the game window has focus.

sturdy trail
tawny bear
#

There definitely are ways though

#

Maybe packages or smth

sturdy trail
#

I g you are not the angel im looking for ty though ^^

tawny bear
sturdy trail
tawny bear
#

Ooooh

#

You're talking about an actual hardware piece a physical steering wheel for say like a racing game?

sturdy trail
#

ye

tawny bear
#

Ah yeah that might be an issue

#

Cuz that's probably a niche that has a lot fewer answers

sturdy trail
#

well will still look for a while for an answer

tawny bear
#

Good luck!

sturdy trail
#

With your good luck I can already see an angel stomping down from heaven wanting to give me an hint how to solve this. TAKE ME ANGEL INTO YOUR ARMS 🫂

jolly token
sturdy trail
jolly token
sturdy trail
jolly token
sturdy trail
#

also

jolly token
#

The doct also says

A Windows application must have focus to receive input from an Xbox One Controller.
So that’s not good for you

sturdy trail
#

I just noticed this, so maybe no wonder I couldn't get this to work

#

ye

jolly token
#

Anyways, you might need lower level API or you might be out of luck

sturdy trail
#

also I tried doing DirectInput it worked for me but it didnt work for my friend. Any reasons you can think of what can be blocking access to controller ? At the same time direct input found normal gamepad for my friend but it was blocked when out of focus, any indeas what can be blocking controller when out of focus that i am being blind about?

jolly token
sturdy trail
muted pilot
#

i have a way to check internet reachablity

#

how can i check slow internet connection

#

????

tawny bear
#

In Unity?

muted pilot
#

yes

#

how to check unstable internet?

tawny bear
sturdy trail
undone coral
sturdy trail
undone coral
#

just help us understand what's actually going on

sturdy trail
#

I just click other window so the main app is out of focus.

undone coral
#

okay

#

but why is that important

sturdy trail
#

im not doing it through code

undone coral
#

i undersatnd

sturdy trail
#

o

undone coral
#

is this a driving game?

#

why is it windowed?

#

just to confirm, the wheel works fine when the game is focused?

sturdy trail
#

thats because the main focus of the window will be on other games. The app is supposed to run in the background gathering X axis then sending it to another application through websocket. I did web socket part and connection to antother app just the input im stuck at.

undone coral
#

what is going on in this application (in the general sense. not a specific executable, but application means "the thing you are trying to do")

#

what does it do

sturdy trail
#

are you asking about the app gathering input or the app that's receiving input through websocket later

undone coral
#

see

#

i'm asking about both apps

#

i'm asking about this whole thing

#

what is it?

#

however many apps there are

#

i have 8m

#

until i have to go

sturdy trail
#

its a plugin for vtube studio.

undone coral
#

okay

#

so what you're saying is, you're trying to connect a racing wheel to vtube studio?

sturdy trail
#

Interacting through websocket is the only way they allow it i cannot run in inside the vtube studio itself

undone coral
#

i never used vtube studio, and i only vaguely understand what it's for, but super succinctly - what is the idea? so let's say you could just directly connect the steering wheel

#

to vtube studio

#

what is it used for?

sturdy trail
#

you know vtubers?, its for someone who is vtubing basically. Its just supposed to look good on streams while they are turning the wheel the avatar does also

undone coral
#

okay

#

the avatar turns a wheel... sure

#

so listen

midnight venture
#

I must say using unity for this really doesnt sound like a right tool.

undone coral
#

this is ridiculous

#

why not remap the steering wheel to a mouse input?

#

there are a bajillion ways to do this

sturdy trail
undone coral
#

here you go

#

huh?

undone coral
#

what is this for

#

i've asked almost 10 times

#

you should be able to express what htis is for

#

because it will help you engineer it

sturdy trail
#

what more do you need to understand i feel like i said enough that anyone should already understand

#

its basically it

undone coral
#

alright

#

that's the best we can do then

#

you can use UCR to achieve this

#

it's your best bet*

#

good luck out there

sturdy trail
#

its not

#

when i remap axis it wont translate to the degree, you turn the wheel. It would be like a pressing a key giving max value

midnight venture
#

I think he wants to use the regular input in a racing game and at the same time send the input to vtube studio to control character there, like you had a youtuber playing game fullscreen and pip showing the tuber

undone coral
#

yeah but UCR lets you create virtuawl output devices

#

as many as you want

#

the wheel can be mapped to (1) a virtual wheel and (2) a virtual input device supported by vtube studio

#

it supports axis to axis mapping

#

okay i gotta go ran out of time

sturdy trail
#

there is no input device that is supported by vtube studio that has gradual axis like wheel does. They only have api to connect that you send the value itself

sturdy trail
#

its basically stream visual thingy

terse bobcat
#

Hey im trying to create a multiplayer game with steam and managed to create function that creates a lobby now i want to invite friends i also found a solution for it, but if the friend accept the invite this here does not get triggered:

    {
        Debug.Log("Requested to join lobby");
        SteamMatchmaking.JoinLobby(callback.m_steamIDLobby);
    }```
Does anyone have an idea?
undone coral
#

just so i can understand what it is

terse bobcat
undone coral
golden saddle
#

in our class declaration we can do generic classes with a constraint on the type; lie MyClass<T> where T is IInterface. Is there a way to this for list declarations? IE, I want a List<ConcreteClass> to be passable as argument to a function that accepts <IInterface> (assuming, of course, that concrete class implements the interface. Can this be done?

austere jewel
golden saddle
#

I might be asking the wrong way

austere jewel
#

Or are you saying you have made T the interface type, not constraining it

brisk pasture
#

not sure i full understand, so you want something that is List<IInterface> to be passible to a arg that accepts IInterface?

#

little confused since when you say MyClass<T> where T : IInterface that does not mean MyClass implements the interface just means a T arg used in the class must implement the interface

golden saddle
#

sorry yes, it means T implements the interface

thin mesa
# golden saddle in our class declaration we can do generic classes with a constraint on the type...

https://learn.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance

You cannot assign an instance of List<Base> to a variable of type List<Derived> or vice versa

Edit: i believe i initially misread the question and this info isn't exactly applicable here, for some reason i thought the question was about making the List parameter the Interface type instead of just using literally List<T> as the parameter for the generic method and constraining that generic type for the parameter and method

golden saddle
#

my issue is that if the list is of type Interface, then I have to downcast things back into concrete classes

brisk pasture
#

chances are i would just use linq to convert the list

#

like items.OfType<IInterface>().ToList()

#

which will return you a new list with every casted that was possible to cast

#

either way if you need a list of a certain type i would just make a list of that type

thin mesa
#

assuming you don't need to use any List<T> specific methods you could just use IEnumerable<IInterface> as the parameter instead

golden saddle
#

let me get back to my underlying issue: I'm trying to create a modal selection window: Select one of these X things - Select a card to add to your deck; select a trinket to add to your inventory, etc. What I want to do is make a new Selection Request - something like create a *new Selection<T>(List<T> options) * where T is constrained by needing to implement the interface. This allows me to do something like pass in a callback that can receive type T, which is nice. Actually this is what I have, that all works. But I want to put an event on that Selection class and be able to subscribe to it without knowing the type beforehand so that my UI can subscribe.

#

so I was hoping I could remove the generic declaration from the class and use the same Type constraint on a function that replaces the constructor.

brisk pasture
#

if it was accepting just T you could do that

#

but not with List<T> for the reason @thin mesa posted a link for

golden saddle
#

I'm thinking there's just a different/better way to accomplish what I'm trying to do?

brisk pasture
#

really just think i would not being has as much generics in this situation as you are

thin mesa
#

so while you can't actually assign a List<Derived> to a List<Base> if you are just constraining the type to a specific interface it should work for the method, but as i said you could alternatively use IEnumerable<T> as the parameter if you aren't adding/removing from the list and just looping over it

golden saddle
#

How should I approach this? I want to get selected object(s) back - what's the alternative to generics?

brisk pasture
#

well if you really want to use this pattern, can simple rebuild the list with the right type

#

if you know all items implement the interface, just make a new list or IEnumerable with that interface type and manually populate it

golden saddle
#

for eg, "Select a Card to Add to your hand" - I want to be able to pipe in a List<Card> that is the options, and receive back a List<Card>. And I want to be able to reuse that for Items, Weapons, whatever type. Do I just need to come up with version for each conceivable <T> ?

brisk pasture
#

not sure what you want really can work, since with what you are saying it sounds like you are also wanting every item in the list be a different concret type, and being able to get that type back on return without casting again

golden saddle
#

no, any given list would be of a single concrete type

golden saddle
#

nvm

undone coral
#

hmm

#

do you though

#

i think so

lapis summit
#

yo

#

i need help

#

my weapons trigger collider isnt identifying my enemy's collider

#

anyone?

severe topaz
#

@lapis summit does one of them have rigidbody? are layers/masks all good?

lapis summit
#

neither had a rigidbody

cerulean scaffold
#

Did you find a solution? I'm facing the issue that my bootstrap scene fails to switch to the main menu scene in my build.
The last logs I can see are also from Enlighten.

terse bobcat
fallow dune
#

Hey! I was wondering, I have 3 ScriptableObjects
WeaponSO
UtilitySO
ConsumableSO

I want to pass them through as a parameter of a method, but I don't want to specify the type as I don't know what tipe it would be . Is this possible?

public void AssignScriptableObjectMethod(UnknowsScriptableObject unknownSO)
{
var scriptableObject = unknownSO; //<-- depeding on what is passed will chage to WeaponSO, UtilitySO, ConsumableSO
If(scriptableObject.name = "WeaponSO")
{
//do something
}
If(scriptableObject.name = "UtilitySO")
{
//do something
}
}
sly grove
#

Pass the base class or interface in as the parameter type

#

then just call a virtual method on it

fallow dune
#

I have something set up like that based on feedback last night, but I was hoping to try something different . Guess that will be the best way forward then

sly grove
#

In this case you might have a common base class like:

public abstract class Item : ScriptableObejct {
  public abstract void Use();
}```
#

And each subclass implements the "Use" method

#

and then in your function you just pass in an Item and call Use on it. No need for the if/else stuff

#

this is sort of the basics of polymorphism

urban warren
#

Quick question about the job system.
For ScheduleParallel there is the innerBatchLoop. Does that basically do this in a thread

for (int i = jobIndex; i < jobIndex + innerBatchLoop; i++)
{
  job.Execute(i);
}

instead of just

job.Execute(jobIndex);
sly grove
#

that's not quite true but it creates n executions and schedules them across the threadpool

urban warren
sly grove
#

Oh sorry IDK why but my brain glazed over the whole inner batch loop thing you're asking about

urban warren
#

Am I understanding it correctly?

#

LOL

sly grove
#

so yeah I think your example is pretty accurate

#

I'm not sure if they are consecutive like that

#

but probably

urban warren
#

Okay, cool. I was about to do exactly that haha

sly grove
#

I think basically the whole job size n is split into t batches where t is the number of worker threads available

#

and each worker thread gets a loop like that

#

more or less

urban warren
#

Yeah that seems right

sly grove
#

so each thread gets n / t jobs

#

er, n / t executions

#

for the job

urban warren
#

Another jobs question. Do we have any idea what point it is better to have one larger job vs multiple smaller jobs?

sly grove
#

Generally I think you want to split into multiple jobs only when you:

  • need some intermediate result (in which case you split into a job before and after that result is created)
  • The output of one set of calculations is required as input for another set (job depending on another job)
urban warren
#

I am working on a mesh thing that can instance meshes and then run modifiers on them, but the instances meshes can create instances which can have modifiers and so on. So if I have one job per instance, than each of those instances also instance things which have their own jobs.... that is a lot of jobs potentially...

sly grove
#

Or when you're just doing multiple completely independent things with no interdependencies, those should be two jobs

urban warren
#

So I am trying to figure out if the instancing should just be a single job where each execution creates the mesh, instead of creates/sets part of the vertices/indexs

rough sky
#

Is this how interfaces are meant to be utilised - by having a larger body iterate through them and perform separate functionality on those that have the interface?

#

I have known about interfaces and what they do for a while, but I never worked out what the intended purpose/use case was

#

I got a pretty nifty use out of it in my UI Manager, but I don't know if this is how I'm supposed to do it

sly grove
#

So, contrived example:

public Interface Item {
  void Use();
}

public void UseAll(List<Item> items) {
  foreach (Item i in items) {
    i.Use();
  }
}```
#

now each of those items could be a different thing like...

rough sky
#

Oh, I get it

sly grove
#
class Potion : Item {
  public void Use() {
    HealthManager.health += 50;
  }
}``` for example
rough sky
#

So the functionality could be extended with many different script types

sly grove
#

but the code that calls Use() doesn't have to know or care what the thing actually is

rough sky
#

but it does require a larger body to have references of it

#

I get it

quiet bolt
#

It's basically a contract

#

Any class, no matter which one, that has signed the contract, aka inherited it, has to do what it says, aka implement the method needed

hybrid belfry
#

Hi, how can I make my "Debug" variable maintain it's current value instead of it defaulting to False when the Play button is clicked?

sly grove
#

The Editor itself is not persistent

#

so for example making it a field on the BezierPath could do it

#

Or you'd have to save it in an asset (SO) somewhere. Like a BezierPathEditorSettings asset

quiet bolt
undone coral
hybrid belfry
#

Ok cheers

undone coral
# urban warren I am working on a mesh thing that can instance meshes and then run modifiers on ...

one of the limitations of mesh generation afaik is that you are doing some function f(x..y..z) = f(x..y) U f(y..z) (i.e., something that can be parallelized, like generating a heightmap). then you want to turn the result of that function into a mesh, and you'd like the procedure that turns that data into a mesh to obey g(f(x..y..z)) = g(f(x..y)) U g(f(y..z)). which isn't possible in a general way. i believe this is what mesh shaders are for

hybrid belfry
undone coral
#

does that make sense?

hybrid belfry
weary adder
urban warren
weary adder
weary adder
urban warren
#

I think I came up with a good solution where I just have a single job execution handle generating a whole instance. That will work best I think for how the job system handles things. And most instances will be a pretty small number of vertices. And with the way it is setup I can always schedule it to be one job per instance instead of it is a really high vertex count.

weary adder
weary adder
urban warren
#

My plan is to just have each modifier/deformer be a job that is scheduled just like the generation.

silent matrix
#

How do systems like Siri understand what you're asking, or abstract what you're saying to provide answers?

#

Because everyone words stuff differently

#

there's like 100 ways to ask how someone is doing, you have to figure there's some sort of abstraction?

untold moth
weary adder
#

Siri especially is not ideal, and gets it wrong very often, lol. Its a lot of heuristic guessing essentially, machine learning has brought it way farther up then even like 5 years ago;
At least when I was contracting on Cortana Connected Home (RIP) at MS, there device model was a fairly simple categorizer that would attempt to identify proper nouns (device names) then actions (verbs), it would then send that as a data block to the glue systems we were working on that would act as middle-men between the MSGraph and whatever 3rd party there was

wooden cedar
silent matrix
#

Hmm that's interesting

wooden cedar
#

Although modern AI doesn't require this kind of spoonfeeding as much

silent matrix
#

I was considering adding some sort of OpenAI functionality into my game, but I'm not sure if they have a suitable SDK/API to use

weary adder
silent matrix
#

that's why I have no business writing some complex AI 😄

#

I thought it would be cool to have some sort of voice input which deciphers to text (which I can find open source I'm sure) and then the tricky part is understanding what the user is saying

#

and then from there the AI can respond and I can use TTS to make it talk real-time in the game

#

but that's an extremely complex subject

weary adder
#

The problem with the natural conversations problem is that english, and any modern language really, is messy. If you provide a subset of stricter grammar structures, a reduced abstraction and synonym vocabulary, and a bit of directional nudge with bias inputs, the conversational potential of AI goes way up

undone coral
#

Siri is to ChatGPT what Scribblenauts is to DALL-E

shrewd bear
cerulean scaffold
muted root
#

Question: I have a high poly character (20k vertices) and want to detect mouse click/hover on him. How can I make it accurate without being too costly in resources? Knowing that I'll have several characters on screen, sometimes with colliding animation like hugging each other.

  1. Adding a box collider wouldn't be accurate enough depending on the animation, if it even update with animation. Plus if characters are colliding with each other, which collider takes priority?
  2. Mesh collider would be accurate but isn't 20k vertices a lot for such a collider? For each character?
    I'm using raycast on the character list to check collision with mouse at the moment. Dunno if it's the most efficient way either.
    Any help welcomed ❤️
severe topaz
midnight venture
#

Combining primitive colliders is almost always better than mesh colliders

#

Don’t think your character as single collision and instead consider having collider per bigger bone (and possibly joints)

muted root
#

Got it, thanks a lot

sly grove
#

Let's say I'm executing an IJobParallelFor. I want to perform graph algorithms like Depth First Search in each execution. Therefore I want each execution to have its own Stack or Queue data structure to use freely.

How do I do this? Can native collections be allocated within jobs on a temporary basis? I.e. can I create a new native queue inside the job (with the TempJob allocator)?

serene pawn
#

DOTween question.

How to properly change a gameobject's parent while it is performing a dotween animation?
Because if I do it, the animation just stops and the object teleports to 0,0,0 coordinates (setparent's keep world position is set to true so it shouldn't do this).

humble onyx
serene pawn
serene pawn
# sly grove can you show the code

it's in different scripts but it's just this:

thing.DOMove(newposition, 1f);

and for example 0.5 seconds later another script can call this: thing.SetParent(newparent, true);

and as soon as the setparent is called, the object teleports to the 0 0 0 coordinates and the animation it was doing stops completely

sly grove
#

oh also thanks for the examples I almost forgot I need to call Dispose() on them 😱

sage radish
sly grove
#

SO if I'm creating and executing and Complete()ing the job in a single frame, Temp should be good

sage radish
#

Yep, and I think you should always use Temp if you know it's going to be disposed of quickly.

sly grove
#

Although now that I think of it I might actually be able to get away with running these jobs for at least Time.fixedDeltaTime which may actually span multiple frames... 🤔 I'll tackle that after it's working

compact ingot
icy knot
#

Hi! So I was trying to draw a ray in unity but it didn’t work. I am doing it in the update() method so every frame and I am using the DrawRay, I tried multiple configurations of it, but that’s what I am currently using now:
Debug.DrawRay(transform.position, mousePos-transform.position, Color.green)

#

where mousePos is my mouse position.
What am I doing wrong?
I can shoot a ray with the camera, from the mouse position successfully like that:
ray=camera.ScreenPointToRay(Input.mousePosition)
But I can’t draw it.

#

I also apparently cannot do Debug.DrawRay(ray) and use the ray I am already casting from camera so no variables I guess

jolly token
#

What ray are you trying to draw

#

Also make sure your gizmo is turned on

icy knot
#

gizmo?

#

I am just trying to draw a ray from my mouse cursor

#

To experiment

#

Well I did convert the mousePos to a world point but it didn’t work either

icy knot
jolly token
icy knot
#

Oh yeah maybe I need to check

#

It might not be enabled

trim turtle
#

hi, I got another problem and I'm here to find solution. I need to make distance airblast check, (projectile is very fast). And check when is projectile in-front (not left / right side especially mid screen) of player and return true / false. Is it possible to make?

severe topaz
hexed meteor
#

How can I make a method run every time a new scene starts

#

I have tried onEnable in the past

#

but it is not called at the beginning of a new scene for objects that persist across multiple scenes

lyric dragon
#

does anyone have experience in integrating python code to unity?
I want to use some ML models implemented on python in my app, how can I do so?

quartz stratus
#

@lyric dragon Have you tried the Python for Unity preview package? They have an out-of-process API

lyric dragon
quartz stratus
lyric dragon
lyric dragon
#

Guys, I still need help with python

digital osprey
#

but procedural geometry nodes accept it

#

*procedural from blender

#

and unity reads alembic pretty well

quartz stratus
lyric dragon
spare wharf
#

I assumed to post this doubt here since the advanced code users will have a more keen eye to spot what might be going on here

#

This code is open source and im trying to apply it in apersonal project, but it gives me a CS1022 error and i cant seem to spot what is wrong with this thing

#

(mind you it worked fine with no errors in its original project)

#

Hopefully someone can lend some help with this, thankful nonetheless.

severe topaz
#

@spare wharf you fucked up brackets

spare wharf
#

The shame is overflowing

#

Where are those

severe topaz
#

just copypaste script again without losing brackets lol

spare wharf
#

Just thought it was something far more complicated

#

Which ones are missing tho?

severe topaz
#

although it's not that hard to fix

spare wharf
#

It has been directly imported

severe topaz
#

is it really

spare wharf
#

Thats why its been so confusing

#

Yes, from one project to another

severe topaz
#

it would be fine if it was inside namespace

#

i'm not gonna count the rest of them, that last bracket needs to be either before class or removed entirely

spare wharf
#

Ill try to fix it and give an update , thanks for the answer

severe topaz
#

no need for the update, you can skip straight to sitting in the corner of shame

cobalt drift
#

is there a way to force unlock the save file path ? by default unity file savepath can only be application.datapath or persistentdp

#

i want to save the file to anywhere i want

lyric dragon
jolly token
#

There is nothing blocking you from writing where you have permission

cobalt drift
#

oh ok

#

i think i need to open access to all location then , thx

untold moth
#

It depends on the platform, but you'd usually have access to any path that is not used by the system, like Program files, System32 etc...

lyric dragon
livid kraken
# lyric dragon I guess ml agents does not support python for now...

How much python integration do you need ? I have a old answer here that might be of help https://gamedev.stackexchange.com/questions/123526/a-python-script-controlling-a-unity-game/123545#123545

rancid viper
#

How do I get the json string of a Unity scene file, cause I'm trying to parse it to get the sepcific values from keys

zenith crest
#

string[] _names = new string[6] { "Sam", "Tim", "Jonas", "ME", "YOU", "US" };

        for (int i = 12; i >= _names.Length; i--)
        {
            Console.WriteLine(_names[i]);


        }

can someone tell me why this forLoop can be wrong
i am starting from 12, decrementing till 6

severe topaz
karmic viper
#

Hello Is there any option in Unity

cerulean scaffold
#

Hi everyone, I have a Git question.
Since a few days ago there is a scene which is always shown as having changes, even if I revert any changes with Unity closed.
It's making it impossible to do rebase because you can't have local changes when rebasing.
Is my Git VCS corrupted or could this be caused by something else?

upbeat path
undone coral
sly grove
flint sage
#

Also helps to not store scenes as binary

cerulean scaffold
cerulean scaffold
flint sage
#

Would at least give some insight on what's changing

undone coral
#

are you working iwth other people, or is this only your work?

midnight venture
#

@cerulean scaffold Have you tried fresh clone?

#

(I haven’t yet encountered problems like this with git, but with svn just taking fresh checkout and copying modified files will solve all local problems, even if it’s something even ”hard reset” svn commands can’t solve)

spare elbow
#

I am trying to catch when the admob finishes initializing. What should i put inside the initialize function?

#

MobileAds.Initialize(InitializationStatus => { });

#

it says it requires "Action<InitializationStatus> initCompleteAction" in the function info

rancid swift
compact ingot
spare elbow
#

i was unable to find any docs for it

#

this is the class definition:

#
{
    public class InitializationStatus
    {
        public AdapterStatus getAdapterStatusForClassName(string className);
        public Dictionary<string, AdapterStatus> getAdapterStatusMap();
    }
}```
cerulean scaffold
cerulean scaffold
cerulean scaffold
lime plover
#

Real quick question, anyone know if WaitForSecondsRealtime is frame dependent? I.e., would it run correctly on an extremely laggy pc?

jolly token
#

Your scene file does not seem like YAML format

sly grove
jolly token
sly grove
#

It will continue on the first frame after the amount of time has passed

#

so if you wait for 1 second you'll actually get something like 1.01 seconds

#

and that error is up to the duration of a whole frame

lime plover
#

I see, makes sense, thank you both

cerulean scaffold
jolly token
quartz stratus
undone coral
undone coral
cerulean scaffold
cerulean scaffold
undone coral
#

yeah ask jason

#

he'll help

#

in his disceurd

cerulean scaffold
#

either way it's not such a big deal, either the file is changing 'by itself' or git is corrupted. I'll fix the problem tomorrow.

jolly token
#

I do think that's part of issue 🤔

cerulean scaffold
#

I'll have another look tomorrow ^^

#

Thanks for all the suggestions!

jovial totem
#

Is anyone here experienced with spherical harmonics? I need to extract the brightness at a given point

serene pawn
undone coral
#

the animation rigging package has good support for this stuff from the point of view of someone with CG / VFX experience

serene pawn
undone coral
#

what are you trying to achieve?

#

what is the idea

serene pawn
# undone coral what are you trying to achieve?

the setparent function has an override that says "world position stays" and setting it to true doesn't make it stay for some reason when the object is currently in the process of moving via DOTween

#

it goes to 0,0,0 coordinates and stops animating

undone coral
#

what is the idea

#

like what is the effect

#

what are you trying to animate

#

for example "i am trying to animate a hand picking up an object in a 3d FPS game"

#

"i want it to look natural regardless of the position of the hand and object"

serene pawn
# undone coral what is the idea

UI objects are moving. setting parent is how i change ui object sorting order. so i want an object to sort differently while its moving

undone coral
#

okay what is the ui element

#

you are trying to animate

#

like what is this

serene pawn
#

its parent must be set to the inventory's gameobject

undone coral
#

finally

#

thank you

#

so you don't have to do anything complex to achieve this.

#

here is an example

#
IEnumerator TakeToInventory(
  RectTransform targetObject,
  RectTransform inventorySlot,
  RectTransform topmostLayer,
  float durationSeconds=1f) {
  // bring it to the "top" layer
  // this should be an empty rect transform game object at the
  // topmost hierarchy (meaning bottommost in the hiearchy view) with anchors
  // configure to fill the screen with no margins
  targetObject.SetParent(topmostLayer);
  yield return targetObject.DOMove(inventorySlot.position, durationSeconds);
  targetObject.SetParent(inventorySlot.parent);
}
#

@serene pawn does this make sense?

#

so don't change it mid animation. if you need to do that, you know, break it up into two tweens. it seems traightforward to me

serene pawn
undone coral
#

which why would you do that

#

i don't even touch world position stays

serene pawn
#

I dont touch it either, but it goes to 0,0,0.

undone coral
#

so

serene pawn
undone coral
#

i think you'll figure it out

serene pawn
#

there must be a way to avoid it teleporting to 0,0,0

undone coral
undone coral
#

i haven't seen your code

#

it's a bug in your code

serene pawn
#

it's in different scripts but it's just this:

thing.DOMove(newposition, 1f);

and for example 0.5 seconds later another script can call this: thing.SetParent(newparent, true);

and as soon as the setparent is called, the object teleports to the 0 0 0 coordinates and the animation it was doing stops completely

undone coral
#

you can't do that

#

it's buggy

#

what doy ou want?

#

i showed you an approach that works

serene pawn
#

I removed the setparent call and it no longer teleports. but then i lose the setparent functionality which is essential.

undone coral
#

you will have to create a special ui only duplicate of this object, that is already on this topmost layer

#

okay

#

well like i said you'll figure it out. i am repeating myself now

#

for what you want to do, the approach is clear

#

i'm not 100% sure what you mean by "it's still moving"

#

i think you are trying to do something kind of complex

serene pawn
#

duplicating the object makes things worse i think, since how do i give it the same position as the original and having it continue the original's animation from the point it left off?

undone coral
#

it sounds like you are trying to take a thing that has some sort of velocity and have it arc into an inventory slot

#

is that the effect you want?

#

it just isn't clear yet what you want to do

#

forget about the approach you currently have

#

dont' talk about it anymore

#

just answer my questions

serene pawn
#

yeah, except it needs to be sent to the topmost layer without having its movement stop

undone coral
#

so give me the full picture of what you actually want

#

stop talking about topmost layer and movement and whatever

#

i feel like i could have said anything and you would say yes. so what is it?

#

what's actually happening in the game that you want to animate?

#

🥺

jovial totem
#

@serene pawn Are you trying to do something like subnautica?

undone coral
#

don't get distracted by the beautiful celebrities. focus on my question

serene pawn
# jovial totem <@798203494279938049> Are you trying to do something like subnautica?

i dont know what part of subnautica you mean but heres what should happen.

item is moving around in the game, player clicks on it, item gets sent to the topmost layer while moving, it must keep moving to where it was originally going to move and like 1 second later it starts flying into the inventory.
what actually happens: item is moving around in the game, player clicks on it, item gets sent to the topmost layer and teleports to 0,0,0 and stays still, and 1 second later it flies into the inventory

undone coral
#

no

serene pawn
#

i hope that clears it up

undone coral
#

you're talking about your implementation again

#

what is the game?

#

last chance

#

what are you doing?

#

grabbing dishes of sushi off a moving sushi conveyor belt?

#

and it has to look like it flies off the conveyor belt into an inventory slot?

#

don't talk about your bug anymore

#

please

#

i'm begging you

#

the bug is because the implementation is wrong and has to be approached a different way

#

you don't comprehend well enough to fix it

serene pawn
#

stardew valley but you have to click on items that are rolling on the ground and when you click them they start glowing but keep moving and then after 1 second they fly into your inventory..

undone coral
#

so don't worry about it anymore

#

OKAY

#

thank you

#

what's rolling on the ground?

#

just give a specific concrete example

jovial totem
#

Calm down, doctor. John, you've been falling into the trap that software people get into where they describe the implementation before they describe what they are actually trying to accomplish. What is the goal of this whole routine

#

there we go

undone coral
#

just so it's super concrete

serene pawn
undone coral
#

okay

#

and these cabbages are animated using a rigidbody or a DOTween tween?

serene pawn
#

dotween

undone coral
#

okay

serene pawn
#

the animations are great and everything but the problem is the teleporting to 0,0,0 coordinates when i do the setparent

undone coral
#

please enough with the 0,0,0

#

it's over

#

you're not going to worry about that problem anymore

#

last question - you click the cabbage, it's still moving with its current velocity right?

#

so after a "short period of time", it abruptly should move into your inventory? the effect would be the same if it were stationary

undone coral
#

okay

#
class CabbageLike : MonoBehaviour {
 bool interactable { get { ... } set { ... } }
 void Glow() { ... animate glowing ... } 
 void StopGlow();
}
IEnumerator TakeToInventory(
  RectTransform targetObject,
  RectTransform inventorySlot,
  RectTransform topmostLayer,
  float delay=1f,
  float durationSeconds=1f) {
  var cabbage = targetObject.GetComponent<CabbageLike>();
  cabbage.Glow();
  yield return new WaitForSeconds(delay);
  cabbage.interactable = false;
  // kill all pre-existing animations
  cabbage.StopGlow();
  targetObject.DOKill();
  // bring it to the "top" layer
  // this should be an empty rect transform game object at the
  // topmost hierarchy (meaning bottommost in the hiearchy view) with anchors
  // configure to fill the screen with no margins
  targetObject.SetParent(topmostLayer);
  yield return targetObject.DOMove(inventorySlot.position, durationSeconds);
  // it is now in your inventory
  targetObject.SetParent(inventorySlot.parent);
}

@serene pawn

#

that's it

#

the thing it sounds like you were missing was to cancel the previous animations

#

all this stuff about your bug and layers and whatever...

#

it doesn't help me write a correct example for you

#

does that make sense?

#

my feedback is: always say what it is that you are doing

#

this is just psuedocode, you can't yield return on a tween directly

serene pawn
serene pawn
# undone coral why?

well my inventory doesnt have a list to keep track of objects, i do that by just counting everything that's a child of the inventory gameobject as being in the inventory. and objects have to count as in the inventory immediately. so im also counting the topmost layer as being in the inventory, this way there will be no bugs where if you are quick enough you can go past the inventory limit or something and break the game

undone coral
#

so surely you see

#

what a problem that is

#

i mean obviously you have to keep the list of inventory objects separately from the hierarchy, which is meant for rendering

serene pawn
# undone coral okay

but everything else has no issues, its just the fact that i need to set parent while its moving. surely i dont have to redesign the entire inventory system from the ground up for this

undone coral
#

why are you saying everything else has no issues?

#

why lie

#

to yourself and your ancestors

#

why besmirch them

#

i am being facetious - i am trying to add some color to how ridiculous this is

#

you do indeed need to redesign the inventory system

serene pawn
#

so here's what my question started off as. how to setparent while a dotween is running without it teleporting to 0,0,0?

undone coral
#

you're trading a good inventory system for crazy code elsewhere

#

you sitll have the same amount of new code

#

do you see that?

serene pawn
#

what do you mean? this is the only thing i need to fix

undone coral
#

observe that the answer to the qeustion, "what is the effect?" was "there is no effect"

undone coral
#

you can spend your time writing a workaround for your bad inventory system, which will have another bug later

#

or you can spend your time on making a better inventory system

#

either way you must write new code. one option is worthless code, and the other option is good code

#

do you see?

#

@serene pawn it's good that you went and asked about this though

#

you must see

serene pawn
#

and redesigning a system entirely because of one small bug will definitely introduce many new bugs

undone coral
#

okay well maybe create a ghost object

#

then you can move it into the inventory slot later

serene pawn
undone coral
#

i suppose you just read its position

#

the original object

#

and you create a new tween with the right amount of time remaining

#

hope that helps

serene pawn
# undone coral and you create a new tween with the right amount of time remaining

well if i knew how much time it had remaining then after the setparent i could just teleport it back and start a new tween on the same object, problem is i dont think there's a way to know how much it had left nor what its position was. unless i make a database where i store timers and positions and stuff for each object, seems like way too overkill of a solution though

jovial totem
#

okay, so. What is the best way to go about detecting light levels for a stealth mechanic? I'm trying to use light probes and sphere harmonics, but the equation I got for extracting lightness from it is a bit of a black box and I don't totally understand it. What if I pointed a low resolution camera at the player and averaged the light value I get from there?

compact ingot
jovial totem
#

That would work in interior, but what about with dynamic lights?

compact ingot
#

is your game based on a dynamic lighting mechanic?

#

or is it just a nice to have?

jovial totem
#

uuuhhhh well. the sun does move. so yeah

compact ingot
#

yeah what?

#

is it critical to your game that you have moving shadows and that you have a lot of them just before/after dark?

#

i think overall its very difficult to dynamically detect whether a certain agent is fully shadowed relative to a dynamic light source... it may be possible to do for a single agent with a utility cam & shader but for N to N visibility checks you can't realistically calculate that to any degree of accuracy, not even with probes

sly grove
compact ingot
#

also considering that you'd have to check for silhouetting of an agent against a lit background

#

but you could generate/bake shadow volumes for certain times of day and cast them as convex mesh colliders

#

or just assume that when an agent stands on a shadowed surface they are entirely "in shadow"

#

thats how you'd do it in a 2D top-down game

sage radish
jovial totem
#

boy this is tricky

compact ingot
#

real time light probes are extremely expensive if any amount of precision is required

#

basically your gameplay has to be cleverly designed around the limitations/issues of how shadows are calculated

#

AAA producer would just tell you to do it with custom authored widgets that a level designer can place and art direct, then automate once the manual system works

#

tbh, if you have an engine that uses shadow volumes (instead of shadow maps), it would actually be much simpler

#

so maybe try to get an id tech license 😉

sage radish
#

The question is whether you're going to do this on the CPU side or the GPU side. The ideas Anikki and PraetorBlue have suggested have all been CPU side. The idea you suggested, rendering a low res camera of the player, is more GPU side. Another thing you could do is render a custom shader that does all the same lighting calculations a pixel would do, but just writes it to a 1x1 texture. That should be faster than rendering an actual camera of the actual player.

#

But doing anything on the GPU side means you will eventually have to copy it over to the CPU, which can take a bit of time, a few frames of delay.

compact ingot
#

i think this isn't necessarily a CPU vs GPU issue, any solution would involve both

#

and mind that extra cameras in SRPs are expensive

jovial totem
#

Here's an idea to tackle both how much of the player is visible and how much of the player is in light:

  1. Raycast to make sure the player is potentially visible (in an FOV and not completely obscured by an obstacle: I've already done this)
  2. Have a low res (32x or 64x) camera pointed at the player and render the whole scene to a texture, and then render a texture with only the player layer not culled (perhaps also somehow fit the fov around the player?)
  3. compare which pixels are the same between the full scene and the player to get how much of the player is obscured by something (Can't stencil buffers also do this?)
  4. Make a mask of the overlap between the player-only texture and the full texture, and then average the albedo light value of everything within that mask, giving us our perceived brightness of the player
  5. Could also figure out contrast?
sage radish
compact ingot
#

i mean a proper solution would probably involve GPU und CPU components

compact ingot
#

imo doing 3 raycasts to the sun for each agent (feet, torso, head) is probably the easiest solution that gives plausible results if the origins are placed well, should also be quite fast if you cull raycasts based on player proximity

sage radish
# jovial totem Here's an idea to tackle both how much of the player is visible and how much of ...

The resolution of the additional cameras wouldn't be the main overhead. You probably wouldn't see much difference in performance between 1x, 32x and 64x. The main overhead would be everything that happens before the GPU takes over; the culling and draw calls. If you only needed to render the player, then it's super cheap. But figuring out what part of the environment also needs to be included is more expensive.

jovial totem
#

It's just the player's layer, and then everything. You mean occlusion culling?

jovial totem
compact ingot
#

as a strategy, i'd try the raycast to the sun method, make sure its not good enough before diving any deeper into camera based options

#

after all, stochastic path/raytracing is the best of all solutions

jovial totem
#

What about interiors, where there's no sun?

compact ingot
#

depends on the light source

#

you can cast to the closest point source or make colliders that define volumetric sources and cast towards those

harsh lion
#

@jovial totem Would using CullingResults.visibleLights help?

jovial totem
#

Spherical harmonics has been working alright, but the output's space confuses me. I'm tryhing to get the value, but these are all magic numbers I got from reddit. Does anyone know how to make sense of the data that comes out of it?

LightProbes.GetInterpolatedProbe(point, null, out SphericalHarmonicsL2 harmonics); //Get light for point
                return
                    ((0.2989f * harmonics[0, 0]) + (0.5870f * harmonics[1, 0]) + (0.1140f * harmonics[2, 0]))
                    .Do(r => r / 0.3f)
                    .Do(r => math.clamp(r, 0, 1));

(Do is basically just the |> from functional languages, because my brain works better that way.)

jovial totem
harsh lion
#

You don't necessarily need to calculate spherical harmonics or use realtime probes everywhere. Shooting a raycast to all visible lights to detect occlusion, then use the inverse square law and add the visible lights together. Indirect light is the problem then, but from what I understand visibleLights includes light sources that are obstructed (and would fail the raycast).

#

You can then sample the part of the screen that your player model is in and detect any lights that affect that area (see VisibleLight.screenRect)

sage radish
#

But isn't the point to get the brightness of the player, from the point of view of the enemy? So if the light is behind the player and backlighting them, that's not as bright as if the light was in front of the player, between the player and the enemy.

#

I suppose you can apply N dot L as part of the inverse square attenuation calculation to account for that.

jovial totem
#

I also have to ask if indirect lighting actually matters in this case.

#

because the AI perception doesn't have to be 100% true-to-life, the camera thing was just the only thing I could come up with

jovial totem
jovial totem
#

oh god

#

doing a FindObjectsOfType would be expensive, I'm assuming

harsh lion
#

Yeah you can get them from the CustomPassContext.cullingResults

harsh lion
#

There is an optimization on that coming soon (now in alpha) that doesn't sort but yeah FindObjectsOfType is pretty expensive

jovial totem
#

wait... oh, I'm confused. How am I to use a custom pass to get visible lights? Can I get it from just regular passes?

undone coral
#

i've noticed that e.g. realtime reflection probes are much faster in built in

#

i don't understand why - as long as i do camera.render in late update or earlier, can't unity batch the CPU side of stuff a lot better?

jovial totem
#

I'm using URP myself

harsh lion
#

Custom passes are available in URP as well afaik, I was assuming you're using HDRP but I guess I was wrong 😄

harsh lion
#

It's fancier 🙂

undone coral
#

i actually want to do some innovation with multi-camera unity, especially at the level of performance of single pass stereo

#

in other words, i would love to disable culling and render all cameras "simultaneously", if it would allow camera N + 1 to reuse all the non-view-dependent stuff from camera N

harsh lion
#

You are probably better off forking URP/HDRP and writing your own passes or writing an RP yourself if you want that flexibility