#archived-code-general

1 messages · Page 277 of 1

chilly surge
#

That's a really hacky way of doing things.

hard viper
#

i have nothing to add but ditto

past kite
#

Is there something fundamentally wrong with using filename+line as global key?

#

Hm. Haven't tried if you have two files with the same name and start it in the same line of code. No clue what C# does about that.

#

filename might include the path.

cold parrot
hard viper
#

just generally speaking, you should not rate-limit input. you should rate limit the RESPONSE

chilly surge
#

The fact that this happens:

var foo = RateLimiter.Instance;
var bar = RateLimiter.Instance;
foo == bar; // false
RateLimiter GetRateLimiter() => RateLimiter.Instance;

var foo = GetRateLimiter();
var bar = GetRateLimiter();
foo == bar; // true

Is extremely counter intuitive and error prone.

past kite
hard viper
#

a few hours ago, he was talking specifically about a spawner, and spawning too much by spamming input

#

so at least in this case, spawner should have a cooldown

cold parrot
chilly surge
hard viper
#

oh, for a server you mean

#

i thought we were talking more about input as in player input

past kite
chilly surge
#

A very counter intuitive design.

hard viper
#

i was so confused by all the file discussion, mb

cold parrot
chilly surge
#

There's no sane people looking at this behavior and think, yep that's completely fine.

var foo = RateLimiter.GetKey();
var bar = RateLimiter.GetKey();
foo == bar; // false
string GetKey() => RateLimiter.GetKey();

var foo = GetKey();
var bar = GetKey();
foo == bar; // true
past kite
hard viper
#

for servers you really have to gate input, for both congestion and DDOS-like scenarios. Not exactly DDOS, but you know what I mean

cold parrot
#

say if you have a 200 Hz input poll rate (because you are making a golf game) and you may be stalling your handler... you might want to use a dynamic limiter on top of the hard-coded polling frequency

past kite
#

You can now paste this if (!RateLimiter.Instance.passRateCheck(RateLimiter.GetKey(), 1f)) return; anywhere in your code and it will ensure that you pass this barrier only if the rate has not been exceeded.

#

Maybe I should call it /barrier/ instead of rate limiter.

cold parrot
#

anyway, not the point of this disco

past kite
#

I still don't know how you would implement this any different without requiring more code on the side of calling the limiter. Most solutions I found require you to define separate variables or have the problem of deferred calls.

chilly surge
cold parrot
# past kite I still don't know how you would implement this any different without requiring ...
hard viper
past kite
leaden ice
#

It would be cleaner if you have it return a token or something you can use

chilly surge
#

What you are using it for is irrelevant to the implementation.

past kite
cold parrot
#

if you don't use objects in C# you are just making it harder for yourself. the language is not really working well if you do C-style API design

#

you're not required to do all out OOP, but you need to accept that there are objects.

past kite
# cold parrot if you don't use objects in C# you are just making it harder for yourself. the l...

I agree, but my concern is with the top item listed here: https://stackoverflow.com/questions/1407113/throttling-method-calls-to-m-requests-in-n-seconds that you uave to manage "throttle" for every such barrier separately. So if I want need 10 rate limiters in the same functionality, I would need to define 10 rate throttlers. Where in my approach you have only 1 line of code to manage.

#

In my approach, this object is managed implicitly in the dictionary. They key idea is to use filename+line as unique identifier.

cold parrot
past kite
cold parrot
#

if you ever have to change the rate limiter of some of the users, you'll have to validate those changes against all other usages and if you use a different implementation you are fragmenting your code in a hard to trace way.

#

where a "separate instance" implementation would not create any expectations that any other system uses the same implementation or needs to be validated.

past kite
#

Ideally I would like a more streaming approach, so I can add traffic shapers on subscriber notification events.

cold parrot
#

anyway, i don't think your approach is fundamentally bad, its just not something you typically see in C# and it wont survive review in a team project.

past kite
#

So basically key presses become action events, they go into a queue, and then I use filters&shapers on these queues.

#

but I'm worried that this causes too much compute overhead.

cold parrot
chilly surge
cold parrot
past kite
dense estuary
#

because when I used rigidbody last time the movement was super slippery and the player had very little control. There was too much acceleration.

spring creek
#

Also, did you apply any physics materials?

dense estuary
dense estuary
spring creek
#

Ok, yeah, that is the most "slippery" way to use rigidbodies

#

With AddForce, you especially want to use GetAxisRaw

#

GetAxis uses smoothing

dense estuary
#

I'm using the "new" input system now

dense estuary
spring creek
#

Setting Velocity or using MovePosition is less susceptible fo that

cosmic rain
#

Add force is basically how objects move in real life. If you push some object, it will keep on moving until friction stops it entirely.

spring creek
dense estuary
#

or would I need to make them normalized

spring creek
dense estuary
#

Alright, I'll work on movement with rigidbodies I guess.

deep shale
#

does anyone know how to fix the error when trying to reference a volume?
in the screenshot it doesnt show my mouse cursor, but i am trying to drag the volume component into the volume reference.

swift falcon
hard viper
#

if you do WASD input, i believe you get vectors like (1,1)

#

if you use a left stick, I don’t recall if you can get (1,1)

leaden ice
dawn nebula
hexed whale
#

Hello! So, I'm a bit of stuck. I need to determine which data structure to use to improve the (taking 95% according to profiler) worst performance aspect of my game, which is: finding the closest target which has a certain flag in its DamageableModule enabled.
Game is 2D, side view. The world is possibly infinite(auto-generated in the needed direction).
I've looked into spatial hashing stuff, researched quadtrees a bit, but cannot grasp if it's what I need or not.
Currently you can play up to 80-120 concurrent enemies when it's starts to heavily lag.
My current approach(lagging one) is the simplest one, which is, well, to brute BoxCastAll and then filtering the results(in Update). I've added a layer mask, but that did not help much. I understand that I can possibly change layers instead of searching by flags, but that will break things since I have multiple flags enabled, but you can only have 1 physics layer set.

earnest gazelle
#

Can we add runtime navlink using navmesh agent?
For example adding start and end point

mossy snow
chilly surge
hexed pecan
chilly surge
hexed pecan
#

So you reuse an array instead of allocating a new one every time

#

What did the profiler say though? What exactly is causing performance issues?

#

Quad/Octree is an option here, but Physics spatial partitioning is already pretty efficient

hexed whale
# hexed pecan What did the profiler say though? What exactly is causing performance issues?

Wait. May I ask for a difference between BoxCastAll and what I've just found, OverlapBoxAll? I'm extremely sure that the latter is better. And probably the non alloc versions of these two are even better...

Anyways, ~600ms every frame with this code.

public static bool TryGetClosestAttackable(
    Transform startRaycastPoint, float distance, Vector2 boxCastSize, Traits searchedTraits,
    out DamageableModule attackable, LayerMask layerMask, Vector2 direction, bool checkOppositeSide)
{
    attackable = null;
    List<RaycastHit2D> hits = Physics2D.BoxCastAll(startRaycastPoint.position, boxCastSize,
        0f, direction * 1, distance, layerMask).ToList();

    if(checkOppositeSide)
        hits.AddRange(Physics2D.BoxCastAll(startRaycastPoint.position, boxCastSize,
            0f, direction * -1, distance, layerMask).ToList());

    bool foundAttackable = false;
    float minDistance = Mathf.Infinity; 
    foreach (RaycastHit2D hit in hits)
    {
        if (hit.collider == null) continue;
        if (hit.collider.attachedRigidbody.TryGetComponent(out DamageableModule damageable) == false) continue;
        if (FlagExtensions.HasAnyFlag(damageable.BattleTraits, searchedTraits) == false) continue;

        float checkedDistance = Vector2.Distance(damageable.transform.position, startRaycastPoint.position);

        if (checkedDistance < minDistance)
        {
            minDistance = checkedDistance;
            attackable = damageable;
        }

        foundAttackable = true;
    }

    return foundAttackable;
}
spring creek
#

In simple terms

hexed whale
#

Yes, should have mentioned that this part I get about the 2, sorry.
I don't get which one performs better

hexed whale
latent latch
#

One optimization is make sure the components that you're grabbing is part of a GO with limited amount of components

spring creek
latent latch
#

a better optimization is only be grabbing stuff from a layer that has those components but that's usually a little harder to manage

#

rather speaking, filter through layers than doing the comparisons through getcomponent

hexed pecan
little meadow
#

Have you tried deep profiling? Nothing of that code seems 600ms bad to me 🤔

#

OverlapNonAlloc would be faster, buut not 3 orders of magnitude faster

hexed pecan
latent latch
#

nonalloc for sure though since you'd run more into gc problems first honestly

little meadow
#

Not making lists and adding them to each other would be faster

#

But also not 3 orders of magnitude 😄

mild coyote
hexed pecan
latent latch
#

that's actually not that bad of an idea, just iterate through active enemies and compare distances. I'd profile that idea

little meadow
#

Any chance that this is called 50 times a frame?

hexed whale
#

Okay, first things first, I profiled wrong 😅
It's about 60ms from what I can see. Second thing, it turns out, it might not be boxcast, rather this:

#

Which looks like this.

public static bool HasAnyFlag<T>(T flags, T flagsToCheck) where T : struct, Enum
{
    var flagsValue = Convert.ToInt64(flags);
    var flagToCheckValue = Convert.ToInt64(flagsToCheck);
    return (flagsValue & flagToCheckValue) != 0;
}
cosmic rain
hexed pecan
#

Can you expand the Convert.ToInt64 and GC.Alloc hierarchies?

cosmic rain
#

I feel like it's converting a string or something similar

latent latch
#

why not just make all enums long?

#

is there a reason to convert (oh, I see that you do want that generic constraint which is a pain)

knotty sun
#

it's gonna be boxing and unboxing which is expensive

hexed pecan
#

I think you could do something like cs (flags & flagsToCheck) == flags?

#

I'm pretty terrible with flags/bit operations but wouldn't that work?

#

If their sum is the same, then nothing changed

hexed whale
#
[Flags]
public enum Traits
{
    None = 0,
    Enemy = 1 << 1,
    Player = 1 << 2,
    NPC = 1 << 3,
    Props = 1 << 4,
    HasAttacker = 1 << 5,
    //the list goes on...
}
knotty sun
#

should be able to use the Flags attribute and HasFlags

hexed pecan
#

It only has HasFlag

#

Not sure if that works if you want to check if it has any of the provided flag

cosmic rain
#

I feel like it's the conversion to int64 that is the problem. It doesn't make sense in the context too, as enum is an int32 by default

latent latch
#

yes

#

I cant imagine it's because of the bitwise operation since that's the idea of using them instead of doing a bunch of comparisons, but then again I don't know too much about c# in this regards.

knotty sun
#

agreed, it's gotta be the Convert

cosmic rain
#

Just cast the enum to int instead

hexed pecan
#

Making extensions for enums flags is more painful than one would imagine

hexed pecan
latent latch
#

yeah, I do that a bit, but 32 bit enum is usually plentiful

hexed pecan
#

Something like that should work. But then you can't use it as an extension method as you need to know the type (Traits here).

latent latch
#

breaking them down a bit more and doing an additional operation is fine

hexed whale
hexed pecan
#

Yeah I feel that. Making those extensions was too demoralizing for me so I just stopped trying lol

#

I use flags for performance, and having to use Convert kinda defeats the purpose

hexed whale
#

but performance is more important, of course. Will check if converting to int32 is better. if not, then this is the way.

thin aurora
hexed whale
#

highest enum value? eh?

thin aurora
#
void HasAnyTrait<TEnum>(TEnum traits, TEnum traitsToCheck)
  where TEnum : INumber<Enum>
{
  return (traits & traitsToCheck) != 0;
}

Can't you just do something like this? Enums are inherited from numeric types, right?

#

I guess Unity doesn't support INumber yet

hexed pecan
#

Yeah INumber ain't available

#

You got my hopes up for a sec

thin aurora
hexed pecan
#

I hate having to make the same extension methods for every new flags enum type I make

thin aurora
#

But I don't think you can do this easily, you can add a generic constraint to struct and/or Enum (but Enum probably also doesn't exist in Unity), but this probably doesn't allow for something like this

#

You could check what HasFlag does, but I believe it's a big wall of code

hexed pecan
#

Enum exists but you can't really do much with it without Converting it into an int

#

Apparently HasFlag does this

latent latch
#

yeah I don't use hasflag

#

I remember someone linking a whole blog about that a while ago

thin aurora
#

But still really bad

#

So, casting to an integer yourself is not possible?

#

There's no boxing involved as far as I know so that's should not be that bad?

hexed pecan
#

Can't cast from Enum to int, if that's what you mean

thin aurora
#

You can't? Huh

#

Works for me. Integer too

#

Or am I misunderstanding it

hexed pecan
#

Yeah but the thing is that the enum type is known here. It's a Packet

thin aurora
hexed pecan
#

But if you make an extension method, your type must be Enum

thin aurora
#

Oh okay

#

FYI this is what HasFlag decompiles into for me

#

I can't find GetRawData, I kind of hoped it might give a good solution

#

That class has partial files all over the source code, and none have this method

latent latch
#

Right, the problem is generic constraint of type enum here, but that does that specify the bits and to do these bitwise operations we'd have to convert them equally. I do use these for enums which I aren't checking every single frame, but otherwise I just do a dictionary lookup table for enum types and delegates.

#

I could probably ditch the lookup and just specify it directly, but similarly I do these large distance/component checks

mossy snow
# hexed whale posted the code 🙂

I see there's a nice discussion going, but I'll add this: your profiler indicates you are hitting 2500 items in your typical boxcast. If 120 of them are the enemies you're after, then over 95% of the time you're doing useless work in the best case where you always hit all 120 enemies. You might consider moving them to a different layer, or if that's too much breakage maybe it's time to keep them in a list and iterate over that once instead of finding them via boxcast

little meadow
little meadow
# hexed whale Okay, first things first, I profiled wrong 😅 It's about 60ms from what I can s...

A thing to note about deep profiling is that if you have loads of calls inside a function, that would impact the function's "self" time, because some amount of time is spent to measure the things inside.
Which is why deep profiling is good to get an idea about what's happening where, but the measurements do get somewhat off and should be compared to non-deep with Profiler.WhateverTheMethodWas or using Stopwatch

tribal coral
#

This absolutely helped, thank you. I dont really get how things are going to be added over time as its only looking for objects in the Start() method

#

Or am I missing something?

dawn nebula
#

Nah it's removing/adding in update as well (you can see with those Add and RemoveAt methods).

tribal coral
#

The only thing its doing is moving things between the lists. I have to make so that new game objects are checked for all the time

hexed pecan
tribal coral
#

The only solution I had was a for loop but it just gave me more problems 😂

tribal coral
hexed pecan
spring basin
#

not sure if its the right thread but i have this problem where the textmeshprougui components disappear when a object with textmeshpro is spawned in the 2d space, on android devices

#

tried searching only but the threads seem to be open ended

#

tried having different materials for both the objects and it didnt work

cosmic rain
#

Probably not really coding related. Take a screenshot of the object.

spring basin
#

yea couldnt find a thread for textmeshpro specifically :p, so went with general

#

one min

spring basin
#

okay ty

cosmic rain
spring basin
#

okay 😄

hexed pecan
#

@tribal coral I'll try to give an example...
So you have a class (ListenerClass) that wants to know when an object of type ObjectClass is created.
In some class (I'll call it EventClass), create an event that ListenerClass can subscribe to:cs public static event System.Action<ObjectClass> ObjectAddedEvent; // This could also be in ObjectClass - up to you really
And a method that raises the event (called when you want everyone to know about it):cs public static void ObjectAdded(ObjectClass obj) => ObjectAddedEvent?.Invoke(obj);
Now ListenerClass can have a function that has ObjectClass as parameter.cs void ObjectWasAdded(ObjectClass obj) { ... }
Because its parameters match, you can have it subscribe to the event:cs EventClass.ObjectAddedEvent += ObjectWasAdded;
And finally to "raise" the event, the newly created ObjectClass instance can call EventClass.ObjectAdded:cs EventClass.ObjectAdded(this);

#

Oof that got confusing. I tried my best

#

To put it simply: When an ObjectClass ìs created, it raises the event in EventClass. ListenerClass which is listening to (subscribed to) that event will invoke its method ObjectWasAdded and receive the new ObjectClass instance as a parameter

tribal coral
#

That looks complicated lol 😂 I will try

#

Thank you

hexed pecan
#

But events are pretty useful once you get the hang of it

dawn nebula
#

Probably best to explain events in general before tossing the observer pattern at them 😛

tribal coral
#

Thanks

hexed pecan
#

But yeah make sure to read on events in general first

cosmic rain
#

Basically events are a way to say "something happened, whoever's interested, do what you want with it".

tribal coral
#

@hexed pecan it doesnt let me do this

#

EventClass.ObjectAddedEvent += ObjectWasAdded;

#

That or im not getting it lol

hexed pecan
tribal coral
#

I made a event like this:

#

public static event System.Action<GameObject> AddObjectEvent;

#

Is that right??

#

Because I cant seem to access it from the other script

hexed pecan
tribal coral
#

There is no error with that line. I just dont know how i should do this step

#

EventClass.ObjectAddedEvent += ObjectWasAdded;

hexed pecan
#

Well you ofc need to use the class/method names in your project, not my example names

hexed pecan
tribal coral
#

So the first part should be in the object that is being spawned?

hexed pecan
#

Wdym with first part?

hexed whale
# hexed pecan <@587239452045213706> I'll try to give an example... So you have a class (Listen...

@hexed pecan (thought you might find this interesting.. maybe?)
sad, but that infamous tool says that with enums the closest thing to do flag checks is to do this:

public static bool HasAnyFlag<T>(T flags, T flagsToCheck) where T : struct, Enum
{
    return ((int)(object)flags & (int)(object)flagsToCheck) != 0;
}

which helps! but still allocates. and there are no easy ways to fix this due to C# limitations.

tribal coral
#

This: public static event System.Action<ObjectClass> ObjectAddedEvent; // This could also be in ObjectClass - up to you really
And this: public static void ObjectAdded(ObjectClass obj) => ObjectAddedEvent?.Invoke(obj);

rough musk
#

Hello, I was wondering where can I go to ask for some help with a unity project

hexed pecan
#

I think it still defeats the purpose of using flags in the first place

hexed whale
hexed pecan
#

Good to know

hexed pecan
#

Maybe in some manager script, or maybe just in the object's class itself

hexed pecan
tribal coral
#

The this I need to know how to do is this: EventClass.ObjectAddedEvent += ObjectWasAdded;

hexed whale
hexed pecan
#

You can decide where they go

tribal coral
#

So GameObject in my case?

hexed pecan
#

Well, no, you can't modify the GameObject class

tribal coral
#

Mine looks like this

#

public static event System.Action<GameObject> AddObjectEvent;

hexed pecan
#

Don't these objects have any common script on them?

#

Like an enemy script, or whatever these are?

tribal coral
hexed pecan
#

Would be easier if they would. But you can work with GameObjects too. Just need to raise the event from whatever class is spawning them

tribal coral
#

The script is checking how many of a type of structure is close by a structure

tribal coral
hexed pecan
#

How are the structure objects created?

tribal coral
#

With Instantiate

#

But that script is on another object.

hexed pecan
#

That script is the one I mean with 'the class that is spawning them'

#

The point is, someone needs to raise the event when a structure is created

tribal coral
#

Cant I just use the Start() method in the object that is being created??

#

I olny want to know what I should write here: EventClass.ObjectAddedEvent += ObjectWasAdded;

#

What EventClass should I put there?

hexed pecan
tribal coral
#

They have not

hexed pecan
#

It is static so you don't call it with an instance, you call it with the class name

spring flame
#

where is the unity bug reporter if I my unity crashes on launch...

spring flame
#

Is the only way to report unity bug really just via the editor?...

cosmic rain
spring flame
#

some specific problem, I can reproduce it and I know what is causing it, but the bug seems to be in a unmanaged unity engine code

#
Stack overflow in unmanaged: IP: 0x7f5bf6a79e5a, fault addr: 0x7ffe88431f78
Stack overflow: IP: 0x7f5bf69819e5, fault addr: 0x7ffe88429fe8
cosmic rain
#

Is there a stack trace?

spring flame
#

it's happening probabily on the script recompilation stage

#

Yeah, the log itsel has 20k lines

#

I spliced it to exclude repetitions

little meadow
#

Does it include your code?

cosmic rain
#

Can you share some of the stack trace?

little meadow
#

In those 200k lines

knotty sun
spring flame
cosmic rain
#

Not the editor log. The stack trace of the error...

spring flame
#

for example there is SessionId, "Serial number assigned to: ..."

#

yeah, but the editor log contains the stack trace

cosmic rain
#

Well, share the last 20 lines from the log

#

Or so

cosmic rain
spring flame
spring flame
spring flame
cosmic rain
#

What's in this script on line 17?

me.tooster.sdf/Editor/Controllers/SDF/SdfCombineController.cs:17
hexed pecan
#

!bug

tawny elkBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

hexed pecan
#

Apparently there's an exe you can launch from the unity directory

spring flame
#
// me.tooster.sdf/Editor/Controllers/SDF/SdfCombineController.cs:17:
public override SdfData sdfData => Combinators.binaryCombine(
  MergeData,
    GetComponentsInChildren<SdfPrimitiveController>().Select(p => p.sdfData).ToArray()
);

private SdfData MergeData(SdfData d1, SdfData d2) => mode switch
{
    Mode.SIMPLE_UNION => Combinators.CombineWithSimpleUnion(d1, d2),
    Mode.INTERSECTION => Combinators.CombineWithSimpleIntersect(d1, d2),
    Mode.SMOOTH_UNION => new SdfData
    {
        evaluationExpression = vd => AST.Hlsl.Extensions.FunctionCall("sdf::operators::unionSmooth",
            d1.evaluationExpression(vd),
            d2.evaluationExpression(vd),
            (LiteralExpression)blendPower
        ),
    },
    _ => throw new ArgumentOutOfRangeException(),
};
#

wait a moment, I think I'll open the github repo to public to allow for easier browsing.

cosmic rain
#

It kinda looks like an infinite recursion to me

spring flame
#

could be, possibly masked behind some weirder error

cosmic rain
#

You do know that GetComponentsInChildren returns the object itself too, do you?

spring flame
#

but why would it crash the editor?

cosmic rain
#

Because it's stack overflow

#

There are many ways to crash the editor

cosmic rain
#

You can easily crash almost any program. It's not a matter of "why", it's a matter of creativity

spring flame
pallid barn
#

anyone know how to solve this?

#

every single unity game I have

#

crashes

#

I do not know why

cosmic rain
pallid barn
spring flame
#

what is just pretty wild to me is that unity simply crashes and fails to startup instead of catching this error and aborting compilation task...

cosmic rain
#

You'll need to contact the developers of the games that crash. We can only help with your own unity project, not released games

spring flame
#

Now I'm stuck in sime kind of lifeloop, but I think I will manage that, thanks for help btw

pallid barn
#

and its only unity games

spring flame
#

I had similar cryptic stack overflow case once and completely forgot about it

cosmic rain
cosmic rain
pallid barn
cosmic rain
pallid barn
cosmic rain
#

Or at least, they should have a better idea.

pallid barn
#

all unity games

spring flame
pallid barn
#

not one developer

#

if I would contact anyone

#

it would be unity

cosmic rain
# pallid barn I said

And I said contact the developers.
Contact all the developers of all the games that you played.

cosmic rain
pallid barn
#

welp thanks for nothing

cosmic rain
cosmic rain
spring flame
#

dunno, .Net framework 4.5 or something

cosmic rain
spring flame
#

what system are you on?

cosmic rain
#

Then you can contact unity and report a bug report if it happens.

#

Or provide more details in the discord for people to help figure it out.

spring flame
#

Things you could check could also include

  • similar threads in the web (https://steamcommunity.com/discussions/forum/7/2254560552302022403/?l=schinese&ctp=3)
  • do you have any system updates pending
  • are your drivers up to date (and are games using GPU if yu have any)
  • did you install the game (if under windows) to a "correct" directory (some windows directories on more recent systems have some hidden implicit "write permission" restrictions — For example Documents/ directory. You may not exactly know if you have installed to one of those if you don't check where data is installed. I remember once encountering it by installing software to a desktop directory, while desktop directory itself was a kind of "protected" dir)
cosmic rain
#

There's no point. It could be anything. Just because we're programmers, doesn't mean we can magically solve an issue from looking at a screenshot of a crash log without access to the project, source code or even debug symbols.

#

It's like your phone being broken and you go to the company that builds microchips for your phone and ask them to help you while providing a photo of your broken phone.

thin aurora
#

We can help with code, not debugging some game that crashes for you that's not yours

#

Oh they already left, good riddance

timid depot
#

is there any way i can get element scale relative to the world, not localScale?

#

for example:

- Element 1 - scale 0.5
   - element 2 - scale 1.5
       - element 3 - scale 0.5
#

and i want to get scale of element 3

#

which will be 0.375

outer brook
#

just having forgetful knowledge but if I were to find a prompt of wanting a button to be held in order to make an if statement active how do I phrase it as

#

instead of "canbepressed"

timid depot
#

now bolts dont have random sizes

slender urchin
#

Unity2D is their a way to layer your colliders from 2 objects that are overlapping

#

So the raycast from a mouse can pick one over the other

cosmic rain
swift falcon
hard viper
#

I think i need a better method to control multiple UI menus, layered on top of each other. Right now, I use an enum for the UI state, and use that enum to target specific gameobjects to turn them on or off.

#

But this system sucks when you nest menus, because any “parent” menus need special cases to stay on.

#

Any recommendations for how to handle in a simple way?

#

I’m contemplating making a tree data structure, but idk if there is a simpler way

round violet
#

might be a werid question, but i was wondering if i can make a line break in the comment that is showing when hovering

hard viper
#

yes. i forget the syntax tho

round violet
#

ill try google it

hard viper
#

look under xml, i think it’s called paragraph or something

round violet
#

well its <br/>

#

like html

hard viper
#

yeah. xml docstrings have features, and are really good.

leaden ice
#

HTML is XML BTW

round violet
#

you can trick VS and use para aswell

round violet
#

can you have a private set let you set the value from inspector ?

#

i have a var that will not change at runtime, but I want to set it using a compoennt in the scene

hard viper
#

yes

wide dock
#

Serialize the backing field

hard viper
wide dock
#

if it's an auto-property then [field: SerializeField]

hard viper
#

yeah. or serialize the backing field like caesar said

round violet
#

ty

#

what does [field: SerializeField] mean for Unity ?

hard viper
#

[SerializeField] private int _myValue;
public int MyValue {get => _myValue; set { _myValue = value; }}

hard viper
#

in this case, you defined an auto property, so field: makes the attribute target the automatically made backing field for it

#

this works for other attributes as well

round violet
#

👍

hard viper
#

for reference: [field: SerializeField] private int _myValue;
is the same as
[SerializeField] private int _myValue;

#

as it is already a field

mossy garden
#

hello, how can i drag a gameobject from one scene to a field in the inspector of an object from another scene please ?

mellow sigil
#

You can't

mossy garden
#

thanks

mossy garden
# mellow sigil You can't

can i just have a button that modify the value on one scene, and the text from the other scene just display the variable ?

#

it's what im trying to do with the cross scene drag and drop

mellow sigil
#

You should have a DDOL object that exists in both scenes and store the value there

mossy garden
#

i use playerprefs to store the value

mellow sigil
#

Then what do you need the gameobject for?

mossy garden
#

i have a button that increment the value on scene1 and a text that displays the value on scene2. i had a script that needed to link the displaying text to the button

mellow sigil
#

That's still a job for a DDOL manager that handles all that

mossy garden
#

i've never done that before :) i'll give it a try

mossy garden
tribal coral
#

@hexed pecan I DID IT!!!

#

Not in the way you wanted but I solved it! 🥳

mellow sigil
#

The only thing different about DDOL is that the object isn't destroyed when a scene unloads

mossy garden
mellow sigil
#

no

mossy garden
#

so if i want them to stay should i use a DDOL anyway ?

mellow sigil
#

That has nothing to do with persisting the values. You'd use playerprefs for that just like you've done so far

mossy garden
#

but it doesn't work

#

i want a button to increment playerpref value and a text to display that value

mellow sigil
#

Yes, and for that you make the DDOL controller object

mossy garden
#

i'm struggling lol

hexed pecan
mellow sigil
# mossy garden i'm struggling lol

Linking the button with the text and storing the value between sessions are two different problems with two different solutions. Don't try to find one solution that would solve both of them at the same time, that doesn't exist. Solve them separately.

mossy garden
#

i'm trying my best x)

tribal coral
# hexed pecan What did you do?

I made two scripts. One checking for already placed object which is on the reciever and one which checks for nearby structures when its built which sits on the sender. The sender then calculates the distance and sends over information adding to the counter if its close by.

I made it over complicated at first but then I understood what I had to do

mossy garden
#

or should i create one for every link i'll make

mellow sigil
#

Yes, one is enough

mossy garden
#

i have many buttons to links to text and many variables to store

#

ok thanks

#

a few

tribal coral
#

How do you get a code box when pasting from vs??

hard viper
#

is there a good tool already for managing nested menus?
Specifically:

  1. Child menu => all parent menus stay enabled in background, but not interactive.
  2. Inputs work like a simple FSM, that let you navigate to certain menus from others.
tawny elkBOT
tribal coral
#

Thanks

#

@hexed pecan thank you for your help even though I didnt end up using it. I will probably use it sometimes in the future though

thick terrace
pearl bay
#

hi! i'm new here. sorry if this is the wrong channel, but i'm curious if somebody could help me with clamping and inverting a quaternion? I've tried Quaternion.Inverse() and tried converting to euler angles and clamping the appropriate axis and recombining the axis, but neither seem to work. I'm happy to include footage if it helps explain my issue!

I should clarify that I'm using the IMU of two Joycons as prototype VR controllers. That's what the initial Quaternion rotation is sourced from. 🙂

hard viper
#

this is such a common problem, i feel like there have got to be tools for this already

thick terrace
#

like a no code way to define your states? or what do you imagine it looking like?

hard viper
hard viper
# pearl bay

clamping a quaternion doesn’t make sense imo. you would clamp euler angles used to make a quaternion

pearl bay
#

That's what I said above 🙂

hard viper
#

converting a quaternion to euler angles isn’t quite a perfect transition. so quaternion => euler => clamp => quaternion will have problems

pearl bay
#
                case RotationType.TESTROT:
                    var testInput = playerHand.localRotation.eulerAngles;
                    testInput = new Vector3 (Mathf.Clamp(testInput.x, 45, 115), 0, 0);
                    pivotPoint.transform.localRotation = playerHand.localRotation.normalized;
                    pivotRb.MoveRotation(Quaternion.Euler(testInput));
                        break;
#

oh, i see! so really this is going to be trickier since i'm starting with a quaternion regardless?

hard viper
#

yeah, it’s going to be a little trickier imo

#

point being the math is just different

pearl bay
#

I've been reading into quaternions over the past two days in hopes that something would click, but ultimately it just seems like quaternions are very inaccessible.

#

and not really designed to be tweaked?

hard viper
#

think of a quaternion like a rotation operator. you do not try to dig into the guts of an operator

pearl bay
#

ofc!

hard viper
#

you apply operators to operators etc to get what you want

thick terrace
pearl bay
#

i was hoping that i could take the local rotation of the lever and multiply it by a localized IMU quaternion to basically send it in one direction when motioned

mellow fossil
#

after jumping multiple times

hard viper
mellow fossil
#

anyone ?

#

heres my code

pearl bay
#

and that much works, but i'm not able to lock the lever's rigidbody axises since it isn't a physics-driven function, it's hard-setting the rotation.

hexed pecan
pearl bay
#

With that, I built my own quaternions with only one axis.

#

but then everything is inverted, even if i use Quaternion.Inverse()

hard viper
thick terrace
hard viper
#

it’s ok. my system is already like that, and I want to move away to a smarter one lol

#

as in different architecture

pearl bay
#

i guess ultimately, i'm wondering why the quaternion will not invert, using Quaternion.Inverse() as it should be doing

hard viper
#

why are you inverting anything tho

#

you’re trying to constrain a rotation

pearl bay
#

i'm doing both

hard viper
#

well just focus on one at a time

pearl bay
#

because vert and horz rotations are inverted

#

i almost had the whole thing done but got stuck flipping the rotations

#

so i went back to the start and ended up here now

hard viper
#

apply quaternion to vector, represent vector in spherical coordinates, modify vector, then generate new quaternion based on the operation to go from old to new vector

pearl bay
#

i think since angles are modular and wrap, i should just add rotation rather than entirely replace it right? that's my understanding

swift falcon
pearl bay
hexed pecan
radiant elm
#

maybe because they are triggers?

hexed pecan
#

Well, that too

swift falcon
hexed pecan
#

But having non-trigger colliders doesn't automatically make them avoid obstacles

radiant elm
#

good point

vagrant blade
#

@swift falcon Please don't crosspost. Stick to a channel.

swift falcon
hexed pecan
#

I don't think the builtin NavMesh works with 2D so you might need something else

hard viper
#

quaternion methods can handle turning different representations into a quaternion

#

but you need to be able to do the math to articulate wtf you actually want

pearl bay
#

I just know how I want it to behave

hard viper
#

but how do you want it to behave

#

the computer is not psychic

pearl bay
#

I have the player's hand, which i'm currently feeding a transform to the lever via interface

hexed pecan
#

@swift falcon Search for unity 2d pathfinding

pearl bay
#

and i want the lever end/handle to track to the player's hand, by rotating the lever's pivot

hard viper
pearl bay
#

as well as that, i want it to be clamped A) to one axis and B) to a range between two angles

swift falcon
swift falcon
#

❤️

hard viper
#

you can represent a restiction in angles as clamping a specific angle in a spherical coordinate system

#

idk if unity has a tool to do that, but if you have the equations already, you just need to type that shit in

#

doesn’t matter how complex the math is, if you are just copying

#

https://en.m.wikipedia.org/wiki/Spherical_coordinates This article should explain how to interpret the variables

In mathematics, a spherical coordinate system is a coordinate system for three-dimensional space where the position of a given point in space is specified by three numbers, (r, θ, φ): the radial distance of the radial line r connecting the point to the fixed point of origin (which is located on a fixed polar axis, or zenith direction axis, or ...

pearl bay
#

i burst out laughing opening that webpage my god

#

that algorithm is horrifying

hard viper
#

terrible to solve, but not to copy paste

pearl bay
#

i'll be right back, but thanks very much for your help. i'll take another shot at clamping things and if it doesn't work i'll come back crying 🙂

hard viper
#

fyi, you only need theta and phi. These are the zenith and azimuthal angles. Clamp those, then convert back to cartesian.

#
theta = Mathf.Atan(Mathf.Sqrt(vec.x * vec.x + vec.y * vec.y)/vec.z);
rho = vec.magnitude;

//clamp phi and theta.

//Come back
x = rho * Mathf.Sin(theta) * Mathf.Cos(phi);
y = rho * Mathf.Sin(theta) * Mathf.Cos(phi);
z = rho * Mathf.Cos(theta);```
#

then Quaternion.FromToRotation from your input vec to the new xyz

pearl bay
#

isn't division on FixedUpdate poor optimization?

#

would Mathf.Atan(vec.y*-vec.x) be better?

spring creek
pearl bay
#

oh okay, thank you for clarifying!

#

back in uni, they told us to consider optimization but never how much we should optimize 🤦‍♀️

hard viper
#

division used to be bad in the N64 era, where division would take 4-6x longer than multiplication. Now not so much

hard viper
#

1000 divisions per fixed update isn’t going to do shit

pearl bay
#

okay great, thanks so much

hard viper
#

the only caveat there is checking you aren’t dividing by zero

pearl bay
#

oh i heard about that actually being really bad computationally lmfao

spring creek
hard viper
#

yeah, you need to check first. 100 zero division errors being thrown will basically destroy your performance, and also make the game literally not work

pearl bay
#

i guess it was older computers - like pre-GUI computers - that had that issue

hard viper
#

throwing an error effectively slams the breaks on the program, meaning the whole part where you assign the rotation does not happen

spring creek
pearl bay
#

that's when a script is disabled, right?

hard viper
#

i would just preprocess x and z to make sure their absolute value is no less than some tiny number

#

dividing by 10^-6 would send this algorithm way off course anyway

#

actually, the trig functions can probably handle weird shit, so maybe

#

note ATan probably gives output in radians

outer brook
#

Hi, I am making long notes for a rythm game and I want to have the note destroy after it passes though I am left unsure on how to make it work

hard viper
#

(programming tends to punish people who slept through high school math)

spring creek
pearl bay
#

i definitely didn't sleep thru high school math, but its been a loooong time since high school for me

little meadow
hard viper
#

we had a guy a few months ago making a football game. slept through high school math. he could not do basic algebra, so his football game effectively died.

pearl bay
#

oh that poor soul

hard viper
#

it’s not something you need every day. but it is something that comes up enough to be necessary

little meadow
#

I know a lot of people with poor math skills who do great as app / BE devs.... but in game dev math comes A LOT more often, yeah

outer brook
#

what I need is a way for the game to be demanding to keep holding the button

little meadow
outer brook
#

yeah that's what I am doing now, just need to set the if statement correctly so it can deactivate after the duration

little meadow
#

or you compare the down with the start and the up with the end of the note

steady moat
little meadow
#

ah, fair, fair 👍

steady moat
#

It was like: As a designer, you need good math but as a programmer not that much.

little meadow
#

that is somewhat true though, isn't it?

#

game designers also need more math than programmers 😄

steady moat
#

Not at all ?

little meadow
#

ah, you mean designers as in people who do visuals, UI, UX? yeah, they probably don't need much math

steady moat
#

Game Designer as people that design the system or the level. Such as what X enemies will do or how the game will progress

little meadow
#

those things do need some math-ing though, no? for balance reasons and to understand scaling of things and what to expect (which not every game needs, I guess, but from what I hear they do use math not too rarely)

#

anyway 🙂 yeah, I was talking about non-game programming vs game programming specifically

pearl bay
#
                case RotationType.TESTROT:
                    Quaternion q = new Quaternion
                        (-playerHand.rotation.x,
                        -playerHand.rotation.y,
                        playerHand.rotation.z,
                        playerHand.rotation.w);
                    pivotRb.rotation = Quaternion.Euler(q.eulerAngles);
                    Debug.Log("Hand rot:" + playerHand.rotation.eulerAngles);
                    Debug.Log("Lever rot:" + pivotRb.rotation.eulerAngles);
                        break;
#

okay so same situation, i am unable to reverse the axis of the quaternion without throwing off the entire rotation and causing it to change orientations.

#

does anybody have any recommendations?

#

besides that, it works just fine

little meadow
#

oh, no no, if you do new Quaternion(x,y,z,w) you can't ask questions about rotation, that's the rule

pearl bay
#

again, clamping will be easy with the way it's setup

pearl bay
little meadow
#

exactly

pearl bay
#

really though, i am so confused, i'm not sure what to do with this

#

if i use eulerangles, i assume that the orientation will always be the transform.up of the world

#

but that doesn't seem to be the case?

#

i understand that it's 180 degrees around the center point so it goes from 90 to -90

little meadow
#

what's the objective? how should the object behave?

pearl bay
#

it should follow the player's hand, but the rotations are all reversed

#

to give the illusion that the player is physically grabbing and pulling the lever (the hands in=game are controlled with two joycon controllers)

little meadow
#

ah, okay... and the thing can only be rotated in one axis?

pearl bay
#

it will be only rotated on one axis, but the axis all get switched around whenever i invert an axis to correct their rotations

#

so if i invert the Y axis, suddenly Z and X are swapped

#

which is making setting the quaternions up very confusing, especially since you can't visualize them in editor

little meadow
#

so you need the player's hand position relative to the center of rotation... project it on a plane with a normal that's the axis of rotation... and then... multiply the current rotation with a FromTo rotation between the current direction of the thingy and the projected direction you calculated 🤔

#

that sounds a bit more complex than I'd like... 🤔 but should work, I think

#

you'll position the handle so that it points at transform.right from the object that you're rotating, and the axis of rotation will be transform.forward... and then it's just

var targetDir = Vector3.ProjectOnPlane(playerHand.position - transform.position, transform.forward);
var rotation = Quaternion.FromToRotation(transform.right, targetDir);
transform.rotation *= rotation;

where transform is the object that you're rotating with its position being the center of that rotat-y thing
@pearl bay

#

hope that helps 😅

hexed pecan
#

Isn't this just basic "look at" or am I missing something..?

pearl bay
#

I tried look at, it didn't work!

#

I guess direction could be done with look at

#

but it needs to ONLY rotate on one axis and be clamped, so lookat can't be used to pivot it

chrome trail
#

This might be a bit of a strange question, but is there any way I can bisect a navmesh along a line like this and calculate the area of the two halves?

hexed pecan
#

And then clamp and apply that on that one axis only

pearl bay
#

signed means it can be a negative or positive value, right?

hexed pecan
#

Many ways of doing it. I just noticed the real mathy stuff before and thought that it's over complicating it

hexed pecan
pearl bay
#

oh amazing, thank you!!

#

i'll try that now

#

is the axis argument normalized?

#

like (0,0,1) being Z?

#

it asks for a Vector3 but ofc that doesn't make sense

hexed pecan
#

Axis length doesn't matter

#

But yeah 0, 0, 1 would be Z. Make sure it is relative to the lever tho

pearl bay
#

var angle = Vector3.SignedAngle(playerHand.rotation.eulerAngles, pivotRb.rotation.eulerAngles, pivotRb.transform.forward);

pearl bay
#

oh no

hexed pecan
#

It takes in directions, not euler angles

#

Check the docs!

pearl bay
#

oh my bad!

#

is it okay to leave local variables without a type too?

hexed pecan
#

Like var you mean?

pearl bay
#

i could clarify Vector3 but i'm not sure if it's necessary beyond readability?

#

mhm!

hexed pecan
#

That's up to you. I personally use var a lot. Depends on how clear it is from the right-hand side

hexed pecan
#

So yeah maybe be explicit about it

pearl bay
#

sorry i'm just between this chat and working so i'm not thinking, i meant float sorry ;p

hexed pecan
#

Np

little meadow
#

🤦‍♂️

#

yes, that was pretty much a LookAt aligning right instead of forward...

#

and now when we put it like that... just do transform.right = handPosition - transform.position 😄

#

and make sure the hold-y part goes to the right of the object... or if forward or up just set forward or up 🙂

hexed pecan
#

This would make it rotate on potentially all axes

little meadow
#

right, so do the ProjectOnPlane thing

pearl bay
#

okay so when grabbing the lever, i need to consider changing the transform direction, and then clamp it as i am doing?

little meadow
#

that would give you a direction that's on the proper plane so that it only rotates around one axis

pearl bay
#

how is subtracting one position from another (which isn't normalized) be okay to set to a normalize value like a direction?

#

does it normalize it automatically?

little meadow
#

in this case specifically it does, yes

pearl bay
#

why is that?

little meadow
#

but you need this to be on one axis ```
var targetDir = Vector3.ProjectOnPlane(playerHand.position - transform.position, transform.forward);
transform.right = targetDir;

pearl bay
#

sorry for all the questions!

little meadow
#

because Unity implemented the setter of forward/right/up to normalize the value you give it 🙂

pearl bay
#

i see, thanks

#

hotloading between all of these little tweaks to the script is trying my patience. please pray for me.

unborn shard
#

I don't speak English, I'm translating with Google so it might be a little out of context.
I'm having a problem with the lives system. I'm following a tutorial on YouTube. Everything is OK in parts, I put the lives correctly, when he loses 5 lives he dies, but he is not appearing visually. When I lose life I was supposed to change the sprites for the empty heart, but it only changes when I lose 5. Please help me.

#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class sistemadevidas : MonoBehaviour
{
public int vida;
public int vidamaxima;

public Image[] coracao;
public Sprite cheio;
public Sprite vazio;



// Start is called before the first frame update
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    if (vida <= 0)
    {
        HealthLogic();
        DeadState();
        
    }

   
}

void HealthLogic()
{
    if (vida > vidamaxima)
    {
        vida = vidamaxima;
    }

    for (int i = 0; i < coracao.Length; i++)
    {
        if (i < vida)
        {
            coracao[i].sprite = cheio;
        }
        else
        {
            coracao[i].sprite = vazio;
        }

        if (i < vidamaxima)
        {
            coracao[i].enabled = true;
        }
        else
        {
            coracao[i].enabled = false;
        }
    }
}

void DeadState()
{
    if (vida <= 0)
    {
        GetComponent<movimentoplayer>().enabled = false;
        Destroy(gameObject, 0.1f);
    }

}

}

tawny elkBOT
unborn shard
knotty sun
little meadow
#

so, like in real life, right? 😄 you only care about your health when you're between dead and very dead 😅

unborn shard
#

Wow, I didn't even see that there was that hahahahaha, being a beginner is tough. thank you friend.

#

it worked here blushie

knotty sun
unborn shard
marsh wadi
#

I have an annoying problem where I want to save some replay data when I exit play mode* (or when exiting the game for that matter), but since the order of OnDestroy calls is seemingly random, I don't always have this data available anymore.. is there a workaround for this?

lone echo
#

Can Someone Help me?

using UnityEngine;

public class SpaceBackground : MonoBehaviour
{
    public bool rotateAstronaut = true;
    public GameObject astronaut;
    private float rotationSpeed = 50f;

    public bool moveBackground = false;
    public GameObject background; 
    private Vector3 backgroundSpeed = new Vector3(50f, 0f, 0f); 

    void Update()
    {
        if (rotateAstronaut && astronaut != null)
        {
            astronaut.transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime);
        }

        if (moveBackground && background != null)
        {
            background.transform.position += backgroundSpeed * Time.deltaTime;
        }
    }
}

https://www.youtube.com/watch?v=mdedHvFjJuQ

#

I want that the Background is looping

round violet
#

lets say that my player got a backpack

the backpack can :

  • be on the back of the player (attached with the player movements)
  • placed on the ground (fixed to the ground)

for now i found two possibilities :

(1)

  • changing parent to Player/None when the player drops/pickups the backpack

(2)

  • the backpack is never parented to the Player (its parent is the scene root), instead we have a Update that sets the position of the backpack if the Player has it on its back

what would be the best solution ?

knotty sun
#

there is also Parent Constraint

heady iris
#

I start with parenting, then do something else if something makes parenting problematic.

round violet
#

ill test it and see

knotty sun
#

Fen is right, parenting is probably the best option if possible

#

can be problematical if both player and backpack have rigidbodies

round violet
#

they will have

#

just tested parent constraint and seems to have all the features i need, ty again

hard viper
#

I’m thinking of a system to stage collision callbacks. I currently have ObjCollsion : Monobehaviour, which has OnCollisionEnter/Stay/Exit2D, and it then invokes Action<ObjColData>, which is a simplified struct of collision data. ObjCollision.onCollisionStay is that action which all of my classes subscribe to for triggering collision callback logic.

Right now, I am thinking about effectively sorting logic so it can go off after collision callbacks in a sorted way. eg contact state checks go first, then reference frames, then pushing/pulling, then death detection logic, then death execution. This way each function can rely on a certain set of assumptions of what is ready or not.

#

I do currently have a class that can invoke a certain function after all collision callbacks are done. I am thinking about making enum PostColCallbackStage with values for the above stages. And I’d like something like:
ObjCollision.onCollisionEnter += MyFunction, but to actually call it at a given stage.
Recommendations?

little meadow
chilly surge
#

You could just expose many different events and subscribe to the one of your interest.

hard viper
#

one per rb

chilly surge
#

(Although I personally dislike using conventions as a way to prevent logical errors)

little meadow
#

You want to handle collision checks and have an updated "collision state" and only then do all the processing of said state? (after ALL collisions are detected?)

hard viper
#

it’s not a perfect solution, obvs. But it’s kind if awkward for something that fills up contact state to occurr before or after something that causes death.

#

Depending random order

hard viper
little meadow
golden garnet
#

So apparently Unity doesn't allow animation events to be used that contain a bool parameter?

#

Why?

hard viper
#

idk, I’ll think about it some more

#

ty guys

wicked scroll
chilly surge
#

A subscriber can declare that "call me after A, B, and C have finished, and I'm going to do D and E." The event can take information of all subscribers and produce a deterministic call order that satisfies everyone.

simple egret
# golden garnet Why?

By design, I guess. As an alternative you can accept an int and convert it with something like this:

public void EventHandler(int v)
{
    bool b = v != 0;
}

Pass 0 for false, anything else for true.

chilly surge
#

This avoids a need to declare a convention of "stage 1 does A, stage 2 is only called after stage 1 so you can now safely assume all works of A has been finished, etc" because that kind of system is extremely fragile and requires you to go into the event emitter and read its code (or have it properly documented) to know the order.

golden garnet
simple egret
#

Especially when other kinds of events (like UnityEvent) allow methods with a bool parameter

chilly surge
# chilly surge This avoids a need to declare a convention of "stage 1 does `A`, stage 2 is only...

Lots of systems do things like that (having an arbitrary number to indicate order) and you know how they all end up, systems like script execution order, z-index in CSS, etc. The amount of codebases that have completely irrational z-index in CSS is hilarious, because someone comes along and be like "A used to be the top most thing so it has a z-index of 9999, but now I have a new thing B that I want to be top most even above A, guess I'll make the new thing to have a z-index of 99999" and eventually every time someone wants to modify z-index they have to search the entire codebase to see what values there are.

hard viper
#

so like an enum flag that describes all dependencies of prior work that must be done?

golden garnet
#

Also found out that animation events cannot contain more than one parameter. Super lame.

little meadow
#

What Burrito says is a super cool system... but also seems like extra high effort. (I'm a big fan of KISS, so I feel that whenever things get complex, it's a good time to take a step back and think of simpler solutions and whether something is needed 😅 )

chilly surge
# hard viper so like an enum flag that describes all dependencies of prior work that must be ...

Sure, the representation of dependencies could be enum or could be something else, it doesn't really matter. As long as each subscriber clearly describes intents (before you call me, make sure all modifications to player position has been completed, and I'm going to modify player health) then the event emitter can be like, okay I'm going to put you after all event subscribers that modify player position, but before all other event subscribers that need player health to be finished modifying.

hard viper
#

how would I implement this, tho?

wicked scroll
chilly surge
wicked scroll
#

i would start there since that's pretty simple -- are your systems simple enough that you can assign each a group and then order those groups? cause then you don't need to do any programatic dependency resolution

chilly surge
#

That's basically the magic execution order approach yes, which will work for most simple systems.

wicked scroll
#

kind of, it has much more explicit intent than assigning random numbers

#

much more readable/understandable when you come back to it later

little meadow
#

what's not understandable about 153?

chilly surge
#

I wouldn't say so, you can give meaning to "random numbers" by using enum, const int, whatever, so instead of .Subscribe(9999, OnFinalize) you would write .Subscribe(Stage.LateUpdate, OnFinalize)

#

That doesn't stop it from still being a random number under the hood, because ultimately if you need a new stage, you have no choice to but go into the definition of those numbers and change things around.

golden garnet
#

Any ideas on how to make an animation event hold multiple params?

wicked scroll
hard viper
little meadow
#

well, you'll space them out so that most of the time you wouldn't need to change others, just insert in the right place... but all in all if you do something else, you'll probably still need to change things around when you need a new stage, because some old stuff will now need to be after it, and it will need to be after some things, so you'll need to know what all things are to put it there

wicked scroll
#

yeah, enums exist because giving names to magic numbers has a lot of value

hard viper
#

but that runs into the convention problem burrito was talking about

wicked scroll
#

yeah, i mean if you have the time and budget to build and maintain a system to handle all of this, by all means go for it

#

i just would argue that most games people are working on here need not be, and should not be written in a way that is that complex

hard viper
#

i’m not exactly sure how I plan to very quickly sort these dependencies if they aren’t like a non-flag enum based order

wicked scroll
#

you don't have to sort them quickly, you can cache the depenency map

chilly surge
#

Yeah for z-index abuse, if you use any modern CSS you'd get to properly put all your magic numbers somewhere together, which solves at least the "anytime I want to change something let me search the entire codebase for all z-index values first" problem, but ultimately these types of systems still rely on "using convention to prevent logical errors" which sometimes is good enough, sometimes it's not. Entirely depends on your need.

wicked scroll
#

iirc there's a pretty in-depth gdc talk about how they did this on destiny

little meadow
#

@chilly surge with a system like you describe, is it gonna be better? you'll need to know all things you can depend on... and when a new thing comes, some of the old ones may need to start depenging on it, which will be super annoying to setup, no?

wicked scroll
#

any of these automatic job systems need to do similar stuff so that's a good place to look for implementation ideas if that's what you want to see

#

same with ECS frameworks which tend to order systems

wicked scroll
chilly surge
# little meadow <@451999506918277131> with a system like you describe, is it gonna be better? yo...

The thing is, the subscriber knows what itself depends on. I know I'm going to need A, B, C to finish before I want to run, and I know I'm doing D and E. I do not need to know what other subscribers are doing. All modification to myself can stay local, if I suddenly no longer need C to finish before I run but instead need F, I modify my own code and that's it.
In a system with numbers representing execution order, if I need to change -C +F, I need to go into the definition of these execution order numbers and see which one would work, and if there isn't one that would work, I need to add a new number, which can potentially affect other subscribers.

#

If you are inserting yourself into middle of the execution, you also need to check "okay will any subscriber executing after me get affected by what I do?"

hard viper
#

that is fair

#

that is the common issue

#

i think I might do it with the basic enum, and later I can change the underlying implementation to a flag enum to check dependencies. Mostly because OnCollisionStay is going to get me some giant lists.

#

and I cannot envision what burrito is saying being done in one pass.

#

you need multiple passes to figure out the order

little meadow
#

It's never a bad time to mention that OnCollisionStay is sad performance-wise 😛

hard viper
#

i know

#

if I could have avoided it, i would have

#

i have no choice in my case

#

and it hurts

little meadow
#

I recently recoded part of Oculus VR SDK to kill OnTriggerStay and improve performance... it was eating TONS of time, even after we tried to be smart with layers 😦

chilly surge
#

Btw if at compile time you know all of your subscribers and their dependencies (so no dynamically created subscribers with dynamic dependencies), then you can solve the execution order at compile time and generate the magical execution order numbers, so there's no runtime cost of solving dependencies.

hard viper
#

my custom physics engine is already kind of caveman-like, as every object calls .Cast like 10 times per fixed frame

hard viper
little meadow
#

ah... custom physics engine... okay, in that case you know best 👍

hard viper
#

yeah, unfortunately, I still need unity to calculate contacts, because its methods don’t work to parse collisions with multiple contacts of different normals/points

#

otherwise, my collision callback system would be custom as well, and much smarter

chilly surge
hard viper
#

yeah. it’s one of those things where it would take me at least 2 days to figure out how to do and implement, when magic number enums will probably get me there

little meadow
#

2 days is extremely optimistic

hard viper
#

i do not expect a big web of nonsensical crap dependencies for my game. the core things that need ordering are contact state generation, general callbacks, logic that triggers death, followed by actual death

#

and none of these should be allowed to depend on something below it in that order, or I have a bigger problem

marble mauve
#

how I can change the alpha value of an image

rigid island
marble mauve
#

and what is the prop of the alpha channel? of the color

rigid island
#

dot a

marble mauve
#

so image.color.a

rigid island
#

yea

marble mauve
#

thanks

rigid island
#

but its prop you cannot directly modify it

#

make a copy and apply it back

#
var col = image.color;
col.a = 0;
image.color = col```
pearl bay
#

@hard viper @little meadow thank you very much for your help!

#
                case RotationType.TESTROT:
                    Vector3 targetDir = Vector3.ProjectOnPlane(playerHand.position - pivotRb.transform.position, directionRef.forward);
                    pivotRb.transform.up = targetDir;

                    Vector3 clampedDir = new Vector3
                        (Mathf.Clamp(targetDir.x, minAngle, maxAngle),
                        targetDir.y, targetDir.z);
                    pivotRb.rotation = Quaternion.Euler(clampedDir);

                    bool approxValue = Math.Abs((pivotRb.rotation.z * 360 ) - successAngle) < 0.1F;
                    if (approxValue)
                    {
                        Debug.Log("Success!");
                        puzzleSuccess = true;
                    }

                    break;
#

this was my code in the end

marble mauve
pearl bay
#

it's defintely functional now.

rigid island
#

all values are 0-1

#

Color32 only is 0-255

pearl bay
#

i feel like maybe some of it could have been refactored into their own functions

#

and the switch usage could have been used to toggle between axis instead of boilerplating a variation of the same code three times.

#

thoughts?

hexed pecan
#

But if you know what youre doing then do it your way

pearl bay
#

i was using Debug.Log to get the quaternion value and noticed it was going from 1 to -1, but wasn't sure if it could go past that with this implementation (since euler just does -180 to 180 and wraps)

#

eulerAngles is the same as multiplying by 360?

#

using euler was doing a weird snapping thing at the 180 degree points around the lever's rotation and just did not look great at all like that, very easy for the player to potentially break

hard viper
#

targetDir has units of meters. You are clamping one of its coordinates with an angle in degrees. This won’t work

#

for starters, if you want this approach, then you’d need to normalize the vector to bring it to dimensionless distance.

#

then you’d need to do math to convert the angle to a distance on the unit circle to clamp it properly

#

right now, you are asking the computer effectively to give the closest value to 15 meters between 45 and 110 degrees, which doesn’t make any sense.

acoustic sorrel
#

What is the proper way of getting image ui components that are children of something. I am figured I could use GetComponentsInChildren<Image>(); but I just get an error saying that Image needs to derive from monobehaviour, component, or is an interface. Can someone show me the right way of doing this?

somber nacelle
#

you've got the UIElements namespace instead of UnityEngine.UI

rigid island
#

ah yes prob namespace issue

#

wrong class imported

acoustic sorrel
#

now im getting this

#

oh wait nvm im dumb

leaden ice
vital oracle
#

What would be a simple way to handle item recipes/combos?

Say instead of a grid like minecraft its just stacking items on top of eachother for simplicity.

So for example if you place item A, then B you get item C. And if you place item A, item B, then C you get item F

modern creek
#

Does the "crafter" have multiple layers? ie, 9 layers, and {A}-{B}-{ }-{ }-{ }-{ }-{ }-{ }-{ } is valid but so is { }-{ }-{A}-{ }-{ }-{B}-{ }-{ }-{ } ?

#

(and do A & B need to be in the correct order, or any order)

leaden ice
modern creek
#

If they don't need to be ordered, then I'd create a way to serialize them and compare that serialized value against a list of known recipes.

For example, let's say you have a unique letter for every item.. you'd make a ToString method like this:

public override string ToString()
{
  StringBuilder sb = new();
  foreach (Item item in Items.OrderBy(x => x.ItemCharacter)
  {
      sb.AppendChar(item.ItemCharacter);
  }
  return sb.ToString();
}
#

yeah basically combine PB and my code, then you can just do if (craftingTableIngredients.ToString() == recipe.ToString()) // give the player the outputs

vital oracle
modern creek
#

my approach still works, unless they have to be in specific slots

vital oracle
leaden ice
vital oracle
vital oracle
golden garnet
#

How can I make a NavMeshAgent move away from the destination?

somber nacelle
#

give it a destination that is away from the position you want it to move away from

leaden ice
golden garnet
leaden ice
#

but there's no guarantee that direction is somewhere valid

#

it might put you right into a wall for example

golden garnet
#

Hmm I see

#

Okay follow-up question, what if I wanted to do this dynamically? Say the player is moving, and the NPC is purposefully running away from the player, changing its direction as the players position transforms. What should I do then?

leaden ice
#

were we not talking dynamically before??

golden garnet
#

I'm just moreso emphasizing the idea of the target's position changing and how to account for that

leaden ice
#

I don't see how it changes anything

#

you do the calculation again periodically

#

or every fixedupdate

golden garnet
#

Would that be expensive?

leaden ice
#

¯_(ツ)_/¯

#

expensive is a relative term.

#

Worry about optimization after you get shit working

oblique spoke
#

Are you just trying to create distance between characters?

#

Casting along navmesh in the opposite direction of the character you are trying to move away from might do.

pearl bay
#

i think in my head i was thinking "yes, the target angle", completely missing that it's direction.... even though it's called 'targetDir' 🤦‍♀️

pearl bay
#
                case RotationType.TESTROT: // Up-down test rotation
                    Vector3 targetDir = Vector3.ProjectOnPlane(playerHand.position - pivotRb.transform.position, directionRef.forward);
                    pivotRb.transform.up = targetDir; // Project on a plane and set the up transform to the result

                    Vector3 clampedRot = new Vector3
                        (Mathf.Clamp(pivotRb.rotation.x, minAngle, maxAngle),
                        pivotRb.rotation.y, pivotRb.rotation.z);
                    pivotRb.rotation = Quaternion.Euler(clampedRot);

                    bool approxValue = Math.Abs((pivotRb.rotation.z * 360 ) - successAngle) < 0.1F;
                    if (approxValue)
                    {
                        Debug.Log("Success!");
                        puzzleSuccess = true;
                    }

                    break;
#

hopefully this makes more sense! if you set the up transform of a game object in a script and then set its rotation, it doesn't reset the rotation does it?

quartz folio
#

and treating it as a euler rotation

#

pivotRb.rotation.eulerAngles is what you would need to use

pearl bay
#

i was having issues with the way euler rotations wrap, since through the center is -180 to 180

#

it was causing the object to snap to the other side and behave incorrectly

quartz folio
#

Well what you're doing now makes absolutely no sense

pearl bay
#

i figured, i feel a little lost. i thought i understood, but honestly quaternions are very confusing as a non-programmer

pearl bay
# quartz folio Well what you're doing now makes absolutely no sense
                case RotationType.TESTROT: // Up-down test rotation
                    Vector3 targetDir = Vector3.ProjectOnPlane(playerHand.position - pivotRb.transform.position, directionRef.forward);
                    pivotRb.transform.up = targetDir; // Project on a plane and set the up transform to the result

                    Vector3 clampedRot = new Vector3
                        (Mathf.Clamp(pivotRb.rotation.eulerAngles.x, minAngle, maxAngle),
                        pivotRb.rotation.eulerAngles.y, pivotRb.rotation.eulerAngles.z);
                    pivotRb.rotation = Quaternion.Euler(clampedRot);

                    bool approxValue = Math.Abs((pivotRb.rotation.eulerAngles.z) - successAngle) < 0.1F;
                    if (approxValue)
                    {
                        Debug.Log("Success!");
                        puzzleSuccess = true;
                    }

                    break;
#

this should be better right? 😄

#

i might change the tolerance to a variable on the success angle check and make it larger tho

calm basalt
#

Hello! Has anyone worked with ScrollRect for mobile devices before? The component works on the editor with clicks but for some reason it doesn't allow me to scroll on mobile with touch, does anyone have any suggestions?

rigid island
#

make sure you anchored everything properly

little meadow
pearl bay
#

i think i picked something dumb and tough right?

#

honestly, it doesn't need to be 'good' for the prototype, it just needs to work, so even if i use hammy scripting and know it could be done better i'm sure it'll be okay

#

ik that's not a good thing to say in a code chat of all places

little meadow
silk portal
#

Is it somehow possible to spawn an object under mouse cursor in a way that it would trigger IBeginDragHandler.OnBeginDrag --> IDragHandler.OnDrag?

And at the same time not force to hold left click down for it, but instead trigger IEndDragHandler.OnEndDrag on click?

pearl bay
#

is this for a dropper tool/feature?

silk portal
#

I have an inventory with item stack and a button for splitting it. But I'd like the new stack to spawn under mouse as if it was being dragged already.

#

If I can't figure this out, I can just drop it into next free slot or ground.

pearl bay
#

is the instantiated object a generic draggable type which you assign a value to or is each one unique?

silk portal
#

hm, not sure I understand what you mean

pearl bay
#

sorry i misread

#

can you call the interface functions directly?

#

so when the object is split, you instantiate the object and call the function

silk portal
#

I remember I tried this some time ago, but failed... it kind of worked partially

pearl bay
#

I figured you'd just be able to do OnEndDrag(), right?

silk portal
#

I'll try that again and try to remember what the exact issue was

#

anyways thanks, I probably won't get to it before tomorrow morning

pearl bay
#

good luck!

calm basalt
acoustic sorrel
#
SerializedObjectNotCreatableException: Object at index 0 is null
UnityEditor.Editor.CreateSerializedObject () (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.Editor.GetSerializedObjectInternal () (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.Editor.get_serializedObject () (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.EditorUtility.IsHiddenInInspector (UnityEditor.Editor editor) (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.PropertyEditor.ShouldCullEditor (UnityEditor.Editor[] editors, System.Int32 editorIndex) (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.PropertyEditor.ProcessEditorElementsToRebuild (UnityEditor.Editor[] editors) (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.PropertyEditor.DrawEditors (UnityEditor.Editor[] editors) (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.PropertyEditor.RebuildContentsContainers () (at <25578071f6e44201aac745680e5c8dfc>:0)
UnityEditor.InspectorWindow.RedrawFromNative () (at <25578071f6e44201aac745680e5c8dfc>:0)
#

what do

pearl bay
#

context? 🤔

acoustic sorrel
#

i fixed it

pearl bay
#

ah.

acoustic sorrel
#

some how restrarting unity for the 5th time worked

#

no idea why the first 4 times didnt work

cosmic rain
#

It looks like a random ui bug. It must be some window or tab misbehaving.
Usually resetting the windows layout would fix it if it's recurring.

hard viper
round violet
#

if i have a child with a collider, does the OnCollision event called in the parent ?

hard viper
#

ie expect loss of information

round violet
#

if the parent doesnt have a rb

hard viper
#

if child has RB, I believe the callback goes there

round violet
#

none have RB

#

its a trigger

pearl bay
#

don't collision checks expect a rigidbody?

#

pretty sure you need a rigidbody and a collision compoent of some kind, trigger or not

round violet
#

but this object doesnt have rb, only a collider of trigger type

pearl bay
#

also i think you can only do OnCollision/OnTrigger events from a game object that has a collision component, not its children or parents

#

i could be wrong, but i was looking at that today and it seemed unanimous

hard viper
#

is there an equivalent to Debug.Assert that gets removed in final build, but without using UnityEngine?

#

some generic helper clases I write would not need to import UnityEngine if not for Debug.Assert

cosmic rain
little meadow
celest iron
#

What is the difference between CapsuleCastAll and CapsuleCast with a RaycastHit[] array as parameter?

little meadow
celest iron
#

I did, they seem to do the same thing

#

But I assume they must be different, otherwise why have two things

somber nacelle
#

Where are you seeing an overload for CapsuleCast that takes a RaycastHit[]

celest iron
#

Literally the second declaration

#

And the third even takes a list

little meadow
#

well, it's for performance reasons

#

these don't allocate, unlike CapsuleCastAll

celest iron
#

I guess the array is the result on the same collider?

somber nacelle
lean sail
#

Ah physics 2d. I was wondering the same as boxfriend

celest iron
#

Oh, sorry

#

Should've specified

somber nacelle
#

but anyway, CapsuleCastAll returns an array. CapsuleCast populates an existing array to reduce garbage generation

#

prefer CapsuleCast over CapsuleCastAll and reuse the array

celest iron
#

Is there any use case for CapsuleCastAll?

somber nacelle
#

laziness, and if you want to get a new array with the exact number of hits in it

little meadow
#

being lazy / not caring about some cast, because super rare... but mostly it's there for backward compatibility I guess

celest iron
#

I see, ty

hard viper
little meadow
pearl bay
#

it always bothered me that you can't have a script on a child object and push all of its exposed variables to the main parent for the sake of prefabs being easier to work with

little meadow
#

you can always do #if UNITY and define UNITY in Unity (there's possibly some pre-defined symbol)

pearl bay
#

is there a work around for that?

little meadow
#

ah! you can use Pulni's Editor Tools, which I just made public yesterday! 😂 you'll probably be the first user and tester, so fair warning that there might be stuff that needs fixing

pearl bay
#

that is a VERY bizarre coincidence

#

could i get a link to install the package?

little meadow
#

on the scale of 1 to 10, how forbidden is that here? 😅 I can DM you the repo link, yeah

hard viper
pearl bay
#

i'm surprised the standard starter content for unity doesn't contain things like that, or folder colorings

little meadow
pearl bay
#

still shocked we can't change the icons of folders, only scripts 💔

hard viper
#

does that one throw a formal error?

#

also twilight sparkle was my college roommate's second favorite

pearl bay
#

i have avatar icons turned off on discord and got v confused for a second

little meadow
round violet
#

can InvokeRepeating have params to pass to the method ?

#

in the docs it doesnt look like it

little meadow
little meadow
#

@pearl bay I DM'd you btw

round violet
#

im curious, why is it bad ?

little meadow
#

bad performance, also uses strings which makes it super fragile, also no params, and the list probably goes on

hard viper
little meadow
#

you can make a much nicer InvokeRepeating method if it's something you need often and don't wanna write the coroutine every time

little meadow
# hard viper rainbow dash

Very good choice! RD was one of my initial favourites as well, but over time I started appreciating all of them. The series make quite a lot of good points about... being tolerant and accepting people (ponies) for who they are.

deep shale
#

how come unity says that my variable "percentageComplete" doesnt exist when it is literally defined in my code?

tawny elkBOT
deep shale
round violet
#

any ideas why a StopCoroutine doesnt stop a coroutine ?

little meadow
#

no reason

#

it really does stop the coroutine you tell it to stop 🙂

round violet
#
public void SetConnectedStatus(bool newStatus)
{
    if (_isConnected != newStatus)
    {
        StopCoroutine(HandleHealth(!newStatus));
    }
    _isConnected = newStatus;
    _playerHealthBatterie.SetStatus(newStatus);

    StartCoroutine(HandleHealth(newStatus));
}

private IEnumerator HandleHealth(bool gain)
{
    while (!_playerHealthUI.AddHealth(gain ? 3 : -1))
    {
        Debug.Log(gain);
        yield return new WaitForSecondsRealtime(1);
    }
}

when i do

SetConnectedStatus(false);

i lose health every sec

then when i do

SetConnectedStatus(true);

i regain health until max, but i still have the removing coroutine going

#

i did some test with Debug.Log and it is doing StopCoroutine(HandleHealth(false))

somber nacelle
shut wadi
somber nacelle
#

if you're going to use pastebin, at least have the courtesy to select the correct language so there's syntax highlighting. you also just dropped nearly 300 lines of code on us with very little info about what isn't working

shut wadi
#

Sorry I did this fast, I'm super tired and I've never used pastbin.

#

The script allows you to procedurally destroy an object in several parts

#

And I'd like those parts to get destroyed after a while

deep shale
somber nacelle
#

if you've gone through all of the steps to configure it and it still isn't providing proper syntax highlighting or underlining errors, then yes, regenerate project files and restart visual studio

somber nacelle
shut wadi
#

I did a simple coroutine with a destroy and it didn't work

shut wadi
#

And in the coroutine I was destroying the object so

somber nacelle
#

please see #854851968446365696 for what to include when asking for help. because honestly i have no idea what specifically you are having trouble with, and you expect me to read through your 300 lines of code to figure it out for you

shut wadi
#

In theory, I think I've said it all. I agree, I screwed it up a bit in a hurry. But in itself it's just a script to procedurally quote a mesh into several other mesh.

#

And I'd like to destroy the parts after x amount of time

#

I had made a coroutine using a GameObject as an argument and then destroying it.

#

And this coroutine I called line 80 with the argument parts[i].GameObject

#

But it hadn't worked

chilly surge
#

I feel like #854851968446365696 could include "describe what you want to happen, what you have tried to make it happen, and what's actually happening"

#

"Not working" isn't much information for people to help, you gave the second part but not the first or third.

somber nacelle
#

pretty sure it did have that (or rather something very similar to that) for a while. no idea why it got removed though

wicked scroll
#

It doesn't matter so much what you put in the readme because the people who you actually need to read it are the ones who don't. So I expect it's a balance of keeping it concise enough that it actually gets read.

chilly surge
#

Eh, not sure. I mean what @wicked scroll says is also very true, and it's hard to measure how effective it is.

hard viper
#

if you have enough situational awareness to read the readme, then you also have enough awareness to explain your situation

chilly surge
#

I mean, "describe what you want to happen, what you have tried to make it happen, and what's actually happening" is very concise and a lot of badly asked questions are boiled down to missing some/all of the three parts.

#

The argument of "people who don't read are the ones that need it the most, so there's no point in improving it" is kind of flawed.

wicked scroll
sweet perch
#

anyone know how to make water like terraria in a procedurally generated world or know any tutorial for it?

modern creek
dense estuary
sweet perch
rocky basalt
#

Hi, first off, sorry if I'm overlooking something incredibly obvious, but I'm trying to allow user to click a waveform (generated via a texture) and the game will know at which point in a waveform it was clicked. Just like Audacity/DAW.

So, like the % of the length of a object/collider the click occurred on would be enough information to estimate it, I suppose. But is it possible to get that level of detail about a collider (or other) click? Thanks for any tips!

wicked scroll
lunar python
#

how do you guys keep const like float variables in sync between scripts?

hexed pecan
fervent furnace
#

You cant change const value

cosmic rain
#

Const variables are not meant to be changing, so that sentence doesn't make sense.

#

You don't need to sync something that doesn't change.

lunar python
#

sorry for misunderstanding, what I wanna change is movement speed, normally it is stored in PlayerData but I wanna keep it short like movementSpeed instead of data.movementSpeed, but in the process of playing the game, the movementSpeed may subject to some changes

#

most classes are stored as references, can I do similar things to float etc

cosmic rain
#

Create a property:

float MovementSpeed => data.movementSpeed;
lunar python
#

thats exactly what i need

#

thanks

spring flame
#

is there a way to enable rider inspections in read only packages? Specifically, I would like to be able to browse ShaderGraph module

#

For now I only found that in the top-tight of editor window I can enable inspections for one file only, but then all references are red if I don't enable in other files as well.
And it seems I'm unable to find "enable inspections for directory"

woeful narwhal
#

how would i make adialogue window that resizes like this because when im trying to making a dialogue system outside of a canvas, the vertical layout group and the content size fitter dont work. how can i create the same effect outside of the ui or will i have to code my own custom script that takes the values from the textmeshpro component

placid summit
#

to use JSON.Net that is il2cpp supported do you have to use the Unity package that is included with entities or something in 2022?

mild coyote
woeful narwhal
mild coyote
#

you can/need to calculate the image position based on the character.
or make a worldspace canvas, attached to the character, to contain the textbox

woeful narwhal
#

alright ill give that atry

tired elk
#

Hi ! I'm using a UnityEditor.PopupWindow which is working well, but each time I'm using VisualStudio debugger, it catches an ExitGUIException that is thrown when I try to open the PopupWindow. In the documentation, it is said that this exception is by design and that I shouldn't catch it, but do I need to do something to prevent VS from stopping each time I'm trying to display a PopupWindow ?

long quarry
tired elk
little meadow
long quarry
#

okay i send the codes

knotty sun
tawny elkBOT
little meadow
#

should be simple though - just check what's observing what and adjust so that each things observes what's appropriate