#archived-code-advanced
1 messages · Page 189 of 1
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
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.
the server then scrambles those 32 bits and sends it out to clients
the shulker box wand is held entirely on the server
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?
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
So server is looking at player's inventory, then client is not sending server anything
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
Why can't server just send back a spell ID, rather than send back a cryptic 32 bits and let client decode it?
i only came to ask how to encrypt a collection of bits, not have people dissect what i was using it for 
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
Then use anything to compress your payload and not tie your networking to a specific algorithm.
i want spells to be completely randomized in their color, shape, path, damage, etc
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.
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
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.
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
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
this is a very low ROI problem
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
It won't, that's the thing. I'm going to analyze the scene statically and store the references
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
how do you think find all objects of type works
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.
afaik the implementation of that is pretty dumb in unity. it just goes through every object and tries to query the given component
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
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.
@cloud badger if it works (2), there's no reason to encrypt anything. it is not reversible.
That solves your problem of to test something you always have to reach from the main scene all the way to it.
It's 2, I'm not trying to have the runes have any actual specific effects on the spell
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
okay
I'm only encrypting it so players can't know how to make a spell beforehand
then there's absolutely, positively no reason to encrypt anything
That's it
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"
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
Mostly, but I'll still have to mock their dependencies somehow. They usually do concrete things that have ingame impact
I was reading about that earlier
@cloud badger you can just look up one time pad and be done with it
Can't those only be used once
One time pads were like indecipherable as long as you only use them once since they don't add any information
if you are not using (2), if you are doing (1)
the runes are correlated with the spell behavior
I'm an active hater of singletons now
you are telling me you aspire to do (2), but you are doing (1)
and they're not something in between possibly
I have main method that runs first in game (or when previewing in editor) which sets up every systems needed for the game to work.
Then all systems are global by default and can be accessed by everything.
it's either or
@maiden turtle eventually, somewhere, somehow, like in your main method, you have to declare, "there is a relationship between X and Y"
Fair enough, but I'm personally not sure about everything, or really, anything, being global. It feels like cheating to me when I see Something.Instance
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
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.
X has an Initialization method taking Y as a parameter, no? Or do you mean the fact that it gets wired automatically? I don't like that either, which is why I started this discussion in the first place.
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.
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.
eventually, you have to express the relationship somewhere
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
Not just that. If you need to pass it explicitly, then it's only natural that Y has to have been initialized prior to it being used in X. Also, it creates context for when you're trying to understand X. Then it's clear what thing X depends on what it gets upon initialization, and nothing global extra.
yes, but... anything where the depth of predecessors of dependencies is greater than 1 is by definition tightly coupled anyway
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
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.
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
explain the arrows
i am saying this is your thing about
I don't understand the notation
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
having flat dependency structure is good, deep - bad
is basically what you're saying
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
I see your point: don't pull stuff apart unless it's used in one place only
don't pull stuff apart if it's used in one place only*
there is a place for DI. Dagger is it
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
yea
But like you do agree that if there were an F that also depended on E, then you'd have to share it
not necessarily. it's just telling you those three things are tightly coupled
and do their initialization as well
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
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
what is this a CFG reduction quiz?
(and probably events for syncing stuff, and maybe getters for convenience)
what's CFG
context free grammar
ah lol I get it
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
yeah I've seen this one a lot, and I've done this one sometimes too
it's tempting
that's why people use it
I've been also thinking about storing state in components and not just as fields somewhere
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
It's especially fun with Unity serialization, because you don't get (good) tooling unlike code based workflows.
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
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.
So I was thinking about splitting it into components and just storing parts of data there, separated, but still in one place
yeah
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
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.
yeah Unity lacks a lot of quality of life features
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"
yeah I see your point
if you can make the same comfy to set up with code only, go for it
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.
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...
The GUID reference github thing is here https://github.com/Unity-Technologies/guid-based-reference
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.
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
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
Or just loop backwards if order doesn't matter.
indicators.Where(i => !agents.Any(a => a.targets.Contains(i)).ToList()
use this if you don't really care about memory or performance
Why not use List.RemoveAll?
i dont know linq so i try to avoid it
It removes all items for which a predicate returns true.
either that, or use RemoveAll with a delegate parameter, like @vagrant gulch suggested
I guess I just wasn't aware of this method. I very rarely use lists, usually plain arrays work for me.
Does anyone know why my text file turns into pure chinese when i write too many characters to it from c++?
So I mean... it is scalable and maintainable, because there is examples of people using it at scale with simple-enough maintenance. But, yeah, I'm the type of person who will investigate bugs by looking through diffs, and not having those tools really annoys me, often to people being like "Ah what's the big deal? Do it the old fashioned way." while they make endless, avoidable bugs.
And, yeah, I've merged commits to scene files and prefabs before. Possible, but definitely not fun or straight-forward.
Sure, it's scalable and maintainable if you are willing to put up with pain 😄
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.
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 🥲
Likely because you are writing Chinese characters to the file and not because you are writing "too many" characters to a file.
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
You haven't really given any information about the issue. I'd guess you're running off the end of a buffer.
That is the issue
That’s the only issue
It creates a text document with the password
And it shouldn’t be Chinese
Right. How is anyone going to be able to help you debug that issue with such limited information?
That’s all the information I can give
do you append bytes to a string?
?
if you add bytes (not chars) to a string you can create utf8 characters that represent chinese characters
Random English characters are added
but to do that you'd have to have a byte array and turn that into a string at some point
But even if that was the case it shouldn’t all be Chinese
the chinese may be an artefact of the way how you compose that string
No clue
generating a chinese character has a high probability since there are so many of them
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
maybe you need to show some code
show it
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
if you want help, you need to show code
That’s all the code is
There’s literally no reason
Unless certain symbols would script code magically
thats what they always say
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
None of this is Unity related anyway - it's off topic
There is no job/collab posting here. See #📖┃code-of-conduct
@scenic forge can you share your UI thing? I'd love to see what it looks like
#002 Camera behavior has always been a bit over my head. Can anyone help me in creating camera behavior similar to what's shown here? Zooming I can handle, that's just FOV stuff. The camera tilts up whenever the camera hits a "floor" relative to the ships, that's the part I'm most worried about.
Just use cinemachine
I’ll look into that, thank you.
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.
What's the method in question?
As I stated: I'd like to keep it general for now.
I know it's not helpful, so please don't let me waste your time any further.
Ah, I found it.
Was in an obscure file.
Next time I'll just download the entire git and search the files directly.

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*
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
does it need to be either? couldnt it just exist as a field on the player class and be a normal C# service?
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
Is there a way to upload cloud build to app store automatically?
Hello
My UI framework is designed to be component based and code only, if you have done modern web frontend/desktop app development it should be very familiar to you.
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.

[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...
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.
neat
thats quite a bit of allocations, no?
Has anyone ever used an Animator Controller to store variables and read the current state to update a State Machine?
So is creating it via prefab.
It does allocate slightly more and take slightly longer than Unity’s built in, but worthy trade off imo.
Why would eliminating the editor, unity’s most powerful tool, be a good idea?
It isn't.. else I'd just use a framework.
Does anyone know the implementation of screenpointToRay to cast a ray through a pixel?
@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.
it's the preffered way if you want to stay away from prefabs work flow, and you want to distribute it as a library/package that anybody can use. not a de-facto but ideal in those use cases and some others
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.
I have just one question to counter all your points: how do you enable non-programmers to cooperate with you?
^
so you are saying your whole architecture only makes sense in "personal projects"
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.
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
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.
Does Unity have full integration with xamarin? Or something like that?
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.
you could use the migration attributes like [FormerlySerializedAs] and [MovedFrom]
Sure, but that doesn't stop the removal issue.
What about methods referenced by UnityEvents?
thats a feature nobody should use in a scene/prefab that makes it into a pushed commit IMO
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 😄
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.
Yeah, it's very inspired by other UI technologies.
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
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.
"modern" doesn't mean that its good, only time will tell, lots of false starts in UI frameworks in the past 30 years
i'd say the ugui approach (while not being the perfect implementation) is actually quite unique and powerful
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.
But back to this point, while this is fixable by the user, the unreadable serialization making code review impossible, is not.
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)
it should be unnecessary to review serialization
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.
Why do you think that?
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.
you should not have to do that by looking at serialized data, just like you generally don't review IL code to make sure your c# did compile correctly
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.
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
How is this example pointless?
you can't evaluate styling in code, you need to look at it
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?
you need to implement some sort of style management if that is important, you can't expect a person to manually review such things in a text format
Except in every code based workflows, yes you can absolutely review styling in code.
you are not a designer are you?
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.
where is the knowledge about what is "correct" stored?
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.
you could try looking at them in the editor
could even tell the intern to compare their work to the guidelines
Yep, and that slows you down so much.
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
So in your opinion, every commit should be error free and truthful, and the author would never make mistakes.
That's how to resolve a mistake, the better practice is to properly review your commit so mistakes don't even happen at all.
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
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.
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
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.
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)
Yes, and neither am I advocating to throw away editor completely, I'm saying for places that you can avoid editor you should.
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
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.
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
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.
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
Having better serialization doesn't mean the workflow will be slower
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
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.
yes, rider for example does the whole reference lookup that unity lacks
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.
what does "better" actually mean?
Well for one, being actually readable would be a good start.
how would that even work?
maybe some sort of IDE plugin that shows the names of the referenced objects?
The serialization itself should just be better
You certainly don't have issue reading HTML.
html can't express non-hierarchical structures
There's nothing different, I can convert YAML to JSON, to HTML, to XML, to whatever.
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?
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.
what alternative is there? URIs?
Or that instead of just storing children in order, it apparently has a m_RootOrder property.
Yes, that's how almost everything works.
Unity's explanation for using GUID is that "because paths aren't universal but GUID is"
Which is a really flimsy argument.
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.
Does someone have an idea how to find farthest point on a map from you current position?
In a 3d game 🙂
What kind of map?
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
do you need more info? 😉
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 🤷♂️.
Teleport?
I definitely like the thought of having greater amounts of control. Though I probably wouldn't be able to practically use it.
yes Sir, want to create a skill which will teleport you to the farthest position on the map
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.
The discussion was already quite long, but my point is yes for cases where I don't need to work with non programmers I do code only instead of using editor and deal with all those issues. That doesn't mean my entire project has to be code only, the UI framework can mesh perfectly fine with other parts of the project.
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.
i do not like this idea. I do not want points if the player does not have the teleport skill 😉
What?
The flaws of serialization and potential user errors from changing references 😛 but otherwise interesting stuff you've been working on.
It is possible that the player won´t have the teleport skill
Yeah. You don't need to check those points then.
Yep and those flaws do impact your productivity. If everyone is a perfect being then we don't need static typing, compiler errors, GC, etc, because we all write perfect code right?
Mistakes are unavoidable part of any development, and I'd like to minimize that than "fix it when it happens"
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..
I definitely agree, reinventing the wheel is fun but a huge slow down.
Thats true but i don´t want entities in my scene which i don´t use,
it will become more and more if i create new skills with similar problems.
I only reached this conclusion after using scene and prefab based workflows first and found them to be less than satisfactory.
What entity are you talking about?
gameobjects
?
My old workflows had packages like https://github.com/edcasillas/unity-missing-references-finder plus a lot of other ones I've written myself.
Wow, that's nice ^
these fixed points would be gameObject in the scene ?
You did not think about hard coding them right?
No, they would be a list in the TeleportSpell class or however it's implemented.
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
Fill the list when the player gets the skill or something.
Of points on the map.
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?
are you seriously talking
Change your tone if you want to get any help.
sure 😄
sorry and thanks for help!
Like i did say i don´t like you idea it is not very clean at last in my case.
But if you try to help some one than maybe answer a question like what is the type of the list and don´t send a page which tells you need a typ for a generic list 🙂
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.
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.
Oh sorry, the first version should be DerivedObject derivedObject = sourceOfObj as DerivedObject
where sourceOfObj is a BaseObject
In what line do you get an exception?
Maybe it's not of type DerivedObject after all.
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?
a cast is generally a code smell, in most cases its a sign of laziness or questionable design, but there are legit cases where it is practically unavoidable, it comes up a lot when dealing with serialized data and interop with dynamically typed languages
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.
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
A BoxCollider is a 3D collider. A BoxCollider2D is a 2D collider. https://docs.unity3d.com/ScriptReference/BoxCollider2D.html
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.)
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
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
where do you disconnect?
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.
maybe a ScriptableSingleton would work for you here. https://docs.unity3d.com/2021.3/Documentation/ScriptReference/ScriptableSingleton_1.html
Has anyone done a foot ik placement with animation rigging package that would work nicely? Can't properly sync
the farthest point on a rectangular map is always going to be one of the four corners, the one with the furthest distance
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.
since this is editor only use the most straightforward thing possible
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
^ ScriptableSingleton
i don't think this stuff works quite exactly the way you think it does. start with a sample
i see lol
are OnGizmo methods acutally stripped in builds or just not called?
Well no I don't 😦 because someone kinda made it for me when I asked how I could do this. He said that when a player disconnects from the server it will give back the nummer
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?
one perspective is that you are on the start of a very long journey
Well that's not good...
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
so why are you trying to recover from a player disconnecting at all?
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.
Thanks, I'm looking into that and it seems to be what I want. This is probably a dumb question but how do I edit the fields? Does Unity automatically hook it and I can somehow open an inspector on it, or am I supposed to write my own editor for it?
its a scriptable object, so you can edit the asset from script or in its inspector and reference it through the singleton instance
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.)
okay
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
Hmm ok
I'm not sure about the "or in its inspector" part. Where should I see or create this inspector? From what I can see in the documentation I would need to make my own editor for setting the fields in the ScriptableSingleton. Am I misunderstanding this?
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
the ScriptableSingleton has no obvious SO instance inside the project folder by default
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.
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
Thanks, that makes sense I suppose. I had figured there might be a different workflow for it since you can create as many Scriptable singleton assets as you want in the project folder, although it does log some errors if you try to do that.
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.
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.
Thanks
thanks just read about the algo, it looks perfect 😄
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 ?
Hi
I'm trying to use a function stored in a dll but I have this error
the error concerns the line 28
looks like the dll you specify did not get loaded / could not be found
I managed to fix he problem
ty !!
I don't remember being able to use #pragma target in compute shaders. But you might be able to do #if SHADER_TARGET >= 50, which corresponds to 5.0.
That can be compiled - but the editor still says its targeted to direct3d11 and the "else" code is not executed for me
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
Lines of code is such a pointless, meaningless measure of anything
What you should really be concerned about are things like the principle of single responsibility
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.
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)
As i'm here : anyone online now who has an idea how to solve this ?
Challenge accepted. 🥵
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?
Playfab
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)
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.
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
with playfab you can connect those analytics directly to dynamic scaling
waste of time imo
yeah, probably
Until you have super exotic needs
if i did some off the shelf "enterprise" software i'd probably be needing to manually calculate a lot of that crap
Playfab is not a trivial api though
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?
It scales through the roof and you have to deal with that complexity
No
it’s just a callback and some rest APIs
The sdk is just data models for the endpoints
https://docs.microsoft.com/en-us/gaming/playfab/sdks/playfab-sdk-intro K, seems straightforward enough
I just generally hate any sort of dependencies, it was a pain in the dick to get my CI/CD working as it is
And do yourself a favor and don’t use the unity sdk … unless you love callbacks over async
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
Playfab is not that
hm
Hi to all, who can guide in a right direction with a project setup? ) Trying to figured out in some tetris genre 😄
it very much requires work
Just ask the question, don't ask to ask. 🙂
wdym by lightweight anyway?
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)
depends on what you mean by setup
That definitely isn’t the playfab SDK. It’s minimal but not in the ‘easy to use, does everything for you’ sense
https://docs.microsoft.com/en-us/gaming/playfab/sdks/unity3d/quickstart
Can I not use anonymous data points? Every user has to log in, or register a login with playfab..?
You can use a custom anonymous id
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
This installation/implementation doesn't look too bad?
@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 😄
You don't want to use collisions/physics for a game like tetris, I imagine.. Or maybe you do? Sounds like it'd be fun, but... it won't "work" the way tetris does. To do that, you'll need to use tiles, arrays, lists, grids, etc.
Physics tetris sounds hilarious though
Yeah, people tend to be way too hooked on using physics for what should be basic things.
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
there's at least one such game
just to hijack your Q. Do you have 1-5 key points that make Mirror ‘terrible’? I’m looking for reasons to never touch it again.
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...
$14.99
8764
80
part of appmana's value prop is that you can write a local multiplayer game and it becomes networked via low latency AV streaming
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
Hello, besides C# in depth of Jon Skeet, do you have any recomendation of C# resources for senior developers? (relevant to C# and Unity)
What do you expect to learn from them?
so your main point is that it is conceptually flawed, just like all other high-level networking frameworks/libraries?
Which of the following is faster?
- In the constructor
rb = this.gameObject.GetComponent<Rigidbody2D>();
col = this.gameObject.GetComponent<Collider2D>(); - assign in the editor with a public variable
- assign in the editor with a [SerializeField]
2 and 3 are faster. GetComponent needs to search for the reference but 2 and 3 just uses the already existin reference you have set in editor
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
pretty much. i can count on my hands how many realtime multiplayer games built with unity got big
rust & hearthstone roll something bespoke
or people use PUN
whatever modern PUN is
fusion
I believe tarkov had to rewrite a ton of netcode just to get it to work
Anyways, whenever netcode is brought up I always like to mention RipTide, since it's worth looking at https://github.com/tom-weiland/RiptideNetworking
it implements "client disconnected" which is not an idea implemented at the networking library level in the most mature multiplayer games
if you want to avoid having to manually do the editor drag/drop assignment, you can set it up with [SerializeField] and do the GetComponent call in Reset()
It's a smaller project for sure, but it doesn't approach things the same way as mirror where any client can also be a "host" server. Dedicated server with separate solution is the way to go for bigger pvp
"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
yeah no way I could build something like that worthy of production
@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
I've built out stuff using some js libraries for websockets and webgl, been meaning to try out webrtc as well
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
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#
the deployment story for a pure C# backend is poor
nothing against Java
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
I'd be using the "more mature" .NET backend stuff like Identity and Claims
you'll discover that none of it really works
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
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
.net core was released in 2016
windows was released in 1989 lol
still has a bajillion bugs
I'd rather do it in cpp
do what you guys want
idk what argument ur trying to make then
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
Same, I would do all development in C, using C# for unity interop
i think the hearthstone team kicks itself in the head every day for that decision
do you mean in general or for games specifically? because asp.net is pretty widely used as a backend
.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
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
Delete the asmdef file
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?
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?
yes
Thank you!
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?
sure why not. If you teleport the Rigidbody via rb.position = newPosition; when readjusting for floating origin it should work fine.
how do i create a prefab from an editor script?
thanks
Classic issue
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
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?
I don't really know if I can do that
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
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
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
Ive gone through all the tutorials for bolt and im super stuck
both cases, you will need to do esentially the same
raycasts to detect slopes, get the normal and gradient and add forces accordingly
Can I do that in real time? Or should I do it only when the player gets x far away from origin?
does anyone know how to fix this?
That one is broad
wydm
Meaning a lot of things could be wrong
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.
so delete the library folder?
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.
so do you have to delete the library folder in the project im working on or unity its self
You shouldn’t be able to access it within Unity.
It’s not in the Assets folder.
Delete the folder from Explorer/Finder
@ocean raptor i reinstalled unity because I was confused but whats the best version of unity?
oh god don't ask things like that you'll inspire jihad..
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?
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
you are in bad shape
you can use a controller from the asset store for a head start. kinematic controller is good
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");
I dont understand your question.... just use a different file name
string Json = File.ReadAllText(Application.dataPath + "/saveFile.JsonTwo"); will be suffice? @livid kraken
What... no not .json2
Savefile2.json
Do you know what a filename and a file extensions is ?
Okay got it, first time using Json
First time using files is more like it. 🤣
blame Microsoft for default hiding file extensions (I DO)
I dont the amount of times Ive seen peoole try to change the file by simply changing the extension is too damn high
The extension means nothing in this case since you are reading the binary data as text with File.ReadAllText
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.)
You could check the contents of your json file to check if the correct data is in there.
Then it's probably an issue with the loading implementation, not saving?
Are you sure your JSON file contains the correct data? GameState isn't serializable so JsonUtility won't write it.
like when I first time start game push button 5 or 6 it gives me 5 or 6 respectively
let me check
It includes {"Stage":1}
It's solved thanks
What all types can ImageConversion.LoadImage take as binary?
The documentation has this little vague line:
https://docs.unity3d.com/ScriptReference/ImageConversion.LoadImage.html
Loads PNG/JPG (or supported format) image byte array into a texture.
What does it mean by "or supported format"? What are supported formats?
i think that refers to loading a byte array in an internal texture format like DXT
Makes sense. I can work with that
basically those https://docs.unity3d.com/ScriptReference/TextureFormat.html
i think unity only supports loading pngs and jpegs specifically
because it uses libpng and libjpeg
It does seem to work with RGBA32-formatted bytes so I think you nailed it on this one. That's what I was hoping for.
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
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
its more about code review
i think all the commented out code
is really noisy
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
Hello: I've been stuck on this problem for 3 days now, Im attempting to make a "reposition" state for my AI. however, once it goes into this Reposition state, the AI does not move. they just walk on the spot. Does anyone see anything obvious that is wrong?
Archer Skeleton Class: https://mystb.in/NoneSearchesCreate.csharp
Base Enemy Class: https://mystb.in/UrlLemonSubmission.csharp
Video of problem: https://streamable.com/2f2iyb
i have debugged his current position, his destination, his movement speed. all is as expected. he just doesnt move.
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
Hm NavMesh, never used it unfortunately
Someone else will have to skim over that :/
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
when you say reposition state
the original looks nice or mine? ... i spent alot of time to refactor
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?
i meant this looks nice 🙂
yeah it looks good
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
i supplied the code above ^
Not important
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
okay
you probably want to print the state every frame
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
i apprechiate the help you're trying to give. But to actually help, it'd be good to actually read my code
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 😦
it is printed every frame it is in the state
it's very hard to run a state machine inside an update loop
i am not using Unitask
i dont want to re-write it, i just want my guy to move
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
That's a load of rubbish, getting a variable from another instance of a class is no where near advanced or general
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?
I am not saying it is advanced I just said I didn't get answer on general
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
I said I removed inheritance that class in not monobehaviour
and the question was not about monobehaviour
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
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
have you been on the zenject for a while?
wdym
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
what problem is it solving for you?
Injecting elegantly!
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
okay, what is the average number of implementations per interface
Now, I would like to handle the installer as the last task
i bet i can guess what the average number of implementations per interface is
can you?
lol
Sqrt(1)
😐
yes exactly
No, it is not true
i was actually imagining a very specific meme frowning face
you're saying it's not 1?
hmm...
This package will be used in 3 active projects. OK
i'm skeptical
can you show me an example?
like a screenshot
from your IDE
of something other than this app store
One simple class named ClientVersion. It is used in that package.
Each project has their own implementation to get client version.
hmmmmmm
okay
I cannot change that implementation existing in all projects. I should only create an interface and let the projects add their own implementation
let's say, in a single codebase
There are many examples like that
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
You say there is impossible to exist interfaces in a package and implementation in the project itself?
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
In that package, base url has been used (required). Do you know base url and include it in a general package?
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

