#archived-code-advanced

1 messages · Page 189 of 1

cloud badger
#

on the left side of the hotbar is supposed to be a really shittily drawn wand

#

wands can be opened like shulker boxes from minecraft and runes can be stuck in

#

when a player wants to cast a spell, the server looks through the runes in the wand and generates a 32 bit code from them

scenic forge
#

It doesn't matter, if server doesn't verify what client sends and just scrambles the bits then send it back, it's fundamentally unsafe.

cloud badger
#

the server then scrambles those 32 bits and sends it out to clients

#

the shulker box wand is held entirely on the server

scenic forge
#

What's stopping me from sending your server a 32 bits that represent runes that I don't have, and see what 32 bits it returns and decode to see what spell it produces?

cloud badger
#

unless players find some kind of duping glitch they can't freely generate outputs

#

the 32 bits are generated from the wand inventory, which is completely server sided

scenic forge
#

So server is looking at player's inventory, then client is not sending server anything

cloud badger
#

which is probably how i should have started this

#

i didn't want to bring up the inventory system because i thought it would just cause confusion by being irrelevant

scenic forge
#

Why can't server just send back a spell ID, rather than send back a cryptic 32 bits and let client decode it?

cloud badger
#

i only came to ask how to encrypt a collection of bits, not have people dissect what i was using it for zzzzzzzz

#

because the spell is made up of IDs, not one ID

#

it's made of like a hundred different IDs

#

all of which are generated from the encrypted 32 bits

scenic forge
#

Then use anything to compress your payload and not tie your networking to a specific algorithm.

cloud badger
#

i want spells to be completely randomized in their color, shape, path, damage, etc

scenic forge
#

But you are right that all you are asking for is a way to scramble bits and not to be questioned about it, so I'm definitely not helping, my apologies.

cloud badger
#

honestly it's given me a better understanding of what i want, thank you

#

the way i see it it makes no difference whether the spell is generated on the client or the server

#

the same spell can be built from 32 bits, so this can either be thought of as a compression problem or an encryption problem depending on where the spell is built

#

for me it seems the best compression algorithm would be leaving it as 32 bits- you can't get any smaller than that

scenic forge
#

Your networking should not depend on the implementation details, that's all I'm trying to say.

#

If in the future the spells server send back can no longer fit into a 32 bit number, you have to modify both the server code that scrambles (and making sure the same runes will scramble into the same spell despite now it being more than 32 bits) and also the client side code to decode.

cloud badger
#

that's true

#

that should only happen if i were to fundamentally change how it works or add/remove runes though

#

to me it seems worth it to have to tweak some values around if for some reason something like that needs to be changed if it means only needing to send what's necessary over the network

undone coral
#

the amount of work needed to understand a scene will not pay back how few things need dependencies injected

#

somewhere, somehow, there will be a FindAllObjectsOfType<> call

#

so you still wind up doing unity's default dependency injection

undone coral
#

from the client's point of view, it's an identifier, encryption hasn't achieved anything

#

if we replace runes with "identifier", it doesn't matter how many times you apply F(identifier_1) => identifier_2

#

if it returns a spell script

#

the client knows a mapping from an identifier to a spell

#

you're using a lot of terms that are obscuring what's really happening

#

it was your choice to make these runes correlate with spell behavior

#

encryption isn't going to change that. while encrypted(identifier) may not be correlated with the spell behavior, identifier will still be, and identifier is known to the client

#

so what did you achieve? nothing

#

do you see what i am saying?

#

if you don't want the runes to correlate with spell behavior... don't make the runes correlate with spell behavior

#

does this make sense now?

#

if the runes are NOT correlated with spell behavior, if they turn into an identifier that is used as a random seed and not for some more purposeful process

#

then the runes are not correlated with spell behavior. it will be impossible to reverse a set of runes to get a desired spell behavior

#

does this make sense?

#

so lemme spell this out for yo

#

your procedural spell generator can work 1 of 2 ways:
(1) given a set of runes, compute a spell behavior depending on the runes
(2) convert runes into a number, which is used as a random seed in an algorithm that generates spells

#

if it works (1), there is NOTHING you can do to prevent people from reversing the spell behavior

maiden turtle
undone coral
#

if it's (2), it is considerably more challenging to reverse the spell behavior, HOWEVER it is worse gameplay! it's fun to know how the runes work

undone coral
#

how are you going to analyze the scene statically? eventually you will call find all objects of type

#

by statically you mean at editor time. sure.

maiden turtle
undone coral
#

i understand you avoid doing it at runtime. but find all objects of type already queries arrays of components

#

hmm

#

i think people have visited and revisited this problem a bajilion times

scenic forge
#

For UI specifically, my own UI framework allows it to be mounted directly into an editor preview stage and making it actually playable directly in the editor itself

#

So I can isolate and test each individual UI whether it's a button or a full functional menu.

undone coral
#

@cloud badger if it works (2), there's no reason to encrypt anything. it is not reversible.

scenic forge
cloud badger
#

It's 2, I'm not trying to have the runes have any actual specific effects on the spell

crimson python
#

Im getting confused now from the SO i just made. Do i now need another class to pull the SO data from so im not access it directly? @undone coral

cloud badger
#

I'm only encrypting it so players can't know how to make a spell beforehand

undone coral
#

then there's absolutely, positively no reason to encrypt anything

cloud badger
#

That's it

undone coral
#

they cna't

#

they just can't

#

it's a random seed

#

it's already "encrypted"

#

they will not know how to make a "spell beforehand"

cloud badger
#

A seeded random value can have duplicate outputs

#

Otherwise I'd be using one goodbywah

undone coral
#

i have spoken

#

i'm kidding.

#

it's just tough dude

#

you can go ahead and do this thing you are trying to do

#

just don't sweat it. use any encryption algorithm you'd like

#

it won't matter lol

#

it will still work just as well

#

i suggest one time pad, because it will end this super ultra low ROI part of the journey for you

maiden turtle
cloud badger
#

I was reading about that earlier

undone coral
#

@cloud badger you can just look up one time pad and be done with it

cloud badger
#

Can't those only be used once

undone coral
#

i don't know

#

use it twice

#

because it will. not. matter

cloud badger
#

One time pads were like indecipherable as long as you only use them once since they don't add any information

undone coral
#

if you are not using (2), if you are doing (1)

#

the runes are correlated with the spell behavior

maiden turtle
#

I'm an active hater of singletons now

cloud badger
undone coral
#

you are telling me you aspire to do (2), but you are doing (1)

#

and they're not something in between possibly

scenic forge
undone coral
#

it's either or

cloud badger
#

Unity actually had this built in

#

Actually just kidding AES doesn't work

undone coral
maiden turtle
undone coral
#

and i would not waste too much time concocting alternatives to this

#

it's better to just assign.

#

or use the name (X and Y) as directly as possible

#

i think dependency injection is a bad way to declare a relationship between X and Y

#

it exists because when you're google and you want all your tests automated and you write everything in Java

#

you can't peek inside these internals or mock things easily

#

it doesn't exist for the purpose of better performance compared to FindAllObjectsOfType<>

#

nobody's profiler stack will have find all objects of type causing their FPS to go to 1

scenic forge
#

My view on things like systems is simple, when something needs to access say your game save system, you aren't really asking for "this" game save system or "that" game save system, you ask for the game save system.

#

They are supposed to be global and there is supposed to be only one.

maiden turtle
scenic forge
#

For my UI system, for each UI component, their ctor takes in parameters like pubic Foo(Bar bar) and in editor it automatically generates an interface for you to drag and drop things into bar, and you can preview/test it with specific data.

#

But never systems imo, they should always be global and initialized the same way.

vagrant gulch
#

If Y always expects the same X then it's just globals/singletons with extra steps. If Y needs some X that can be different then it makes sense to pass it along.

undone coral
#

you can do it in the constructor of a class

#

or you can do it with an assignment

#

do you see what i mean?

#

dependency injection doesn't make anything "easier"

#

not for games, not for C#

#

SOMETIMES for C#

#

but not really anymore

#

because C# has internal

#

which obviates the need for dependency injection

#

you can [ExposesInternalsTo] and you're done

#

java has module opens, but it didn't when Dagger was created

#

since you control almost 100% of the source of ryour game, it's obscuring

maiden turtle
undone coral
#

it was a mistake to author those things separately

#

it makes sense if you are a giant organization constantly making such mistakes

#

but you're one person in a codebase you 100% completely control

#

indeed, you don't need [InternalsVisibleTo] or whatever it's called because you can just change the source

maiden turtle
# undone coral do you see what i mean?

If you mean the fact that every class has to declare its context then yes. But it doesn't have to be called explicitly by hand by you, it might as well have been autogenerated.

undone coral
#

the autogeneration is low ROI

#

@maiden turtle like think critically about situations where

#

A -> B -> C

#

do you know what that's telling me? they should have all been written as X together

#

the decoupling was a mistake

#

@maiden turtle in real life, a well written program usually looks like

A -all-> C
B -all-> D
         E
         F
         G
#

you don't need dependency injection for 2 dependencies

#

if you have

#
A -all-> C
B -all-> D
         E -> H
         F
         G
#

H is tightly coupled to E. they should be merged into each other

maiden turtle
#

explain the arrows

undone coral
#

i am saying this is your thing about

maiden turtle
#

I don't understand the notation

undone coral
#

the order of resolving dependencies mattering

#

as a "feature" of dependency injection

#

that H takes E as an arg to its construct, and E takes B and A as args to its constructor

#

and your DI framework correctly constructs everything in the right order

#

which i am calling bogus, because E -> H is a bad design

#

there aren't any well written programs that look like "a big DAG of dependencies"

#

indeed that means the program was terribly written

#

does that make sense?

#

it's only natural that Y has to have been initialized prior to it being used in X.

#

that's what i'm trying to show is true, but not valuable

maiden turtle
#

having flat dependency structure is good, deep - bad

#

is basically what you're saying

undone coral
#

i'm saying a flat dependency structure is what your game will eventually look like

#

if you try to decouple stuff that isn't valuable to decouple, you will wind up with a deep one

#

which may be aesthetically pleasing in some engineering sense, but is a bad design

#

almost always the reason Unity developers reach for DI is because they are decoupling things that do not need to be decoupled

#

exhibit A: player controllers

#

input system vs rigidbody is as decoupled as player controllers can get. people who try to put stuff in between wind up with something of little value

maiden turtle
#

I see your point: don't pull stuff apart unless it's used in one place only

undone coral
#

don't pull stuff apart if it's used in one place only*

#

there is a place for DI. Dagger is it

maiden turtle
#

To me, there's still some value it that, to a degree:

  • it's easier to notice common logic between different component;
  • the classes are concerned with less things and generally make more sense in isolation;
  • if the requirements change, it's going to be easier to parametrize in the future

Clearly, the downsides is that you'll need these parts to communicate somehow, which is another cog that'll have to be understood

maiden turtle
#

But like you do agree that if there were an F that also depended on E, then you'd have to share it

undone coral
#

not necessarily. it's just telling you those three things are tightly coupled

maiden turtle
#

and do their initialization as well

undone coral
#

or that you haven't figured out how to migrate F into the first level

#

into the A and B column

#

F should probably be merged with A or B

#

in real world games

#

in my experience, the first layer is some reactive data store of your game state, static assets, etc., and then the functions you need to manipulate it. that's it

#

then the second layer is your unity game

#

and often i see the biggest flaw is

#

"well my weapons manager should contain a reference to all the weapons"

#

the weapons should exist on something that provides all the game data everywhere

#

but people sprinkle these things around in a bajillion places

#

need to use them in two or more places sometimes, and that's where the toxic crap comes from

#

"single source of truth" is what is missing in this dialogue, and it is really the Problem with most codebases

#

missing a single source of truth

maiden turtle
#

yeah

#

The weapon system can store a reference to this data, but it must not own it

#

It doesn't necessarily have to be just global data, it's just that you must know where to find the data you need. And it shouldn't be on some weird UI manager, but rather on a separate object, with data only

formal lichen
#

what is this a CFG reduction quiz?

maiden turtle
#

(and probably events for syncing stuff, and maybe getters for convenience)

#

what's CFG

formal lichen
#

context free grammar

maiden turtle
#

ah lol I get it

undone coral
#

your code should look like

GameData.instance.allWeapons...
#

and that's it

#

when you need to get all the weapons defined in your game

#

you should never have

#
[SerializeField] private WeaponScriptableObject[] weapons;

on your UI controller, your weapon controller, etc.

#

but that's what people do!!

#

they store state on game objects

#

it's unavoidable if you use unity physics for rules, but everything else you do not have to do that

maiden turtle
#

it's tempting

#

that's why people use it

maiden turtle
#

so that you could only take references to certain parts of your data model

#

otherwise getting the data becomes fragile and, what my colleague calls, "a train"

#

data.instance.cars[0].configuration.parts.wheels.colliders[0] kind like this

scenic forge
#

It's especially fun with Unity serialization, because you don't get (good) tooling unlike code based workflows.

maiden turtle
#

I too have my data in one array on some object, and what I started doing is "proxies" for certain context from that data, so that this long chain of things is essentially encapsulated in the proxy. But like that's just terrible, involves a lot of meaningless boilerplate

scenic forge
#

Finding everywhere a prefab is used? Refactoring? Enjoy pain.

#

Drag and drop a new prefab into a list? Good luck in code review to figure out what that is from its GUID.

maiden turtle
#

So I was thinking about splitting it into components and just storing parts of data there, separated, but still in one place

maiden turtle
#

I've been thinking also about generating a custom editor for every class

#

Not a single generic editor for all classes, but a separate one for each class instead

#

Based on custom attributes

scenic forge
#

I'm moving to a code only workflow now, zero editor and everything are just plain C#.

#

It's not doable for most games because editor is essential for artists etc, but my game it can and I've had enough of editor nonsense.

maiden turtle
#

yeah Unity lacks a lot of quality of life features

scenic forge
#

Not only that, the serialization itself is ridiculous.

#

So you have a dialogue prefab for errors, now you want to add a retry button besides the cancel button?

#

Oh look, you have 300 lines of diff in your commit.

#

Good luck code reviewing that and figuring out things like "where's the new button is placed, what's the gap between the two buttons, are they styled the same"

maiden turtle
#

yeah I see your point

#

if you can make the same comfy to set up with code only, go for it

scenic forge
#

Yeah if you don't need the ability to change things in editor, then don't use anything editor related, is my advice.

#

I've moved from scene based, to prefab based, to now code only workflow, and you can never convince me drag and drop reference is scalable or maintainable, it's such a joke.

formal lichen
#

That Guid reference reminds me of a github for that mentioned in a really great video I watched on keeping bigger projects optimized and working well https://www.youtube.com/watch?v=kML67qB9Chk

Making huge games in unity can quickly lead to problems - hopefully this video can help you to avoid them.

Links:

CrossScene Reference / GUID Based Reference:
https://github.com/Unity-Technologies/guid-based-reference

Material Property Override:
https://github.com/Unity-Technologies/FPSSample/tree/master/Assets/Tools/MaterialPropertyOverrid...

▶ Play video
scenic forge
#

Doesn't solve other editor issues though, and you still lose basically all benefits of code based tools.

#

Find and replace, nope; find all references, nope; etc.

#

Essentially all these boil down to: it's magic strings.

meager kite
#
    public void clearClickIndicators()
    {
        List<WaypointIcon> listOfIndicators = FindObjectsOfType<WaypointIcon>().ToList();
        List<UnitRTS> listOfAgents = FindObjectsOfType<UnitRTS>().ToList();
        foreach (WaypointIcon c in listOfIndicators)
        {
            foreach (UnitRTS d in listOfAgents)
            {
                if (d.targets.Contains(c.transform))
                {
                    listOfIndicators.Remove(c);
                }
            }
        }
        Debug.Log(listOfIndicators.Count);
        foreach (WaypointIcon a in listOfIndicators)
        {
            Destroy(a.gameObject);
        }
    }```
#

this method keeps throwing this error

#

why is this?

#

it doesnt progress past the first foreach loop

maiden turtle
#

you can't modify a list while iterating through it

#

is what it's saying

#

the idea is that when you call Remove it has to reorder the elements and whatnot

#

and that interferes with the position that you're currently at

#

if you can afford to filter it, you could just filter

#

removing elements while using index iteration gets pretty complex

#

first, you'd need to go from last to first

#

second, you'd need to decrement the index when you remove

scenic forge
#

Or just loop backwards if order doesn't matter.

maiden turtle
#

indicators.Where(i => !agents.Any(a => a.targets.Contains(i)).ToList()

#

use this if you don't really care about memory or performance

vagrant gulch
#

Why not use List.RemoveAll?

maiden turtle
#

does it remove a range?

#

of items

meager kite
vagrant gulch
meager kite
#

so wait should i just rewrite this as a for loop?

#

im sorta confused

maiden turtle
#

either that, or use RemoveAll with a delegate parameter, like @vagrant gulch suggested

maiden turtle
proud cipher
#

Does anyone know why my text file turns into pure chinese when i write too many characters to it from c++?

red osprey
#

And, yeah, I've merged commits to scene files and prefabs before. Possible, but definitely not fun or straight-forward.

scenic forge
red osprey
#

Yeah, it gets into the whole "dependency injection" argument. The editor is really a dependency injection system, which is a magic wand when it works, or a painted stick when it doesn't.

scenic forge
#

It's the fact that it basically makes you ditch everything that's nice about what code based workflow offers, which is everything IDE brings.

#

To find everywhere a piece of code is referenced, hit a button in IDE.

#

To find everywhere a prefab is referenced, open that prefab's meta file, copy GUID, do a full text search on your entire project; and when they are found, read through the unreadable YAML and figure out exactly where that is.

#

To rename an event handler, hit a button in IDE.

#

To rename a method that's referenced via Unity Event, do a full text search on your entire project; and when they are found, read through the unreadable YAML and figure out if OnButtonClick is the one you just changed or another class'.

#

I can go on and on about the pain points of working with anything it has to do with Unity editor, but yeah if you can stomach them sure it's usable 🥲

vagrant gulch
proud cipher
#

No

#

You see I had it generate a password

#

And if I inputted it to be too long it just filled with Chinese characters

#

I have no idea why

#

I may have hacked myself lol

#

@vagrant gulch

vagrant gulch
#

You haven't really given any information about the issue. I'd guess you're running off the end of a buffer.

proud cipher
#

That is the issue

#

That’s the only issue

#

It creates a text document with the password

#

And it shouldn’t be Chinese

vagrant gulch
#

Right. How is anyone going to be able to help you debug that issue with such limited information?

proud cipher
#

That’s all the information I can give

compact ingot
proud cipher
#

?

compact ingot
#

if you add bytes (not chars) to a string you can create utf8 characters that represent chinese characters

proud cipher
#

Random English characters are added

compact ingot
#

but to do that you'd have to have a byte array and turn that into a string at some point

proud cipher
#

But even if that was the case it shouldn’t all be Chinese

compact ingot
#

the chinese may be an artefact of the way how you compose that string

proud cipher
#

No clue

compact ingot
#

generating a chinese character has a high probability since there are so many of them

proud cipher
#

It’s only an issue with over 500 characters

#

I’m not like writing codes or anything tho it should just add letters to a string

compact ingot
#

maybe you need to show some code

proud cipher
#

The code works completely fine

#

To a limit

compact ingot
#

show it

proud cipher
#

Cant rn but I have 3 strings with characters, numbers and basic symbols, then it loops through randomly connecting them to a string and then writes that to a new file

compact ingot
#

if you want help, you need to show code

proud cipher
#

That’s all the code is

#

There’s literally no reason

#

Unless certain symbols would script code magically

compact ingot
proud cipher
#

There isn’t tho

#

What causes a character to be created

#

Like I’m not entering any binary or low level codes

#

It’s just normal characters

#

:(

#

@compact ingot it’s tweaking

sly grove
#

None of this is Unity related anyway - it's off topic

austere jewel
maiden turtle
#

@scenic forge can you share your UI thing? I'd love to see what it looks like

ocean raptor
ocean raptor
iron pagoda
#

If one of the previous versions of Unity had a method that doesn't exist in any of the others
is there a way to find it?

I'd like to keep it general instead of specific for now.
Suffice to say: I've installed the Editor version from the example I found online,
but while the Class exists, the Method does not.

ocean raptor
iron pagoda
#

Ah, I found it.
Was in an obscure file.
Next time I'll just download the entire git and search the files directly.

ocean raptor
stoic compass
#

Should your inventory system be a scriptable object/composed of scriptableobjects, or not? I'm having trouble with my SO inventory system referring to monobehaviour items, and I don't know if making the inventory system monobehaviour is the solution.

#

is a good solution*

cosmic basalt
#

seems like an inventory could just be an array, no?

#

that holds SOs potentially?

stoic compass
#

Right now it's basically a list, yeah

#

But should that list be a monobehaviour or SO? Does it really matter that much?

#

Seems like it makes a lot more sense as an SO

cosmic basalt
#

does it need to be either? couldnt it just exist as a field on the player class and be a normal C# service?

stoic compass
#

Well it's going to be one or the other in practice

#

I guess I'll make it monobehaviour, because otherwise I don't know how it will store reference to monobaheviour items

#

It's kind of confusing. The only reason I made the items monobehaviours is because I couldn't find any good way to spawn them during runtime as SOs

daring pelican
#

Is there a way to upload cloud build to app store automatically?

proud cipher
scenic forge
#

Everything is just plain C# code:

public class Counter : Widget
{
    private readonly string _name;

    public Counter(string name)
    {
        _name = name;
    }

    protected override WidgetBase Setup()
    {
        var count = Ref(0);
        var countText = Computed(() => $"{_name}: {count.Value}", count);

        var doubled = Computed(() => count.Value * 2, count);
        var doubledText = Computed(() => $"{_name} doubled: {doubled.Value}", doubled);

        return new Rows().Children(
            new Lbl("This is a Counter").FontStyle(FontStyle.Bold),
            new Lbl(countText),
            new Lbl(doubledText),
            new Cols()
                .Margin(top: 80)
                .Height(160)
                .Gap(40)
                .Children(
                    new Btn().OnClick(() => count.Value--).Children(new Lbl("Decrease")),
                    new Btn().OnClick(() => count.Value = 0).Children(new Lbl("Reset")),
                    new Btn().OnClick(() => count.Value++).Children(new Lbl("Increase"))
                )
        );
    }
}
#

When you click on this script in editor, it uses reflection to generate UI for you to input parameters on the ctors:

#

When you launch, it mounts into an editor preview stage, and you get to actually test it in isolation (the buttons are clickable and actually run the code to change count) and you can look at hierarchy and what not:

#

Even though it's a "UI framework," in reality it's way more general purposed and doesn't have to be used only for UI.

#

In essence it's a way to organize game objects via code only instead of via prefab/scene.
When you return new Foo().Children(new Bar(), new Baz()), what you are really saying is "making Foo, Bar, Baz and put them in the scene, where the Bar and Baz are children of the Foo"

#

You could very well do something like:

return new Container().Children(
    new Player().Children(
        new Camera(),
        new Weapon()
    ),
    new Environment().Children(
        new Enemy()
    ),
    new Canvas().Children(
        new InventoryUI()
    )
);

And organize your entire scene without any messy Unity editor stuffs, and get all the typical benefits from code based workflow.

fossil lava
glacial wedge
#

[Worker1] Attempting to get Camera relative temporary RenderTexture (width || height <= 0) via a CommandBuffer in a Sriptable Render Pipeline.
What I have to do to fix this error? it is not blocking compile, but pretty frustrating...

glacial wedge
#

already found this thread. didn't help me

#

I just recompiled the full library

urban warren
#

I am working on a node graph where each node will have properties that can be exposed as ports on the node so they can be controlled from other nodes.
What I am wondering is, should there be 'layer' between the 'raw' mechanical functionality and the more 'interface' type layer.
Same sort of question for adding undo/redo.

cosmic basalt
#

@urban warren in my opinion yes

#

i think thats pretty analagous to MVC

placid violet
stuck vector
#

Has anyone ever used an Animator Controller to store variables and read the current state to update a State Machine?

scenic forge
#

It does allocate slightly more and take slightly longer than Unity’s built in, but worthy trade off imo.

compact ingot
#

Why would eliminating the editor, unity’s most powerful tool, be a good idea?

orchid marsh
eternal scaffold
#

Does anyone know the implementation of screenpointToRay to cast a ray through a pixel?

scenic forge
#

@compact ingot @orchid marsh To have an actual discussion, how do you deal with:

  • Unreadable serialization.
    If you have a dialogue prefab with one button and you add a new button, suddenly you get 300 lines of commit diff that's impossible to code review.
  • Past commit pollution.
    If your script has a serialized field that's later removed, it will not update serializations to remove it. Instead the next time you delete/move that component, Unity suddenly realizes and remove it, resulting in an action from past commit polluting future commits.
  • Finding references.
    If I want to find everywhere a prefab/certain object/component is referenced.
  • Missing references.
    There is zero warning or error about when a missing reference happens. To be fair this one can be dealt with: by using another editor script.
  • Refactoring.
    If you have a button click event linked to a script's certain method, and you rename that method, it is now missing. This ties back into the previous points that it's also impossible to find where a certain method is referenced to prevent it.
#

For most projects you also need to work with non programmers and so it's incredibly important for them to also be able to work on the project, in that case yes editor stuffs are vital.

#

But otherwise?
30 years ago there was no IDE, when you are trying to find a reference/refactoring it's all about find and replace. Using editor stuffs has genuinely feel like that's what it's like.
Every time you edit something, you are worrying about missing references or broken links that will error at runtime, so you have to test every step just to make sure existing features don't break, or use editor scripts to do all the missing checks for you.
When you edit .prefab/.scene files in any complexity, they might as well be opaque and completely irrelevant to source control. You can't do code review on them unless you are willing to sit through 20 minutes of reading GUIDs and index referencing.

#

I still use editor for testing (in my UI framework, I can isolate and test each individual UI components without having to enter play mode and somehow get from starting scene to the thing I want to test) as well as project organization, there are also things that the above don't apply so those are fine.

novel plinth
scenic forge
#

It's definitely not for every project or every part of a project, but I didn't move from scene based, to prefab based, to finally now code based workflow for no reason.

#

The problems I've outlined above are genuine problems that is negatively impacting my productivity by a huge degree

#

If there's a way to make use of editor but without all of those downsides, I'm all ears.

#

Otherwise no I'm not going to waste more of my time fixing missing references, dragging and dropping more, or not being able to code review at all and just pray that every change I made in .prefab/.scene files are what the commit message claims it to be.

compact ingot
compact ingot
#

so you are saying your whole architecture only makes sense in "personal projects"

scenic forge
#

You don't have to do it for the entire project, it heavily depends on who works on what.

#

If the UI part of the game is done by programmer only, code based workflow is just indefinitely better.

#

What you are really saying is: I'm only tolerating these problems because I don't have another choice.

compact ingot
#

no, i'm saying the editor is an amazing platform to create integrated tools with relatively little effort, and instead of embracing that path, you prefer to regress in doing stuff like in the 90s

scenic forge
#

Integrated tools such as my UI framework being able to test components directly in the editor, binding properties and run it, inspecting the game object it creates, inspecting the state of how those properties interact etc?

#

Like I said not every part of the editor is terrible, I still make heavy use of it.

#

Serialization is just not it.

#

There are lots of places where you can do code only and zero editor, and in those places I'm saying code only is a much nicer alternative, unless Unity can someday fix those problems.

carmine summit
#

Does Unity have full integration with xamarin? Or something like that?

scenic forge
# compact ingot no, i'm saying the editor is an amazing platform to create integrated tools with...

Funny you say "regress in doing stuff like in the 90s"
If I rename Foo() to Bar(), and then have to carefully think about "where has Foo() been used? I better go check all those places now, or I can do a full project find and replace" is more 90s to me; pressing a single keybind in IDE to refactor and everything will work correctly, is modern.
If I delete a prefab and I have to carefully think everywhere it's used and properly deal with those places, is 90s; deleting a class and compiler tells me where it goes wrong, is modern.

compact ingot
scenic forge
#

Sure, but that doesn't stop the removal issue.

#

What about methods referenced by UnityEvents?

compact ingot
scenic forge
#

Yeah well that's my point

#

UnityEvent is made so people can drag and drop things to bind event handlers via the editor, and people don't use it because the downsides are too great.

#

So are a lot of other editor stuffs, and we kind of have to put up with it.

#

If serialization was better? I wouldn't be here talking about it 😄

wispy lion
#

I mean, @scenic forge 's framework looks a lot like UI Toolkit, just defined in C# instead of XML. So Unity seems to agree that this is the way forward for UI. And the entirety of modern web development as well, looking at the function above, it feels very Flutter-y.

scenic forge
#

Yeah, it's very inspired by other UI technologies.

compact ingot
#

i'm not against doing stuff in code, i just think the key is knowing exactly what power exists due to unity's editor and serialization, use it wisely and construct tools that make UnityEvents and Bolt and any other way too powerful mechanisms unnecessary for a project while still pushing as much of what makes the game into data instead of defining it in code

#

i totally agree that you need to keep stuff traceable, if it can't be traced some sort of manager/tools must be constructed

scenic forge
#

The way I see it is that

#

For issues related to references (whether it's finding, refactoring, or deleting) you can circumvent it by using editor scripts and scan all the changes to make sure nothing is broken.

compact ingot
#

i'd say the ugui approach (while not being the perfect implementation) is actually quite unique and powerful

scenic forge
#

I mean web frontend doesn't use any visual editor, it's all code; so is mobile with Flutter; so is desktop native with WPF and friends; so on and so forth, many areas converge and agree on code only is the way forward, at least for UI.

scenic forge
compact ingot
#

most ui frameworks suffer because they have no usable editor, this is something unity can leverage to come up with its own design (which it has)

compact ingot
scenic forge
#

You know, back in the early 2000s when web was still a baby (side note it sucked hardcore back then 😄) people weren't set on code only being the way to go

#

Dreamweaver was a thing, people used that to make websites by visually designing things and dragging and dropping HTML tags.

#

Look at where it is now.

scenic forge
#

If I have a dialogue and I'm adding another button to it, yes I need to review it to make sure the button is positioned/styled correctly and will behave correctly, all of these are in the serialization.

compact ingot
scenic forge
#

Yeah, you review the C# code, in diff view and you can see side by side what changed.

#

What do you even review prefab changes with?

#

Open the project in editor, look at what it's like and memorize it, roll back a commit, look at what's different.

compact ingot
#

you don't, there is no point, prefabs contain configuration that would be impossible to review in any other form

#

you could write validators to constrain what is allowed and what isn't and provide the user feedback about any mistakes they made

scenic forge
compact ingot
scenic forge
#

If a new member joins in the project and they don't know cancel buttons are supposed to be red color and positioned on the left side, am I supposed to trust every commit they put in blindly?

compact ingot
scenic forge
compact ingot
#

you are not a designer are you?

scenic forge
#

You can review a web project commit and know exactly if your intern accidently bolded a button that they shouldn't have.

#

You can review a desktop app and the same.

compact ingot
scenic forge
#

I'm not talking about knowing what's correct, that's a different problem.

#

The problem at hand is that, even if I know what's correct, prefabs are still impossible to review.

compact ingot
#

you could try looking at them in the editor

#

could even tell the intern to compare their work to the guidelines

scenic forge
compact ingot
#

you have a very specific idea what a review is supposed to do i assume.

#

you could also just have your coworkers to take responsibility and use reviews as a way to inform each other what has changed

#

i.e. if they made a mistake, fix forward instead of rollback

scenic forge
#

So in your opinion, every commit should be error free and truthful, and the author would never make mistakes.

scenic forge
#

That's how to resolve a mistake, the better practice is to properly review your commit so mistakes don't even happen at all.

compact ingot
#

but if you do that you come up with ideas like your architecture and remove responsibility from people.... might be a tossup on the benefits of either approach

scenic forge
#

I'm not sure why you would think not being able to review prefab isn't a problem.

#

Here's a real example, I have a counter UI component, and I changed something, can you review this commit diff and tell me exactly what's changed?

#

You can see everything from that diff.
The obvious thing is:

  • A reset button is added and it resets the count.
    The less obvious things but you can still conclude:
  • The reset button is in between increase button and decrease button.
  • Instead of using left margin to layout the buttons, it uses gaps on column now, likely so that you don't have to repeat margin on all buttons.
compact ingot
#

i'm not saying that its not a problem at all, i'm say its not as big a problem as you make it to be

scenic forge
#

Now here's that exact commit diff but done via prefab (I'm sure they are the same because I use my UI framework to export the result into a prefab), can you tell me what's changed?

#

The difference is night and day.

compact ingot
#

i.e. not being able to review prefabs does not keep me from finishing the project, but not having an editor based workflow does (in my team at least)

scenic forge
#

Yes, and neither am I advocating to throw away editor completely, I'm saying for places that you can avoid editor you should.

compact ingot
#

and i am also not saying your architecture is bad in principle, its bad when you it takes away power of moving forward, flexibility in who can do the work and intuitive tools anyone can navigate with minimal help

scenic forge
#

I'm sure everyone has changed something in the prefab and go on with their day, only to find out sometime later that your game broke because of a missing reference, and the reason you didn't find out earlier is because that part of the game is rarely tested.

#

All these time wasted fixing these small issues add up really fast.

compact ingot
#

i've used you approach a lot where it seemed appropriate but that has in the past made me the only person able to change stuff, and the editor-based workflow allowed me to delegate much of those trivial changes to someone else who required 5 minutes of training and retained that training indefinitely

scenic forge
#

That's a very good point.

#

In an ideal world serialization isn't god awful so we aren't stuck in this situation at all.

compact ingot
#

i really dont understand whats so godawful. its serialization, its what it is, it is absurdly powerful to have it, its not magic and false expectations are frustrating but i take it any day over a purely code based workflow or having to write custom serializers all the time.

#

unity might not make the most of it (yet?), but it being 100% serialized is a great foundation

#

i say that mostly in regard to enabling a quicker workflow for writing tools, which IMO is what gamedev is all about

#

the plain editor and using its primitives directly is painful, but so is any kind of generic framework without specialized tools

scenic forge
#

Having better serialization doesn't mean the workflow will be slower

compact ingot
#

well, for one, your references lookup would need a cache that is constantly updated

#

its certainly a nice feature unity should have

#

but it is a bunch of background compute that has to run on a codebase that isn't designed for background processing

scenic forge
#

I mean, the same can be said about programming, IDE needs to resolve the entire project and have it available, doesn't stop them from giving you a good DX.

compact ingot
#

yes, rider for example does the whole reference lookup that unity lacks

scenic forge
#

We are put into a situation where we have to choose between using and not using editor serialization is telling enough.

#

If it was better, no one would even suggest the idea of not using it.

compact ingot
#

what does "better" actually mean?

scenic forge
#

Well for one, being actually readable would be a good start.

compact ingot
#

how would that even work?

#

maybe some sort of IDE plugin that shows the names of the referenced objects?

scenic forge
#

The serialization itself should just be better

#

You certainly don't have issue reading HTML.

compact ingot
#

html can't express non-hierarchical structures

scenic forge
#

Wdym?

#

Unity serializes to YAML.

compact ingot
#

unity serialization is an object relation database

#

html is not

scenic forge
#

There's nothing different, I can convert YAML to JSON, to HTML, to XML, to whatever.

compact ingot
#

doesn't mean that conversion makes sense

#

converting yaml to xml doesn't make it readable

#

yaml is already the most readable serialization format

#

so you are suggesting there is a better schema that would make it more readable?

scenic forge
#

What doesn't make sense, is that to read Unity serialized prefab/scene, you need to open a notepad and write down every GUID you see and what each means, unless you have superhuman memory.

compact ingot
scenic forge
#

Or that instead of just storing children in order, it apparently has a m_RootOrder property.

scenic forge
compact ingot
#

in webdev maybe

#

its absurdly inefficient

scenic forge
#

Unity's explanation for using GUID is that "because paths aren't universal but GUID is"

#

Which is a really flimsy argument.

compact ingot
#

why?

#

how do you make a uri universal without creating a custom URI schema?

scenic forge
#

Paths? Whether it's relative or from project root.

#

You move a file your IDE knows how to handle import moving (or even if it can't, to implement it is extremely easy)

#

Using GUID everything has to go through Unity, it's so fragile it's recommended to only touch your project using Unity's explorer.

#

Everything you want to do with file must be done via Unity and properly update asset database

#

Which btw, internally still uses paths.

lusty crater
#

Does someone have an idea how to find farthest point on a map from you current position?

#

In a 3d game 🙂

quaint socket
#

What kind of map?

lusty crater
#

hmm it's a cemetery surrounded with trees, so the map is surrounded with colliders, box collider

#

well this is the way i will design the map later for now it is just a plain field, but surrounded with collider

#

and the map is plain y=0

#

my only idea would be with raycasts but i don´t know if that is a good idea, i need this point for a teleport

lusty crater
orchid marsh
# scenic forge <@544260011430248467> <@335967437315112961> To have an actual discussion, how do...

I don't like to bother discussing non game development topics but if you're so concerned about serialization, couldn't you just not serialize members to the editor? Just use properties and do nearly everything in code.. That would negate the pollution, missing references, necessity of finding references, etc... just as you're doing so to attempt to solve Editor referencing 🤔 Oh well, not like I care. Definitely seems like it's going backwards though as the sole reason for me migrating to Unity was for it's front end. Else I would've continued to use SDL + OpenGL and whatnot for game development 🤷‍♂️.

orchid marsh
#

I definitely like the thought of having greater amounts of control. Though I probably wouldn't be able to practically use it.

lusty crater
quaint socket
#

Have a set of fixed positions and when the spell is used check which one is farther away. No need to chase the farthest-farthest one, it will end up on some edge anyway.

scenic forge
#

Not sure where the idea of anti editor comes from, when I demoing my UI framework it explicitly showing editor integration to isolate and test a component.

lusty crater
quaint socket
#

What?

orchid marsh
lusty crater
#

It is possible that the player won´t have the teleport skill

quaint socket
#

Yeah. You don't need to check those points then.

scenic forge
#

Mistakes are unavoidable part of any development, and I'd like to minimize that than "fix it when it happens"

orchid marsh
#

I honestly try not to change working solutions and follow the principles of SOLID relative to Game Objects, components and whatnot. Not very applicable in large teams..

scenic forge
#

I definitely agree, reinventing the wheel is fun but a huge slow down.

lusty crater
scenic forge
#

I only reached this conclusion after using scene and prefab based workflows first and found them to be less than satisfactory.

quaint socket
#

What entity are you talking about?

lusty crater
#

gameobjects

quaint socket
#

?

scenic forge
quaint socket
#

Wow, that's nice ^

lusty crater
quaint socket
#

No, they would be a list in the TeleportSpell class or however it's implemented.

lusty crater
#

yes an empty class on a prefab and the objects in the game scene, so objects in the game scene i maybe do not need if the player does not have the skill

#

Or, what would be the type of the list ?

#

And i will have different maps

quaint socket
#

Fill the list when the player gets the skill or something.

lusty crater
#

List of what ?

#

List<what?>

quaint socket
#

Of points on the map.

lusty crater
#

and how do you define the points in the map?

#

Or are you seriously talking about hard coding Vector3s in a list, for each map?

quaint socket
#

are you seriously talking
Change your tone if you want to get any help.

lusty crater
stoic compass
#

When doing DerivedObject base = sourceOfObj as DerivedObject; Debug.Log("{base.derivedVariable}"); The above gets a null reference. sourceOfObj is of type BaseObject, but is in practice also of type DerivedObject. HOWEVER when doing BaseObject base = sourceOfObj; if (base is DerivedObject derivedObject) Debug.Log("{derivedObject.derivedVariable}") it works. In these examples, the object itself is the same, and is a monobehaviour. Anyone know why the second one works but not the first?

#

Worth noting that when the object is a scriptableobject, both work.

quaint socket
#

Well, base has a type of BaseObject which doesn't necessarily have derivedVariable. You converted it to DerivedObject in the first line but the effect of this conversion doesn't last: it's still of type BaseObject. In the second example derivedObject is of type DerivedObject, so it works fine.

stoic compass
#

Oh sorry, the first version should be DerivedObject derivedObject = sourceOfObj as DerivedObject

#

where sourceOfObj is a BaseObject

quaint socket
#

In what line do you get an exception?

#

Maybe it's not of type DerivedObject after all.

stoic compass
#

When the variable is called

#

So casting doesn't work for monobehaviours?

#

Well in both of these examples, the same object is used. And in the second example, the variable is successfully called.

#

What if you just had the collider2D of that object, and cast that as BoxCollider? Would that work?

#

Apparently it doesn't

#

Well that would be the same as my above example

#

How much is casting done in good codebases anyway?

compact ingot
#

A cast basically means "I know X is Y but I don't care to explain why"... in a statically typed language the goal is to eliminate those situations.

#

but if you for example have two integers and want to do fractional division, you have to use some form of casting.

peak tulip
#

Does anyone know if there is an asset/resource that acts like a dictionary(A websters definition dictionary) to dynamically look up parts of speech and such? Googling any combination of unity, dictionary, asset, resource, just turns up the related c# information

#

nvm, i can just dl the actual dictionary as a json and store in the project

#

imma dummy

red osprey
#

A cast does not actually change the object. It just changes how you access it in memory.

#

So if you construct a BoxCollider... then it doesn't matter how you cast it, it's still a BoxCollider. (Things like int -> float are an exception because it's actually a different process going on... but the syntax is very similar so they get lumped together.)

kind flare
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using UnityEngine.SceneManagement;
using Steamworks;

public class CustomNetworkManager : NetworkManager
{
    [SerializeField] private PlayerObjectController GamePlayerPrefab;
    public List<PlayerObjectController> GamePlayers { get; } = new List<PlayerObjectController>();

    static int[] arr = { 1, 2, 3, 4, 5 };
    List<int> uniqueID_List = new List<int>(arr);

    public override void OnServerAddPlayer(NetworkConnectionToClient conn)
    {
        if(SceneManager.GetActiveScene().name == "Lobby")
        {
            PlayerObjectController GamePlayerInstance = Instantiate(GamePlayerPrefab);
            GamePlayerInstance.connectionID = conn.connectionId;
            GamePlayerInstance.PlayerIdNumber = GamePlayers.Count + 1;
            GamePlayerInstance.PlayerSteamID = (ulong)SteamMatchmaking.GetLobbyMemberByIndex((CSteamID)SteamLobby.instance.CurrentLobbyID, GamePlayers.Count);

            NetworkServer.AddPlayerForConnection(conn, GamePlayerInstance.gameObject);

           
            int i = Random.Range(0, uniqueID_List.Count);
            GamePlayerInstance.UniqueID = uniqueID_List[i];
            uniqueID_List.RemoveAt(i);      

            GamePlayers.Add(GamePlayerInstance);

        }
    }

    public override void OnServerDisconnect(NetworkConnectionToClient conn) //for leaving the server (add leave button in lobby)
    {
        Debug.Log("OnServerDisconnect initiated");
        foreach(PlayerObjectController GamePlayerInstance in GamePlayers)
        {
           if(GamePlayerInstance.connectionID == conn.connectionId)
           {
               GamePlayers.Remove(GamePlayerInstance);
               uniqueID_List.Add(GamePlayerInstance.UniqueID);
               break;
           }
        }
    }

    public void StartGame(string SceneName)
    {
        ServerChangeScene(SceneName);
    }
}

Can someone help me? OnServerDisconnect

#

is called, but it's not giving back the players uniqueID to the list

kind flare
#

So the code isn't really right probably. At onserverAddplayer I give the player a unique ID to differentiate them later on, at Onserverdisconnect I want to take that ID back in the list to add to someone else joining, but appearently you just take the ID back into main menu

gusty nimbus
#

where do you disconnect?

vagrant gulch
#

Hello. I have various DrawGizmos() functions that draw some editor debug geometry for various components. I'd like to have some external information in those functions: a global debug draw config and access to mesh geometry to draw. The meshes are debug visualisation meshes, nothing to do with how the gameobject is actually drawn in the world.

What's a good way to go about this? My current implementation has a DebugDrawConfig class which is a ScriptableObject. This give me editor support configuring debug drawing, including setting the Mesh objects to use. Anything that needs this config gets it through a global instance which is created like this:

instance = Resources.Load<DebugDrawConfig>("DebugDrawConfig");

This all works but it requires the scriptable object to live in a Resources folder and for it to be manually created at runtime. It feels a bit clunky but I'm not sure if there's better way to approach such a problem in Unity.

spare pond
#

Has anyone done a foot ik placement with animation rigging package that would work nicely? Can't properly sync

undone coral
#

if your map has a mix of passable and unpassable areas, and you mean which point is the furthest path from your current point, you have to visit all possible paths and return the longest one. dijkstra's algorithm can answer this question .you can look online for "longest" instead of shortest path for the clue how to transform a longest path problem into a shortest path one.

undone coral
#

there is support for editor configuration nowadays

#

like a configuration asset that you slot into your project / player prefs

#

that is probably the best option for you

#

it has a distinction between stuff that's carried into runtime versus edit time

compact ingot
#

^ ScriptableSingleton

undone coral
undone coral
compact ingot
#

are OnGizmo methods acutally stripped in builds or just not called?

kind flare
#

but I guess a total disconnection means disconnecting from the game entiraly

#

But then

#

Can I put this code in a scenemanager getactivescene "Game" so that when the game is started they get the numbers?

#

And then the code "uniqueID_List.Add(GamePlayerInstance.UniqueID); to an onscenemanager disconnect game function?

#

so that the player get's the ID going in the game and gives it back leaving the game?

undone coral
kind flare
#

Well that's not good...

undone coral
#

you're discovering how truly complicated a multiplayer game is

#

right now the error you are making isn't

#

how you are using this API

#

that's what you think you're doing wrong

#

what you are doing wrong at a higher level

#

is you are trying to recover from a player disconnecting

undone coral
#

when you look into this problem - recoverable disconnects - you'll see that the underlying engineering will not resemble what Mirror or whatever wants you to do

#

another perspective is that you can narrowly figure out this API, but it will be very low ROI

#

anyway, some stuff to thik about.

vagrant gulch
compact ingot
kind flare
# undone coral so why are you trying to recover from a player disconnecting at all?

Well I just want to give the player a Unique number when they join game, from 1 - 5 (5 players in total). When they go back to lobby or when they leave the game they have to give the number back to the list so that when another game is started, the numbers randomly drop on them again. I wanted to do this because I thought it would make it easier for me to differentiate them (Spawning them depening on their given number, giving them different player models depending on their number, giving them different movement depening on their number, etc.)

undone coral
#

when i last did a realtime multiplayer server, i didn't struggle with assigning player ids, and i feel like you are overengineering things a lot here

#

you should already have a list of players at the time the lobby is full, and you sort their unique player ids and assign the player numbers that way

#

you do not need to keep track of disconnections for the purposes of assigning player ids

kind flare
#

Hmm ok

vagrant gulch
humble loom
#

the inspector is the tab titled "inspector"

#

its the thing that updates based on what you're currently selecting

#

i really don't want to come across as rude @vagrant gulch but if you don't know what the inspector is, i don't think code-advanced is the most beneficial channel to be posting questions in

compact ingot
vagrant gulch
#

Maybe it wasn't clear from my message but I'm not asking what the inspector is. I'm not sure if unity was supposed to hook into scriptable object singletons or if I have to write some glue code to have it editable in an inspector window.

compact ingot
#

But you can put one inside the project folder by configuring its path attribute, and that one should be accessible and editable through the inspector

vagrant gulch
inland prairie
#

Hello, what is the best standard for removing a delegate? If I do
OnAction -= myAction;
Then I get the following Resharper warning
Delegate subtraction has unpredictable result
But I don't know what is the correct way of doing this.
Appreciate any help.

unkempt nova
#

Basically in your case, should be fine since you're removing the same one every time

#

ReSharper is issuing this warning because multicast delegate subtraction can have gotchas, it isn't condemning that language feature entirely. Luckily those gotchas are in fringe cases and you are unlikely to encounter them if you're just instrumenting simple events. There is no better way to implement your own add/remove handlers, you just gotta take notice.

lusty crater
carmine agate
#

Hello i need 9 buffers in my compute shader but it tells me :
Shader uses 9 UAVs (0 textures and 9 buffers), which is more than the 8 maximum currently supported on D3D11.0.This is OK if you are only targeting D3D11.1 platforms at kernel CSMain (on d3d11)
Now i wanted to change my target and tried it my using #pragma target 5.0 but it tells me 'target' : unknown pragma ignored Can anyone tell me how to proceed to upgrade my target ?

quaint flint
#

Hi
I'm trying to use a function stored in a dll but I have this error
the error concerns the line 28

compact ingot
quaint flint
#

I managed to fix he problem
ty !!

sage radish
carmine agate
mint sleet
#

How many lines of code is too much for an backend "business" layer?

#

I have user manager for example, which is 500 lines of code.

#

and its increasing day by day

sly grove
#

What you should really be concerned about are things like the principle of single responsibility

lucid girder
#

To tack on to the previous comment: You can have 1000s of lines of code run smooth at 60+ fps, or you can have 10 lines of code running at 1 fps. It all depends on what the code does and how optimized it is written.

carmine agate
# mint sleet How many lines of code is too much for an backend "business" layer?

The size shouls not be your concern. But a thing that keeps growing sounds really bad. most likely it keeps getting responsiblilities asssigned (like does that and that and ...). What i would suggest is keeping the manager free of logic and have multiple smaller classes for each "thing" it should do. Like spawn, organize, checks, ui calls. And the manager just might be needed to organize theses smaller classes that actually do the work (a bit like a company. You don't want you ceo to change the wall painting, but have staff for that)

carmine agate
misty glade
#

I have a this stack: headless C# server running in an azure container; CosmosDB database; Unity3D clients; Blazor/Razor admin tools back end. I'd like to start implementing better telemetry (standing up the product was mostly Serilog console/file/Slack logging). Things like "number of users connected", "number of battles completed", "login attempts by IP address" etc - Ideally I just dream up a data point, throw it into the codebase, and it writes the datapoints out to some service or whatever. "Telemetry" being some combination of reporting on historical data and live data points.

Any suggestions for technology?

misty glade
#

Any thoughts/experience with Azure Application Insights?

#

(I'm 30,000 feet right now, just googling randomly)

#

The instrumentation monitors your app and directs the telemetry data to an Application Insights resource by using a unique instrumentation key. The impact on your app's performance is small. Tracking calls are non-blocking, and are batched and sent in a separate thread.

This seems nice

#

(that's AAI)

compact ingot
#

Not specifically, but playfab is basically all the magic of azure bundled for games and ready to use. All the backend services are already done.

misty glade
#

Yeah - just reviewing all these services.. I don't think I need a lot of it (already have a lot of it built)

#

Looking at the real-time analytics stuff though.. it looks good

compact ingot
#

with playfab you can connect those analytics directly to dynamic scaling

misty glade
#

I was thinking I'd be rolling my own reporting for AU data points

compact ingot
#

waste of time imo

misty glade
#

yeah, probably

compact ingot
#

Until you have super exotic needs

misty glade
#

if i did some off the shelf "enterprise" software i'd probably be needing to manually calculate a lot of that crap

compact ingot
#

Playfab is not a trivial api though

misty glade
#

Well I was hoping we could do some A/B testing of game content.. you know, like, "show me what crew members people are selecting for battles" and stuff

#

Does it bloat the end user client?

compact ingot
#

It scales through the roof and you have to deal with that complexity

compact ingot
#

it’s just a callback and some rest APIs

#

The sdk is just data models for the endpoints

misty glade
#

I just generally hate any sort of dependencies, it was a pain in the dick to get my CI/CD working as it is

compact ingot
#

And do yourself a favor and don’t use the unity sdk … unless you love callbacks over async

misty glade
#

I mean, I don't mind them, I'll just discard them 🙂

#

I really want fire & forget API consumption as much as possible

#

nonblocking calls, lightweight SDK, etc

compact ingot
#

Playfab is not that

misty glade
#

hm

wraith rover
#

Hi to all, who can guide in a right direction with a project setup? ) Trying to figured out in some tetris genre 😄

compact ingot
#

it very much requires work

misty glade
compact ingot
#

wdym by lightweight anyway?

misty glade
#

Nothing specific - hopefully minimal client install/fiddling, easy to use (like, one line of code in the client to register some sort of data point)

maiden turtle
compact ingot
misty glade
compact ingot
#

no login required

#

first time playfab receives a new id, a user is created but no login mechanism is a attached unless you wish to do so

misty glade
#

This installation/implementation doesn't look too bad?

wraith rover
#

@misty glade im trying to figured out with some tetris stuff. When we have a tileBased system in tetris in most cases it works with falling blocks and clearing lines on a bottom, but i want to make it simpler version of it but with horizontal blocks that just staying on board(not falling not rotating. Move blocks by dragging blocks and checking horizontaly if line is filled(merged). So the question is - is it good to make it by rb+bound collision check on a 3d space without messing it up with tiles, arrays, lists and grids tetromino ???Sorry for my English 😄

misty glade
#

Physics tetris sounds hilarious though

red osprey
#

Yeah, people tend to be way too hooked on using physics for what should be basic things.

undone coral
#

is anyone familiar with a detailed breakdown of rocket league "physics"? i understand as replicated multiplayer physics written years ago, it must be something that can be recreated in unity using bad ideas of the time, like mirror

maiden turtle
compact ingot
maiden turtle
#

Grab your wizard’s robe and spell book, time to use your engineering skills and build some Tricky Towers! Stack your bricks and use your spells to create the tallest stable tower, for what self-respecting wizard wouldn’t want to show off their skills by towering literally over their peers! But be wary of jealous rivals, who will try and push you...

Price

$14.99

Recommendations

8764

Metacritic

80

▶ Play video
undone coral
#

the short answer is unity and unreal for that matter are not engineered from the ground up to network-replicate game rules. DOTS is probably doomed to fail to deliver on that attempt

#

the solutions for network replication of most game rules is bespoke, so a generic solution is sort of doomed always

#

exhibit A: Improbable

#

it is too complicated to use

#

$500m and you get an API that feels like you're reinventing a database every time you try to author a game

#

mirror is the "making tools to make a bespoke thing easier" approach

#

there are so few PvP experiences period

#

that people play

torn bolt
#

Hello, besides C# in depth of Jon Skeet, do you have any recomendation of C# resources for senior developers? (relevant to C# and Unity)

quaint socket
#

What do you expect to learn from them?

compact ingot
hazy hearth
#

Which of the following is faster?

  1. In the constructor
    rb = this.gameObject.GetComponent<Rigidbody2D>();
    col = this.gameObject.GetComponent<Collider2D>();
  2. assign in the editor with a public variable
  3. assign in the editor with a [SerializeField]
somber swift
#

Theres no performance difference between 2 and 3

#

3 is the suggested one when you dont necessarily need to use public

#

GetComponent isnt too slow either assuming you only call it once in start/awake etc. (well you can call it dozens of times per frame without problems but usually theres no reason to do so). I have started prefering [SerializedField] over GetComponent as its bit faster and doesnt take too much time to just drag and drop in editor

undone coral
#

rust & hearthstone roll something bespoke

#

or people use PUN

#

whatever modern PUN is

#

fusion

formal lichen
#

I believe tarkov had to rewrite a ton of netcode just to get it to work

undone coral
gray pulsar
formal lichen
undone coral
#

"client disconnected" is a gameplay concept

#

of the major pvp games on PC, none are locally hosted for 99% of players

#

i don't know. there are a lot of wizards out there

#

trying to write this stuff

formal lichen
#

yeah no way I could build something like that worthy of production

undone coral
#

@compact ingot there's an expanding brain meme for multiplayer and it's pretty long

 1. use my platform's provided multiplayer toolkit and
    i'm going to do great
 2. it turns out that is really hard. what if i start
    with a tutorial?
 3. hmm, how can i serve more than 1 player? what about
    connecting without an ip address? i guess i'll use
    photon. <-----------the best choice for most people
 4. my game uses unity physics to resolve its rules, and
    this was the problem all along. i will now write my
    own rules... but now i don't gain anything from using
    photon, so i'll use a separate networking
    library <------------------------the mirror userbase
 5. those libraries add little value, because it doesn't
    help me scale to greater than 1 backend host. i guess
    i'll use unity servers and something to scale them
    up and down. oh wait, that service does not 
    exist <----where most people stop their multiplayer journey
 6. my game rules and backend will be written in a
    mature server technology like Java <---most professionals
formal lichen
#

I've built out stuff using some js libraries for websockets and webgl, been meaning to try out webrtc as well

undone coral
#

there's no 1 source of value for multiplayer. it's the way rules are resolved, it's the story about scaling and matchmaking, it's the ease of development...

#

all of these things matter

#

there's no comprehensive product for all of this

#

improbable tried and failed

#

they're good engineers

#

it turns out the generic ruleset is the hardest value to provide

#

they didn't succeed in doing that

formal lichen
#

Riptide is kinda where my step 6 was for multiplayer. You can access everything in unity and also build out networking for your server/client connections

#

plus I can keep it all in C#

undone coral
#

the deployment story for a pure C# backend is poor

formal lichen
#

nothing against Java

undone coral
#

seems to be why it's 2022 and no big game still has adopted C# in the backend, except the cygames people but they're crazy

#

they made everything bespoke to do that

formal lichen
#

I'd be using the "more mature" .NET backend stuff like Identity and Claims

undone coral
#

if microsoft had a public issue list you'd walk away from those things

#

it was only recently you could even deploy C# backend apps on linux

formal lichen
#

hmmmm I haven't gotten to production yet so I'm still early on. Don't really want to switch to Java so I'd have to really research the benefits

cosmic basalt
#

.net core was released in 2016

undone coral
#

still has a bajillion bugs

formal lichen
#

I'd rather do it in cpp

undone coral
#

do what you guys want

cosmic basalt
#

idk what argument ur trying to make then

undone coral
#

i wouldn't make a backend in C#

#

that it blows for that kind of development

#

the asp net ecosystem is bugtastic

#

because no one is using it and no one is reporting bugs for it

placid violet
undone coral
cosmic basalt
#

do you mean in general or for games specifically? because asp.net is pretty widely used as a backend

formal lichen
#

.NET keeps changing constantly, hopefully .NET 6 will start to bring things together...but then we will have to wait for mono to get a newer version of .NET and unity to use it

cosmic basalt
#

.net 6 out already

#

thats the lts

topaz pilot
#

Is there any way to dissolve assembly definitions? I cant reference different scripts from an asset store package I own because it has an assembly definition firewall blocking all my main script's references

silk trench
#

I'm creating a first person character using a Rigidbody and I'm trying to code the ramp movement

#

So far, I have a raycast from the center of the player down and it gets the normal of the ground below

#

Then I move the player using Vector3.ProjectOnPlane() so that I can walk up and down the ramps

#

But the problem is that when I walk down a ramp, the player doesn't stick to the ground and just starts flying off and the only way to stop it is to become completely still on the ramp then start walking down

#

How can I make my Rigidbody character stick to the ground?

lost dove
#

Is it possible these two bitwise operations into one to pass as a method argument?

State &= ~MovementFlags.Running;
State |= MovementFlags.Walking;
Server_UpdateState(State);
#

Would it just be something like State = (State & ~MovementFlags.Running) | MovementFlags.Walking?

lost dove
ocean raptor
#

Is there any way to have a floating origin grid system and maintain the built-in Rigidbody behavior?

#

I'm moving the player by applying forces and torques on the rb. Can I keep doing that and still use a floating origin?

#

Or should I move to some other system?

#

What about a threshold floating origin?

sly grove
meager kite
#

how do i create a prefab from an editor script?

meager kite
#

thanks

rocky mica
#

My recommendation is to ditch the rigidbody for movement

#

use a CharacterController instead

#

either way, you would need to use a raycast/raycasts to detect the ground, get the normal, and rotate your gravity vector to be opposite to the normal

#

also, use the same normal to get the gradient with your ground plane and normal to get a vector parallel to the slope, pointing downwards, to slide your character down when standing in slopes that you cant walk on

meager kite
#
    public UnitBehavior unitBehavior;
    public void CreateObjectPrefab()
    {
        GameObject object = new GameObject(objectName, typeof(UnitRTS), typeof(unitBehavior)));
    }```
#

line 4 errors out, since I cant have my specific unitBehavior in this sense as a component of the gameobject im trying to create

#

how would I achieve this?

silk trench
#

I'm trying to recreate source engine movement

#

which means surfing

#

and in my experience, character controllers don't handle slopes very well

#

at least slopes that are over the max slope angle

rocky mica
#

my experience is the complete opposite

#

haha

neon knot
#

Ik everyone here is way to smart but I have a problem with the enemy ai in the bolt platformer tutorials, can someone please help? The project is using scripting

rocky mica
#

I was never able to get something I really liked with RigidBodies, when i switched to CCs I was able to create a perfect system in a week

neon knot
#

Ive gone through all the tutorials for bolt and im super stuck

rocky mica
#

raycasts to detect slopes, get the normal and gradient and add forces accordingly

ocean raptor
regal olive
#

does anyone know how to fix this?

ocean raptor
regal olive
ocean raptor
#

The "turn it off and on again" solution for this kind of stuff is to delete the Library folder.

#

When you reopen the project, it'll take longer, as it has to rebuild that folder, but it's step one.

#

If that doesn't work, someone smarter than I would have to help you.

regal olive
#

so delete the library folder?

ocean raptor
#

Yes

#

The one next to the Assets folder.

#

Don't worry about it damaging your project. GitHub's own Unity gitignore even ignores it by default.

regal olive
#

so do you have to delete the library folder in the project im working on or unity its self

ocean raptor
#

You shouldn’t be able to access it within Unity.

#

It’s not in the Assets folder.

#

Delete the folder from Explorer/Finder

regal olive
#

@ocean raptor i reinstalled unity because I was confused but whats the best version of unity?

ocean raptor
#

Use the latest version tagged with LTS.

#

God it’s late. How far into your project were you when you just yeeted that Unity installation?

#

Are you just learning?

lost dove
#

What's wrong with upgrading to the latest LTS?

#

I've probably done that 20+ times by now. I don't think there's been any significant API changes lately

undone coral
undone coral
calm sleet
#

I am using Json in two places , how to give it different path so it won't confuse one file for other

#

my current path is string Json = File.ReadAllText(Application.dataPath + "/saveFile.Json");

livid kraken
calm sleet
#

string Json = File.ReadAllText(Application.dataPath + "/saveFile.JsonTwo"); will be suffice? @livid kraken

livid kraken
#

What... no not .json2

#

Savefile2.json

#

Do you know what a filename and a file extensions is ?

calm sleet
#

Okay got it, first time using Json

livid kraken
#

First time using files is more like it. 🤣

iron pagoda
calm sleet
#

No actully I wanted to type SaveFileTwo.Jaso

#

I mistyped it

livid kraken
lost dove
#

The extension means nothing in this case since you are reading the binary data as text with File.ReadAllText

iron pagoda
# regal olive <@122816258306605056> i reinstalled unity because I was confused but whats the b...

He wanted you to delete the Library folder inside your project folder.
It will be regenerated when you open the project. This can solve problems.
It is located in the same parent folder as the Assets folder, and is thus not visible inside the Editor, so use Windows Explorer.

2020 LTS is the most stable LTS, and I argue best for learning, due to less problems overall.
(Haters can react with emojis.)

vagrant gulch
#

You could check the contents of your json file to check if the correct data is in there.

calm sleet
#

I did using debug.log

#

it returns 1 all time

vagrant gulch
#

Then it's probably an issue with the loading implementation, not saving?

calm sleet
#

Infact it works at first time

#

then it starts giving me 1 each time

vagrant gulch
#

Are you sure your JSON file contains the correct data? GameState isn't serializable so JsonUtility won't write it.

calm sleet
#

like when I first time start game push button 5 or 6 it gives me 5 or 6 respectively

#

let me check

plain abyss
compact ingot
plain abyss
#

Makes sense. I can work with that

compact ingot
undone coral
#

because it uses libpng and libjpeg

plain abyss
buoyant vine
#

ive tried to rewwork an old asset into MVVM pattern.. after hours of unwiring i got that, does that fulfill mvp ? or atleast good splitup .. last one was static spaghetti code so im happy that i got so far atleast
https://pastebin.com/ceVrmsgq

#

its more about code review

undone coral
#

is really noisy

buoyant vine
#

the commented out code is the leftover from the old asset

#

i couldnt manage yet to make autocomplete command working

#

noch raus == has to get removed

#

thats the original

#

@undone coral

zenith ginkgo
#

i have debugged his current position, his destination, his movement speed. all is as expected. he just doesnt move.

fresh salmon
#

Nobody will do the work for you. Unless you ask on the Forums, expect compensation
Here, we help with issues you're struggling with. Show what you tried, what's expected and what happens instead. Errors, logs, anything that could be useful

zenith ginkgo
#

Take what i wrote, for example

#

but also help me too 😎

fresh salmon
#

Hm NavMesh, never used it unfortunately

#

Someone else will have to skim over that :/

zenith ginkgo
#

the Chase code works, you see it at the end of the video, where i walk out of the guys range, he'll walk to me

#

However, if i simply call Chase(); inside Reposition();

#

He will not move

#

it is a logic thing im sure. I just cant figure out what

undone coral
#

when you say reposition state

buoyant vine
#

the original looks nice or mine? ... i spent alot of time to refactor

undone coral
#

you mean you have a behavior tree, and the AI archer skeleton enters a "reposition" state where it's supposed to move from its current location back to a sentry position. you're observing that it is not moving to the sentry position while in this state?

zenith ginkgo
#

I've not actually done the "reposition" logic. since i encountered this problem, for now i just want it to run at my player position

#

but it just stands still doing the state animation

undone coral
#

okay

#

so

zenith ginkgo
#

i supplied the code above ^

undone coral
#

i don't understand

#

what is the meaning of the repositioning state

zenith ginkgo
#

Not important

undone coral
#

okay

#

have you seen the chase behavior work?

zenith ginkgo
#

yes, it is also shown in the video

#

(at the end)

calm sleet
#

Hey guys can you tell me how to get updated value of A in script One int A, setA(){ A=5}, script two One one new One , debug.log (one.A)
now I want updated value of A
tell me what change I need to make

undone coral
#

okay

undone coral
#

and see what happens

#

it is probably only being changed to the reposition state for 1 frame, before it toggles back to attacking, chasing or patrolling

zenith ginkgo
#

i apprechiate the help you're trying to give. But to actually help, it'd be good to actually read my code

undone coral
#

UpdateState in the archer code seems the most dubious to me

#

Current State isn't printed in the log you shared

#

so it's hard to say

#

unfortunately, if it were me, i'd rewrite this all 😦

zenith ginkgo
#

it is printed every frame it is in the state

undone coral
#

it's very hard to run a state machine inside an update loop

zenith ginkgo
#

i am not using Unitask

undone coral
#

lol

#

i'm not going to say that

zenith ginkgo
#

i dont want to re-write it, i just want my guy to move

calm sleet
#

Hey guys can you tell me how to get updated value of A in scriptclass: One int A, setA(){ A=5},
script two
One one new One , debug.log (one.A)

now I want updated value of A
tell me what change I need to make

#

I am getting 1

calm sleet
#

In General actully

shadow seal
#

That's a load of rubbish, getting a variable from another instance of a class is no where near advanced or general

timber flame
#

I have a problem with Zenject.
I have implemented a custom package. Now, I would like to include zenject installer into my package as well. The problem is that some implementation classes do not exist (only there are interface types in the package). One solution is to remove installer from the package and force others to implement it but in my opinion, it is not a solution!
My approach is to define the installer as an abstract class. Others should implement an installer class derived from the base installer.

   public abstract class BaseInstaller : MonoInstaller
    {
        public override void InstallBindings()
        {
            Container.BindInstance(CreateAppStoreTargetSelector()).AsSingle();
            //...
            Container.BindInstance(CreateShopService()).AsSingle();
           //...
        }

        public virtual IAppStoreTargetSelector CreateAppStoreTargetSelector()
        {
            return Container.Instantiate<AppStoreTargetSelector>();
        }
        //...
        public abstract IShopService CreateShopService();

or even better (imo), instead of creating an instance, return an intended Type

{
 Container.BindInterfacesAndSelfTo(GetInAppPurchaseServiceType()).AsSingle();
}
 public virtual Type GetInAppPurchaseServiceType()
 {
     return typeof(InAppPurchaseService);
 }
public abstract Type GetShopServiceType();

What is your suggestion?

calm sleet
shadow seal
#

You did, they told you to stop newing MonoBehaviours

#

They told you to use AddComponent if you wish, which returns a reference

#

You can also Google it, it's probably the most written about thing in Unity

calm sleet
#

I said I removed inheritance that class in not monobehaviour

#

and the question was not about monobehaviour

shadow seal
#

MonoBehaviour matters, so it is entirely relevant

#

This question is easily Googleable, if you are using a plain class that isn't inheriting MonoBehaviour then your basic C# knowledge should help

#

If you don't know how to create an instance of a plain class, you should do the Intro to C# pinned in #💻┃code-beginner

undone coral
# zenith ginkgo i dont want to re-write it, i just want my guy to move

in pure updateloopese,

bool transitioning = false;
void Update() {
 foreach (var possibleState in states) {
  if (ShouldTransition(currentState, possibleState)) {
    PerformTransition(currentState, possibleState);
  }
 }
 if (!transitioning) {
  DoState(currentState);
 }
}

virtual void DoState(State state) {
 // example
 switch (state) {
  case Chasing:
   if (!chaseCoroutineRunning) {
    chaseCoroutineRunning = true;
    StartCoroutine(ChaseCoroutine);
   }
   break;
 }
}

virtual void PerformTransition() { ... }

virtual void ShouldTransition(State current, State dest) {
 // example
 switch (current) {
  case Chasing:
   switch (dest) {
    case Repositioning:
      return repositioningTimer > repositioningTime;
    break;
   }
   break;
 }
}

#

i mean it's

#

extremely cantankerous to do this correctly

#

i already got tired of doing it

#

there's just a ton of pitfalls.

#

and you're running into them

undone coral
timber flame
undone coral
#

like have you been trying to figure this out

#

usign zenject

#

what value is it providing you

#

i am looking at code that does zero work

#

there are a millions of packages that abstract away app stores

#

you can't make a single model for all of them

timber flame
#

I selected zenject and have reasons for that

#

You mean I should not use zenject?

undone coral
#

what problem is it solving for you?

timber flame
#

Injecting elegantly!

undone coral
#

hmmk

#

what application problem

timber flame
#

There are many classes. Most classes depend on only interface types.

#

In that package, there are some base implementations. When you add that package, you can use it or define new implementation instead of internal implementations

undone coral
#

okay, what is the average number of implementations per interface

timber flame
#

Now, I would like to handle the installer as the last task

undone coral
#

i bet i can guess what the average number of implementations per interface is

#

can you?

#

lol

compact ingot
#

Sqrt(1)

undone coral
#

yes exactly

timber flame
#

No, it is not true

undone coral
#

i was actually imagining a very specific meme frowning face

#

you're saying it's not 1?

timber flame
#

NO

#

one example

undone coral
#

hmm...

timber flame
#

This package will be used in 3 active projects. OK

undone coral
#

i'm skeptical

#

can you show me an example?

#

like a screenshot

#

from your IDE

#

of something other than this app store

timber flame
#

One simple class named ClientVersion. It is used in that package.
Each project has their own implementation to get client version.

timber flame
#

I cannot change that implementation existing in all projects. I should only create an interface and let the projects add their own implementation

undone coral
#

let's say, in a single codebase

timber flame
#

There are many examples like that

undone coral
#

is the average number of implementations, 1?

#

but you control all the code

#

it doesn't make sense to inject

#

ClientVersion

#

clientversion is a terrible example

#

i've never seen that injected anywhere, ever

#

can you show me a screenshot from your IDE

#

of a type hierarchy

#

where, other than this app store, there are 2+ classes descending from one of these interfaces?

#

i think being able to access ClientVersion.instance.version is very low ROI. unity already has a version field

timber flame
#

You say there is impossible to exist interfaces in a package and implementation in the project itself?

undone coral
#

i'm saying you have 1 implementation of an interface on average

#

so you didn't need injection at all

#

the amount of work you have to do to interact with it is greater than what it saves you

#

you haven't yet shown me an example

timber flame
#

In that package, base url has been used (required). Do you know base url and include it in a general package?

undone coral
#

you're describing configuration

#

base urls, versions

#

these are just pieces of data

#

why is your code concerned with it at all? the class implementation is the same regardless of what string version or baseUrl is

#

and if it IS different for some reason

#

it will be different. it will be an if statement and you can move on

#

anyway you didn't show me an example

#

i have a feeling the people you are working with

#

are as puzzled about having to use Zenject as i am

#

they probably don't like this either