#archived-code-advanced

1 messages · Page 118 of 1

winged holly
#

My project was an old project. I moved it to Unity 6. Everything works in the editor.

#

But most of them do not work on mobile.

#

The print below does not work either.

random dust
#

That said, are there no errors in the console? Did the project compile at all?

midnight violet
#

Is your scene in the build profile scene list of your platform?

winged holly
midnight violet
winged holly
#

It's a company computer so if I get an SS it will be difficult to transfer it to my phone.

midnight violet
#

You are printing something about "Task". Is that really a task or do you just call it task? Is the object destroyed when the scene is loaded?

winged holly
#

Nope.

#

It works fine in the editor.

#

by the way the text changes are not working

#

textmesh does not change or image slider does not change

#

I think there is a compile error in Unity 6.

midnight violet
#

Text changes?

winged holly
midnight violet
#

Thats not visible anywhere in the screens.

winged holly
#

google login successful

midnight violet
#

Again, are you sure, your build scene list for the target platform is set correctly?

winged holly
#

Here

#

Normally the text should also be changed

#

Here

long ivy
#

confirm that your code is running on the main thread. It's possible your sign in api isn't 1:1 with the editor and runs on a second thread in a build, which would cause LoadScene to throw an exception

midnight violet
#

would be good, to see, if you just disabled error logs and only get the normal dbeug logs in your console. You can hook into application errors and just print them to a textfield to see, what happens. And for research, could you try to remove the space in the mainmenu 1 name?

winged holly
#

I will look at the main thread

#

makes sense

#

here's another idea, let me try it from a different phone

winged holly
#

when I tried yesterday, print(“Starting scene loading...”); this was not entering either

long ivy
#

StartCoroutine is also not thread safe and would throw. You need to show more context around this method (ideally with a paste site) at this point

winged holly
long ivy
#

yes a threading issue. Your GoogleSignIn.DefaultInstance.SignIn().ContinueWith( line should be using ContinueWithOnMainThread instead

winged holly
#

I remember I tried that too. I will try again immediately thank you

long ivy
#

also you said it worked in the editor but I don't see how, you're using a mobile API. I assume It's not actually running in the editor and userid isn't blank

winged holly
#

for editor is userid "admin"

long ivy
#

yes so you're never actually calling this method in the editor, you're calling StartCoroutine(LoadScene2Seconds()); instead and bypassing all the task stuff

#

otherwise it would have blown up a lot earlier

winged holly
#

yes sir my bad

long ivy
#

for local builds you might consider disabling il2cpp and using the mono backend on Android instead; it'll build faster and save you time (disable script profiling as well, if enabled)

winged holly
#

this is a very good idea, it will speed up my work thank you very much

winged holly
#

do you have crypto wallet for a coffee gift

long ivy
#

no thanks, not necessary

dusk cove
#

Hello I'm trying to recreate Super Monkey Ball Controller. In my first iteration I was rotating the level based on its pivot point but it's wrong.
In Super Monkey Ball, the level pivot point is the monkey position. I tried with transform.RotateAroundbut I need a better control over the rotation not just adding degrees.
Do you have any idea ?

long ivy
#

What do you mean by better control over the rotation? You have total control over the rotation already

bleak citrus
#

I would calculate the entire transform matrix for the world every frame (or every physics update, really)

#

rather than trying to modify the transform matrix from the last frame

#

that sounds much more annoying

sage radish
#

You could also just tilt the camera, change the gravity vector and use a custom skybox shader that ignores the tilt.

trim void
#

hi

#

is there anyone

#

i have asked to help about ScriptableObject and i have that error again

#

so the game cant recognise it

#

so i cant clone styles to car

sly grove
#

you need to explain your problem if you want help

trim void
#

yes

#

i have writed this too see what error is and it give me this errors code:

#

public static bool StyleIsBought(LockedContent obj, int index)
{
if (obj == null)
{
Debug.LogError("LockedContent obj is null");
return false;
}
if (obj.Car == null)
{
Debug.LogError("Car is null in LockedContent");
return false;
}
if (obj.Car.AvailibleStyles == null || index < 0 || index >= obj.Car.AvailibleStyles.Count)
{
Debug.LogError("AvailibleStyles is null or index is out of range");
return false;
}
if (obj.Car.AvailibleStyles[index]?.Styles == null)
{
Debug.LogError("Styles is null at index " + index);
return false;
}

    return PlayerPrefs.HasKey(string.Format("{0}_{1}", obj.Car.AvailibleStyles[index].Styles.name, C.Bought));
}
#

error:Car is null in LockedContent, ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
NullReferenceException: Object reference not set to an instance of an object

#

Car is scriptableobject

trim void
#

i think they cant help me

#

its definitely not for beginners

shy nebula
#

The fact that you don't understand what the error means proves that this is a beginner question

#

This is an extremely basic error

trim void
#

if its basic then help me

#

i have this error since 1 year and i cant resolve it

shy nebula
#

You've struggled with understanding arrays for one year and think this automatically an advanced issue? 🤦‍♂️

trim void
#

.\

shy nebula
#

A month is just as bad

trim void
#

dont comment it if you cant help i dont need any judgement from anyone

shy nebula
#

I'd be willing to help if you stopped with this arrogance

trim void
#

ok

upbeat path
# trim void ok

this

if (obj.Car.AvailibleStyles == null  index < 0  index >= obj.Car.AvailibleStyles.Count)

is not even close to C# syntax, so how can this be an advanced question?

humble leaf
#

They're using || in there, but it's unformatted code so it's changing it to spoiler tags.

#

But also this is definitely not an advanced coding issue. #💻┃code-beginner. The channels are not for the kinds of people who can help you, but for the kinds of questions being asked.

sly grove
#

So I made a little mistake here 😆

Part of the design of C# source generators is that the output of C# source generators is completely invisible to other C# source generators.
Guess what MessagePack uses to make serializers for your MessagePack annotated C# types?

#

If you said "also Roslyn source generators", you would be completely correct!
Notice there are not generated formatter classes here for my generated companion types 😭

upbeat path
sly grove
#

It's looking like MessagePack might be out for this project. On the bright side these generated objects are completely dumb POCOs so it will be easy to swap in another serializer. The question now is... which one? For the moment just playing around with Newtonsoft but it's quite slowww. And MessagePack can't handle serialization without a formatter in IL2CPP because there's no Reflection.Emit which is what it would use to generate formatters on the fly at runtime

odd turret
#

not sure about the best options for binary though

sly grove
# odd turret I'm trying out System.Text.Json, and it's looking good there's also a new Unity ...

I was originally thinking of an ultrafast binary serializer (hence the Messagepack exploration) just for performance/user experience reasons (I LOVE when games are super snappy when it comes to saving and loading), but I also see the appeal of allowing users to modify save files etc. THere's a nonzero chance I'll make a setting in the menu somewhere to switch between binary and json formatters 😆

sly grove
scenic forge
#

I use STJ in my project, but I've never benchmarked it in Unity 🤔

odd turret
#

well, when you pick json performance is not priority anymore 😄 so I guess any of the popular frameworks are fine

compact ingot
#

how much time is taken up by the serializer in your typical save/load operation?

upbeat path
compact ingot
#

probably depends on the project but a couple of gameobject instantiations could potentially make any serializer gains irrelevant

upbeat path
compact ingot
#

thats more of a streaming situation?

upbeat path
#

no, just the ability to save, for example, every fixed update without noticing a drop in fps

compact ingot
#

i would call that streaming 😉

upbeat path
#

I would call streaming replay without control, this is actually replaying the gameplay from data

pastel whale
upbeat path
pastel whale
#

as long as it is in memory its not a problem, not sure what the goal is, but just avoid write/read calls to disk

upbeat path
bleak citrus
#

I wonder if you could approach it like video compression

#

Store an "I-frame" (a full game snapshot) every few seconds, then store "P-frames" (just the inputs) very rapidly

#

You can reconstruct any game state by rewinding to the most recent snapshot and then simulating the game from there

compact ingot
sage spindle
#

Should I use a global pool or a specialized pool for each weapon? Imagine if I have 10 different weapons in the scene, all shooting different types of projectiles, missiles, lasers etc. Should each weapon itself have its own pool or should I use one big pool for all bullet types?

sly grove
sage spindle
#

That is the conclusion I came to, just not sure about if the overhead is big

sly grove
#

The disdvantage is that once elements in the pool are allocated, they generally stick around until you manually dispose of them

#

so if you have, for aexample, a big firefight happen, with lots of projectiles, and the pool gets large, and then the fight stops, the pools will remain full of objects taking up memory until you manually dispose them.

compact ingot
#

its generally a good idea to make budgets for your game's systems and not allocate dynamically so you don't run out of memory unexpectedly

#

growing pools without a hard limit should be avoided (they can easily run away). In many cases prewarming them to decent size offers the best UX.

sage spindle
#

That would work for me, I have a combat scene that I just get rid off after the combat is over

misty glade
#

SGs are a bit above my head - I tried to dabble in them a while back, along with a custom linter.. and gave up because it wasn't giving me the dopamine hit in time for me to stick with it 😛

sly grove
#

That's specifically the part that won't work for me because the types I want to serialize are generated by my own source generator

bronze glen
#

If I have empty animation curves in my Animation Clip (definition: if curve has only two keys and they are equal, then this curve is empty), is there a way to remove them from animation clip asset, maybe via script somehow? I didn't find any information, how to get curves from anim clip in script, maybe I am missing something or asking a wrong question?

drifting solstice
bronze glen
#

yes, I am sure about that. I've spend a lot of time cleaning animations from this type of curves. Why? When you export model from blender (FBX), it will automatically fill not used curves with two identical keyframes, this prevents unity from properly "blending" animation clips with animation layers

drifting solstice
#

just to be clear, im not talking about false negatives, im talking about false positives

#

this kind of animation curve fits your definition of "empty", so if you're not actually looking at the curve, but just its endpoints, then you could end up removing actual animation data

bronze glen
#

nah, they are really empty. Thanks for warning though, but now I am just looking for a way to get curve from clip, see it's points, and if needed, remove it.

bronze glen
drifting solstice
#

im not asking about those being empty

#

i think this might be what you want

bronze glen
#

hmm, looks like it, I will try to use it, give me a minute

drifting solstice
#

i guess you would do
GetCurveBindings to get all the float bindings

GetObjectReferenceCurveBindings to get the object bindings -> GetObjectReferenceCurve to get the keyframes, which... is undocumented..?

bronze glen
#

Yeah, I think Animation Utility is what I need, it has all needed functions. Thank you!

drifting solstice
#

also SetCurve with a null curve removes it

bronze glen
bleak citrus
#

I've been generating a ton of animation clips via script recently

#

(for VRChat purposes)

bronze glen
bleak citrus
#

ah, yes, and you have to use AnimationUtility to get the curves

#

I don't fully understand the distinciton between editor curves and regular curves right now

#

Unity internally combines position curves, scale curves, and rotation curves. When curves are combined, keyframes are set at the union of all keyframes points. In the Editor AnimationClip, you can specify special editor curves that are not combined and allows the user to edit curves in a more intuitive way.

bleak citrus
#

so I guess that the editor curve is what is presented in the animation window

#

and then you actually get more keyframes than that

#

if you set X at t=0 and Y at t=1, I guess you get keyframes at both times for the non-editor curves

undone coral
bronze glen
#

If I understand right, you can set layers in Animator controller to play animations "on top of each other". For example character walks, and if you interact with it, it will play face animation not stopping it's movement animation, face animation will just overwrite curves for some bones on top of moving animation. Or for example I have a robot, that should approach the player, but also look at him, turning it's head, and I can't turn the head via script if there is those "empty" curves in clip

undone coral
#

and you also want to be able to animate the robot looking at something while also walking, for example?

undone coral
#

what would you say is your experience level with animation

bronze glen
#

with animation components or animating the models?

#

for first, not much. For second, none at all, all models and animations are being made by our 3d modeller

undone coral
#

creating a rig, understanding ik, and the approaches to solve problems like the one you are describing using either unity or cinema tools like maya

#

gotchya

#

well generally if you have another person rigging your character for you, you are supposed to use IK to solve things like looking and interacting; and animation layers to solve things like having a separate facial state from body state.

#

the humanoid avatar is similar to the humanik solution in maya

#

i am pretty sure they are totally compatible? i haven't done this using unity 6

#

you're not supposed to programmatically manipulate the animation curves

#

if you are doing that, you are going to end up reinventing IK

#

and suffer lots of other issues

#

does that make sense?

#

i think this can sound way more intimidating than it actually is. one cheat you can do is upload gnomon workshop videos about this to Gemini, and then ask it about the content.

#

you can also reject my advice and continue down your path but it is unfortunately not viable

#

the way animation works is based on a bunch of conventions/traditions

#

but i don't know though, i've just done feature animation and make games lol

#

there are also asset store assets that are more opinionated about how the character should be rigged, and solve a lot of problems for you

#

the alternative system is something called motion matching, and there is also a high quality asset store asset to achieve this

bronze glen
# undone coral does that make sense?

actually, yes, but this kinda isn't the case. Before making actual characters we've experimented and learned about animator controller and animating in blender, and the problem we've encountered is actually with the blender, because it creates a lot of empty curves for all of the bones, even if they are not used. This prevents animations from being layered properly, empty curves of one animation overwrites non-empty curves on lower level. We will eventually get our hand on fixing this in blender, but in simple words, we don't have that much time to do this with our 3d modeller, just because he is 15 yo and got exams soon, so for temporary solution we've decided to hand this to me, since I can write script in unity to clean all unused curves

undone coral
#

it isn't viable to write code to clean the curves and stuff. it's too much of a waste of time

#

how many animation clips have been authored?

#

like how many animations are you trying to deal with

#

for example, a walk, attack and idle animation?

#

that's "3"

#

i'm pretty confident you can clean empty curves when exporting from blender. you definitely can when exporting from maya

bronze glen
#

we've got three simple animations: walk, put hands down and put them up, but it's just now. Today modeller finished another model with much more complicated rig that will have a lot more animations (10-20) and almost all the time there will be about 2-3 of them layered on top of each other, so this blender shenanigan becomes a real problem

bronze glen
undone coral
#

so one thing we are doing is trying to describe the actual problem. then you can at least google around for a solution. it sounds like you've tried

#

can you try

Export with Correct Settings:
When exporting to FBX, ensure that only the necessary objects and animations are selected.
In the export settings, under the "Bake Animation" section, enable "NLA Strips" and "All Actions" to ensure all relevant animations are included.
Set the "Simplify" value to 0 to prevent Blender from adding unnecessary keyframes during export.
#

do you have blender open right now with the proper stuff?

bronze glen
undone coral
#

of course

#

i think this has potentially a straightforward fix

bronze glen
simple bobcat
#

hello team, i have this image (province map from eu4) and im trying to make provinces i can click. ive come to a solution using marching squares but im kind of stuck now.... i want to have a map of the edges of provinces (the border of 2 colours) by the targeted color WITHOUT reading over the whole image file (since thats taking forever for even a single province). any help/advice would be appreciated

 void GenerateProvince(Texture2D colourImage, Color32 target)
 {
     Dictionary<KeyValuePair<int, int>, int> pixelAreaOccupation = new Dictionary<KeyValuePair<int, int>, int>();
     for (int x = 0; x < colourImage.width; x++)
     {
         for (int y = 0; y < colourImage.height; y++)
         {
             if (colourImage.GetPixel(x, y) == target)
             {
                 pixelAreaOccupation.Add(new KeyValuePair<int, int>(x,y) , 1);
             }
             else
             {
                 pixelAreaOccupation.Add(new KeyValuePair<int, int>(x, y), 0);
             }
                 

           
         }
     }
 }

current code (trying to get a pos-1/0 map but its alwful slow since the image is like 5000x2000

timber shadow
#

You want the edges of this image?

#

Is there a dead space color to the image?

#

Such as "unused" pixels which aren't a part of the used content?

simple bobcat
simple bobcat
timber shadow
#

I would scan row by row, jumping by some fraction of the minimum area height looking for where the area might be.

#

Then I would spread out from the found pixel once 1 was found.

#

At minimum you skip a lot of pixels in this naive approach.

#

Ideally though, I would do this in an editor script and pre-build this data.

#

I would have a scriptable object which has a list of all territories where the key is the color and each entry would have a pixel offset.

#

Then I would be able to scan a much smaller list of territories instead of scanning through 10 million pixels.

#

Or at least then I would have a pixel coordinate per territory which I could scan at runtime if this territory map changes.

#

A starting point to do a "growing search" which continues growing pixel by pixel to all neighbors which match the territory color.

simple bobcat
#

hmhm

#

ill look into it

simple bobcat
# timber shadow I would scan row by row, jumping by some fraction of the minimum area height loo...
void GenerateProvince(Texture2D colourImage, Color32 target)
{
    Vector2 firstPixelOfTarget = new Vector2(0, 0);
    Dictionary<Vector2, int> pixelAreaOccupation = new Dictionary<Vector2, int>();
    for (int x = 0; x < colourImage.width; x++)
    {
        for (int y = 0; y < colourImage.height; y++)
        {
            if (colourImage.GetPixel(x, y) == target)
            {
                firstPixelOfTarget = new Vector2(x, y);
            }
        }
    }
    
    // check north
    if (firstPixelOfTarget.y + 1 < colourImage.height)
    {
        if (colourImage.GetPixel((int)firstPixelOfTarget.x, (int)firstPixelOfTarget.y + 1) == target)
        {
            pixelAreaOccupation.Add(new Vector2((int)firstPixelOfTarget.x, (int)firstPixelOfTarget.y + 1), 1);
        }
    }

    // check south
    if (firstPixelOfTarget.y - 1 >= 0)
    {
        if (colourImage.GetPixel((int)firstPixelOfTarget.x, (int)firstPixelOfTarget.y - 1) == target)
        {
            pixelAreaOccupation.Add(new Vector2((int)firstPixelOfTarget.x, (int)firstPixelOfTarget.y - 1), 1);
        }
    }   

    // check east
    if (firstPixelOfTarget.x + 1 < colourImage.width)
    {
        if (colourImage.GetPixel((int)firstPixelOfTarget.x + 1, (int)firstPixelOfTarget.y) == target)
        {
            pixelAreaOccupation.Add(new Vector2((int)firstPixelOfTarget.x + 1, (int)firstPixelOfTarget.y), 1);
        }
    }   

    // check west
    if (firstPixelOfTarget.x - 1 >= 0)
    {
        if (colourImage.GetPixel((int)firstPixelOfTarget.x - 1, (int)firstPixelOfTarget.y) == target)
        {
            pixelAreaOccupation.Add(new Vector2((int)firstPixelOfTarget.x - 1, (int)firstPixelOfTarget.y), 1);
        }
    }

}

so i quickly assembled this. and it loads when i play, in theory i have a map of vector2 + 1's, what would be best way to visualize this?

#

i dont even need the dict, just a list of vector2

timber shadow
#

You're going to need to stop scanning the entire map once you find a single pixel of the desired target color. After this you would grow the selection until all adjacent pixels are found.

#

As for visualization, I don't know enough and it's outside of the scope of the original question.

simple bobcat
#

true

timber shadow
#

And as mentioned, I would precaculate the regions before runtime unless this is dynamic. But in either case I wouldn't work with image data in either case for a full implementation of whatever you're doing.

#

I would have the regions as individual data sets which can be scanned through in a fraction of the time.

#

the list of, presumably, roughly 200 territories would be much faster to iterate than the 10 million pixels in the source image.

simple bobcat
#

that is true

timber shadow
#

The method used to precalculate those territories is irrelevant if it can be done before the game runs

simple bobcat
#

are you suggesting manually making these regions?

timber shadow
#

I'm suggesting you could preprocess the image at design time generating a data set which is more conventient to work with.

#

You could write an editor tool which can take a source image and output a ScriptableObject derived type which has all territories as datum in a list.

#

Those territory entries could have their bounds within the original image, their target color, whatever.

simple bobcat
#

that does sound quite handy

timber shadow
#

Each entry could have an array of the territory pixels, an offset where this block of pixels originates from in the original map, etc.

#

Whatever is convenient for your needs.

#

But I wouldn't work with a raw image in this case unless I had no other choice, in which case I would preprocess it once if possible at runtime.

simple bobcat
#

i see, tho, if i may ask, do you know how to work with coding shaders

timber shadow
#

I don't do a lot with shaders.

#

The question as asked isn't very useful though.

simple bobcat
#

since i already have a mapping of Province Id's and their respective target colour (which will be the base of all data driven logic) so all of what searching for is to visually show the provinces

#

and i thought going for marching squares / meshes would be feasible

timber shadow
#

It still sounds like you need to precalculate those regions (you mentioned it being slow), and after that it sounds like you need to generate geometry for the regions.

simple bobcat
#

yeah

timber shadow
#

You'd need to look at 2d hull generation algorithms.

#

This would be my first thought.

#

Someone else might have a better idea/approach.

#

Personally though, if this is a 2d map and you've already preprocessed the data to find each territory, you have map of each of the regions.

#

Could just generate an image per territory and render each one on an appropriate quad with a texture generated from the pixel data.

simple bobcat
#

didnt think of that before

timber shadow
#

Hopefully useful. Good luck.

simple bobcat
#

thanks alot

timber shadow
#

An alternative algorithm, btw, is to not seek a target pixel color.

#

You already have to iterate the whole map per territory in what you showed.

#

Instead perhaps iterate the whole map, and generate a bucket for each unique color found.

#

Then just keep adding to the buckets until finished.

#

You iterate it once, instead of hundreds of times.

#

After that you have a map of territories to iterate (a couple hundred) to find a given territory, and not 10 million pixels.

simple bobcat
timber shadow
#

Yes.

#

If you were to have each Procince have a list of pixels then you would have subdivided the whole map into regions.

#

Each time you find a pixel which is already matching a key in ProvinceDef then you add that pixel to the province.

#

Then you know every pixel belonging to each province.

#

You can take these lists of pixels and create whatever you want with it for display.

glacial tundra
upbeat path
#
Dictionary(Color32, List<Vector3Int>>
timber shadow
#

Er... derp

#

List<Vector2Int>

upbeat path
timber shadow
#

Then later I would probably generate a texture and store an origin relative to the source map coordinate system.

upbeat path
timber shadow
#

Yeah I'd store the id as the source color.

#

But I wouldn't store each pixel color.

upbeat path
#

so as I said, only split up

timber shadow
#

Just a bit different, yep.

upbeat path
timber shadow
#

You wouldn't need it in the end. If you generate texture, an appropriately sized quad, for each of the provinces, you can raycast all then do a sub region check to see if your pixel coordinate falls into the province or is in dead space within the bounds.

#

or if he generated a hull (mesh) you don't even need that check.

#

You just rely on raycasts to tell you what province you're in.

#

Lots of options.

#

Your thinking works too I'm sure.

upbeat path
#

so why not just do a mouse over and check the colour that the mouse is over?

timber shadow
#

He wanted to be able to do more interesting rendering too.

#

So it'd be conventient to have the per province data in either case.

#

This is just how I thought about it based on his descriptions.

#

@simple bobcat Consider what @upbeat path has said here as well, it's an interesting approach.

#

You could have a shader which just acts as a map where you decide how each pixel is to be rendered if the color in the sampled "map" texture matches the color of the province you're interested in.

crisp temple
#

Playing a bit of catchup but sounds like you basically want a reverse-bucket-fill? Assuming all the borders of one 'colour' are guaranteed to be only in one place

timber shadow
#

Sounds correct. It really depends on his needs.

upbeat path
#

tbh, to make it efficient, I'd throw a Bounds into the mix depending on the kind of data interaction required

timber shadow
#

I think I mentioned generating a bounds per region when you fill the buckets.

#

But maybe not.

#

You'd want it for appropriately positioning the quads if you generated a texture per region and "rebuilt" the map.

#

They may not need any of this though if all they wanted to do was render the hovered region differently.

upbeat path
#

not just that but to use for a narrowing down process if you needed to ask which Province is x,y,z a part of

timber shadow
#

Your suggestion of just sampling the color in that map based on hover and rendering differently based on sampled color could cover a lot of cases.

#

Much simpler too.

#

You'd just need to keep track of the key pixel colors.

#

Could allow for conquering territories too if you group territories.

#

Lots of stuff.

#

👍

simple bobcat
timber shadow
#

👍

simple bobcat
#

like, for more detail or whatever. i dont need to interact with the visuals itself.

#

tho

#

copying a province looks promising

#

by color/id

#

though i also found this video

#

In this series, I will talk about how to implement the area movement mechanism, which is used by many board games and popular Paradox grand strategy games, in Unity. The first video will address the most subtle part, pixel shader based coloring and area selection.

Chapters:

0:00 Introduction
1:04 Edge detection Shader
1:56 White & Black map
1:...

▶ Play video
#

which utilizes shaders

timber shadow
#

You want to generate the borders?

#

Render them, anyway?

simple bobcat
#

indeed

timber shadow
#

In a shader, if you have your texture, and you were to sample the adjacent pixels then any time you find adjacent pixel color doesn't equal source pixel color you would know it's a border pixel.

simple bobcat
#

im digging more into shaders so

opal wigeon
#

do you need to generate it dynamically?

simple bobcat
#

thats preferable

#

tho

#

pregenerated is also fine

#

i just... dont want to make them manually and theyre purely visual

opal wigeon
#

seems relatively simple

signal stirrup
#

I'm using the unity pool namespace for my pooling of enemies. However, when I am prewarming I do

private void PrewarmPool()
    {
        for (int i = 0; i < initialPoolSize; i++)
        {
            Health health = healthPool.Get();
            Debug.Log($"Prewarmed Health instance: {health.name}");
            healthPool.Release(health);
        }

        Debug.Log($"Total objects in pool after prewarm: {healthPool.CountInactive}");
    }

However, the Release function actually removes it from the hierarchy instead of just inactivating. From what I understand this isn't expected behaviour. Any ideas? (if I comment out the Release() function they are definitely being created). Is the unity pool namespace just a bit buggy and not worth using? I'm on 2022.3

compact ingot
signal stirrup
#

    private void Start()
    {

        healthPool = new ObjectPool<Health>(
            CreateHealthInstance,
            OnTakeFromPool,
            OnReturnToPool,
            OnDestroyPoolObject,
            true,  // Allow the pool to grow beyond max size
            initialPoolSize,  // Starting pool size
            maxPoolSize  // Max pool size (limit)
        );


        PrewarmPool();
    }

    private void PrewarmPool()
    {
        for (int i = 0; i < initialPoolSize; i++)
        {
            Health health = healthPool.Get();
            Debug.Log($"Prewarmed Health instance: {health.name}");
            healthPool.Release(health);
        }
        Debug.Log($"Total objects in pool after prewarm: {healthPool.CountInactive}");
        Debug.Log($"Max pool size: {maxPoolSize}, Current inactive pool size: {healthPool.CountInactive}");
    }


    private void OnTakeFromPool(Health health)
    {
        Debug.Log($"Taking from pool: {health.name}. Pool has {healthPool.CountInactive} inactive objects.");
        health.IsPooled = false;
        health.gameObject.SetActive(true);
    }

    private void OnReturnToPool(Health health)
    {
        Debug.Log($"Returning to pool: {health.name}. Pool has {healthPool.CountInactive} inactive objects.");
        health.IsPooled = true;
        health.gameObject.SetActive(false);
    }

    private void OnDestroyPoolObject(Health health)
    {
        Debug.Log($"Destroying Health object: {health.name}");
        Destroy(health.gameObject);  // Only destroy when necessary
    }```
#

maxPoolsize is 300 and initialPoolSize is 100

#

OnReturnToPool(Health health) is being called, but the object is being destroyed anyway

#

OnDestroyPoolObject(Health health) is not being called

#

(what happens here is that 100 are created in prewarmpool() and then healthPool.Release(health) just destroys them totally)

compact ingot
sly grove
#

Afaict you only have one instance at a time

#

I don't see 100 beong created in the prewarm

#

You would need to get all 100 before releasing any for that to happen, no?

signal stirrup
# compact ingot How does the stack trace of the OnDestroy method of Health look like?

this is interesting I'm currently looking at how to get a stack trace from a function that doesn't have an error in it, I haven't done that before. I just tried:

    {
        LogStackTrace();
        if (!IsPooled && !isPendingRemoval)
        {
            TriggerPendingRemoval();
        }
    }
    void LogStackTrace()
    {
        StackTrace stackTrace = new StackTrace();
        string stackTraceString = stackTrace.ToString();
        UnityEngine.Debug.Log("Stack trace:\n" + stackTraceString);
    }``` 
but it's not writing anything
sly grove
signal stirrup
sly grove
#

You neednt do anything special

sly grove
#

You create one, release it to the pool, and then get that same one again

#

100 times

#

I don't think anything is being destroyed here

#

You're simply only creating one instance

signal stirrup
#

iiiinnnnnteresting this sounds entirely possible

#

because yes I have 1 "surviving"

sly grove
#

Basically the pool is working exactly as intended

#

To do the prewarming you basically need two loop passes.
First Get 100 times without releasing, then release them all

#

I generally don't bother with prewarming though unless the instantiate cost has been shown to be particularly high

signal stirrup
#

just testing a fix for this but your reasoning is solid

#

I'm spawning up to 300 enemies at once which have their own init scripts and stuff so I'd rather front load them

sly grove
#

Don't they need to be init-ed when they get pulled from the pool anyway?

#

Even if they were prewarmed

#

I think it would be worth profiling to see if prewarming actually has tangible benefits. Because it comes with a definite cost

signal stirrup
#

things like heatlh, position etc. yes, but not a bunch of getcomponents() etc.

#

I get a noticable game freeze for a couple of frames on first instantiation

#

in editor anyway

sly grove
#

Of a single object? Or during the prewarm

signal stirrup
#

If I have a script that spawns 100 or whatever enemies during runtime I get a momentary pause (without pooling. it is instant when pooled - using a different method I've abandoned)

sly grove
#

Does that ever actually happen? 100 at once?

The prewarm is guaranteed to do that

signal stirrup
#

yeah, the idea is that prewarm happens before you even experience anything, and have no frame of reference to see a stutter

scenic forge
#

Given an arbitrary y = f(x), what's an algorithm that can be used to rasterize it such that it doesn't look horribly aliased? Eg I have an arbitrary f(t) where it gives a player's performance at time t, I'd like to plot it as a graph.

drifting solstice
#

wouldn't it just be smoothing at the boundary?

bleak citrus
#

You need both values and derivatives, but you can just approximate the derivative

#

Ah, but that's not the issue -- this is about drawing a line or filling in the space under a line, right?

scenic forge
#

Yeah, filling under the line.

bleak citrus
#

In that case, you might be interested in something like the Gupta and Sproull algorithm to draw a nice anti-aliased line.

#

You'd completely fill in all pixels beneath the line afterwards

#

I haven't actually implemented that one before. I've only done Bresenham's line algorithm (to pick targets for a line-shaped attack)

#

and that one is not anti-aliased

scenic forge
#

Yeah I've looked into Bresenham and the derivates that support anti aliasing, but they are designed for drawing a line from P1 to P2, not for any arbitrary function.

bleak citrus
#

Can you not just do linear interpolation between each point?

bleak citrus
scenic forge
#

Well kind of, I was thinking to treat "drawing the column x = 4" as "drawing line P(3.5, f(3.5)) to P(4.5, f(4.5))"

#

And apply whatever anti aliased line drawing algorithm to it.

#

But I feel like there might be an established way to do it out there.

sage spindle
#

What is a good way to ensure I only have 1 scriptableobject in the project of a type. For example config files?

upbeat path
sage spindle
#

😄

upbeat path
#

actually, if you are using a menuitem you can disable them if, for example, an object of type exists

sage spindle
#

I am using the right click menu. I would be satisfied with just logging an error if it already exists in the project and returning

upbeat path
#

so you are using menu items

sage spindle
#

Right, asset menu I guess it's called, CreateAssetMenu

upbeat path
# sage spindle Right, asset menu I guess it's called, CreateAssetMenu

ok, here is some example code

        [MenuItem("Tools/Save for Unity/Manage Script Optimisation", false, 2)]
        public static void ShowWindow()
        {
            // Open window
        }
        [MenuItem("Tools/Save for Unity/Manage Script Optimisation", true, 2)]
        static bool SourceGen() { return Save.roslyn != null; };

note how both options have the same MenuItem, one with true and one with false
the first version will be used if the second returns true

#

if the second returns false then the menu item is disabled

sage spindle
#

That is for the top menu? It does not seem like CreateAssetMenu has the same functionality?

[CreateAssetMenu(
    fileName = "DatabasesConfig",
    menuName = "Game/Config/Databases Config",
    order = 0
)]
public class DatabasesConfigSO : ScriptableObject
{
    public StatDatabaseSO StatDatabase;
}
upbeat path
signal stirrup
#

nm got it thanks

undone coral
signal stirrup
#

PraetorBlue got it

undone coral
minor garden
#

How to encrypt local build asset with a private key?

stuck plinth
minor garden
echo coral
minor garden
echo coral
#

and the fact that the game needs to be able to decrypt the file makes this kinda pointless as someone who cares enough will bypass this

short blade
#

Encrypted assetbundles sounds like a good suggestion though for adding that extra hurdle to dissuade people trying to rip your assets.

untold moth
#

If it's sprites, they can just use something like PIX or renderdoc to get the textures right from the GPU I think.

#

No encryption would help.

short blade
#

Of course it would help, if we're talking about dissuading. Any additional layer of PITA you add will weed out your average script kiddies.

echo coral
#

The asset bundle route may be best, i wonder if with a custom provider in addressables would make it easy to integrate 🤔

tall ferry
untold moth
short blade
#

That is true, I imagined this was to avoid modding.

minor garden
untold moth
#

I guess it could help a little bit. But there's also the performance overhead to consider and the time/effort/money you gonna spend on implementing it. Probably not worth it for any indie game.

tall ferry
#

First you need to make a game where people would wanna rip the assets in the first place

#

And then you realize it doesnt matter what you do, as people will rip it anyways

minor garden
#

Thank my guys

untold moth
#

But if you're dead set on encrypting, just Google it. There seem to be some plugins/assets for unity that do it. Honestly, this is really not an advanced question, unless you need specific advice on implementing it yourself.

#

At which point you should probably have at least some idea of where to start.

minor garden
#

I have encrypted my bundles using AES for the assets route (It's not absolutely secure, but I'm satisfied with it), and I'm looking for ways to encrypt assets locally. I really appreciate everyone's advice.
Have a good day!! 😊

echo coral
#

single assets isn't possible unless you can load the asset in from a generic data source at runtime (textures, videos, some models via gltf)
Bundle route is going to be best i think 👍

long cloud
#

Question I hope someone here can answer, I'm trying to create a custom Unity Crash Handler to deal with crashes and issues but I don't know how the Unity Player will tell the crash handler that a crash has occurred. I would presume that when playing a Unity project and a crash occurs, the crash handler (if open) would get a call with the details of the crash but how would I know this has happened? I'm using .NET for the handler so It should work. Anyone know how I can do this?

#

I have found PlayerSettings.enableCrashReportAPI but the docs doesn't provide any information. Is this what I need?

echo coral
long cloud
#

I've found out that Unity runs the crash handler at start of a Unity project, now I just need to know what Unity does with the app when a crash occurs

echo coral
#

"unity project"? You mean the editor or builds?

long cloud
echo coral
#

Then check for the platforms you want to support how to configure a crash/sig handler for a process. I presume the editor already has some handling setup for common platforms but im not sure how unity cloud/firebase or others interface with it (or if they implement this on their own)

#

hopefully some investigation of these can reveal more info

long cloud
#

I'll look into it. Thanks!

echo coral
undone coral
#

unity's approach is to quickly record crash information when it occurs, given what the platform permits you to do. then, that at the start of your game, it uploads crash reports

#

both google play and the apple app store provide crash report collection

#

what are you trying to do in terms of "deal with crashes and issues"?

long cloud
#

This is for Windows. All I want is to know if a crash has occured

long cloud
#

Not the best but I'm not looking in memory

undone coral
#

did you enable Cloud Diagnostics?

long cloud
undone coral
#

if you use the crash report API, you will only get the reports the next time the game runs

#

is that what you want?

#

the game has crashed. so it's not like you get a chance to upload something to the internet from inside the game

#

"Note: this API currently is available only for iOS targets." is kind of illuminating for what this is meant for

#

what kind of crashes are you seeing on windows? actual crashes might be quite rare

#

compared to exceptions

long cloud
#

All I want is when my Unity projects crash, a sperate application will be aware of the issue and do some logic about it. I looked a bit before on how to do this but it would mean tapping into the Windows Registry and stuff which I don't want to deal with. So it seams like what I want to do isn't possible which a lot of code

vivid fjord
#

ok trying different angles on the vfx challenge i talked about here. any of yall got any clever ideas i can start hacking at? #✨┃vfx-and-particles message

the fundamental design constraints im working with are this:

  • procedural zones with wide variety of theme and structure.
  • each zone has 12 altars (procedurally) scattered throughout the zone, players have to unlock each altar to unlock the zone and progress to the next zone
  • each zone starts out "impassible" -- originally i was thinking a wall-of-fog type effect, and the unlocking of each altar clears out the wall-of-fog for a radius around the altar (which grants visbility to nearby altars that can then be unlocked

but at this point i just want a super-simple way to implement this so i can prototype the gameplay. i know there are lots of ways to potentially implement this, but im looking for the MVP approach

blissful wagon
echo coral
#

Firebase is pretty good for what is free but sentry can be self hosted. I even made a sourcemod extension to use it for tf2 servers (creators.tf)

fringe root
#

hey im looking into building a little multiplayer text-based RPG where the multiplayer functionality is pretty much just a database with shared data between clients.

So far i made a little authentication script with Unity gaming services and im looking to use Cloud Code and Cloud save as well.

I'm slowly chewing through the documentation and some youtube resources but i was wondering about some do's and dont's. For instance, could i just access the player data on login and then save on application quit or is that not reliable?

Can i handle changes in player-specific data like item equips, unequips, item drops, experience, levels, health, etc.. on the client side and then just save? Probably not right?

Do I need every data change to go through the server and then get responses?

Thanks!

misty glade
#

I'd save periodically and on player quit. It's reliable though (as long as your app doesn't crash).

If you're saving items on the server - then you're probably gonna wanna do a trusted and untrusted version of the player model. For a game I did in the past, I would let the client have free reign on the player data, and serialize it for networking - send it to the server, where the server would throw away any untrusted data (and re-hydrate the object with the "known" data). Whenever I'd send a player file back to the player, I'd strip out the same.

Every data change can go through the server if that makes sense for you, but it's probably more efficient to create messages for actions (instead of sending the whole player file back and forth every time there's any tiny change) and then just keep the data files in sync on both devices

#

This is a big architectural task, but mostly because managing data across two brains requires some thought and effort.. It's not complicated per se, but it is a lot of work.. Happy to show you some code examples for my solution if you want.. create a thread here and ping me. @fringe root

fringe root
#

Awesome dude, i'll do that tomorrow for sure. That can totally be a great help! Do you have any resource you recommend for learning those nuances? @misty glade

misty glade
# fringe root Awesome dude, i'll do that tomorrow for sure. That can totally be a great help! ...

twelve months of staring at a screen and trying to figure it out 🙂

In all seriousness, no, I kinda bumbled my way through it on my own, talked to a lot of industry connections and friendly developers (and this discord). I'm sure I didn't do everything right but what I did come up with worked pretty well.. it made finding cheaters pretty easy too.. literally Day 1 of the app being released we had someone trying to send clearly modified data up to the server (setting things like PlayerLevel=999999999)

royal island
#

Does Unity 6 still have a lot of garbage collection overhead from using reflection methods?

final steeple
#

Are you asking if Unity's own code is garbage-heavy, or if using reflection in your own code is?

royal island
#

Reflection in my own code

#

I'd like to cleanly get a method with a custom attribute on it without garbage collection overhead

sly grove
#

you're getting attributes at runtime?

#

for what?

royal island
#

I'm working on a library that targets Unity as one of its supported use-cases

thin mesa
#

yeah depending on the use case, a source generator might be a better option

sly grove
#

I think a source generator would be a better option than reflection.

#

jinx

#

dammit

#

lol

royal island
#

Here's an example of what I'm trying to do

#
[Subscribe(DatagramTypes = typeof(DatagramA), priority = 1)]
public void MyMessageListener(IDatagram datagram)
{
    // client code
}
#

psuedo garbage code

sly grove
#

You could totally do this with a source generator, if I understand it properly. You want to put this attribute on a method and have it get called whenever a DatagramA event is published?

royal island
#

yes

sly grove
#

Yeah with a source generator you could basically automatically generate code for this class to register itself and that method to the event bus if that attribute is present

royal island
#

.NET Standard 2.1 supports source generators?

sly grove
#

The source generator itself must target .NET Standard 2.0 to use it in Unity, but you can use it from any project afaik

royal island
#

Cool, cool. Could you direct me to a good source generator resource so I can get going on that? I'm not familiar on how to implement one

sly grove
#

I just did this myself for the first time last week

#

there's a slight learning curve but now that I'm in the groove of it it's great.

royal island
#

How do I do this in a way where it's completely abstracted away from the client?

#

Like the client application so it's like reflection magic using source generation?

final steeple
#

Or in other words, it's not really Unity's fault -- the current design of the API just requires lots of objects and boxing

#

There's work underway in .NET to add new APIs (if you know member names statically you can use UnsafeAccessor in modern .NET for example), so things may improve in Unity 7 when CoreCLR is available

#

But yeah, source generators are usually the better option here anyway

#

I wouldn't particularly recommend the guide Unity has there because it uses the old ISourceGenerator interface instead of IIncrementalGenerator, so your generator will be subject to a lot of restrictions and will perform quite poorly relative to an incremental one, but the downside is that Unity doesn't support incremental generators out of the box because the C# compiler it ships with is too old, so you have to update it manually for them to work

#

I have a tool for updating the bundled Roslyn here: https://github.com/DaZombieKiller/UnityRoslynUpdater
But just note that doing this requires modifying your Unity install, so if you aren't comfortable doing that (or requiring it for your project) you're stuck with the old ISourceGenerator API

thin mesa
#

incremental source generators work in unity 6, and probably 2022. 6 uses code analysis 4.3.1

final steeple
#

Oh so they finally updated the in-box one to support them? Nice

#

I still update Roslyn manually though since I use C# 13 kekw

raven flicker
#

Howdy folks. So I've got a bit of a Unity 2D performance killer here. My game's UI is organized on its own canvas, ordered to render above the game's tilemaps and sprites and whatnot. It has a render mode of Screen Space, and renders to the Main Camera. The game is a top down RTS style, so I adjust the camera's Orthographic Size for zooming on the map. Unfortunately I've found the act of zooming is causing the entire UI and all its elements to redraw/calculate every frame of the zoom. On mobile this is destroying performance. As a temporary workaround I disable the UI during zooming. But it would be nice to keep it around. I'm just not experienced enough with Unity to understand why it is redrawing every frame during zoom actions, and how to redesign the UI to avoid this performance bottleneck. Any insight would be appreciated!

sly grove
#

If not, couldn't you render the UI on an overlay camera, which wouldn't need to be zoomed?

raven flicker
#

The UI consists of some borders, buttons, backgrounds, resources bars and text. That sort of thing.

sly grove
#

The reason it's redrawing is because you're changing the camera size which means the positions of the UI objects all need to change to adjust for the new camera settings

raven flicker
#

:nod: Yeah that makes sense.

sly grove
#

If you ever look at a screen space - camera canvas in the scene view, it literally follows the camera around and adjusts to its frustum

raven flicker
#

I recall when I first set everything up, having it as an Overlay didn't work well. Like, perhaps there was a bug on mobile with elements blocking raycasters and this is how I worked around it. Something...

sly grove
#

Well I was mentioning an overlay camera, not switching to an overlay canvas

raven flicker
#

Oh, the camera itself.

sly grove
#

as in - using camera stacking

raven flicker
#

I'll have to read up on that more, I've not heard the term.

sly grove
#

Are you using URP?

raven flicker
#

Yes.

raven flicker
#

Thank you for the links!

#

Ok so I effectively have one camera pointing at the UI, and another pointing at the gameworld, and I can combine them together?

sly grove
#

Well the overlay camera (which draws the UI) would draw on top of the base camera

fringe root
#

Cloud save architecture

shell horizon
#

Is there a way to trigger a domain reload through a script?

opal wigeon
#

Can I use strings with jobs/burst?

bleak citrus
#

I know that there are fixed-size string structs

opal wigeon
#

burst keeps saying my struct must be unmanaged and all it has left is an array of structs containing bools and ints

#

Does burst hate arrays too?

sage radish
opal wigeon
sage radish
#

As opposed to NativeArray, which is unmanaged.

opal wigeon
#

I naively thought that converting a function to jobs would be easy

#

now I don't even think it's possible for me

livid kraken
#

Just use a native array

dapper cave
#

is there a way to get the triangles of a particular agent? NavMesh.CalculateTriangulation();

#

nacmesh baked with nacmeshsurface

lament salmon
#

I forget how exactly agents are bound to areas

#

Oh right, agents an Area Mask property in the inspector

#

So sounds like areas should have everything you need.
You can iterate over the triangles and skip the ones that are in an area that the agent doesn't use

lofty falcon
#

I'm drawing meshes with a CommandBuffer, but I'm running into an issue. I'm trying to change the color on the material between calls to DrawMesh, but only the last color is drawn since the command buffer doesn't get executed till the end. How can I set the color on a material with the CommandBuffer?

#

I can get it to work with MaterialPropertyBlock, but I'd prefer not to use that

dapper cave
#

it's doable and might work well

sly grove
#

Property block is probably the best I think

undone coral
#

it's procedural, provided what you want to do is supported in the first place

undone coral
#

have you looked at the profiler?

#

additionally, redrawing the whole UI on a modern mobile device isn't expensive

#

tilemaps and sprites are not in a canvas. so you only have one canvas. i wouldn't use the words "organized on its own canvas" - i guess, it's the only thing in its own canvas

#

you are probably doing something else that invalidates the canvas while zooming as a side effect

echo coral
#

Id love to see this UI that is soo complex it does this.
Also wouldnt using 2 cameras solve this as you could avoid modifying the "ui only" one?

undone coral
#

the UI isn't rendering to a camera at all in screen space overlay

bleak citrus
#

the canvas is in "Screen Space - Camera" mode, hence the problem

undone coral
#

" It has a render mode of Screen Space, and renders to the Main Camera." is too vague

echo coral
#

i thought you could select the camera it uses

bleak citrus
#

If camera stacking doesn't cause a major performance hit, then that sounds fine too

echo coral
#

I can understand why screen space camera causes a redraw as i presume it needs to be resized + positioned and thus is all made dirty

raven flicker
#

Mobile devices are the ones being affected by this detrimentally. Dropping from 30fps down to 10fps during zoom events. As long as I hide the UI during zooming its fine, but I'd prefer not to do that.

#

The main camera is an orthographic projection camera using the CinemachineBrain. I basically followed a tutorial ages ago to setup the pan and zoom effects on a 2D tilemap and didn't think much of it beyond that.

#

I'm preparing to try stacking to see how it shapes out.

untold moth
raven flicker
#

In time perhaps. Going to see if stacking fixes it all first.

opal wigeon
# undone coral what is your goal? the chatbots are capable of doing the rote work of rewriting ...

Voxel terrain generation, I figured out the mesh generation part but I'm having trouble with UVs because nested arrays are not allowed. Also for now it's not running in parallel, is there a way I can call a single job so it runs in parallel and only generate the mesh(on the main thread) when it's ready? Something like: I call the job on frame 1 and when the mesh data is ready on frame 4 I generate the mesh

undone coral
#

and have you looked at any assets that do this?

opal wigeon
solar mist
#

Hello there!
I have this netcode code:

async Task ConnectThroughLiveService(string sessionName)
    {
        Debug.Log("ServicesHelper: ConnectThroughLiveService - Starting");
        
        try 
        {
            var options = new SessionOptions()
            {
                Name = sessionName,
                MaxPlayers = 4,
                IsPrivate = false,
            }.WithDistributedAuthorityNetwork();    
   
            m_CurrentSession = await MultiplayerService.Instance.CreateOrJoinSessionAsync(sessionName, options);
        }
        catch (Exception e)
        {
            m_ConnectionState = ConnectionState.Disconnected;
            Debug.LogError($"ServicesHelper: Failed to connect: {e.Message}");
            Debug.LogError($"ServicesHelper: Stack trace: {e.StackTrace}");
            throw;
        }
    }

On PC and Mac m_CurrentSession is assigned succefully, but on WebGL is always null. Can someone help me out?

Funny thing is that the WebGL client still creates or joins a session, but just does not assign value to the m_CurrentSession. And I kinda need that later to take the player offline and such.

PS.: Catch is also never called.

Thanks for any help.

echo coral
#

I ask as webgl doesnt support other threads so im not sure if thats causing a problem

raven flicker
#

Only caveat, is I liked seeing the UI render in place in the editor where it belongs, floating over the tilemap/sprites. But I have to move it out of view or it'll pick things up I don't want it to. Not sure what the best solution for that is.

untold moth
raven flicker
#

If I am not mistaken, I had that originally. And while it worked fine in Windows, it had many issues on mobile platforms due to raycasting bugs in the 2022 unity release.

#

I really need to document engine workarounds better going forward, heh.

#

In any case, it fixes the issue enough that I can move on. Appreciate all the insight. I've moved onto Unity 6 for other work, and am sure everything will turn out differently going forward with it.

echo coral
#

glad that fixed it. Not sure what these raycasting bugs are i have worked over many 2022 versions (mobile too) with UI and 2d physics with stuff

untold moth
twin galleon
#

would it be possible to modify the TMP code to add another custom rich text tag, and then how would i go about checking for that tag in my code and finding out what words are within that tag?

echo coral
twin galleon
#

maybe i should explain fully what i am trying, so i am trying to add an addition to my game's dialouge system to add text effects like how games like celeste have them, so i bought this text effect asset and am trying to hotwire a tag system as a separate script because i do not understand the scripts code at all (almost all the variables are random Spanish characters??) by modifying the imputed ForceWord Var (i think that determines which words the effect is given to), i have been trying to make my own tag system, but thought that might be easier to hotwire TextMeshPro's rich text tags instead, so i was wondering how i would do that and then get what words have that tag to put into the ForceWord variable, if that is even possible (sorry for the long message)

echo coral
twin galleon
#

this is way better than the asset i had, thank u so much

echo coral
#

i rememered one that may be better but no idea where that is. Searching github and openupm can find cool stuff!

twin galleon
#

thank u :)

wind nebula
#

Building block ability system

neon raft
#

Can somebody help me? I've been struggling with this for a while in this pic im trying to determine the red dot points position based on their heigh meaning that the highest point is "left" the one in the middle is obviously middle and the closest to the threspoint which is the blue line respresents "right" this is the start of the song the notes are very close to the threspoint hovewer if we move more forward in the song for example the second image the notes go like really high you now see why im struggling I cannot set an umbral for this and idk any other approach I could go with any ideas?

random dust
#

If this is socket-based then it might be possible that this system uses sockets not supported in a webbrowser.

#

I would expect an exception however

midnight violet
neon raft
#

I've tried this method but it puts the notes in random places which is not good ```csharp
string DeterminePosition( float spectralFlux )
{
if (spectralFluxSamples.Any())
{
//float maxFlux = spectralFluxSamples.Max( s => s.spectralFlux );
//float threshold1 = maxFlux / 3;
//float threshold2 = 2 * maxFlux / 3;

    //if (spectralFlux < threshold1)
    //    return "left";
    //else if (spectralFlux < threshold2)
    //    return "middle";
    //else
    //    return "right";

    var rand = new System.Random();
    int randomnumber = rand.Next( 1, 4 );

    if (randomnumber == 1)
    {
        return "left";
    }
    else if (randomnumber == 2)
    {
        return "middle";
    }
    else
    {
        return "right";
    }
}
return string.Empty;

}``` you can see in this vid https://youtu.be/r4f2_VXgcpE

#

song name is VØJ, Narvent - Memory Reboot

#

The commented code is more like peak oriented which means that it will try to find the highest peak but it always output "left"

#

I mean randomness sometimes is not half bad but is not rythm oriented

#

Im trying to make something like audiosurf which it has this grid kinda thing

midnight violet
#

So you need a relative distribution based on the highest and the lowest red dot within a certain time span?

neon raft
#

Yeha I guess that works but the dots are not consistent

midnight violet
#

You mean, sometimes your red to y span is from 0-2 and later from 2-20

neon raft
#

I mean sometimes the highest can reach 3

midnight violet
#

whatever 3 means in your case. is that high, low?

neon raft
#

so its like a float it can go from 0 to the highest

#

Im not sure how to explain

#

Maybe with this you understand ```csharp
public void setPointHeight( Transform point, float height )
{
float displayMultiplier = 0.06f;

point.localPosition = new Vector3( point.localPosition.x, height * displayMultiplier, point.localPosition.z );

}```

midnight violet
#

Yeh, I get that. But you dont know how to get the highest, because the highest could be at 20 (for example) and only if one note is that high, all other dots would be to the left because of dividing by 3 simply would result in this

#

Did I get your issue right there?

neon raft
#

More or less you are in the right track

#

I mean yeha it finds the highest peak but sometimes there are other dots below which are high as well

midnight violet
#

As you seem to have a time span in your song based on your visuals, like you can only see 20 at that time (in distance), you can use that as a timespan and calculate your distribution a) based on the height and b) based on the amount of notes being in that height range

#

Not sure, it is clear, what I mean with the dynamic distribution. So you dont divide only by 3 to get left, middle and right, but you would have a range percentage, that adapts based on the amount of notes, that are in there

neon raft
#

Technically this is preproccessed

#

which means the audio gets processed before playing it

#

Im not sure I understand maybe you would need to see the code

#

I use the preproccesed one

#

Now the problem is organizing the notes accordingly to be "left", "middle", "right"

midnight violet
#

I do not really care about the process of the song. In the end, you get your array of red dots and their heights. No matter where they come from. And from this array based on its values, you need to distribute them on your 3 visual tracks. And to do so, you can chunk the array into parts like from current note + 20 and take that range to calculate the next note track

#

So your distribution would always adapt to the next range of heights instead of the whole song for example. And within that range, you need to check, how many of "high" notes are there to basically ease out peaks

neon raft
#

I guess what you mean is what it does here like it only displays a certain amount ```csharp
public void updatePlot(List<SpectralFluxInfo> pointInfo, int curIndex = -1) {
if (plotPoints.Count < displayWindowSize - 1)
return;

int numPlotted = 0;
int windowStart = 0;
int windowEnd = 0;

if (curIndex > 0) {
    windowStart = Mathf.Max (0, curIndex - displayWindowSize / 2);
    windowEnd = Mathf.Min (curIndex + displayWindowSize / 2, pointInfo.Count - 1);
} else {
    windowStart = Mathf.Max (0, pointInfo.Count - displayWindowSize - 1);
    windowEnd = Mathf.Min (windowStart + displayWindowSize, pointInfo.Count);
}

for (int i = windowStart; i < windowEnd; i++) {
    int plotIndex = numPlotted;
    numPlotted++;

    Transform fluxPoint = plotPoints [plotIndex].Find ("FluxPoint");
    Transform threshPoint = plotPoints [plotIndex].Find ("ThreshPoint");
    Transform peakPoint = plotPoints [plotIndex].Find ("PeakPoint");


    if (pointInfo[i].isPeak) {
        setPointHeight (peakPoint, pointInfo [i].spectralFlux);
        setPointHeight (fluxPoint, 0f);
    } else {
        setPointHeight (fluxPoint, pointInfo [i].spectralFlux);
        setPointHeight (peakPoint, 0f);
    }
    setPointHeight (threshPoint, pointInfo [i].threshold);
}

}```

#

But still this would not work because I proccess the song once

#

and then the notes move according to the time

midnight violet
#

But even with the whole song, you should be able to distribute all notes evenly by adapting the percentage of your visual track distribution according to the amount of notes in that range

#

So if dividing by 3 (your track amount) would end up in
| oooooo | ooo | o |
you can then just shift the division to the left to get something more evenly distributed
| oooo | ooo | ooo |
if you get what I mean

neon raft
#

I get it but how I can achieve this?

#

I mean in terms of code what I do

midnight violet
#

🤔 trying to come up with an example

neon raft
#

Right now I have like this```chspar
private IEnumerator HandleEndProccessing( List<SpectralFluxInfo> spectralFluxInfo )
{
if (spectralFluxInfo != null && spectralFluxInfo.Count > 0)
{
for (int i = 0; i < spectralFluxInfo.Count; i++)
{
SetupTarget( i.ToString(), spectralFluxInfo[ i ] );
yield return new WaitForEndOfFrame();
}

    FindHighestPeaks();
}

yield return null;

}```

midnight violet
#

Wait, why do you even consider the height of notes, if you distribute them evenly anyways?

neon raft
#

we can use spectralflux is the same thing

#

the height is based on that

#

also another thing to consider I wanna add sliders

midnight violet
#

But to distribute to middle, left or right, you basically just need to add up all height values, divide by 3 and then check against those, right?

#

This would already consider more notes being low and only one being high

neon raft
#

yes check in the list which one is the highest

#

This is what each note contains csharp public class SpectralFluxInfo { public float time; public float spectralFlux; public float threshold; public float prunedSpectralFlux; public bool isPeak; public string position; public bool isSliderStart; public bool isSliderEnd; public float sliderDuration; } dont mind the position because thats what im trying to fix right now

#

also the slider didnt test it yet

#

ispeak determines if a note is above threshold and makes them red

random dust
neon raft
#

What you mean the position?

#

I could use an enum but the point is how I determine this position

random dust
#

Sure, but returning hardcoded strings are a huge smell

#

By all means keep doing it, especially since it doesn't solve the issue. I just don't see why you would do this over an enum

#

Consider allocation, magic strings, stuff like that

neon raft
#

Will take into account

midnight violet
#

So if you have an array of heights (your note class holding the heights, just for simplicity) like [1,3,6,4,15], then the middle height would be 5,8. Now you would need to take this and get the middle to the highest and lowest to get like the range
1 (Left Track) --- 2,4 (Middle Track) 5,8 ( Middle Track ) 10,4 --- (Right Track) 15

#

I am sure, there is some mathematical calculation to this, I do not know 😄 But to get the concept of what I meant, it might make it clear (or not) 😉

neon raft
#

OKay so what if

#
for (int i = 0; i < spectralFluxInfo.Count; i++)
{
    
    yield return new WaitForEndOfFrame();
}``` I iterate through the notes and basically check the next note to see if it is the highest also check the note before or something like that?
#

so we have like 3 notes

midnight violet
#

Then you will never take into consideration all notes, but only in relation to the previous one. So imagine, you have a note sequence going down. 7,6,5,4,3,2,1,0 based on that, your 7 would be right, 6, middle, 5 left and the rest will run on left

neon raft
#

Then I dont understand what you saying xd

#

maybe a range between 10

#

Take 10 notes and see the highest of those

#

Checking the size of the list and checking if doesnt go beyond the list

midnight violet
#

Ill try to write a simple example. give me a second 😄

neon raft
#

Alright cause im getting hella confused

#

I mean I get your point but im not sure how to implement it

midnight violet
#

Hope I can make it in time, gotta go in some minutes 😄

neon raft
#

No big deal I will come up with something eventually I guess

midnight violet
#

!code

thorn flintBOT
midnight violet
neon raft
#

Why on the update?

midnight violet
#

To see the inspector update on runtime 😄

neon raft
#

Can I do this from 1 go instead on update?

#

Because I cannot see inspector this unity version it freezes when debugging

#

Im using 2022.3.0

midnight violet
#

Did you add something to the array in inspector?

neon raft
#

No I dont touch array in inspector only code

midnight violet
#

Its just for testing. But I guess, it freezes cause your array is empty. Its a simple and not well build code just to explain. Do not rely on it and hope, there arent any errors 😄

neon raft
#

Besides when enabling debug mode in inspector unity bamboozle

midnight violet
#

No need to enable debug mode in inspector tho

neon raft
#

I mean like it dies

#

On unity 6 it doesnt happen but still laggy as hell

#

ANyways Ill try to implement your code into mine and test

midnight violet
#

So I gotta go, but I am sure, you can figure it out. Also realised, the order is flipped, so low values are on right and high on left track, my bad. You can of course call the function instead of putting it in update. Its just for me to test on ispector when adding and changing values in the array

neon raft
#

Its okay as if it works its fine

midnight violet
#

It will at least give you some ideas what you could do with your array 🙂

neon raft
#

Alright thx for the help

neon raft
#

@midnight violet Hey man im getting this error you forgot something? SetKeys: Invalid input AlphaKey array UnityEngine.StackTraceUtility:ExtractStackTrace () DistributeUs:Update () (at Assets/_ASSETS_/_SCRIPTS_/DistributeUS.cs:43)

#

Well its not a big of a deal I figure it out for myself the error

#

I have no idea why but is not detecting any right even tho I flipped them.

#

What I did is parse the spectralflux as it is csharp if (pointInfo[ i ].spectralFlux > pointInfo[ i ].threshold && DistributeUs.heights.Count < pointInfo.Count) { DistributeUs.GradientHeight gradientHeight = new DistributeUs.GradientHeight(); gradientHeight.height = pointInfo[ i ].spectralFlux; DistributeUs.heights.Add( gradientHeight ); }

#

Do I need to change any value in your code or all this is automated?

#

ALso maybe because its on the update it doesnt work properly lemme change that

#

Nope still same result

#

What the hell the value is massive thats why it doesnt detect any right.

#

For example the last value is 30 something ,5 and the rightvalue its like 0,4 something

#

That is weird 0.3 considered as "left"?

#

Maybe like I need to round these variables

#

nope thats even worse

#

Idk no clue

#

Okay not sure what I did but now it works 👍

#

I had to change some values to make it work ```csharp
private void Update()
{
if (heights.Count <= 0 || !proccessdata) return;

heightSum = 0;
heightAverage = 0;
leftAmount = 0;
middleAmount = 0;
rightAmount = 0;

heights.ForEach( h => heightSum += h.height );

heightAverage = heightSum / heights.Count;
float maxHeight = heights.Max( h => h.height );

// Ajustamos los rangos
rightRange = new Vector2( 0, heightAverage * 0.5f );
midRange = new Vector2( heightAverage * 0.5f, heightAverage * 1.5f );
leftRange = new Vector2( heightAverage * 1.5f, maxHeight );

// Actualizamos el gradiente (si es necesario)
UpdateGradient();

heights.ForEach( h =>
{
    if (h.height <= rightRange.y)
    {
        h.track = Track.Right;
        rightAmount++;
    }
    else if (h.height > rightRange.y && h.height <= midRange.y)
    {
        h.track = Track.Middle;
        middleAmount++;
    }
    else
    {
        h.track = Track.Left;
        leftAmount++;
    }
} );

}```

#

Now I need to implement this mess into the other mess

#

But first I'll take a break

midnight violet
neon raft
undone coral
opal wigeon
undone coral
#

they already have an example of it

#

you are reinventing vfx graph anyway

#

right now

bleak citrus
#

can you link to this example?

opal wigeon
#

never heard of it either

bleak citrus
#

In the latter case, it is very easy to just use a 1D array -- maybe with some methods to perform 2D or 3D indexing

opal wigeon
#

I'm in the middle of implementing that, should be easy enough

bleak citrus
#

Yeah. You'll just get it backwards 4 times in a row 😛

opal wigeon
bleak citrus
undone coral
bleak citrus
#

ah, thanks! google was failing me

opal wigeon
#

either way I got the mesh generator working and it's running way better compared to the version without burst and jobs

bleak citrus
#

nice (:

#

just make sure you don't log 3 million times per frame in a job

#

it's a hilarious experience

undone coral
#

Also I think there are assets to do this stuff

barren lodge
#

Im trying to make a simulated programming language but im having trouble figuring out how to handle a print command. I want the user to be able to type some combination of text and variables e.g(something like: print("Words" + variable)) and have it function like the c# print commands. I cant figure out a good way to split up the string and replace any variable names with the respective numbers, then stitch it all back together to be printed. Any ideas?

bleak citrus
#

Oh boy!

#

You're about to learn about parsers

#

you can probably use something like ANTLR to generate the actual parsing code. You'd still need to write an interpreter that can understand the resulting parse tree, of course

#

maybe you just want to use Lua? (:

opal wigeon
#

regex

bleak citrus
#

I mean

#

Depending on the rules of your language, it might be possible :p

opal wigeon
#

probably the easiest way would be to divide the command by spaces into an array and check if the first element matches any command, then use the arguments for that
so something like print a is divided into print and a, the first element is print so you execute the print function

bleak citrus
#

(but it won't work in general for any non-trivial programming language)

barren lodge
bleak citrus
#

yeah, get that sort of idea out of your mind -- it will not work for even very basic languages

scenic forge
bleak citrus
#

It's an enlightening journey!

#

I wrote a Scheme interpreter in Scheme (how silly!) in college, and I taught students about parsing in grad school

barren lodge
#

so far ive been working out references but i do have basic variables, mathmatical expressions ,loops, and if statments working

scenic forge
#

A programming language isn't something you just "make" in an afternoon, unless you are using something like ANTLR mentioned above (at that point ANTLR is making the language for you), it's far more involved than just splitting strings.

bleak citrus
#

You still have to implement the interpreter

#

hey look!

barren lodge
#

oh yea i know making a real language is a ton of work, what im making is not really a whole language just a basic scripting language for a game im making

obsidian relic
# barren lodge Im trying to make a simulated programming language but im having trouble figurin...

Question off the top of my head without really understanding your code/what you want your implementation to be, but, could you like, make a dictionary where all the keys are the variables the player has, then use string.replace? So like, when the user sends a command, you could check if the string contains anything that's a key from the dictionary, and if so, replace that instance with the given key's value? Just spitballing here 🤔

barren lodge
scenic forge
#

You really want a parser that parses the code into AST before doing execution like resolving variable values.

obsidian relic
barren lodge
obsidian relic
#

In essence, this is basically a simulated gameplay mechanic right, so I'm thinking about this as basically a case of handling complex user input, not an actual language im guessing

barren lodge
#

pretty much

scenic forge
# scenic forge Depends on how serious you want to take the "making a programming language" part...

I would really recommend going through the Crafting Interpreters book here, it's free. The first part of the book goes through a parser and a tree walk interpreter, which is the simplest kind. You can skip over the latter half of bytecode interpreter if you don't care about performance. You can skim through the first part in an afternoon and get an idea of how programming languages are actually made, instead of trying to invent your own solution that probably has tons of problems.

obsidian relic
#

There are so many string method's and things you can do.. I always tell myself I'm going to learn more about it hehe. I mean, you could like, split the string into substrings on the space character (' '), then for each of those substrings, check if the substring begins with [ and ends with ] (in my tag system), then if so, we know that substring is a variable

fresh salmon
#

I did a few of these, and when the syntax gets complex it becomes unusable lol
There's StringReader which allows you to scan a string sequentially, and you have full control here

scenic forge
fresh salmon
#

Crafting Interpreters is really good btw, recommend

barren lodge
bleak citrus
scenic forge
#

Yeah hence why we recommend you to read the book, this is more or less a solved problem and see how parsers properly deal with this.

scenic forge
# obsidian relic Why would it not work?

[brackets] would be replaced in the text even though it's not meant to. If you bend the rule and say "yes in my language it will always be replaced that's how it's supposed to work" then there's no way to output [brackets] text without it getting replaced.

obsidian relic
scenic forge
#

And it's not desirable to always replace.

obsidian relic
#

It is for the algo i suggested XD

scenic forge
#

Fundamentally "splitting text by space and inspect each term individually" has the issue that each term does not have the surrounding context. The a in a = 42 has very different meaning compared to print("Eat a bannana"), you simply cannot look at a term by itself without context.

#

If you say "okay, we can look at the terms one by one in sequence, and if we encounter " then we know the future terms are in a string and we shouldn't replace them, until we encounter a pairing " at which point we exit the string mode" then congratulation, you have more or less arrived at how a primitive parser would work. Which is why I suggest taking look at existing resources because people have been solving this problem and perfecting the art for a long time, it's good to stand on the shoulders of giants.

bleak citrus
#

amusingly, this "context" is allowed in a context-free grammar

#

Parsing is the art of un-creating a string

barren lodge
#

this is all a lot of really good info, thx for the help everyone. Im def gonna go read that Crafting Interpreters book

undone coral
barren lodge
#

Its based on a game idea i saw online that seems quite fun. The high concept is you're in a small spaceship that received some damage, your goal is to program basic ship routines to gather resources and repair / maintain the ship using a approximation of a 16 bit computer.

undone coral
#

A game idea you saw online. You mean Markus persson’s spaceship game?

barren lodge
#

what nooo, id never steal from hit game devloper Markus "notch" Persson. (yes it is)

undone coral
#

Should it feel like programming or gameplay? Like is it natural language with rules that aren’t that important? Or is it all about carefully following rules?

barren lodge
echo coral
#

oo a programming game? If i were to id probably integrate something like a lua interpreter or similar

barren lodge
#

im not the biggest fan of using lua but it might be a good idea if i can find something like that

undone coral
undone coral
# barren lodge So far ive been making it a simplified version of C, so it would be following ru...

https://assetstore.unity.com/packages/templates/systems/blocks-engine-2-201602?srsltid=AfmBOor6uZauAP7ZM082YfolMtjPGTjwnpYYK7PegwlrYXd_4FKx9Wr5 it really depends how important it is aesthetically that people type code and make syntax errors lol

Use Blocks Engine 2 from MeadowGames to elevate your next project. Find this & more Systems and templates on the Unity Asset Store.

barren lodge
undone coral
#

do you want people to type at all? how much?

#

the zachtronics games do not make you type

#

if you have to type, to a normal person, it's a lot of syntax errors

#

which is not fun. unless the game is intended to be a syntax error simulator

#

is it aesthetically important that the game have a vibe of retrocomputing programmer bullshit?

barren lodge
#

hmm, that is a really good point to consider. I want it to feel like your using an old terminal based computer. Ill do some playtesting on syntax when i get it into a useable state

undone coral
#

have you ever used an old terminal based computer?

barren lodge
barren lodge
undone coral
#

on the one hand you can make what you are saying

#

on the other hand, you know, it couldn't be a better time, maybe in the history of the world, to make a terminal based typing programmery thing but where syntax doesn't matter

#

because if you ask chatgpt to call functions, it will. like that works

#

so that's why i'm asking, is it a syntax simulator?

#

4 years ago, you could only hope to make blockly, or a syntax simulator

#

but now you could make typing, but it does not have to be a syntax simulator

#

if you do that though, retrocomputing people hate LLM stuff. i mean, unless they are using it to write Arch configurations, in the privacy of their own homes.

#

secretly

barren lodge
#

that is a very cool idea, the only problem i can see is chatgpt charges something like 10 cents per web request

undone coral
#

do you know how much it actually charges

barren lodge
#

not exactly i cant find the documentation

undone coral
#

it's like kopecks

#

the pricing per web request is closer to nanodollars than it is to cents

#

it's all about vibes here

#

so it's whatever vibes you want

#

there's an asset for runtime c# compilation

#

it's easy to write a DSL using plain C# and make that the game

#

and it will feel like C

#

does anyone want to do that? i don't know

barren lodge
#

it seems the free version allows for 3 webrequests a min on gpt 4

undone coral
#

it's insanely cheap

#

it's nanodollars per request

barren lodge
#

oo i was on the wrong page i was looking at the ratelimit page

#

on the free versoin gpt4 is ratelimited to 3 requests a min

undone coral
#

that's not the rate limit for the api

#

i mean, i don't know what you are looking at. you sign up for the api, you put in your credit card, and you can go nuts with requests

#

it's like any other service

undone coral
#

the tier 1 rate limit is 500 per minute

#

which is $5 balance*

barren lodge
#

idk what frequency i need to pay that tho

undone coral
#

it's not 500 requests

#

okay well

#

i know a lot about this

#

i'm trying to tell you what it is

#

so if you want to build a game around it you definitely can

#

people already do

#

this is just an idea though

barren lodge
#

oh wait i think i understand it now, the tiers are just how much money you spent on the account its not a charge in itself

undone coral
#

yes, that's how much you have credited

#

so as soon as you put in a $5 credit, you are tier 1

barren lodge
#

ok i see now, yea that isnt that bad then

#

ill take it into consideration thx for the tip! :)

undone coral
#

i've made a retrocomputing terminal blah blah game

#

and i didn't make people program in it

#

since it was about the aesthetics you did a puzzle adventure

#

it's tricky if you want to do this stuff

barren lodge
#

yea definitely

echo coral
lean spire
#

would it be at all possible to create my own script abstract class type and then create an editor field where users can drag and drop scripts that derive from that abstract into it only?

#

like my own version of MonoBehaviour

lament salmon
#

Not drag and drop but a dropdown instead. Dragging in a "script" would not make sense, because MonoScript objects only exist in the editor.

#

Another option is to have your base class inherit from ScriptableObject so you can drag & drop SO assets

lean spire
#

uh yeah basically im making a simple cinematic builder tool and one of the options is "Custom Script" which would let the user override and write out a custom script to run instead of some blocked actions

#

have another idea might be easier

#

one sec

lament salmon
#

Why not?

lean spire
#

fwiw i might just be unaware of the way to make that happen

lament salmon
#

Each SO needs to be an asset before you can drag it in

lean spire
#

still relatively new to unity but i figured this was an advanced question

#

(on the cinematic SO)

lament salmon
#

That setup looks ok, except you don't need [Serializable] for scriptableobject

lean spire
#

trying to drag MyCustomCinematic

#

yeah the attr is an artifact from poking around

lament salmon
lean spire
#

ShowWhen is my own thing

#

so i can do this

lament salmon
lean spire
#

wait what was that about making the SO an asset?

lament salmon
lean spire
#

can't be abstract though can it

lament salmon
#

Add it to the child class

#

Example...cs [CreateAssetMenu(fileName = "New Child Class", menuName = "MyFolder/Child Class")] public class ChildClassSO : BaseClassSO

lean spire
#

that just opens the script for the child class

lament salmon
#

What opens a script?

lean spire
lament salmon
# lean spire

What's wrong? This is an inspector of an asset instance of the child class

lean spire
#

right, but i need it to make a new child class of CinematicScript i mean

lament salmon
#

You can drag it from the project folders to a a field with the type CinematicScript

lean spire
#

like a unique class where the user can write their own Run override

lament salmon
#

Wat. This was not part of your original question at all

#

Wdym by "user"? A developer?

#

What's the problem? You just made a child class

lean spire
#

i'm trying to rig up cinematic events so non programmers can set scene actions up

#

nvm i think i got an easier solution

lyric lagoon
#

Anyone worked with importing and displaying gaussian splat .ply files in Unity?

I got stuck for a while now, I do believe I am importing position, rotation and color correctly, however the scale of splats seems to be off...
I assume that values in .ply file is at exponential values so while importing data I use Mathf.Exp() function. As if I dont use it, the displayed data doesnt make sense at all. Maybe someone had experience and know what kind of math I am missing?

bleak citrus
#

What if you have the wrong base?

#

Maybe it’s 2, not e

#

Bit of a shot in the dark (:

lyric lagoon
upbeat path
thorn flintBOT
jolly scroll
rare gale
#

- Can Object.InstantiateAsync method instantiate multiple instances concurrently, or is it just one at a time? I'm aware of the overload that takes a number of instances to create, but the docs don't specify whether they all are created sequentially or not

bleak citrus
#

Are you asking if it could spread that work over multiple threads for a large number of objects?

#

I would expect all of the objects to come into existence simultaneously, rather than one at a time, if that's what you're asking

rare gale
bleak citrus
#

oh, you mean if you call InstantiateAsync many times in a row?

#

that's going to be 100 completely unrelated operations

misty glade
# rare gale \- Can `Object.InstantiateAsync` method instantiate multiple instances concurren...

It's likely because this team (that did the instantiateasync api surface and work) were all laid off last year. 😦 https://x.com/_jura_z_/status/1758703011453608298

Before leaving Unity I came up with the idea and wrote the foundation of https://t.co/Nr3k5YBDkJ but couldn’t land it.
My friends Ryan Caltabiano, Matthew Davey, Adam Smith finished the work and landed it! Thanks a lot, guys!
And then their org was completely laid off :(

#

(the documentation being incomplete)

#

I don't know the answer to your question but a light google shows that this feature is not well-implemented..

I would guess that multiple calls to it will be just fine - I'm assuming that multiple calls to it in one frame queue up the engine to start the process in an async manner, and each tick of the game, you check on the result to see if the object's been instantiated [yet] or not and act accordingly.

Since our code works all on the main thread, I don't know how the async implementation works under the hood, but I imagine it will be just fine.. and you should maybe just try it and see what happens :p

bleak citrus
#

It would be completely insane if you couldn't call it twice

#

I'd expect the order of completion to be undefined, of course.

rare gale
# bleak citrus that's going to be 100 completely unrelated operations

- Isn't grouping them merely going to aggregate these many unrelated operations into a large one that's going to take just as long? I'm trying to split the load evenly between many operations instead of doing a large chunk of instantiating, followed by a chunk of configuring instances just as large. I was aiming for a "run X instancing ops -> whenever one finishes, do Y to its result" flow instead of "do X instances -> do Y for all of them"

misty glade
#

the result of the call should be fine for you

bleak citrus
#

allowSceneActivation is badly named here

#

it's inherited from AsyncOperation

#

You can set it to false to prevent the operation from completing -- so it won't do the last synchronous integration step

misty glade
#

yeah - just instantiate a buttload of them, listen to the result every tick, and do the "Y" when the result is "done" for the thing you're making

bleak citrus
#

So, fire a bunch of operations and set allowSceneActivation to false on all of them

#

You can then allow a fixed number of operations to complete per frame

#

oh, there's also this

#

Wild guess: This limits how much time can be spent on integration per frame

misty glade
#

Brainstorming.. I need to draw arrows on my hexes to denote a path. I'm looking for nifty ideas to draw/scale the meshes (I'm planning to use a flat 3d mesh) in the hexes.

My thought is to make an anchor point game object, stretch a hex between point1 and point2, and lerp the size of it so the arrow heads don't overlap (since the anchor point will be right at 0,0 (a few pixels up).

Any better ideas?

#

end result would be something like this:

upbeat path
#

that's not really going to work if the points of ingress/egress are the flat sides of the hexs

misty glade
#

why not..?

upbeat path
#

put 2 of them together\

lament salmon
#

What does "stretch a hex between point1 and point2" mean?

misty glade
#

sorry, stretch a mesh* between the points

lament salmon
#

I don't see why this wouldn't work. Seems pretty standard

misty glade
#

so .. if you take hex1's "center" and hex2's "center".. pardon the ascii art:

[hex1-------A------------------B--------hex2]

A and B would be calculated positions between these center points - and I'd plop the mesh down at A, and tip it towards B, if that makes sense

#

(in the shot above - there'd be 5 of these arrows)

lament salmon
#

Sounds alright to me 🤷‍♂️

misty glade
#

I mean, alternatively, and perhaps better UI, would be to just make one "rainbow" shaped arrow going from the start of the path all the way to the end

#

(instead of small arrows on the path along the way)

#

but the UX I'm trying to improve here is a mouse with a special ability that runs along a path and does damage to enemies along the way.. so the path sorta matters, not just the end destination

#

oh - current UI is to just draw numbers on the tiles which is where this is coming from

#

(I don't love it)

bleak citrus
#

Placing an arrow between two hexes would be trivial, yeah

#
Vector3 pos = (hex1.position + hex2.position) / 2;
Quaternion rot = Quaternion.LookRotation(hex2.position - hex1.position, hex2.up);
#

choice of "up" is slightly arbitrary there, but I presume the hexes are all facing the same way

misty glade
#

the other thing I have to solve is... when the hexes have 3d meshes.. the arrow hex (and the number text above) is obscured.. not sure if I want to do a see-through material for that but.. maybe that's the solution

bleak citrus
#

Perhaps each hex could signal how much clearance you need

#

you'd add that offset to the position

#

this would let you have arrows tilt up and down for free

misty glade
#

hm... i dunno if that's easy for me to figure out.. the level designers plop meshes down willy nilly

#

i'd have to .. do some bound calculation.. and i'm not always sure if the hex will have the meshes underneath them

bleak citrus
#

It looks like you have "clear" tiles and "grass" tiles

misty glade
#

like some levels are gonna have some meshes that are "world" meshes

bleak citrus
#

plus a few tiles with a couple tiny shrubs in the back

misty glade
#

oh, no.. lots of world stuff:

#

(there's hexes under those rocks and stuff)

#

like one level has rocks that get destroyed and enemies come out

bleak citrus
#

you mean over here?

misty glade
#

yeah

bleak citrus
#

that looks totally impassable anyway

misty glade
#

not that i need UI for it, i guess.. yeah, exactly

bleak citrus
#

the mouse can't run up that sheer slope, I imagine

#

I'm only interested in tiles that could plausibly need to display something on their surface

#

There is no "surface" on an impassable tile

bleak citrus
misty glade
#

i have a post processing layer i could put the stuff in.. i think that's gonna be pretty close to the best/easiest

#

lemme slap world text in it and see how it looks

#

hm.. doesn't work..

#

oh, maybe post processing only works for skinned mesh renderers?

#

not the normal mesh renderer

bleak citrus
#

i'm not sure what a "post processing layer" would entail here

#

do you mean the layer that you've put your Post-Process Volume on (meaning that you're using the built-in RP and the Post Processing v2 package here?)

misty glade
#

I think - I didn't build that part, but my understanding is it's some settings in URP that adds something to materials (which we're designating by unity "Layer")

#

meshes on units in this layer have a see through effect:

#

ok so it's a "renderer" that I'm thinking of - looks like my tech artist made a "universal renderer" that has a "render objects" .. thing? that after rendering.. does this:

#

and that material has the coloring and stuff

#

anyway.. I think I could do the same with an "arrow" mesh that lives in world space

bleak citrus
# misty glade

yeah, this renderer feature causes it to draw renderers on a certain layer at a specific point in the rendering process

dull fractal
#

Fen do you got some time to help just dunno anymore

misty glade
#

(since the ability lets the scout move 10 squares.. the arrows wouldn't be easy to see how far you've gone without counting hexes manually)

bleak citrus
#

yes, the numbers seem like a good idea

echo coral
#

just my opinion but if its to indicate the path they take, id have some visual element with it still like a dotted line (perhaps that animates in the move dir?)
Or arrows as suggested. Something that indicates the route and dir even easier than just some numbers.

misty glade
#

Anyone got any tips to improve build times for release versions with the webgl builds? our app takes 40 (!) minutes to build on my reasonably high end dev machine and times out with our CI/CD machine

regal lava
#

I believe they did optimize it a bit more with the release of 6, so may be worth looking into updating and trying it out if you're still on an older version

misty glade
#

Yeah, I'm on 6 but .13 so probably could update.. i think latest is .33f now

#

but 40 minutes is just kinda terrible.. and my CI/CD pipeline doesn't seem to cache things properly so it's building from scratch every time

#

it's timing out anyway (not a unity limitation but my CICD tool) so I can't get the cached stuff done once even

echo coral
misty glade
#

codemagic for the builds

#

i used azure/github actions before but i didn't love it

echo coral
#

where i work we have self hosted jenkins using mac minis as nodes (cus we do android + ios)

misty glade
#

codemagic.io works pretty well for me as far as the .. deploying (to google/apple) part but.. the building part is a little underpowered

echo coral
#

do they limit how long builds can take then if it times out?

misty glade
#

on our pricing plan, yeah

#

i think it's 90 minutes?

#

i'd have to look at the specs

echo coral
#

I guess each time its re importing the whole project hence the shit build time. One thing unreal does better i guess.

misty glade
#

is there any way to .. build locally and then use those files in other locations?

#

i don't even see any cache files in the web gl builds

#

you know how normally android builds have that _SaveThisButDoNotShip folder or whatever, alongside the release artifacts

echo coral
#

that stuff is the il2cpp output for debugging i think

#

Usually the parts that take the most time is asset importing then il2cpp code gen

misty glade
#

i mean, i really wanna use this release build stuff - it lowers our build asset from 90mb to 35mb and it's for the web so it's important.. but man.. it's such a headache to do a release build

echo coral
#

can you not build locally or do you not have access to a mac?

misty glade
#

no i can build locally but the "link_webGL_wasm" step takes forever

#

2231 sec in yesterday's build.. (37 minutes)

echo coral
#

if on windows make sure your project is fully excluded from windows defender or any other anti virus

#

and ofc have the proj on a fast drive

misty glade
#

oh, yeah, i could probably do that.. i have the build assets on my windows pooled drive