#archived-code-advanced
1 messages · Page 200 of 1
Instead of 0 and 1?
yes
the deserializer will use properties on the target type, not the indexer, is my guess
nice, does it also work with string integers?
it works both as integer and strings
you can make a custom serializer
so I should extend JsonConverter<Tuple<int, int[]>>?
you could try deserializing to a custom type first
public class CustomTuple<T1, T2>
{
[JsonProperty(propertyName: "0")]
public T1 Item1;
[JsonProperty(propertyName: "1")]
public T2 Item2;
}
Good day everyone
We really need help with our ANM neural network and fixing some problems with our unity game
Very basic stuff, wondering if anyone can hop onto a call and help me out?
are you trying to use the unity barracuda package?
are there any benchmarks showing performance impact relative to garbage per frame?
i guess the profiler says how much time is spent
How to unexpose ExposedReference by code?
Are bit fields bugged out of their mind or something? I don't understand what the Unity inspector is doing here:
[System.Flags]
public enum LookupKey
{
Nothing = 0,
Test1 = 1 >> 0,
Test2 = 1 >> 1,
Test3 = 1 >> 2,
Test4 = 1 >> 3,
Test5 = 1 >> 4
}
[System.Serializable]
public struct LookupValue
{
public LookupKey Key;
public float Value;
}
Ahh, seems it might not like the bit shifting? Setting the values like so seems to have fixed it, unless there's some error in how I constructed my bit field:
[System.Flags]
public enum LookupKey
{
Nothing = 0,
Test1 = 1,
Test2 = 2,
Test3 = 4,
Test4 = 8,
Test5 = 16
}
You failed the shift side, you should move left, not move right the single bit
replace >> with <<
No sir
We hard coded our AI
Good evening guys, we are having a problem where our AI and our player are moving at the same time sequentially and we need them to move individually. Does anyone have a clue how to fix this?
That's the issue we are currently having
Well that's embarrassing... thanks for the simple fix! Classic case of error between keyboard and chair.
Hi, when I set time parameter in the alpha of a Gradient it gets rounded to only 1 decimal.. any fix to this? I need like 4 or 5 decimals
is there a way in event system to send clicks to all objects for the current raycast, regardless of blocking?
should i override input module
and use .use?
Have you tried RaycastAll?
i want to use the event system handlers
as is
the way it should work is .used should default to true, and if i sent it to false (i.e., "preventDefault") the input module should propagate. is this how it works?
as you can see the contractors in beijing who wrote UGUI 6 years ago did not provide much clarity here: https://docs.unity3d.com/2018.3/Documentation/ScriptReference/EventSystems.AbstractEventData-used.html
https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.html the documentation for Command Buffer use cases seems a bit thin to say the least. Anyone got better resources for... general guidelines for using these things. The commands all seem pretty simple, but there's not so much as a foot note "hey dumbass remember to clear these things"
The exact location of the data in resulting list for the specific articulation body can be found by calling
ArticulationBody.GetDofStartIndicesand indexing returneddofStartIndiceslist by the particular body index viaArticulationBody.index.
Huh?
what's your objective?
you can grep.app invocations of it to see examples
Inspired use case? Drawing orthographic overlays, basically identical to canvas really. And then of course just using them for general purposes.
Really not obvious things in the documentation being clearing or modifying command buffers after they've been added to the camera.
i do not undesand this channel at all
when targeting a scriptable rendering pipeline you can implement a custom pass
and then it makes more sense
based on what you're describing, is most of the drawing work done in CPU?
it sounds like the only command you really need then is to blit
if it's the opposite - if the point is to do fully GPU drawing... i think you'll still want to blit?
How can I tell if an object has been culled by Umbra?
IsVisible() won't work, because it always returns true for objects which cast shadows. But I don't mind shadows occasionally popping out of existence when an object is no longer rendered if it means a massive improvement in framerate.
I wanted to familiarize myself with command buffers in BIRP first given the general lack in helpful reading for authoring render passes.
I'm not drawing a fullscreen quad here, just overriding the projection matrices to draw some geometry orthographically.
Also, ideally I'd like to set my objects to be inactive when they're no longer visible, so all the dynamic shadows, Rascal dynamic skinned mesh colliders, and dynamic bones on my avatars are disabled when they can't be seen, but I imagine if I do that the first time the object isn't rendered, it can never become visible again. So I'm wondering if anyone has a solution for that, besides recursively going through the whole hierarchy and disabling or enabling the scripts one by one.
The only thing I can think of is to have a cube with an invisible shader on it which the culling system would think is supposed to be rendered, and then have the actual avatar be a child of that, so I can then use the visibility state of that cube to decide if it should be rendered or not. But this also seems unreasonably complicated. Also I'm not sure if dynamic shadows on children would cause the cube to always be considered to be visible, so that's a concern too I guess.
cool
the HDRP source code is the best reference
because it uses the most features
from that API
Have no idea if you guys can help but my project randomly just stopped working
0x00007FF65F1501E5 (Unity) AssetDatabase::InitializeAssetDatabase
0x00007FF65EA0A91F (Unity) Application::InitializeProject
0x00007FF65EE63E78 (Unity) WinMain
0x00007FF66018582E (Unity) __scrt_common_main_seh
0x00007FFAA0367034 (KERNEL32) BaseThreadInitThunk
0x00007FFAA0682651 (ntdll) RtlUserThreadStart
========== END OF STACKTRACE ===========```
this is the log output
The reliability of unity makes me want to rotate my head 180 degrees.
Does an earlier work?
yes, I cloned my github repo and rebuilt any setting files
it's sad that I know how to rebuild project files so well... i've done it so many times and it's discouraging to happen on my first plan to release project.
got my project back up and running after fixing some file naming inconsistencies.
Doesnt sound like massive improvement at all
ok so, I'm trynna do something pretty advanced, and I don't know how I would go about this
but essentially
I'm trying to make a node script editor, that people can download and use to make maps for my game
kind of like vrchat's UDON
I see Bolt has a good system in place, but I have no idea how I would replicate that
Think there's something called NGP, a node graph library that'll let you make stuff like shadergraph
Can't seen to find it though
@hallow cove
I know how to make a graph editor, I just don't know how I should organize the search window
and handle the connections between nodes because of that
I'm thinking of just copying this from Bolt
I just don't have the time, nor the will to learn how to use someone else's library, plus it has almost no documentation
Ok
I already made my own graph editor, with a compiler to C#, it's just the search window that I don't know how to organize
maybe looking at the source code for Bolt will help
I figure you had a bunch of node types, just organize them that way like bolt does. I think UITK has an element for this view
Bolt and NGP use AdvancedDropdown for their node menus. It's a built-in editor type that is also used for the Add Component menu.
I mean more like, how I would get stuff like all UnityEngine functions like so
what I get back is usually completely unrelated
Oh. Why didn't you say so the first time you asked? Your initial question doesn't even mention a search menu.
yeah it's a little complicated, the real reason I'm asking is because I don't know how I should go about this
this is a tool to make maps for my game, so it doesn't need stuff that's "malicious" or that collects data, just classes like GameObject, the components on them and some custom events
Either you list everything that can be found with Reflection, or you hand pick what to show in that list.
I guess my best bet is to copy bolt in my own system
and just, hand pick what I want
and then figure out how I would handle connections between nodes
seems I'm on the right track
I am trying to do a stats system for my MOBA game. The stats system is similar to League of Legends. There are various stats (health, mana, attack damage, movement speed, etc). Every character has default stats, which progress with level. Then, these stats can be modified through items, spells, etc. Some characters might have mana, while others do not. I am struggling to come up with an effective way to manage it.
My initial prototype:
SO - statDefinition, which has base value and capacity of the stat
SO - statDatabase, which has a list of all stats
C# Class - Stat, which handles adding modifications
MB - StatController, which has a reference to StatDatabase
ok so after researching other approaches to this, I managed to figure out a bit more about how I should make the system
however, getting the methods for a type (GameObject in this case) returns these getters and setters
I can't find set_active and the rest in the source code so
???
It's a setter method of a property, it appears like that when you .ToString them
Same for get_*
how can I not display them?
Depends on how you're getting that list
You can filter them out by passing BindingFlags enum values
Hello guys, I have a little problem. I'm implementing state machine to my game and I am using Zenject Framework. I want to Inject class objects in states to operates on them but when I am trying that the object is null. Like State dosen't see the Container but see the Zenject with field Inject. Pls help.
is there a definitive implementation of converting a PointerEventData position to a rect transform position / localPosition / anchoredPosition ?
that correctly takes into account canvas scaling and whether the canvas is screen space / world space / camera space (most do not)
i have seen and authored this a million times
i don't remembe rit
I build a dog prefab with ArticulationBody, standing up legs straight . I add the prefab to my scene and pose it lying down. when i run the jointPosition reported is still zero. What gives?
Hey! I'm making an enemy that moves between 2 spots along a curve (of bézier). My enemy moves correctly from point 1 to point 2, but I'm not sure how to move him back to point 1 and then continuously restart that process. Here is my code:
`void Update()
{
//transform.parent.GetChild(1).transform.position = transform.position; //trigger moves along
if (count < 2.0f)
{
count += .8f * Time.deltaTime;
Vector3 m1 = Vector3.Lerp(pathPositions[0].position, pathPositions[1].position, count);
Vector3 m2 = Vector3.Lerp(pathPositions[1].position, pathPositions[2].position, count);
transform.position = Vector3.Lerp(m1, m2, count);
}
}
`
What can I add or change to the code so I can make it move back to point 1?
this question is more appropriate for #💻┃code-beginner or #archived-code-general, but if you switch m1 and m2 in the last Lerp it will move the other direction along the curve.
Thanks, I've tried that but it makes the enemy take on a whole other position
Thanks I'll give it a try
I'm attempting to make a "debris layer" sprite for a 2D top down game, I've looked at creating a transparent Texture2D and then using Graphics.Blit to render the Texture2D objects from the debris sprites.
Then using Sprite.Create to build the sprite from the resulting Texture2D
Are there any other methods of doing the same thing?
The goal is to remove the need to have thousands of debris sprites in the scene
Not sure how I missed Graphics.CopyTexture() the first time I looked at the docs, but that's exactly what I was looking for.
Getting errors due to float values
I'm using a vector 2 as the dictionary key
and I can't access the entries because it says they're not in there, when I know they are
I think it's like 0.00000001 different or something
Any suggestions for storing two integers as the dictionary key?
Vector2Int
Thanks
tuples
hey guys, I wanna ask experts about something.
I have a list of object "Impacts" , this Impact object has references to the prefabs that appears on impact
ofc impact would be used more frequently and in masses ( 100-1000s times per match)
I have 3 options of where to store that list that I would frequently use.
1- on the weapon itself ( a little hard to maintain)
2- on every wall or prop object in the scene ( many instances of the same script )
3 - on a manger with a static instance of itself so I can access it all the time ( it will be call the whole time as I explained )
Is any of those methods has a performance consequence ? If yes, which one has the least or if there is a better option ?
Personally, I'd go with option 3. Creating a library of impact effects you can call from wherever, whenever. Of course, these would also be object pooled.
Yeah, i'd use an object pool
@humble leaf @hollow garden thank you so much 🙂
Would it be possible to generate a link to my itch.io game that will run the webgl browser game with a variable?
Ex:
-> launch webgl build, and set myVar to 123456
I’m making a tool that allows you to make a deck for a game I play, and I’d like people to be able to share links with eachother that takes them to the deck that person made
yes but you'll need to write some javascript
Thanks, I’ll look through the doc and try to figure it out, I’ll be back if I can’t though ;)
Scenario:
My player drops bombs with a script. These bomb are instantiated right on top of the player position. Because of this, my player collides with them when they are spawned.
Question:
How do I make it so when my player or any other player has a bomb spawned on top of their position collision is off between them, but as soon as the player is no longer colliding with the bomb collision between the two objects is renabled so they can't walk through it?
I would like to know how to handle this as I believe it would help in a scenario the player clips inside of anything by accident, they can just walk out of it and collision is renabled.
From what you describe you can instantiate the bomb where it's collider will use IsTrigger. Then when the player leaves the trigger area of the bomb, turn the IsTrigger off so it uses normal physics colliders.
You could pass in colliders to be ignored until you can't detect the object with overlap physics queries.
Would this be as simple as just parenting the ball to an empty game object that is positioned in the middle of the tube?
I wonder if that would work.
yyooooo, could you point me to a tutorial please? this sounds interesting.
Cool. Yeah, sometimes you don't need the complete solution given to you, just a nudge in a different direction helps 🙂
Serialize your own colliders, spawn the object, pass those colliders to the object, have the object call https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html for each collider, have the object call one of the Physics.Overlap* methods until none of the colliders are detected and revert IgnoreCollision changes. Ask about the individual steps if you are having trouble.
Wow. Really helpful. I'll try and get to this tomorrow and see if I can do it. I was trying to use IgnoreCollision with OnCollisionStay but couldn't figure it out, this'll probably work better.
Yea can't really ignore collisions and still expect collisions 😄
looks cool
more likely something like this: mypage.itch.io/mygame#deckId=123456
Hey people, I need help with implementing an authentication system to unity for the IOS game center, most websites either redirect you to a monetized asset on the asset store or to an obsolite/depricated method, can anyone redirect me to a proper simple tutorial/document to help me with the said task ?
I implemented the following for Google Play Store using the gpgameservices package a while back, something similar to that really helps.
thank you in advance.
I want to create a property field in my editor class for UnityEvents
public class CutsceneCollider : MonoBehaviour
{
public Dictionary<int, UnityEvent> generalActionDictionary = new Dictionary<int, UnityEvent>();
}
I have this dictionary and depending on the key, I want to display the property field of that event here in my editor.
public class CutsceneColliderEditor : Editor
{
public override void OnInspectorGUI()
{
cutsceneCollider = (CutsceneCollider)target;
generalActionDictionary = cutsceneCollider.generalActionDictionary;
if (generalActionDictionary.TryGetValue(KEY, out UnityEvent VALUE))
{
EditorGUILayout.PropertyField(VALUE);
}
}
How can I turn my "VALUE" into a property?
I need to somehow get the serialized property of a variable in my class by using the reference of that variable and not the name
And I don't know if that is possible or if syntax exists for that
what are the exact benefits of plain C# classes over MonoBehaviours?
it is often required to use as least MBs as possible in vacancies
when you don't need the execution order of monobehavior (start, awake, lots others..)... when you don't want to attach it as a component.. when you want to instantiate where ever you want .. lots others
Well, I wasn't asking which and when to prefer but rather why do companies want people to use as least MBs as possible, perhaps there are some benefits?
this is a very weird requirement tbh, never seen one like this
Well, I encounter them very often when seeing through vacancies
Also the vacancies I'm talking about are mostly for a jun mobiles developer
what is your objective, saving games and leaderboards? unity should already have built in game center support. otherwise, i like the prime31 plugins
ok so I have this type = (Type)SearchTreeEntry.userData;
however the userData is an object which is why I'm casting it
and it can be more than just a Type
so in order to check what it is, I made a variable array like this:
{
"type:",
"method:",
"field:",
"property:",
"parameter:",
};```
and when I assign the userData I add a "type:" at the start for instance
however, I don't know how to cast using a variable
pretty sure you asked this already, and somebody answered you. Either way, you must cast it to a known type on runtime from another variable
someType = typeof(int);
var someOtherThing = Convert.ChangeType(somethingTo, someType);
yeah but that was before I realized the types weren't just Type, and the variable could be more
bcos what you're looking for is to cast from unknown type and hoping to automatically do it for you.. so .. uh
yeah
How do I go about reporting a unity editor crash when it doesn't output anything to the crashes folder?
I mean, you should think about the design,.. you're the one who put the data into someVisualElement.userData.. so obviously you already expecting when or how to retrieve them later on
the userData is some built in function of type object that unity provides
ye ye... it's VisualElement.userData isn't it...
SearchTreeEntry.userData
are you trying to find a Type named some string, and then cast an object to that type?
my brain is tired and doesn't understand that so I'll just re-explain:
I have a method for populating a search window, and another for when I select something. I can assign a userData to each element in the search window, and then retrieve it when I select and element
and userData is an object
here I assign it to a various amount of types
yes
I want to check using the strings I added before the actual variable
so I can get what type of value it is
and then cast it as that
check what?
userData is always a string
there's nothing to cast here
what do you want to cast?
behaviourView.CreateNode(type, name, behaviourView.GetLocalMousePosition(context.screenMousePosition));
the type you see there is what I need
idk how to word this
I need to see what userData is
either a type, methodinfo etc.
class SearchTreeEntry {
Type searchTreeEntryType;
}
then new SearchTreeEntry() { searchTreeEntryType = typeof(MethodInfo) }
yes
does search tree entry need to be something like JSON?
but I need to tell the function if it is a methodinfo or a type
so I can cast it as such
otherwise it returns null
well, typeof(Type) also works
doesn't it?
apparently not
you're using the word type
Type and MethodInfo are different
I can't cast MethodInfo as a type
the thing is, this might be a good thing
I could just give the string
you can switch a string.
cause I need different logic based on if it's a type or a method or a field etc.
yeah
well you are saying type
yeah I know
excuse me I just went outside and I'm introverted, my energy is 0 rn
I guess I'll just update the CreateNode to take in a string and then do logic based on that
i still don't understand what you're trying to do, if you want the type from the method info you can do methodInfo.DeclaringType
yeah I can't really explain it
it's okay
you are trying to do exactly what i wrote
which is the function Type GetTypeWithName(string name)
@hallow cove indeed, the best way to express yourself is to write a function signature that solves your problem
one issue tho
So i am trying to import ReGOAP (https://github.com/luxkun/ReGoap#how-to-use-regoap-in-unity3d) to work with, but I am getting a compiler error. I don't know how i would solve this:
it's okay, it's not disruptive at all 🙂 try to write the function signatures you need to fill in
so, I need to get the class a method or field or property is in
and then the method / field / property itself
try changing your scripting framework from .net framework to .net standard or vice versa first
cause I need to display where the function GetComponent is from
the GameObject class
I guess the best way is to add that to the userData as well, and split the userData string into 3 parts
by detecting spaces
so you're saying you want
struct LookupResponse {
Type containingClass;
// only one of the next three fields is set
MethodInfo methodInfo0;
FieldInfo fieldInfo1;
PropertyInfo propertyInfo2;
int whichFieldIsSet;
}
LookupResponse LookupReflectionInfo(SearchTreeEntry searchTreeEntry);
why does userData have to be a string?
okay nevermind
and I thought using a string is the best way to have it be universal
yeah please explain my brain smooth
I mean I do not understand what that is supposed to be
okay
is that helpful?
why don't you write
a function signature
where what the function returns is what you need
try to express in code what you need
don't even worry about the arguments for now
Where do i do this? :-) (nevermind. Found it in Project settings -> Player -> Other)
Thank you!
I'll write the function that returns an array of strings for everything I need
hmm
i mean you've gotten quite far
maybe you are very, very tired
and you're talking about an array of strings, which is inconceivable to me how that solves your problem
hmm
you definitely know what it means to "write a function signature"
that means
fill in the blanks for
public __YOU_NAME_THE_TYPE__ __MY_FUNCTION_NAME__(__ARGUMENTS__ __ARGUMENT_NAMES__);
i am asking you to write
Blah MyFunction(SomeArg args);
okay, but make decisions about what blah and some arg are
IN ORDER TO EXPRESS
there's something I haven't mentioned yet
so, I need to first check if it is a method, field or property
if yes then I need to display what class they are taken from
this is an example from vrchat's sdk
i inferred that you want to turn a search tree entry into a propertyinfo, methodinfo, or fieldinfo instance, plus a reference to the type that contained that instance
which seems so utterly straightforward
that i am wondering what i am missing
so i am asking you to write the function signature, which is how you would epxress what you need, in code world
you are inhabiting code world
you have to write code
i think you saw OneOf<> and had a heart attack
but hey, this is code world. you should learn what OneOf<> is / means
because it is the solution to your problem
at least, what i am hearing so far
you haven't expressed in code what it is you need yet
you still haven't given it to me
very concerning
I don't know how to express it through code
i'm not asking you to solve the problem
i'm asking you to define hwat you need
which is... a type
it's declaring
class WhatINeed {
int anInt;
string aString;
}
do you see what i mean?
tell me what you need
fill in the class with the fields you need
not searchtreeentry, not userdata
tell me what you want at the end
it depends, I need to see if it's a method, field or property
if it is then I also need the type they derive from
if not then I just need the type directly
struct WhatReimuNeeds {
Type containingClass;
// only one of the next three fields is set
MethodInfo methodInfo0;
FieldInfo fieldInfo1;
PropertyInfo propertyInfo2;
int ifThisIS0ItsAMethodInfoIfits1ITsAFieldInfoIfIts2ITsAPropertyInfo;
}
is this what you need?
lol
I don't know honestly
you're getting caught up in your own bullshit
I struggle with communication that's all you need to know
lol
well it's better to just write in code
but if i send you something
like OneOf
you have to look it up!
you have been struggling with OneOf
that looks like, Type, MemberName, Parameters (Instance if non-static + parameters)
you didn't know OneOf as a programming idea existed until now
class WhatReimuNeeds {
OneOf<Type, MethodInfo, FieldInfo, PropertyInfo> searchResult;
}
you can EASILY implement OneOf informally. it's just whatever field isn't null.
yeah
you can download OneOf from github
cool
but I had to answer and I paused it 😭
now your powers have enhanced 🙂
it's okay
do you NEED OneOf? usually OneOf is a code smell
it really depends what you're trying to do that is common between these four things in your oneof
I won't add it to my project cause I can just do 2 if statements or something to get the logic I need
it is usually better to model it differently - for example
interface WhatReimuActuallyNeeds {
string name;
SlotDefinition[] slots;
}
interface SlotDefinition {
DirectionEnum direction;
bool acceptsInt1;
bool acceptsInt2;
bool acceptsInt3;
bool acceptsFloat1;
...
bool acceptsString;
bool outputsInt1;
...
}
WhatReimuActuallyNeeds ConvertObjectToNodeRepresentation(object target);
i doubt Udon (the framework you use for the node stuff) would allow the use of reflection in production, iirc they're pretty strict on what they allow and disallow, idk if the plan is to visualize all MemberInfo or to use them to build stuff
no, I am trying to recreate Udon
at this point I could just slap Bolt into the project and call it a day
but I've been working on this graph editor for months sooo
if its your own recreation, technically nothing stops you then from 'graphifying' C# things such as Fields, Props and MethodInfos
(Might be hell on performance though)

Delegates are a thing though do take up some memory so its a balance of memory vs speed
I actually made a compiler to C#
it's not done, obviously, since I'm still trying to figure out how to create different nodes based on methodinfos and all that
Hey,
I wanna add an air duct on both sides of the wall by a raycast
so lets say " I ran the raycast function and it hit a wall "
public Transform s;
public GameObject duct;
RaycastHit hit;
if( (Physics.Raycast(s.position, s.forward, out hit, 10))
{
// add duct
GameObjcet item = Instantiate(duct);
}
how do I make sure that the item is going through the wall with its center in the middle ( knowing that the wall thickness is 10 ) ?
hit.point ( gets the point )
hit.normal ( gets the surface ) , anything for the center of the object ?
this is the start of a long journey
Udon was a Mistake
why is that?
they could have started Roblox Studio once
and learned everything they needed about doing that sort of thing
you write your game state machine in lua, and network diffs of the lua memory arena around
didn't vrchat make that just for scripting maps tho-
they are trying to use it to solve general purpose replication
if you need to special purpose replication of a particular thing, like a transform, you declare it specially in lua. that's it.
i would also sooner use Blockly/Scratch to author luna than a node based editor
i think the node based editors have appeal for tech artists, and tech artists belong to fandoms and therefore contribute art-asset-adjacent things like levels
I don't understand what's wrong with their approach-
but if there were an exchange rate, i'd rather convert 1 programmer to contribute than 10 artists
and a programmer will just wanna write C# or whatever
they just made a way to script maps that's more easy to understand by the average individual that doesn't know C#
I don't see what the problem is-
it is the meme of poorly implementing half of basic LISP
that is the problem with their approach
they are trying to overcome limitations in il2cpp too
this is mostly unity's fault
and the platforms
there's no reason you should be able to run whatever code you want in a web browser, but everything has to be signed in an app
Is it wrong if I try to make a system like that? I mean most of the things you'll use it for is just making a button toggle a gameobject and stuff
no not at all
if you wanted to network it, you woul dhave to deal with a bajillion problems very rigorously
as long as networked replication is not on the table you should be gucci
I do tho
hmm
I don't know why that would be a problem
as I said
I am making a compiler to C# for this
so I don't see why I couldn't do that
i see
my Mirror knowledge is still pretty limited
sadly
but I doubt I can't make it work with networking
I'm making a multiplayer game and my intent was to use username/password, but my game designer has let me know that he doesn't want to do that because of IAP-contamination across platforms (ie, Apple/Google might want ring fenced user cohorts or put up a fuss if our product were multi-platform). I disagree, but that's why he gets the big bucks and I "just work here" 🙂
To that end, any thoughts on whether SystemInfo.deviceUniqueIdentifier is good enough (without a password)? I'd be worried that it's an insecure method to track a user - ie, someone could forge that item and "steal" someone else's character.
My original solution is to use the DUI as a starting point, but offer the user the ability to add a password to their account (giving them some sort of in-game bonus). The system would still use the auth token I currently use, so entering a password to an account with one might never actually be needed, so long as the user logs in every 2 weeks or so.
Any thoughts?
Sounds like a security hole in a multi player game
Besides, you probably have to support apple login in ios
So might as well do sso
Well, security hole in what sense?
I'm thinking that a user could optionally add a password to their account - if the user doesn't have a password, then the system just logs them in (automatically) with device ID
if they DO have a password then it logs them in with deviceID/password and grants them a token
quite sure device ID's can be spoofed
oh for sure.. I'm not saying they can't.. I'm just wondering if there's any problems with my approach.. here's sort of what I see so far:
- Device IDs could be spoofed, so if a user A found another user B's device ID, and B didn't enable a password, A could simply log in as B by spoofing their ID.
- I couldn't ban players, since they could just spoof a new device ID. Although I suppose the same would be true of username/password.
- Users won't be able to migrate to a new device - if they buy a new device, all their purchases are gone without support/manual intervention ... and I'm not sure how to do that easily, aside from letting support manually set a device ID.. which brings its own problems (how do I know a user is who they say they are)
If you can't make your own accounts, you should use Apple ID/Google login
Hm, that's an idea, too, although we're going to be on steam/windows as well.. SystemInfo.deviceUniqueIdentifier works on windows too, so I was sort of hoping to build something once that would work for all 3 platforms
that would mean building your own login/account system basically.
I suppose I can't get away from the downsides of any given approach though.. if I want users to be able to just automatically login/create accounts, then I have to tie them to the device id
Yeah, I mean, I have that already
I mean that's... a ui that has username/password fields
I'm told that Apple/Google don't like cross platform
that's not a whole system
Fair 🙂 but I mean, it works, I just don't have a signup workflow built
I have username & password authentication with tokens
you'll need a backend to support that, a signup workflow, etc.. and it's easy to mess this up and do it insecurely
Yeah .. the signup workflow is what I'm building now
I have all the backend & security in place as it is but.. requirements changed
encryption, salting/hashing, auth token etc
well, whenever people think the security side of things is taken care of already, guess what....
They weren't salted before?
they're salted
Anyone saying they have a secure system probably doesn’t know enough to see all the holes 😉
sorry, let me backup and restate the entire problem:
- Current: Users must login with username/password. No signup workflow exists - I was building it today. System is fully cross platform.
- New requirements: No cross platform play. Simple (automatic) signup.
My proposal is to use DeviceID in place of username, and put no password by default until a user enables it.
It also depends on the value of the data
No value, really
The value is probably in migrating the data - like if a user gets a new device, I can imagine them wanting to have all their purchases and progress
(but if I use device ID as the user key.. obviously I can't do that without manual intervention... which.. maybe that's OK?)
Yeah thats pretty common. I usually follow a process like what PlayFab uses. Remote accounts tied to email addresses (optional), for data synchronization. But these days I think most folks just use the on-device iOS and Google Play features (if using mobile).
I'm curious where you end up 🙂
Hm, yeah. Does unity have google play integration? Ie - can I get an email address from a user without them needing to input it?
We're not going with playfab - it was far too expensive in previous projects
like $10k/month at scale
Oh yeah, I 100% don't recommend Playfab
We used nakama for a while before rolling our own in angular/mean stack
I've reproduced nearly everything I think we need and our bill is likely going to be less than $200/month
that's our entire azure stack - cosmos DB, app server, container registry, metrics, etc
game server(s), admin tools, everything
I'm just.. really stuck on this device ID thing.. I don't like it because of the problems it has
But their process is good to copy. You can get Playfab for free for 2 years now, but it is still not worth it imo. But we don't use azure either, we migrated everything to our own servers.
Azure is kind of a pain in the dick but.. it's cheap compared to the comprehensive services (playfab) and.. once you get your head around it, it's not too bad
Yeah, I'd probably want to pair the device ID with a token of some kind if you want to restrict device access. The device ID won't carry to a new phone anyway.
that's with 500x bots running 24/7
OK, I'm going to pull the trigger on this approach. I'll use device ID as the uid and ... if a user upgrades their device, we'll have to figure out how to migrate the user securely (mostly concerned with "they are who they say they are")
We pay about ~80/month, and thats for our 8 dedicated servers (48GB, i7's) with unlimited bandwidth. Great little beasties. But back in the day we used Azure and NfoServers a lot
Maybe I can collect a bunch of data points in the SystemInfo space at signup .. shrug
Anyway, I won't distract, good luck. I'd porobaly build it out the same way unless I really needed to worry about the securement
what's the easiest way to get identifiable information in unity? do I have easy access to google play / ios info, or do I need libraries for both
Guys, a data structures question.
I have a 2D array of a bunch of units.
Let's say, I will frequently need to find the closest valid unit to any of the units in this 2d array.
What sort of data structure should I use, or what method to be able to get that without bad performance?
is the 2d array indexed by space/location?
Unity has its own device ID you can grab, https://docs.unity3d.com/ScriptReference/SystemInfo-deviceUniqueIdentifier.html
Yeah I mean, that's what I meant I'd use, but if a user upgrades device and emails support and is like "trust me I'm Sharping" we have no way to verify that
so if I tracked some identifying information (like email address or username even) then.. they could say "I'm Sharping" and customer support could look and verify that their user was created on such-and-such a date, and had email:sharping@sharping.com or whatever
Yeah I think for that (automatic device ID sync) you'd need to use either a cross platform plugin, or a direct Google Play Games Service or something / assuming you want to let the on-device service handle that sync for you
deviceID by itself wouldn't be comprehensible by a customer support human
So the 2d array represents the grid.
(0,0), (0,1), etc.
But on each point, there is a boolean called valid or invalid.
I need to find to the closest valid point to another point (x, y)
And I'll be doing this very often, so I am worried about doing it the brute force way, cause it'll be many times per frame possibly.
You'll probably want to write an extension method then that finds the closest valid to a given (x,y)
even many times per frame is probably nbd
What or how should I write that best. Is there a known algo
that kind of CPU use is pretty hard to max out compared to .. other things
how many items in your grid, and how big is your grid, roughly?
It could be very big, idk that detail right now
because honestly I'd just write it in the way that would be the least-buggy or least-prone to bugs, and worry about performance later
I mean I know the brute force way is just:
for (int x = 0; x < grid.Width; x++)
{
for (int y = 0; y < grid.Height; y++)
{
// Check distance of this (x,y) to the target point, and record shortest
}
}
so something I'd do then is like...
class GridObject
{
public float GetDistanceFrom(int x, int y) {}
}
But I just thought there'd be something way better
yeah that's just what I was going to write out
There's no way this is the best thing tho
or alternatively if your grid is super sparse - keep track of only the items in the grid
Closest pair of points algo? Pretty common
it really depends what kind of "distance" are you going for? You could use an octree or interval tree or similar spatial partitioning structure.
it's not the best way, but it's the simplest and probably doesn't matter for small grids/sizes
What about a way of iterating through all the nodes in a spiral way starting from the target node itself?
remember, the unasked question's answer is usually: make it the simplest and worry about performance when it becomes a problem
an Octree? I'll look that up, but I assume if it requires me to create an Octree object and I'd be doing this often, that would be worrisome as well
you could do that too but again, sounds complex, and is likely to be buggy on the first few attempts
I have already done the simplest
I have it working, I didn't mention this sorry
I just feel like this is weak code
you'd create it once and reuse it
My operation used to be 80-100 ms, now it's down to 11ms
and I was seeing if I can get it even lower
Can the same Octree be used if I am checking the shortest point to different points each time?
the two simple approaches that come to mind for me are:
// one
for (int x = 0; x < width; x++)
for (int y = 0; y < height; y++) // get distance, track the shortest
// two
List<GridObject> allObjects;
foreach (GridObject go in allObjects) // get distance, track the shortest
11ms or 11ns?
So a different target point from which to find other shortest point
why not
11ms seems absurdly slow for one check of the entire grid - normally you could check millions of elements in 1ms
11ms is my entire thing running 24/7
like my game's map doing operations
which im injecting repetition into
are you often checking from the same x,y? you could just sort the allObjects whenever there's a change, if so
for stress testing, like i am assuming worst case
Not quite, it'd be checking different x,y almost each time
cause that x,y is moving.
sorting allObjects each time it moves would also be bad yeah?
if you don't care about memory usage, you could cache the distance of each grid element to each other (x,y) in the grid and then it's just a lookup, but the memory usage for that would be O(n^2)
the memory use there might be more impactful then the CPU use though tbh, and would bloat real fast if your grid is large
you'd need O(n^2) cpu time to build that distance cache too
it depends on the access pattern frankly - are we doing a lot more reads than writes? If so such a thing might make sense.
like, are you just using your own formula?
btw is octree made for 3d points?
would i use quadtree since im sort of doing this in the 2d space (ignoring y)
maybe?
probably?
idk haha
Ok yes, I looked it up - quadtree is the 2D analog of Octrees so yes.
Btw cool animation of a quadtree nearest-neighbor algorithm in action https://ericandrewlewis.github.io/how-a-quadtree-works/
https://blog.devgenius.io/hybrid-spatial-data-structures-quad-kd-and-r-kd-trees-3831b6bfbabe
Alternative hybrid solution comparisons
catchy image
:0
quadtrees remind me of that HTML game that was popular a few years ago.. i can't remember the name of it but you popped bubbles of an image and it made smaller and smaller bubbles until you had uncovered the image
It reminds me of a Mondrian painting
has anyone run into a similar problem to this java.lang.RuntimeException: Unable to get provider com.*** My project is currently failing on startup due to appcenter
look slike it's ultimately from a NumberFormatException - did you put something weird in a version number string somewhere or something like that?
is it safe to use gameobjects as dict keys
Sure, why not?
as said, why not? but then, why you want to do it though?
I'm doing this map system where a game object can optionally attach itself to a map manager, which keeps a Dictionary<GameObject, Sprite> to display
It can also remove itself by telling the map manager. I'm wondering if multiple game objects will ever share a hash or something
Just remember that a GameObject can get destroyed, which will cause an undefined behaviour, since dicts can't have null keys.🤔
yes, precisely that
No, that should be fine.
On update I also have this thing that also checks the dictionary for any non existent game object keys and removes them from the dictionary
I can think of instead using a list of key value pairs instead so there's no need to worry about dictionary keys being null but performance wise that would be O(n) instead of O(1)
for insertions and deletions
I'd guess that it would hold a reference to the wrapper object. I think when unity objects are destroyed, they're not actually destroyed on the C# side, but they artificially return null. The reference is still there untill the GC can collect it. Might be wrong.
well, a gameobject has an instanceID, it's not entirely reliable specially since it's out of your control, but I guess the hash uses it. But a better way would be assigning IDs that are under your control to said gameobjects, and then use then as the keys. Since they self register, they can unregister as well if destroyed
Even if you have objects with the same hash in teh dictionary it'll still give you the right object
wait, what?
can you elaborate on that?
A dictionary has buckets (indexed by the hash), so if you have multiple items with the same hash it just has multiple items in that bucket, then it uses normal equality comparison to find the right object
what is the hash conflict resolution used by c# dictionary?
Not sure if you're 100% correct in that, but let's say you're, ain't doing a equality comparison between objects, negating the speed of the dictionary, and hence making it not useful for it's usage?
I suppose it only occurs if the bucket contains more than one thing
which for a large enough hash table shouldn't happen
Yeah it only happens if you have a lot of duplicate items
If someone is putting duplicate hashed objects on a dictionary, I would say that person is using dictionary wrong
Hashes don't guarantee uniqueness
But you see, I can always stick a knife on myself, doesn't mean that it's a good choice of an action to be done
They just guarantee that 2 objects with different hashes are different, 2 objects with the same hash can still be different (although unlikely with a good hash method)
yes, but wouldn't you say that this exists as a safeguard exception, and not the rule?
I suppose
How do you import a png at runtime while keeping it's transaprency ?
Using Texture2D tex = new(2, 2, TextureFormat.RGBA32, mipmaps) with bilinear and repeat wrapt mode at the moment
Then load the image but all the transparency becomes black
The fence shouldn't show the black part and the ground black part should be transparent, revealing the grass underneath
I tried settings the pixels but still no luck. What am I missing ?
I'd look into TextureImporter.alphaIsTransparency
it says that it's intended to be used in the editor tho
but black pixels are most likely caused by alphaIsTransparency == false in your texture
sounds more like a material problem to me. Are you using a shader that supports transparency?
define equation for a plane -> sample points on the plane and store block data into a texture to be rendered
GUI.HorizontalScrollbar
it is impossible to change the y size of this bar
and i just searched how to grow everything with GUI.skin
but there is almost no any information about this thing
GUI.skin.horizontalScrollbar.fixedWidth
GUI.skin.horizontalScrollbar.fixedHeight
GUI.skin.horizontalScrollbarThumb.fixedWidth
GUI.skin.horizontalScrollbarThumb.fixedHeight
nvm found a way to do it with gui.skin
Hi everyone, I'm using multiple adittive scene for a dungeon instanced system. So I load the same level over another so the players can play but not see each other.
It work great but... navmesh is global. It also loads all the navmesh one over another and server side it's a mess. Is it possible to have navmesh working on local scene and not globally?
you can have individuals navmeshes using the NavMeshComponents
https://docs.unity3d.com/Packages/com.unity.ai.navigation@1.1/manual/index.html
@fast pagoda so if I have multiple navmesh components one over another they don't merge in one?
thats correct
ok, will try. A new question for you @fast pagoda . I have also some navmesh obstacle. In this case do they work locally on the local scene or they work on all scene? I need them to work locally only on one navmeshcompontent and not on all
hm, for that i don't know, i think the navmeshlink can be used to link the obstacle to a specific navmesh, but again i've never tried so i'm not sure 🤔
but by default all obstacles should work on all navmeshes IIRC
@fast pagoda need to test. Because client side players load only one scene and have of course only one mesh. But server side I load all scene on over another with local physics and it's there that is causing problems
I was also thinking to offset every scene a bit so navmesh and navmesh obstacle don't overlap. But yeah, not 100% perfect
thank you for the help vision!
I'm working on a dungeon generation algorithm, I am generating rooms in a grid and I am using the BFS to find the shortest path between two rooms to create the hallways. However my BFS implementation doesn't seem to be working.
List<Vector2Int> BFS(Vector2Int src, Vector2Int dest) {
List<Vector2Int> queue = new List<Vector2Int> (),
path = new List<Vector2Int> ();
List<Vector2Int> adj_nodes = new List<Vector2Int> ();
Dictionary<Vector2Int, Vector2Int> path_dict = new Dictionary<Vector2Int, Vector2Int> ();
bool[,] visited = new bool[roomCount, roomCount];
Vector2Int node, prev = src;
queue.Add(src);
while(queue.Count > 0) {
// Get first node and dequeue it
node = queue[0];
queue.Remove(node);
adj_nodes = GetNeighbors(node);
foreach(Vector2Int item in adj_nodes) {
if(!visited[item.x, item.y]) {
visited[item.x, item.y] = true;
queue.Add(item);
path_dict.Add(item, node);
if (node == dest) {
print(string.Format("Exit node = {0}, Destination node = {1}", node.ToString(), dest.ToString()));
queue.Clear();
break;
}
}
}
}
print(string.Format("Source = {0}, Destination = {1}", src.ToString(), dest.ToString()));
PrintPathDict(path_dict);
Debug.Break();
// Backtrace
node = dest;
while(node != src) {
print(node);
path.Add(node);
node = path_dict[node];
}
path.Add(src);
return path;
}
The problem is that the BFS never find the dest node for some reason
The if(node == dest) is never executed
The GetNeighbors just return a list with the (x-1,y) (x+1,y) (x, y-1) (x, y+1) positions of the node
I tried changing the line to if(item == dest) since it is inside the neighbor loop but it really does no difference
It makes more sense to be item not node to be honest
Why not use an actual Queue insteead of a List?
Or at least:
node = queue[0];
queue.Remove(node);```
Should be:
```cs
node = queue[0];
queue.RemoveAt(0);```
(though the queue would be more performant)
Also your GetNeighbors implementation would be helpful to see
use the CLRS implementation of BFS
visited should be a set
probably your getneighbors is wrong
it looks like you actually have something almost exactly CLRS
why not use it exactly
use the same words
Sorry for not including the GetNeighbors function but it's really nothing interesting
// Get neighbors for BFS
List<Vector2Int> GetNeighbors(Vector2Int position) {
List<Vector2Int> neighbors = new List<Vector2Int>();
// Neighbor on the left
if(position.x - 1 > 0) {
neighbors.Add(new Vector2Int(position.x - 1, position.y));
}
// Neighbor on the right
if(position.x + 1 < roomCount) {
neighbors.Add(new Vector2Int(position.x + 1, position.y));
}
// Neighbor above
if(position.y - 1 > 0) {
neighbors.Add(new Vector2Int(position.x, position.y - 1));
}
// Neighbor bellow
if(position.y + 1 < roomCount) {
neighbors.Add(new Vector2Int(position.x, position.y + 1));
}
return neighbors;
}
Because I really didn't think of it I just translated my python implementation of the BFS
I did some research on what CLRS is. I had no idea about this book. I just translated an old python implementation of mine to C#.
looks ok. Just wanted to make sure you had bounds checking in there
Based on the Debug.Log there are times that it never reaches the destination even is a simple grid like
Room None Room
None None None
None Room None
and others that the destination is inside the path_dict but it is ignored
shouldnt it be node = queue.Dequeue(); if its a Queue?
ah wait misunderstood i think
any ideas why an iphone build would be 200mb larger then an android build? the only difference is the Iphone build has arkit as well as standard unity ar foundation components associated. where the Android build does not include AR stuff
Yes but it's a List
Yeah i misunderstood, i thought the message after you suggested to use a Queue was to change those lines to account for the Queue
Anyone have experience parsing strings? I am looking to perform a check then cut or leave a string based on what I find. Any tips on how to perform it? here is some pseudocode to illustrate ```
var foo = "@CheckFlag[ExampleFlag, -1] (Phrase to return.)";
if(foo.Contains(@CheckFlag))
{
foo = Data.Flags[ExampleFlag] == -1
? foo.Replace("@CheckFlag[ExampleFlag, -1] (Phrase to return.)", "Phrase to return.")
: foo.Replace("@CheckFlag[ExampleFlag, -1] (Phrase to return.)", "");
}```
since iphone build executables are codesigned by default, the binaries do not compress
unity binaries uncompressed are about 90MB nowadays. in two architectures that's 180MB. system iOS frameworks are not linked statically, unless they happen to be included by your plugins for some reason
Learn regex 🙂
Interesting so you think just the binaries of unity/arkit and maybe something like an ios goodies could bloat it to be that much bigger
so probably @alpine adder it's the two ios architectures
it's not going to be ARKit
i haven't done it in a while, but i believe unity's xcode project specifies both arm7 and arm64
what do you mean by 2 architectures? I believe we are doing arm64? with il2cpp
I see
this is sort of a red herring. the app store only delivers the arches your device needs
you should start optimizing build size only at the end of the development process
you can try building an empty project to set your expectations
i believe a typical small unity game on iOS is around 25MB
over the air
I see xcode does have arm7 on there. yeah we just optomized a ton which was why I think we are so shocked around the ios size
thank you.
also what size are you measuring
the xcodearchive and what you upload to the app store are not the over the air sizes
appstore file
whats interesting is we removed 150mb on our android
but the iphone didn't move
ton of files and changed png to jpeg? which tool are you talking about?
hmm
are you working on a visual novel
and are you placing files into StreamingAssets?
files are in resources. and we are making a item design applicaiton essentially
so just a ton of textures
yup 🙂
i think you should download/buy the Build Report Tool asset and start there
changing the file format from PNG to JPEG had a side effect that improved the build size
but it isn't why the build size improved
for example, if you did jpeg compression 10 instead of 1, the build size would not improve
changing from PNG to JPEG changed your import format (which is what really matters) from one that included lossless alpha by default to one that did not
your build doesn't ship PNGs or JPEGs.
you shouldn't have anything in Resources. you shouldn't use Resources.
our 3d artist took care of all of that basically in our resources folder is our built in textures vs ones from a cms and he optomized thoughts
if you want to reference a list of images, create a Sprite[] on a component and drag and drop them into that field in the inspector
i'm trying to describe what happened
and what would be the advantage?
i think intellectually you see what i am saying
changing the format didn't reduce your build size
changing the import format in the inspector did. that occurred as a side effect of changing the image format
does that make sense?
that does make sense
all files in resources are always included in your build, regardless if they are referenced by anything
but when i say files, and i think this is one of the things you are now getting a better understanding of, i mean imported files
there are no PNGs or JPEGs in your build. there's a compressed texture format that is created, platform specific
clearly, for android, the compressed texture format is idiosyncratically set up to be a more compressed format than the one for iOS
evne though "the files" are the same
you have seen this in the inspector, it's at the bottom.
build report tool can help you see all these things
removing files from your Assets/ directory typically does not change build output size, however, in a resources folder it does.
Really?
yes.
you should never use the Resources/ folder
the worst reason to use the Resources/ folder is to retrieve an array of files via Resources.LoadAll
because that just means you haven't discovered that you can select multiple files in the project browser, then drag and drop them onto an array field
alternatively, if your file structure is complex, make an editor script that goes through your assets folder and assigns the array field for you.
I am purchasing now
i don't think there is anything wrong with this code. try changing Vector2Int node, prev = src; to Vector2Int node = new(); and queue.Remove to queue.RemoveAt(0). it looks like it could be as simple as dest not being within room count.
i really doubt that vector2int doesn't have an equality operator
it's possible
you might just have to compare its components.
you sir. are amazing. doing the build report now but just those sentences are 10/10
Thank you +100 overflow points
lol
np my dude
now, why does unity not have a runtime compressor so that you can use JPEGs directly? i don't know
the performance tradeoff would be worth it for many use cases
this is pretty tricky. you're trying to do Fez right?
any ideas why our ipa is 300mb but our appstore file is 470mb?
the appstore file includes bitcode and probably the two architectures
the appstore file is a red herring
I see so in general unrelated and not much I can do there
i don't think it's a super essential number to optimize. focus on what build report says is big, and explore the texture compression options
Sorry if I am missing something out but new() what thing?
I mean just node = new(); doesn't really make sense
it's just syntax
don't worry about it
there's nothing wrong with this code
something else is wonky
it is a dotnet6 feature. will not work in unity though
if(position.x - 1 > 0) should be if(position.x - 1 >= 0) same thing with the position.y
@undone coral just finished ios and android build size and they are basiaclly the same size when you down into the data it shows. the ios build is technically 1g it says but thats because it genreates an xcode file not the ipa itself. we will have to tackle the things this build report points out and that is probably the best we can do
it does actually
you just need to use the right version that supports it
Unity 2021.3.5f1 is one version that supports it
I have to pass the static TagManager.PlayerPrefString which (as obvious by the name) is a string that is cached in the tag manager. I need to pass the TagManager.PlayerPrefString into the serializefield/ref
I could type up the string, but I would like to pass in the cached ref
What is a TagManager?
static class that caches all strings that are passed to playerprefs and other places
wait dotnet 6 is supported in Unity??
idk, but the new(); thing is atleast
oh 😔
i mean you could try dotnet 6 stuff
im not all too familiar with dotnet things tbh
i just try things until i get errors lol
dotnet 6 is sweet, dotnet 7 is even better
just don't know which decade Unity is going to support them
that's dotnet 5 i am pretty sure
oh 💀
(whispers) static abstracts in interfaces
Oh does it now? Thought it wasn't working yet
yesssss
got no errors when i tried it haha
also ref fields ♥️
Sign up for the Level 2 Game Dev Newsletter: http://eepurl.com/gGb8eP
As of Unity 2021.2, you now have access to some new C# features in Unity. This is thanks to improved support for .NET Standard 2.1 which has given us Unity developers the ability to use all of the features available in C# 8.0. In this video I'll cover a handful of programming...
my fav thing in this video
is new(); c# 9.0 things?
wait hollon, i can see what c# version specific unity releases uses, let me find that page real quick
I love these videos lol
January 8, 2022 new C# features for Unity!!
Meanwhile C#8:
not really... Unity has its own version of C#
😔 or what was equivalent of C# 9.0
I want C# 11
In 10 years, let's be patient
And when .NET15 will be released on the usual November
Guys my UNITY EDITOR CRASHED ON ME!
I couldnt open it at all except in the SAFEMODE
The scene became BLACK all the sudden
I assume that is what is causing it
alls the sudden BOXCOLIDER is not serialized
I have BoxColider as a parameter in one of the functions public void SyncWalls( Vector3 position,BoxCollider col){ //do stuff }... What is wrong with that ??
step 1 to resolve "Unity is giving me this weird compiler error" is deleting the library folder and opening the project again to see if it goes away
ok I'll try that, its very weird and odd
hey is there a way to make a scriptableobject that maps Interfaces to classes?
Hey, I did that and as soon as it finished, i ran into lots of depency issues, after fixing all of them up, it appeared again :S
Unity 2021.3.4f1
should i switch to unity 2021.3.5 ?
is it a unity issue ?
(this is why you need git)
what is the stacktrace? that error looks like it comes from Mirror, based on some google-fu
hi, I am simon & I am currently creating a software in which you can calculate your average score in school. I am done with the GUI, but still need help for the logical part. Would anyone be so kind to support me?
sounds like a question for #💻┃code-beginner
Hello !
I'm using Netcode for a multiplayer game, and need to use the component "ClientNetworkTransform".
But I can't find it...Do someone would know where it is and how I can implement it to my project please ?
I need to check if the player movement direction is directly opposite to the surface normal of a surface.
SO if the player is running left into a wall, the surface normal should point right?
I have the raycast hit.normal
@unkempt moat if you are using netcode for gameobjects they have active discord (Unity Multiplayer Networking) where they will help you (look it up can't post invite links here)
Thank you, I'll look it up then ! :)
yeah, we Unity folks won't be benefited from it.. lol https://github.com/dotnet/runtime/pull/67917 ...what a shame
Hey! I have a question regarding scene rect selection when using a custom VertexAttributeFormat for the vertex positions. Our game is voxel based and due to our very specific setup we can drastically reduce the vertex buffer size, i.e. have 8 bits per axis instead of 32. In code this looks like this:
new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.SInt8, 4)
We decode this position in the shader and we can render our object without any issues. By overwriting the "Picking" and "SceneSelectionPass" passes in the shader we can enable proper picking support in the editor as well.
However, rect selection seems to use a separate system which seems to make intersection tests with all renderer components. Since our position format is not what this rect selection expects we get errors.
Is there a way to support rect selection properly when using a custom format or is there at least a way to exclude the object from the rect selection?
Runtime IL shenanigans are probably unlikely to land on Unity's IL2CPP environment anyway?
There's a hope, that is until their migration to CoreClr complete
hello everyone, so I'm making a visual script editor, and I can't figure out how to get MethodInfo, FieldInfo and PropertyInfo types
like, transform for instance
how can I get it's type?
.GetType() doesn't seem to work
It's not compile time is it? I imagine Unity will continue with IL2CPP unless C# can cover all platforms that Unity can.
it just returns this:
.transform being a property, getting it via reflection gives off a PropertyInfo instance. From there you can get its property type
how exactly?
yeah that too
I'll try to figure out how to get it's parameters as well
I'll redirect you to the official docs on reflection at this point
huh, I did not think of using that
thanks a lot!
You won't find any info on this on the Unity docs, you'll have to do this from the C# docs directly
As reflection is pure C#
Hello, i'm creating Texture2DArrays as containers for procedurally generated textures to feed into a shader that does more processing, i'm using arrays to work around the sampler limit.
My setup worked using Atlases but had some troubles with tiling. I'm creating these bundles in memory feeding them to a shader and baking output then disposing of them with the only thing being written to disk is the output.
however with Texture2DArray, i'm having trouble assigning them to the material without creating an asset first, which require a lot of time writing to disk.
I've also tried using a RenderTexture as an intermediary and assigning that to the material, however then the shader would only treat it as a single texture despite the inspector showing an array.
Is there a way to create Texture arrays and consume them without writing to disk ?
-solved, i wasn't using Apply() while keeping them readable after editing them ...
why doesn't this work with an actual get set property?
objectField_BehaviourObject.BindProperty(serializedObject.FindProperty("behaviour"));```
If I were you, and if I knew I'd be working with bunch of reflections, I'll tag all those(methods, properties, etc) with customAttributes... it will make your life much easier
Hello guys, I have a question. I want to create a magazine (UI). I want to create a scriptable object which contains strings and images.
Like a list:
First element: String
Second element: Image
Second element: Image
Second element: String
Hello guys, if anyone uses PlayFab
I have a short question, how do I call or get player's Display name ?
yes, mudbun does something similar. you can look at their source
Thanks for the suggestion! Seems they are using a custom renderer component (with custom selection) and when they transform their object to a mesh they are using the default mesh layout with 32 bits per axis for the position. Ideally I'd like to keep the mesh renderer component and the Unity selection logic and just extend that but it seems to be quite locked down.
Hey guys, can anyone help?
How bad will it affect the performance if a "if (component == null)" is called in the update method each frame? component in this case is a reference to the component on the gameobject
Will this be bad for performance, how expensive is a null check?
it's fine
is there a reason you need to run it in Update though?
seems like something you could check in OnEnable and then again whenever component is assigned.
Well it's complicated, I have a script that uses a component from the same object. Usually you would just assign it in the start or awake method and thats it, right? Well in this case i also need to access it while the gameobject itself is disabled so start and awake havent been called. so i made a get-set method, and inside the get part i check if it's equal to null and if it is, i assign GetComponent to assign a value to it. but i use this variable in lots of places lots of times, so each time it checks if its null or not, even long after it has already been assigned a value. Do you know if this is the best method to do this and if the performance will be unaffected?
There's no reason to use Update then. Just make a property:
MyComponent _theComponent;
public MyComponent TheComponent {
get {
if (_theComponent == null) _theComponent = GetComponent<MyComponent>();
return _theComponent;
}
}```
Why would you need Update here?
yes this is exactly what i have, the problem is that i am calling TheComponent from inside an update method, and not only from update but also lots of different scripts lots of different times, and i cant change those things, so im worried here if the "(_theComponent == null)" part will cause problems if called so many times, ive heard that null checks are bad for performance
it's fine
Alright I hope so, thanks for the help!
You can always use the profiler and check.
Hard to ... solve/profile issue. I've got this loading screen doing some starfield animation.. it's probably clunky, but I didn't think performance would be an issue for the magnitude of GOs and tweens/coroutines in play. Unfortunately, when connecting to the server, I get stuttering and hiccups. It might be the networking library blocking the main thread since it's not async or unity async, but .. I don't really know how to debug/solve this and I'd like to make it a bit smoother. Any general ideas how how to debug/profile/identify the issue..?
Run the profiler with deep profiling... if you see the networking library running IO on the main thread, that's a problem
Hm.. OK, I'll give it a shot. I haven't dabbled too extensively with the profiler.. I probably should get around to learning to
I looked at it a few weeks to and realized my Action event notification framework.. sucked
yup, networking 😐
Thanks PB
Never used profiler before, I checked it out. When im not doing anything and just staring at the profiler while my game runs it shows most of the stuff is between 5ms and 10ms with occasional spikes to 16ms or slightly above. (theres like 4-5 of these spikes on my screen at once). Does this stuff mean anything? Is it good or bad?
depends what causes the spike. You've got to look at that frame and see what the breakdown is
Profilers generally (I don't know unity's specific details) measure how resource usage for stacks.. so if you think you're having a problem, you .. profile that area and investigate
just running it "all the time" to review your entire game might not uncover anything unless it's extremely egregious
Like... rebuilding a UI and doing multiple GetComponent or FindObjectOfType every frame................ not that that's EVER happened to me in the last two weeks
👀
Well I have been avoiding all bad practices the entire time (For example i dont use findobjectoftype at all), so i hopefully dont have any egregious stuff. Do these spikes im getting mean bad things or is that just normal stuff?
And yea i was looking at just the general thing not a specific area
looks like the networking lib i'm using supports connecting on another thread but.. no idea how to do that
16ms spikes are probably nbd, likely just unity player issues
again you have to look at the spike. A lot of times it's the Unity Editor itself, so you can disregard it. But you have to look
Not sure how to look but when i click on the spike and zoom in on the part below the window it says playerloop(1.82ms), behaviourupdate(0.58ms), update.scriptrunbehaviourupdate(0.58ms) etc. Sounds all normal?
Should I use the unity IJob system to handle this connect code? Or should I roll my own thread using native C#
Dig into the three like I did in the screenshot above to find the worst offender
👆
i need some help
i made code for a cutscene where the navmesh agent component is disabled until the cutscene starts
but when it starts, the component is enabled again, but the character doesnt move
things to consider:
-The Area is baked
-I have a valid script for AI navigation
-There are no errors
-Ive seen with my own eyes that the component does get disabled and then enabled again but the character doesnt move
That only adds up to about 2.5ms
make sure you're looking at the right frame
Or if that is the frame, then you're fine because 2.5ms equates to about 400 FPS
.
Don't @ people directly unless they're.. expecting it.. If you ask a question and don't get an answer, it might be because no one knows, but it also might be because the question isn't... clear enough and people don't necessarily want to engage and help you clarify the question. 🙂
This question belongs in #archived-code-general, though. I don't have experience with navmashes specifically, but just enabling a component may not do what you need it to do - you probably have to tell your character (in script) that the navmesh now exists and to start navigating
you said the component gets disabled and enabled again and the character doesnt move. maybe after it gets enabled again you have to reassign a destination to him? cuz maybe i you assign the destination and then disable and enable the script it forgets its destination
nah
its still there
i think im closer
since there is now an error
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
it says that even tho i have baked the ground and he should be able to walk on it
it means hes not on the navmesh when you are calling SetDestination
he is tho
maybe hes in the air or a couple millimeters off the navmesh
nah
cause when i get rid of the enabled = false
like when i start the game, he is moving and it works
hey guys. Did not use Unity in a while. How are the interfaces in C#? 🤔
I remember having issues with them where if the object got deleted its reference in C# via interface would say its not null for a few frames after that. But would crash when accessed.
Does that still happen?
Sort of - you typically don't manage access to unity GameObjects directly, and you can't check to see if they ==null since unity overrides that operator
But I don't really understand your question - there's obviously a way to delete gameobjects, components, and normal C# POCOs if you need to
When you say "interface" do you mean interface proper, or do you mean the API surface - ie, the methods and properties you use to work with the classes in unity?
interface proper. IDamagable lets say. I used to have this issue where that interface field would pass an if (someDamagableInstance != null) but that crash when accessed inside.
Read that its common behaviour and I should deal with it. So I am wondering if its fixed.
So - yeah, that might not be related to the interface but more that MonoBehaviour - the class from which all unity objects derive - has it's own GC behaviour and operator== is overloaded
in general you're not supposed to use someObject == null in the unity world if someObject is of type MonoBehaviour
And even though that post is now 7 years old - it's as relevant as ever since this question comes up all the time. 🙂 It hasn't been changed. As far as crashing unity when doing that from within an interface, I'm not aware of that issue specifically..?
on the one hand, in unitask this is easy to solve - it has helpers for the threadpool. but if you use ONLY threadpool for async, you don't need it. i suggest running the network tasks on the threadpool.
you will probably want await UniTask.SwitchToMainThread() though, if you want an idiomatic way to get network messages into your game
using async will ensure that your stacks still look like that - super legible
it is extremely valuable to have stacks that look the way they do in your code right now
there are secondly spikes when profiling in editor. you have to profile standalone
to determine if spikes are real or not
there's a ton of code, especially in scriptable render pipelines, that causes spikes in the editor because it's editor-only but in the runtime assembly
I already "fake implemented" it just using async ... dangerously. Because that's how I roll. 😉
_ = ConnectAsync(address);
private async Task ConnectAsync(IPAddress address)
{
await Task.Run(() =>
{
_ruffleSocketClient.Connect(new IPEndPoint(address, GameSettings.ServerPort));
});
}
👀
I'll add a cancelation token to it later in case it kabooms
(which I can watch for in Update())
before
after
isn't ruffles UDP?
yeah, why?
connecting in UDP world is instantaneous because... there is no connection
i guess they implement a connection over udp
sorta - this is reliable UDP so .. there is actually a connection with handshake/challenge/etc
tbh i'd use TCPIP but i couldn't find a library I liked
refactoring it out later for a different library wouldn't be hard without how i setup my networking interfaces internally
pretty much everything on both server and client are routed through two methods (aside from all the connection stuff): SendMessage() and HandleMessage()
if you have any managed C# tcpip libraries you're aware of, by all means let me know
in my experience only grpc offers 100% of what you need for a big, robust multiplayer RPC framework that will last you forever, with the big downside that it does not support arena based allocations for C# and thus generates quite a bit of garbage
yeah - I don't need any of the RPC stuff, I've rolled my own messaging framework
http/3 webtransport is essentially grpc over QUIC (i.e. UDP)
but there's no http/3 for unity.
there's barely http/2
I probably could just go TCPIP and .net Socket but ... work
the rUDP library I am using has some really nice features that seem like they should be built into System.Net.Sockets - connection challenges, pooling, etc
connection challenge especially in this era of ddosing for fun
are you moving the plane and camera in sync (FixedUpdate vs Update/LateUpdate)? You'll see that effect if there is a mismatch
@strange cradle Don't cross-post, pick one channel
can someone explain why the unity debugging editor shows me "My Cell : None (Cell)" as None even though it is being set?
Cell is a class that is not a monobehaviour
You still have to assign it - either in code or in the editor
You've declared it but not assigned anything to it
well i am assigning it in code
That's fine, then, it'll work properly in the game
it shows when i debug.log it
but it doesnt show in the editor
does it say None because it is not actually a gameobject or a monobehaviour?
Are you looking at the prefab in the editor? or the instance of the game object in the scene
its the instance of the gameobject
take a screenshot of your entire unity client again - not just the snipped inspector view
can you show me the code for RoomData.cs?
seems ok but could still be a few other things.. Are you sure there's only one room in the scene?
add this to your debug.log:
Debug.Log($"setting cell on {GetInstanceID()} to {cell}");
oh, it's private
the editor can't see it
i mean, i wasn't even aware that the editor serialized private fields using the debug view like that, but now i know
i think you can make them show up if you annotate it with [SerializeField] but .. tbh i can never remember how that works with private fields
yeah now it works
but im so confused why can it show private fields in debugging but not this one?
apparently it reflects all the fields for help debugging, but it can't access the value of the field? 🤷♂️
may as well just make it public, or make some other public readonly field for unity so you can see the details of a cell
another example here:
it shows my private Dungeonalgorithm script in my dungeon manager
maybe because this one is on the same object/instance?
and it can show it while debugging if its on the same object but not if its refencing a different one
no idea 🤷♂️ It's sort of a weird way of doing it, though. If you need to view/access it, serialize it or make it public.. I've needed debug mode in the inspector pretty rarely, and usually because I'm doing something wrong 🙂
i mean i guess, but im mainly using it because i want to sort of mimic a readonly serializefield
cause this is for things i dont actually want to put stuff into
how can i copy a gameObject without Instantiating it? i have a prefab, and i want a class hold that prefab copy without referencing the original nor actually showing it ingame.
Will Burst optimize away property getters/setters so they are basically zero cost comparing to a field?
(want to instantiate it later)
what
how do i do that lol
Can someone help me with an advice of how to approach a problem, please. I am making a Targeting System which would allow to pick Object in Aoe or pick the closest object. I want to be able to pass what kind of object I want to select. So, I should have types like Team(team1, team2), Object Category(Unit, Structure), Types for each category. For example, I want to pick only Enemies and Heroes, or only Allies and Structures or only Units (which includes heroes and other units) and then return a group with them.
I am struggling to understand how to make subtype. And then I do not understand how to abstract picking criteria. How would you archetecture this? It is MOBA, so it should be efficient
Store all entities into a data structure and query select
What would be optimal data structure?
Hey, is there a way to run Unit Tests on Android and iOS? I feel like I've seen that documented somewhere but I can't find the documentation for it
Up to you, depends on how you want to use it
I'm trying to generate the bolt thingy, And I get this error and then I can't make units in the graph, Can someone help me please?
Do you think it is better than making a MB entity and then make childs as a category and then child subtypes?
Isn't that basically just a tree?
Kind of
Someone please answer me!
I thought about adding them in the dictionary, but I think looping through them would be too intensive
Ask in #archived-code-general probably. Bolt isn't really advanced
uhhh
i figured it out. I wasn't giving the setter method an instantiated version of the prefab. I was giving it a prefab.
I wanted to set the Cells element to the object and the Object's cell to the cell. It put the cell's element as the Prefab and then set the prefab's cell as the correct cell. But i wasnt changing the actual gameobject's cell. I'm not quite sure why it was showing when i changed it to public but that was the underlying issue i was facing.
@buoyant nacelle hmm... Dictionary sounds like it could work... You would have Dictionary<Type, Object[]> where Type is your group classification or whatever, and Object[] is an array of objects that meet that criteria.
When you want to select multiple types of units, you get the values from the keys and combine them into one single array
👆 so sort of this 🙂
@buoyant nacelle The issue with that is... redundancy.. if you have units that meet multiple criteria, you'll have to repeat them per key... now, if that is optimal or not, is up to you
Not a fan of inheritance with multiple subclasses and multiple inheritances
You'll essentially have O(1) time complexity on this (if we ignore merging arrays somehow) but space complexity would be potentially O(N^N) which is horrid
+1 with Joseph. Seems like it would get tricky real fast if you want to inherit from 2 units suddenly
this is pretty tiny, really
I see
Need to think of a better way
The ultimate better way is to use ECS, but I wouldn't recommend it, maybe interfaces may help? Or you can add properties to the class to help with querying
Why not ECS?
Don't see how interfaces can help here
I'd probably lean on linq and lists to select from a list of target objects that match some criteria.. like..
public class ThingInGame
{
public string Team = "GoodGuys";
public ThingTypeEnum Type = ThingTypeEnum.NPC;
public bool Invisible = false;
public Vector2 Location;
}
// AOE spell that targets teammate NPCs that aren't invisible:
Vector2 myLocation;
List<ThingInGame> targets = allThingsInGame.Where(x => x.Team == "GoodGuys" && x.Type == ThingTypeEnum.NPC && x.Invisible == false).OrderBy(x => Vector2.Distance(myLocation, x.Location)).ToList();