#archived-code-advanced
1 messages Ā· Page 156 of 1
would I just use the top answer? cause a lot of the answers have different code
Not sure honestly, but odds are any of them is good enough. I would look into the documentation of each of those APIs to see what they actually represent
so I would need to download something for it to work? or does this work with the base Unity?
it's also saying I need to include System.Reflection which I've never heard before
All of these are included afaik
I'm interested as to why 'Transform' only implements the base IEnumerable and not IEnumerable<T>. Would be lovely if we could use LINQ on it without casting
why do you think i over complicated the effect?
I was using DoTween myCanvasGroup.DoFade(0, 1.0f) and I also had this difference of duration problem thats when I decided to do my own and I dont know why but now is solved. Thats what I wanted to know the why.
Yes, camera.Render is sycronous by default. Since i cant fade out without the render having finished it's ok for it to be synchronous, am I wrong?.
Can anyone guide me from where I can learn code for "Unity's Augmented Reality"?
anyone here has any experience with quaternions and can explain my why this code makes my gameobject rotate on the X axis too? It should only rotate on the Z Axis:
Vector3 dir = Input.mousePosition - pos;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
Quaternion newRotation = Quaternion.AngleAxis(angle, Vector3.forward);
targetPanel.transform.rotation = newRotation;
its hardlocked at 90f on the X Axis
i assume the object is world aligned?
Hi, I have an architecture design based question. Not sure if it's the correct place to ask. I have a few scriptable objects (questRequirements, questRewards & questGoals), which are all referenced in a QuestSO (to basically make a Quest). Now, modifying directly the SOs is not something I would like to do however, this hierarchy needs to be "cloned" during runtime to an object which I can modify on the fly without problems (essentially track and mark the progress of that particular quest). Any bright ideas on the best way to achieve such a system?
You can create new instances of SOs in code
well it could be done if you were to make savefiles. then you could change the SOs and then save the changes
Maybe i didn't explain my problem correctly. I'm finding it hard to explain haha bare with me. Say a quest has 3 goals, kill x amount of enemies, visit a location and talk to npc 2... these need to be tracked...but I cannot set the variables in the scriptable object during runtime, so those variables need to be "cloned" somewhere (like a gameobject) at runtime, where i can modify them as the progress of the quest goes along.
Instantiate(mySO) will clone it
or at least, all of its serializable fields
hmmm...and that will not modify directly the asset but an in memory copy?
If you modify the result of that, correct, it's an in-memory copy
along with all of it's referenced "sub-SOs" ?
No, it will not be a deep copy
If there are references to other SOs on it, it will copy those references exactly
yeah then i need to clone the whole "hierarchy" :/ or at the very least, the questGoals[] SO references :/
Maybe a deep copy method in Quest that actually does the traversal would be the way to do it
and of course i don't assume there is such a thing...it has to be coded manually aye ? š
Not that I'm aware
correct
ehhhhh fair enough... thanks so much for the help
Hi,
i develop a multiplayer game. the player movement is server authoritive with client-side-prediction and server reconciliation.
So i turned auto-simulate off and (sometimes) recalculate physics several times in a single frame on client side.
Is there a way, that only the physics for the own player-movement is recalculated, and other things like weapon projectiles or other objects with rigidbodies are not recalculated?
It would be weird if this physics for weapons shots are also recalculated on client side.
I heard somethind about physics-scenes, is this a way?
depends on what you want to do. there's unity AR Foundation you can get started with. there are lots of github projects you'll find on it
is your weapon projectile authoritative too?
you can try this btw https://docs.unity3d.com/ScriptReference/Rigidbody.Sleep.html
@austere roost I'm doing that with a non-SO class for an active quest in progress. It has references to the SOs that define its parameters, and variables for each objective to track the progress.
I'm trying to convert all the "sub-SOs" into one QuestSo so that I instantiate the whole Quest details. I'm having trouble with a custom property drawer for hiding properties based on an enum in the scriptable object at the moment.
you know, like based on the RequirementType, show a field for an item, or a location instead of showing all the fields... mehhhh so confusing lol
I didn't have a good event system for handling objective tracking, so I should revisit my quest objects now. That code is probably hideous and naive
not yet, but there will be some objects, that are affected by phisics, that are authoritive š
With rigidbody.sleep i could set all rigidbodies to sleep before a recalculate physics, and then wake them back up?
stop cross posting. this has already been answered in #archived-code-general
make sure you have the Input System package installed. Looks like that asset requires it
(also not an advanced question)
so where
i just gave you the answer my guy
i didnt understand any thing
i am sorry but i didnt understand
you don't need to ask your question anywhere else, you just need to install the Input System package.
how
- i am sorry
ohh man it worked you are the best
what is the best way to have an enemy move on a slop?
currently for the player i am doing raycasts to check if its on a slope. I can do this with enemies but that seems like alot of overhead for a simple thing to see if they are on a slope
It hasn't been answered, but I won't cross-post alright.
Hey, how can I create concave collider?
Okay, but when I add rigidbody to go it wont work.
It wont collide with other colliders
@inland cairn you'll have to approximate it with multiple convex colliders as children
Ok I'll try it thanks
Hi, is there some way in dependency injection to find out what lifetime a specific type has? I need to figure out if a type is a singleton service, but I have no idea where to access the ServiceDescriptor list to check that. Is there some class that I can inject alongside my services that give me this information?
Can anyone here help me to deal with long code? I'm advanced in c# but when it comes to read long code that other wrote things get complicated.
thats what partial classes are for
Dependency injection is a concept/technique, but you seem to be referring to some specific DI framework. Which are you talking about?
The build-in one
Sorry, you're right. Should've specified I am doing this with the build in one
If you need to have fixedupdate and update in your script, which one comes first?
Avoid cross-posting.
You can't know, they're not synchronised. One is tied to the framerate, the other to the physics step.
Kk thanks
read about SOLID principles, specially 'single responsability'
A fixed update happens before Update in a given frame. But it doesn't necessarily get called everytime in every frame like Update. It might get called more than once in a frame, it can also not be called in a frame. It totally depends on your fps, fps consistency and your fixed time step
Okay that helped tho thanks
sorry if this is the wrong place to post.
Is there anyway to not let the character leave the platform or max amount of distance possible ?
Current code is changing the direction of the character if no platform is detected, while changing the gravity. However, at higher moving speed, the character will be a distance away from the platform and slowly fall back .
i could potentially get paid thousands to make a crane training sim in vr, could it be possible to make an external controller with say an arduino and use it to controll things in unity?
Yes, you can use an Arduino as input.
sweet thankjs
public class Example : MonoBehaviour
{
void Update()
{
foreach(Animal exampleAnimal in animalList)
{
if(exampleAnimal.isAbleToRun)
{
Run(exampleAnimal)
}
}
}
void FixedUpdate()
{
}
void Run(Animal.exampleAnimal)
{
exampleAnimal.animalRigidbody2D.velocity = movementDirection*exampleAnimal.speed;
}
}
Hi there. I know that i should use FixedUpdate for rigidbody related things. For this code example, how can i do the logic in update and change velocity in FixedUpdate ? Thanks for any help.
or should i ?*
In this specific case, no need, as you only set the velocity directly
If you used AddForce though, you would need FixedUpdate
In that specific case, putting the whole loop inside of FixedUpdate would have solved it
What if i don't add force constantly , the same? I wrote a function to calculate initial velocity for addForce.
In the original code there are a lot of calculations
Separating the code is needed of you need to poll input using the Input class, as Input is tied to the framerate
Is there any way to disable the built in batching of the sprite renderer? I have dynamic and static batching disabled but it still batches objects using the same texture that are on the same order in layer.
There is no input in my code. It simulate things.
What about relatively big calculations ?
But, you need FixedUpdate if:
- You're using AddForce with a ForceMode other than Impulse or VelocityChange
- You're using deltaTime anywhere in the calculations, to "smooth out" the forces over a few frames. That specific case also requires you to use Time.fixedDeltaTime instead.
Oh, probably i will only use impulse.
Thank you so much @fresh salmon . Then, i will continue using Update.
does anyone know what's the code behind transform.Translate?
none of it is complicated
thankx
Why do people say that behavior trees are easy to implement?
I've been doing my own implementation and it doesn't seem like there is great information on how to write up a behavior tree yourself.
The "gameaipro.com" books are full of super neat ideas but a bit sparse on important implementation details
When I look for video guidance, I find variations of this buggy Packt code (https://hub.packtpub.com/building-your-own-basic-behavior-tree-tutorial/) or detail sparse videos like from this channel (AI and games): https://youtu.be/6VBCXvfNlCM which is basically just saying "behavior trees are awesome"
So... Am I an idiot and me struggling with my own behavior tree implementation is a signal of how I just don't grok the subject? Like is there someone out there who can write up a behavior tree implementation with their eyes closed?
Nah, I'm not struggling any more. I finally came up with something that works great
Both of those resources you linked are actually really good at explaining it
It just took a while and I had to tell myself "stop looking for the answer because it doesn't seem to exist publicly"
the video is a good concept primer and the implementation is good to skim over for some gritty details
The bummer thing about the Packt resource is that it's full of bugs...
Maybe that's the problem? Too many people are showing 'concept' examples and not really discussing a real implementation
Sort of a like: "Okay so you want to evaluate at each node and recursively return the state"
And less of a: "I will basically copy this into my game"
I guess in that way, it served it's purpose. Although the second I read through the code I was like 'wait, that won't work as advertised'
I got my implementation going now and it's really good, but wow is there a lot of misinformation out there.
Wait, have you implemented a BT @gentle topaz? Can I see your implementation?
Interesting
Not a call out, I genuinely think its interesting
I feel like it's a partial answer to the original question
Yeah, there are always implementation roadblocks when trying something brand new
Good luck if you get to implementing one. Maybe you will find a good source that can guide your implementation and it will turn out to be simpler than what my lived experience was š
The part that seems a bit vague to me is actually building the tree
But I suppose you might just do that entirely manually
Right now I'm building mine in code. At some point, I will create some editor scripts
Although you can probably use some of Unity's workflow tools (scriptableobjects, etc) to make that process less painful
ah yeah, that's about what I imagined
Yea my plan was to (eventually) think about what the implementation could look like if it used SOs and if I could justify that setup.
At a surface level, seems like it would work quite well
that is not always how things go though, so I would have to try it myself first
Binding the delegate actions would be the difficult part there
Would take some extra labor to get it all set up properly
you get it
Yup. And my question is "how can I justify the complexity of a SO implementation?"
It depends on how much extra work the action binding is, or if you need the AI design to be user friendly (for example if you have other people on a team working on it).
Typically I would prefer scriptableobject to hard coding a bunch of immutable data
How many BTs will I ultimately have in my game versus how much time/effort it would be to create a designer user interface for the BTs
yeah, the number of BTs is also a large factor
Typically I would prefer scriptableobject to hard coding a bunch of immutable data
Interesting... Can you elaborate on this point? I'm curious what your thought process is.
(since this is the internet, I'll also say that I'm asking not to attack you but because I like hearing other people's opinions and experiences)
Just... If I am setting up anything like base stats, pathfinding heuristics, world generation parameters, etc, I like to have it be easily accessibleāand with no recompile involved when editing (which ScriptableObjects are just great for)
I think it also helps me mentally encapsulate the data structures more efficiently
It's just my personal preference
Obviously I can't do that outside of Unity though, haha
So maybe I overuse it
But yeah, basically any set of data that won't change at runtime is something I typically look to ScriptableObjects for when implementing
Thanks! I appreciate the insight
But like you said, that ratio of time spent implementing to amount of SOs used is also important in making this choice
Obviously I can't do that outside of Unity though, haha
To this point... I really, really like treating monobehaviours and scriptable objects as "humble objects" as much as I can and instead try to encapsulate logic in vanilla C# classes. I do it for many reasons, but one of them is practicing pushing the framework/library used as far away from the core domain logic as I can.
Honestly, this is something I have been slowly honing in on as I progress as a developer. The less Monobehaviours used, and ScriptableObjects as well (although those can be replaced with other types of data serialization in other programs / workflows), the better in my opinion
I do use ScriptableObjects quite a bit because of that last point I made there but
I definitely agree that encapsulating logic in vanilla C# classes is a great way to go
I am currently working on my own engine using a framework and I have been quite glad that I already encapsulated most of my logic and used minimal Monobehaviours while I was learning how to program using Unity (which was pretty much the start of my programming career)
Yea. Even if the code isn't portable (Unreal is C++, which != C#), the practice is the thing that helps push away the framework details.
Just makes you a more versatile programmer
Agree
I started when I asked myself "well, how the heck do I test my Wordpress extensions?" turns out... Humble object pattern.
How is the SpriteRenderer able to manipulate the sharedMaterial mainTexture without altering all other objects with the same material, and without instantiating them?
More context: Wordpress testing is a bit rough because of the architecture of wordpress was built before automated testing swept became popular.
I could do a better job of elaborating on the Wordpress stuff but I'll leave it there.
Yeah, not familiar with Wordpress... I am fairly inexperienced in generalāI haven't built many non-game applications or done really any web dev
Trying to work on improving that versatility though (however, games remain my main interest)
@tough tulip thank you i think that might have done it
That makes sense. My day job is as a software engineer building apps in a couple different languages in a devops way (read: leveraging kubernetes). My hobby is game development, lol.
The wordpress stuff is some things I do as a freelancer
@gentle topaz what is your story? Are you a student learning unity for a future career working for a AAA or indie studio? Someone looking to switch careers to find a dream gig?
I am a student (although I am taking a break from college at the moment) and I hope to work in the indie scene. I haven't had any sort of dev jobs because I am 19 and been mainly doing college full-time. Not exactly sure what I am going to do, but I have some freedom for now.. Trying to quickly get as good at development as possible without any real plan (at this point I pretty much do dev at least 11 hours per day)
Whatever I do, making my own stuff will be my hobby, and I intend on continuing on the path of self-improvement
Ha, that's cool that you're a into this stuff and improving your craft at your age. I'm late 20s/early 30s and put my dreams on hold to chase that cheddar (no complaints).
Not sure if this is something you might want or need, but can I talk to you about the legal stuff around games? Just to maybe have a bit of an influence... If you know how to create and maintain an LLC and you know a bit about legal stuff, maybe you could unite your local talent and make something cool. Kinda like how if you know how to be a Game Master/Dungeon Master, you can get a D&D game off the ground.
For your consideration... Here are some GDC talks about legal stuff. If you have some time, I would encourage you to watch and maybe take notes. If you can be the person who knows about this stuff, you can essentially be the glue for talent.
Practical Law for Indie Devs 101: https://youtu.be/8eAW-7Js7NA
Practical Law for Indie Devs 201: https://youtu.be/t8UFJ3obm-Q
Practical Law for Indie Devs 301: https://youtu.be/ePQcAjuiSEo
Wow, thanks so much! I will check all these out. I actually have a few friends who have various talents that synchronize well with game development and also love making gamesāand we frequently work together. I know nothing about actually creating a studio or getting a project off the ground, so this is great.
Actually, I should watch more talks in general. I'll start with these and move outwards to get a better idea of how to "professionalize" this whole thing.
Yea totally. It's actually pretty easy and relatively cheap to start an LLC in your state (presuming you are from USA), although I don't want to bury the lede and not mention that there are requirements for maintaining an LLC over time.
My advice if you do create an LLC is to also create new accounts in Unity,your version control (GitHub), email, and everything else. Only do LLC stuff on those accounts. The neat thing is you could then possibly sell your LLC to someone else if you want to cash out.
This is typically where job experience is nice... But I might as well get a head start, and I also really want to be a startup if at all possible (I at least want to try it out)
Even if you are looking to be an employee, it registers real nice with the interviewers if you know about the business/legal side of game dev.
I say -- don't wait, explore making an LLC. In my state, it cost me $50 to become the CEO (lol) of my own game studio LLC.
Even if you don't do anything with it.
Well that's good to hear, haha
Like I said, this is just for your consideration. If it isn't your jam, no biggie!
Thanks again for all these pointers, seriously. I have been kind of ignoring that aspect of game development because it seemed a bit out of reach
Knowledge is power, I guess
Setting up a company would probably boost some motivation to continue projects as well
I think I should probably log off though, although I will at least watch the first talk (right now I mean). Currently 7:20 AM and I have been programming for like 10 hours lol
An all nighter, heck yea.
Same. I enjoyed this convo. At me if you have questions about BTs, when/if you get there!
Hello Everyone! Does anyone know about saving Scriptable Objects in a List to a json file?
if you're using newtonsoft json, you need to use this attribute to your class [JsonObject(MemberSerialization.OptIn)]
and then use [JsonProperty] attribute to all your fields you want to serialize.
yes
hmm I am still having an issue of it reading the scritable object
It just prints it as an instanceID
I have an interface field in my class. When doing hot reload (changing code), that field becomes null.
How can I run a code when that happens to populate that field again when that happens?
its not possible.
when the hot reload takes place, theres an internal logic which recompiles the code, and then resetting all old classes/structs/objects/fields/etc.
only objects which have references are the objects which are serialized (dragged and dropped in scripts) using unity inspector
after an assembly reload, the previous interface you had saved doesn't exist at all
Greetings gentlemen, perhaps anyone happens to know an asset or a general approach to 2D aiming with ranged weapons?
(perhaps that's a bit more maths/physics question, but I'd consider it advanced enough to be post here)
On attached gif there's my custom implementation, which does not take force of the throw into consideration, therefore the misses you can see with spells. (red line is tangent to quadratic function)
https://gfycat.com/silkyfarawaygecko
If it's a Rigidbody you can't really use a normal parabola equation to simulate the path because the fixed-timestep simulation doesn't generate perfect parabolas. Just step through n fixeddeltatime steps and simulate the position over time using Physics2D.gravity as the acceleration
Taking into account the force is easy, you are only interested in the initial velocity
@gentle topaz you said you were working on your own frame work? Do you mean some development tool for games aswell?
Hello,
I'm trying to use unity's netcode for gameobjects,
I'm trying to call a ServerRpc but it doesn't get executed and returns in the console this warning:
[Netcode] Deferred messages were received for NetworkObject #0, but it did not spawn within 1 second.
Has anyone ever faced something like this?
On the internet I could find basically nothing,
If the warning is accurate, in the emails domain, it means that the server is blocking incoming data?
But clients can connect just fine, it's the ServerRpc that is not working...
I shoul add that I am testing all of this in localhost
I don't think that's true, not entirely anyway.
The interface is a component (actually), it's just exposed as an interface.
I also have another field that's of type component, and that one is working correctly.
Both are assigned at awake only and not dragged and dropped as properties.
That 2nd field isn't null after the hot reload.
So if it's just references - both the interface and that component are references.
If it's just objects that are dragged and dropped in scripts - both don't meet that.
My problem is not that projectile doesn't perfectly follow the artificial parabola, but that even if I know tangent/parabola I can't calculate the force I need to apply to object for it to follow the parabola at least approximately.
Actually I was hoping there might be some kind of ready solutions/assets, but I'm willing to keep try-harding myself :D
the hot reload doesn't guarantee anything. unity tries its best but 99.99% times it doesn't work
@tough tulip any suggestions to make it work with the interface then? or is the only solution to make the type non-interface?
is there a place in Unity where I could have an assembly reference alias set? I am having an issue with a plugin being conflicted with two or more assembly reference. I found something online as a workaround solution, but it seems to work within Visual Studio project solution and not unity's project solution.
I guess my question would be this:
A) Is it possible to infer which assembly reference I want to use inside someone's else plugin, and if that's not possible, B) Where can I go and add reference alias inside unity?
I've tried using directive reference, but no luck!
This also pisses me off that even with implict library reference, it still can't resolve the issue.
Is anyone here knowledgable in Ninja-build?
I'm trying to get it to identify a ninja installation
But no matter where I put it, it always comes up as ACCESS IS DENIED
Even though I've ran it as an administrator.
Check the permissions of that file
Both the file in your downloads folder and the permission of the āninjaā binary
i dont understand
The error message you are seeing appears to be a permission issue. Finding out what your user is unable to access will be key in resolving your issue.
Either there is a file permission āissueā on the binary (ninja) or there is one for the file in your downloads folder.
That said I donāt, I donāt have knowledge of ninja build so if someone else wants to interject
I am the administrator on the system though...
I'm SUPPOSED to have all access to everything.
but then again I deal with windows
@candid thunder permission denied error in windows is sometimes a generic one.
For example sometimes when files can't be accessed (e.g. bad drive or network drive not accessible, or just locked) you'll get that error.
Sometimes it does mean access (because you can change specific access for specific files), but not always.
What are the ways I can fix it?
Is there any reason c# would not be able to create a directory/file on a linux server?
for some reason it does detect the folder and says it exists but when i look on my ftp, i can not find anything
you'll first want to find what the actual issue with the file is. go to the file and start inspecting it, check for anything that looks a bit different/strange
Anyone used OVROverlay? I've got it working, but it has different behavior on Quest vs PCVR. On the former, it's always on top. On the latter, it's in the proper depth but you can make it the other way by turning off Shared Depth Buffer in PC XR settings or checking No Depth Buffer Testing on the OVROverlay script. I'm wondering if there's something the Quest just doesn't support to make it work with the proper depth. There's no similar setting I can find like Shared Depth Buffer for Quest/Android. As far as I could tell, it seems GL_OES_depth_texture extension is what's needed to support that, and when the app runs it seems to report GL_OES_depth_texture as being on. Trying to figure out if there's some way to get it to work like it does on PCVR but coming up with nothing.
Hya. How would I register changes to an Enum in a object (serialized). Use: I got a public array made out of a serialized class. The class is containing a bunch of different variables, among them the Enum. I need to know when the enum changes. I tried using events / delagates, but monobehaviour doesnt seem to work in a serialized class?
https://pastebin.com/Nct3USvC example of the class (that isnt working)
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.
thats correct. you are gonna have to have a monobehaviour class that checks for it.
you could ofcourse make a reference to your serialized class
How would that work out, a reference to the serialized class?
as in, how would I listen to that reference?
I am changing the variables with references to the classes; they are stored in an array, and when I want to change something I call that array. But, for convenience sake it would be nice if I can then Listen to those changes inside the serialized class or inside another ref.
Ahh yeah if you could type out an example that would be awesome
public class RandomClass : MonoBehaviour
{
public class PlayerClientObject PlayerClient;
public void OnEnable()
{
PlayerClient.S_ThrowBall.OnBallStageChangedEvent += BallStageChanged
}
public void OnDisable()
{
PlayerClient.S_ThrowBall.OnBallStageChangedEvent -= BallStageChanged
}
}
Something like this
@warm adder
Ahhh. So I regsiter the events Outside of the serialized class
exactly
And BallStateChange would then also not be a method inside the serialized class?
no it Is probably a method in the serialized class
youd have to mess around with that i am terrible at eventsa
Thanks. Messing around atm š
I just want to compile something
But I need ninja to do it
but ninja needs ninja build
and its there
and has the permissions
but it says access is denied
Hmm, PlayerClient.S_ThrowBall doesnt seem to work
I cant get the class after I reference the object
I think I'll just use properties, that seems to work better
No, using a framework to to make a game that has its own engine
hi, so I have a idea, but i dont really know how to implement it into unity.. so.. I made a character controller, but I want to switch to a different (solid, non-moving) camera
and then I want to switch back to the character camera so he/she/it can proceed with finishing the level
You want to look into cinemachine. This would be easy to achieve with it.
Could someone help me make it so I can make it so instead of clicking the arrow to choose an avatar they could just click a continent that will then be assigned to that player?
Someone has already answered your question in #archived-code-general !
Is there a different way I could do it instead of what the other guy said?
I donāt believe so no, that seems like the most efficient way to me
Why canāt you do it like that?
I have no idea how to do it, and I'm thinking that I have an idea of how I could do it a different way
Okay thatās fine I understand, but maybe you want to look up about clicking on UI elements in the future
Like I could have multiple public voids for each continent and basically making it so when one of those continents are clicked then it will be assigned to that player
Okay that sounds like a good approach!
Good luck š
Thanks
I have a big issue. I have found out that I have to put my code for ScriptableObject inside an assembly, but I already created some instances using the old one, serialized.
I didnt think that adding the Assembly would break the SO that I already created... is there a way to fix this? Some sort of [PreviouslyAssembliedAs("Assembly-CSharp")] or something like that?
The [MovedFrom] attributes is supposed to be used for this. It allows for defining the old namespace, class name and assembly name.
Can you maybe point me to some docs?
Similar to [FormerlySerializedAs]
There doesn't appear to be a documentation page for it
Yeah, it's undocumented. I believe it's in the UnityEngine.Scripting.APIUpdating namespace?
@hot dock But it's used like this:
[MovedFrom(false, null, "NewAssemblyName", null)]
public class MessageNode
{
}
You can see the attribute definition and some basic documentation here:
https://github.com/Unity-Technologies/UnityCsReference/blob/91bea9bc5698d7b18524f5e5016c980e4cece639/Runtime/Export/Scripting/APIUpdating/UpdatedFromAttribute.cs#L46
Confusingly, it's in a file called UpdatedFromAttribute.cs, but the attribute is called MovedFromAttribute
I have seen this example right now, googling. I wonder what every attribute represents...
oh, i see... maybe that will be enough
But I've also done Find & Replace on scene and prefab asset files in the past
I think I had some issues with this attribute not working fully.
So i guess I could try this...
[MovedFrom(true, "Conversa.Runtime.Nodes", "Assembly-CSharp", "MessageNode")]
You can pass in null for the things that haven't changed
oh, nice to know!
This might be enough then
[MovedFrom(true, null, "Assembly-CSharp", null)]
@sage radish I will try it! Thanks a lot for your help!
I was scared for a second, that my existing object were going to be ruined
š¦
transform.position = (float3)transform.position + (input * Speed * DeltaTime);
I don't know what I'm missin to make this code account for the rotation of the transform.
I'm basically recreating transform.Translate inside of a Job.
Move relative to Transform.forward and Transform.right to account for directional deltas else your simply adding input displacement at variable rates to the current position.
Also, the above may get more attention in #š»ācode-beginner as this channel is less populated and often reserved for more complex questions.
You can multiple the rotation with the delta you're adding:
float3 delta = (transform.rotation * input) * Speed * DeltaTime:
transform.position = transform.position + delta;
I hate how simple the answer is
thanks
How would I change this code (https://hatebin.com/olstbqtnsy) to make it so it goes straight to a certain element instead of it switching through the elements?
@regal olive what do you mean switching through the elements?
like before if I clicked an arrow it would go to the next Avatar but I want it so I can click one of the continents then it will shows that continent as my avatar
Hi, i have a big problem. When my Asset Folder gets larger than 70GB the editor becomes extremely slow
Jesus Christ
I am not surprised at all
Not sure how this is #archived-code-advanced though?
it runs fine, until i get to a certain threshold. It's unuseable now, It takes more than 30 min to open a project
It's not coding related, But not everybody has projects this big. Most developers would probably not encounter this error.
So it isn't code related at all then
probably not. At least not my code^^
I mean, I could have left you to the hounds
You could make a Continent component that has the onclick in it instead, and that updates the player properties, and each continent has that script on it. It could have the name of the continent on it, as well. Or, you could make continents an array of Continent and do it from the same class you shared
and that way you would also avoid that class growing with more and more onclicks
All those methods look identical?
Hello,
I'm trying to use unity's netcode for gameobjects,
I'm trying to call a ServerRpc but it doesn't get executed and returns in the console this warning:
[Netcode] Deferred messages were received for NetworkObject #0, but it did not spawn within 1 second.
Has anyone ever faced something like this?
On the internet I could find basically nothing,
If the warning is accurate, in the emails domain, it means that the server is blocking incoming data?
But clients can connect just fine, it's the ServerRpc that is not working...
I shoul add that I am testing all of this in localhost
I think it's essentially saying that the NetworkObject the message is directed for doesn't exist.
I think I was able to debug it correctly, tell me if there is something that looks strange to you:
I'm working with only UI elements, so everything is on a canvas,
If I give a panel the networkObject script, I can parent networkObjects to it, EVEN if there is no networkObject on the canvas.
However it looks like if a panel is deactivated during the loading of a scene, then any child networkObject are not correctly spawned.
I was receiving that error when that NetworkObject was spawned on the server but not on the client because the client was on a build and the server in the editor
And the one on the build connected "wrongly" (?) because of deactivated NetworkObjects.
Is it really impossible to have a scene with networkObjects that start deactivated (or activated but their parent networkObject is deactivated)?
Hey, just checking, does anyone know if (and if so, when) the default behavior for an undefined Layer in a Layermask changed from 1 to 0? I have been investigating an issue for over a day and eventually concluded that even though the LayerMask dropdown look identical, the serialized int between two versions of our project actually was completely different.
(Because all the undefined layers where flipped from 1 (old) to 0 (new).
Can't really find any documentation as to this though.
I think it's always been 0 afaik
You can desync it via various methods though I'm pretty sure.
Yeah, that makes most sense to me, but that doesn't seem to be what I'm observing here
Left, new project version, right old version.
Meanwhile, the same serialized strings
1065352927
00111111 01111111 11111110 11011111
1048454679
00111110 01111110 00100110 00010111
Suspiciously, all the ones that are "flipped" are undefined ones.
It may actually be 1. I am almost certain enum flags are 0. But when you add more layers you annoyingly have to modify culling flags in certain scenarios
None of the code should have to rely on what values are in those undefined layers though?
Hello. I have an architecture question. I know that there is a simple state machine to handle "animations" but I need a "more sophisticated state machine" to handle all the states of my characters. I mean, a state machine with a lot of features like "transition method" that's return true of false if the state transition has been done or not etc... Should I code my own state machine if I need this behaviour ? It's very strange because if I do my own state machine, my states will have to handle the animation state machine transitions... it's really weird.
No, indeed it doesn't, but in this case I was hunting an issue where an object was inexplicably not being rendered. The GameObject's layer value dropdown looked like this.
So clearly set to some value that used to be defined and now isn't anymore. But if that value was ever defined, it had been removed many years ago. So the immediate question was "wait... how did it render all this time then?"
Turns out the old culling mask on the camera had that bit set to 1, even if it was undefined. We recently removed some other value from the camera's culling mask, which must have updated the int representation.
Which leads me to assume that somewhere down the line the behaviour must changed or something, or it would still have worked.
Ah yeah that'd do it. Sadly nothing is really correct in this scenario
No, it's a degenerate scenario to begin with so it doesn't matter that much, but it sure was awfully puzzling. XD
which version introduced this?
I'm not 100% sure. This an old legacy project, started on 5.x and currently moving to 2020 LTS. It happened after the 2020 upgrade, but it can't guarantee it's because of 2020, because IMO all it took was changing some value on the culling mask to update the bitmask.
And I have no record of when/on what version it was last changed. Our git history only reaches to early 2019.
Question about behavior trees (BTs)⦠I noticed that many implementations of BTs have two elements: the BT and the behavior (some call it node for some reason). Also, the implementation of the BT Iāve seen as examples traverse the tree and only return a single status for the traversal.
I want to know which behavior the traversal stopped on, so I can resume if a particular behavior returned a RUNNING status.
Now, I know I have two options⦠I can alter the return type of ābehaviorā to return the status and current behavior. I was also rereading the BT section of this chapter (http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter04_Behavior_Selection_Algorithms.pdf), specifically the algorithm, and it dawned on my; maybe ābehaviorā and ānodeā are two separate entities with two different purposes. Most treat them like synonyms, but maybe they arenāt.
Two questions: what are your thoughts on updating the behavior signature? Has anyone considered a ānodeā and a ābehaviorā as two separate entities, and if so, how are they different?
Updating the signature is the straight forward option, but I feel queasy when Iām updating my non-leaf behaviors signatures (because then they are just passing that data through up to the root node). But maybe that is acceptable
never heard that anyone used behavior in the context of a bt
the behavior maybe some "runner" that executes the graph, like a component
but its always a graph and a node of that graph
and yeah BTs are different from FSM in exactly that any node can execute for indeterminate amount of time, by design
i always assumed that "behavior" is the desired result of your graph
you are creating it with nodes
in a sense you create a behavior with fsm as well
FWIW Iām just talking about BTs, but I think I get why you are bringing in FSM in comparison.
The way you are talking about the BT seems to support the idea of there being three elements in a BT; a behavior tree, the node(s), and the behavior(s). The BT runner is an uninteresting piece of the architecture, as all it does is call the simple BT interface āTick.ā
I think ānode is separate to behaviorā there is where I am evolving my own thinking into right now, but I think I will want to think about it more to make sure it makes sense.
Your comment helps. āI always assumed that ābehaviorā is the result of your graphā suggests, to me, a return signature of the nodes to be ultimately be a behavior.
One more thing: I know that BTs are directed graph but I think the language should be contextually correct. We shouldnāt talk about the math underpinnings of BTs just like we donāt talk about what we want to eat in the language of atoms, if that makes sense.
i have no idea, this is way over my head
No no, trust me. You are doing great
over my paygrade
i see a node graph, i call it node graph, i need agent with certain behavior i use behavior trees to form that behavior with nodes
are those nodes a behavior? is the behavior their return signature or the bytecode of CLR i dont know
Yea and after I submitted the message above I realized⦠unreal calls behaviors nodes so I guess it is contextually correct
ok so.... question about optimization. traditional wisdom says that multiplications take vastly longer than additions. however, if i replace an integer multiplication with an integer addition, i see no speedups. why is this? is it because modern processors are out of order and thus hide such latencies? because multiplication has actually been optimized over the years in hardware? because the compiler is doing something smart that i'm not aware of? is there some other feature hiding the latency? anybody know? thanks.
I need to remind myself what is my own programmer opinion and what is the more universal stuff. āContextually correctā word choice can be used to mask a simple opinion š
i suppose it could be because there's some other operation that takes longer like a cache miss that's hiding the latency of multiplication...
thanks
optimization is fun but hard, especially once you've gotten the low hanging fruit
Note that for simple operations, the optimizer and JIT reduce them.
At compile time: return 4 * 3
Decompiled: return 12
Same thing if one operand is a const
@thick thorn what are you doing there? porting?
just trying to optimize a*
simd in place?
not sure what you mean
hmm.... interesting
afaik burst/dots is vectorized
makes sense. probably not going to rewrite the whole algorithm but if i could group search nodes together manually and apply simd operations on them i wonder if that could get some speedups
nodes are structs?
they are classes
thats a bottleneck
is that because the allocator places them in random locations?
you enforce linearity?
in memory
so like an array of structs?
yeah
i'll try that
nah even then, if they are classes you have no guarantee that they will be sequentially placed
since memory fragmentation can vary, the allocator can stick them in holes far and wide from each other
even if you allocate them all at once
yeah
and then i'm assuming all refs to the nodes have to be ref right?
so no pass by value?
that depends
theres size threshold where ref becomes faster, but it also depends on plain semantics, i.e. where it is necessary
interesting.
i benched ref and its always faster or equal to value, but it can be architectural problem
i see
ok i'll try the array of structs thing and see how much of a speedup i get. is there any different in terms of memory layout between int[,] and int[]?
or is it just syntactic sugar?
fair enough
i guess if it's fast enough for you then it's fast
thanks for your help
you can also design the whole thing for the jobs/burst system from the get go
Yeahā¦. I might do that in the future but itās going to be a more drastic step for me
Actually I wonder if I can just make the body of the main while loop a jobā¦.
Damn this is probably a whole field Iām going to have to look into lol
jobs are designed to work with soa approaches, you feed it primitives in arrays, it multithreads them
even on a single thread i made a struct ecs that performed order of magnitude faster
also abused aggressive inline like crazy
that was on old .net what was that mammoth fossil?
4.8, wait we still use it, HA
Hah.
š„²
i keep seeing those improvements made in new .nets all those intrisics, jit optimizations, and yeah.
Yay Unity
What am I not setting correctly here? I'm trying to recreate the sprite renderer and making it create a new mesh based on the sprite added, which is working, but the Unity selection outline is broken if you select a multi image sprite and not a single texture.
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.
maybe there's some issue with the vertice conversion and they're not in the right order or something
@plucky laurel white box is the girl
there is a way to see the wireframe i know
try finding it in the sprite itself, try inspector debug mode, there should be access to the mesh somewhere, then you can view it in preview window
that should be the wireframe tbh, it only has 2 triangles
typically sprites have optimized meshes to reduce overdraw, so i assumed it doesnt work correctly
ĀÆ_(ć)_/ĀÆ
it is working correctly but something is not working correctly š it's unity's built in preview outline that is bugging out so I have no clue what it is expecting to work right.
certainly not advanced, but can you subscribe null to an action?
private void SetThing(GameObject mgoThing, Action callbackFunction)
{
classMemberGO = mgoThing;
classMemberAction += callbackFunction;
}```
could I call SetThing(goInst, null) and subscribe nothing?
PoC, just copying functionality of some old flash code. Focusing on getting it close enough, then I'll go back through and consider what should be changed š
it would have been faster to type this on a console .net test app and see if its working or not : )
it should throw
oh good idea!
It works without throwing because I call classMemberAction?.Invoke();
Anyone got experience with macOS and Arduino, somehow my simple open serial port script just throws an IOException, No such file or directory. It can find the port and I can use the arduino software to access the hardware, so I am guessing its a Unity issue
I also tried to start the hub with device=all params
Unity works with arduino's?
you can make it work
is this using Uduino? The most common issue I've seen is the com port being hard coded in and being wrong. Here's a video if you haven't seen yet using MacOS https://www.youtube.com/watch?v=SD3iUnLNjY0
In this video we are going to learn how to send and receive messages between Arduino and Unity with an open sourced plugin. The tutorial works on MAC and PC.
I used Arduino Mega on this video.
Twitter: https://twitter.com/MacyKuang
Ins...
Rigidbody question: i am trying to check if an object is touching another object in any direction. i tried the OnTriggerEnter and leave events but those do not trigger if objects are destroyed.. i also tried to sweeptest, but when ever the object is directly on lets say a ground plane, no hit is detected. Any idea how to reliably detect if an object is touching or really close to another one?
https://stackoverflow.com/questions/70523953/how-do-i-create-a-modding-api-for-my-unity-game If someone has an answer to my problem, I would be really grateful
Use Raycasthit... I don't have an example now but use that
Per vertex?
Would probably do the job
Hey, i just discovered bit manipulation in programming, what can we do with it in Unity, where would that benefit us?
It is working now, yes š
99% of the time you'd be doing something involving layer masks, if you didn't know there are already methods to help you with that
@midnight violetI've had problems getting microcontrollers to talk to my USB ports in the past
there's always usually one tiny command you'd be missing that actually enables the port for reading/writing
can someone explain me why my bullet only sometimes registers the collission and sometimes it doesn't
you can see in the logmessage when it collides
Probably your garden variety tunneling
Great explanation with animations here https://gamedev.stackexchange.com/questions/192400/in-games-physics-engines-what-is-tunneling-also-known-as-the-bullet-through
i'll take a look at that thx
Oh lord this is going to be more complicated then i thought
oh that is a great answer on there
not really
start with turning on continuous collision detection mode on the bullet's Rigidbody
your bullet has a Rigidbody, right?
Yeyeyye
and it';s moving via physics, not via the Transform, right?
How is your bullet moving
are you using Transform.Translate and/or setting Transform.position?
Or are you setting the velocity of your Rigidbody / using AddForce?
Let me check
āTransformā vector 3 shootdirection
I think thats transform and not physics
Oh itās pretty big code
that's fine
Show the part where you spawn the bullet
follow #854851968446365696 guidelines for posting the code
show the Bullet script
the script you shared doesn't explain how the bullet actually moves
public class Bullet : MonoBehaviour
{
private Rigidbody rb;
void Awake() {
rb = GetComponent<Rigidbody>();
}
public void Setup(Vector3 ShootDirection)
{
float BulletmoveSpeed = 100f;
transform.rotation = Quaternion.LookRotation(ShootDirection);
rb.velocity = ShootDirection * BulletmoveSpeed;
Destroy(gameObject, 3f);
}
}```
should do this instead
(note you can move rotating the bullet out of the other code now, since you can do it in Setup, but that's just a little extra I threw in)
It will help
because now if you go to the RB
and set Collision Detection Mode to Continuous
you will get less tunneling
It was already on continuous
Ok but now that will actually do something
it wouldn't have with the old way
also i recommend setting Drag to 0 on your RB
So that the velocity will be constant until it hits something.
And disable gravity on it
unless you want it
You were basically not using your RB to actually simulate physics on your bullet before, now it will
Hello fellow humans,
Using the animation rigging package, even if the parent of a constraint's target is moved or rotated, the game objects affected by the constraint do not respond to the changes made by the parent until the Build method is called on the constraint's rig's rigbuilder, furthermore the objects affected by the constraint keep whatever offset the target's parent imparted on the target, untill the Build method is called.
I believe calling the Build method on the rigbuilder is too expensive for frequent use, are there any cheaper alternatives that correct the effects of constraints regarding their target's parents?
Hello, I'm struggling with Unitys Rig/Animation concept and I'm not sure if I can bend it to what I am looking for. I basically want to create humanoid looking avatars with just the rig and then add static cube-meshes to the bones via script at runtime. Can I use the existing Avatar things? The rig would provide animations and my meshcubes would be sort of a programmer style lowpoly combined mesh.
I'm playing around with it but I cannot find access to the Avatar Structure. Theres no documentation on how these things actually work and what they are. Am I missing something? Is there a way to interact with imported animations (just the animations) from fbx files in Unity?
Looks like a beginner problem to me. You need an animation controller for controlling all sorts of Animations and blending in your character. Please browse some YouTube videos and guides on this rather than posting here for your own usefulness
https://docs.unity3d.com/Manual/ConfiguringtheAvatar.html
Just follow the hyperlinks in the documentation as it goes on if you don't want to watch lengthy tutorials
yeah I get that, I want to circumvent that. I try to import just the rig and then add meshes to the rig on my own, at runtime
you could either use Animator.GetBoneTransform. works mostly with humanoid setup.
for other cases use Transform.Find to find the bone and just proceed with your logics
You can also look at unity's Animation Rigging Package if you want to add some runtime custom animation
The way Unity's animation system works, it has to be defined as animating something; that something doesn't have to be a mesh, though. If you can produce an FBX containing a skeleton and animations, then Unity can play those animations on that skeleton fine without a mesh being involved, and you can attach objects to those bones.
The Avatar system is mostly unrelated to that; it's an optional system on top of animation that provides more options for a character if its skeleton matches a narrowly-defined humanoid structure.
Thats what I am looking for, but I'm having problems with that, but I must confess, I suck at animating/rigging and I'm not used to blender 3
Specifically with Blender, I've found that Blender won't actually export an armature/skeleton unless at least one actual "thing" is included in the export. I usually just add an Empty to the scene and export that along with the Animations and Armature, then ignore it.
Beyond that, it should just be the usual process for exporting animations from Blender; I'm sure there are plenty of tutorials that could explain it better than I can.
ok cool so it should be good with using rigify to create the armature, add animations and an empty, export it to unity via fbx and then i can attach objects to the bones at runtime?
I haven't used rigify myself, but yes, the rest of that sounds like it should all work.
sorry to bother you, but the animator component requires an avatar, i guess that the object or mesh it tries to operate on, is it enough if i just create one from the fbx import?
the wizard gives me an option there
The animator component does not require an avatar; if you're not using avatars you can just leave the field blank.
hey wassup
I am being ignored :/
wot
or maybe noone knows any answers
well i have no idea
i started scripting yesterday
still dont have an idea on how to script
xd
all good, hope you enjoy your journey :)
c:
Good news, I brought my 830+ line script down to 431 lines
niceeeeeeeeeeee
oooooooooooof
tis the way
š
I just don't know what went wrong
somehow it not only doesn't work as it did before, but it also is insanely laggy
so somewhere I mucked something up
but I can't find the issuee
Share the code or at least the problem sections
first of all, what is the purpose of the script?
I was working on making some kinda grid based pathfinding thing
A*?
it worked but the way I did it was much too slow cos I relied on physical objects rather than just the data of those objects.
I think some skewed version of BreadthFirstSearch basically
I tried to figure out A*
but it's over my head idk
Anyhoo the issue is definitely in the logic of the code somewhere. something doesn't happen in the right order or gets skipped or somethin
send the code please, or at least what is relevant
also please explain in what way it appears broken to you, what is happening?
it begins as usual, spreading out from the player, and avoiding walls
but then it just nearly crashes the longer it goes, and if it does reach the end, the path never seems to get loaded
I'll drop the link but idk how helpful it will be. it's like 400 lines and right now I'm not sure where the issue is happening
https://www.toptal.com/developers/hastebin/wivefomeha.csharp
the biggest change aside from using data vs a gameobject is that I store all the data when it loads now, whereas before I generated the grid around the player
First tip
Dont use coroutines for this
They have significant overhead that slows things down. I once "inherited" a dungeon generator that was using all coroutines. Getting rid of them and making normal method calls got the generation down from 390 ms to around 2ms
I see no reason for your methods to be coroutines anyways
it is potentially very large though. idk, I'm still new to this tbh.
if you want a headache to look at this is the original code: https://www.toptal.com/developers/hastebin/jibixijoya.csharp
warning: it's double the length, it's messy, it's inefficient.
but it did what I wanted it to [mostly]
Try it 
Yes
Coroutines have much overhead? My understanding of their working is that they're rather simple, just a list of IEnumerators that're incremented when called/start of each frame.
I can't say I've profiled it but that seems a little odd to me.
They allocate memory, so I guess if you had a really deep nested structure of coroutines calling coroutines the allocation and gc costs could add up? Most uses of coroutines won't do that, though.
That makes sense. I definitely don't see that being a common enough thing requiring the banishment of coroutines/ienumerators from one's code though.
that did not appear to work
I mean maybe I'm wrong but somehow it seems like it didn't quite work properly
just a hunch lol
Recursive coroutines are a bad idea. Why don't you change your logic to a Coroutine with loop?
Looking at it you might not even need a complete Coroutine. You can make use of voids as you're not yielding anywhere.
Although the execution of void could be controlled by a Coroutine for cases where your method takes too long to execute and you feel like timeslicing that
ye
look at line 21
@regal olive Move it to #š»ācode-beginner
Hello i am creating a multiplayer 2d game but have noticed that after a few seconds of play time it starts to lag a bit. From a profiler I can see that Physics and others are filling up the cpu like crazy :(. Can anyone recommend how I can resolve this ?
Optimizing is very fact specific so itās impossible to say without looking at your code, etc.
What would be the best way to approach this and fix it by myself? @thick thorn
well firs tyou can click on any frame to see what methods are actually causing the spikes
then you need to go into those methods and look at what things might be happening.
you can do deep profiling with markers if you can't figure it out through intuition
you might also want to turn on the garbage collection view in the profiler to see if you're allocating too many things
point is though it's hard for anybody to tell you what's wrong without knowing more about your project
That is actually what I've been trying to do but I guess I need to get more knowledge in this area.
I get your point and I do understand that. Was hoping for a magic fix anyway š Guess I'll dive into this more and see if I can resolve it.
Thanks @thick thorn
General Unity question: Is it possible to create a separate UI that's only piped out to streaming services? What I'd like to do is have a UI that is oriented towards my player playing the game, but I'd like the output to be formatted for a better spectating experience (and even throw in the player's webcam in a non-obtrusive location). Imagine a Madden-Like game that the player played as normal, but the stream output was a view from the sideline, for example; or Poker where the player was able to hide their cards from the streaming audience.
You can make use of multiple cameras and target displays. tho I'm not sure about that in release builds
@golden saddle Don't crosspost.
Just make an option for another player to join in a "spectator" role. Don't worry about webcams and such, that's what OBS is for
But viewers on Twitch can't join as a spectator
Why not
That's up to you
Well, they'd need to have the game.
Make it webGL
I'm trying to get a point from a array or positions (Vector2), or a spline as you will, and I want to get a position from it based on a alpha, so if I input 0.5 I want to get the middle point of all the positions, what would be the best way to go about it?
Any spline/curve library will let you interpolate along the curve
That's kind of besides the point.
How so
Yes, but I want to keep it simple and also build it myself, I don't want to use a spline library
Literally, the point is to make a better twitch/youtube viewing experience. Sending viewers to an entire other client is the exact opposite of the point.
Then start researching bezier and other spline math
Then why'd you ask this?
You have the twitch broadcaster join as a spectator
And they can stream it or do whatever they want
You can brute force it - calculate the entire distance of the spline, then loop through points[N, N+1] adding the total distance to some value; when the total distance exceeds the halfway point, go back one node and calculate the remaining distance to halfway.
The streamer is playing the game, in the game client.
Sure, they can spin up a second one in spectator mode.
Alternatively use Unity's multi window features
O ye I was thinking of doing it that way, I'll try seeing if there is a better way for performance but if not I'll try that
Again, that's not the point. If you want to address my inquiry please be my guest but I don't appreciate the diversion.
I'm answering your question. Why would you want to rebuild streaming pipe stuff? Someone's already built it and no streamer will want to use your thing instead of OBS or other similar software that they're familiar with and they can do all of the compositing etc. That they will want to do.
Trying to save you a lot of grief
the issue I'm having is the pathfinding works fine, except if I set the worldsize too high it starts to lag like crazy. and it only happens when the pathfinding starts, not when creating the "world" in data.
https://www.toptal.com/developers/hastebin/kopefalece.csharp
if anyone could look this over and point out where there may be error in the logic, I thank you. I'd point you to where the problem is happening, but I haven't been able to figure that out.
only look if you have time, it's quite long and I don't wanna waste yalls time.
thanks in advance. I'll be trying to figure it out on my own for now lol..
@zenith ginkgo I posted it here. if you get the time and you wouldn't mind looking it over at some point, would very much appreciate. only if you want to of course.
Im not sure if it's possible, but is it possible to generate classes by existing classes?
For example. I need to save some Data in my game and I want to save it via JSON.
Right now lets say the class "Item"
I need to create a seperate class called e.g. "ItemData" which is pretty much identical besides having all attributes made for fitting in JSON.
At the moment I need to write it by hand everytime I want to save something new.
Is it possible to somehow automate this process?
So it auto creates a new class when I mark it somehow in one of the classes, and it auto parses the existing attributes to fit for JSON?
Can I write some logic for that?
Grateful for any information or source :))
pathfinding
If you use a framework like Newtonsoft Json you can set the class to use "opt-in" for its properties and mark exactly which pieces you need to be serialized with e.g. [JsonProperty]. You can usually get enough flexibility like that to make a class that is dual purpose - for both serialization and gameplay.
Thanks I'll have a look
hey, I keep getting "Kernel 'CSMain' not found."
When I set buffers and get data I only reference kernel '0' so I'm confused
void SetOrbitPositions(Vector3 pos, Vector3 vel, float mu)
{
int index = orbit_visual_compute.FindKernel("CSMain");
Vector3[] positions = new Vector3[180];
ComputeBuffer positions_buffer = new ComputeBuffer(180, 12);
orbit_visual_compute.SetBuffer(index, "positions", positions_buffer);
orbit_visual_compute.SetVector("position", pos);
orbit_visual_compute.SetVector("velocity", vel);
orbit_visual_compute.SetFloat("current_time", Time.realtimeSinceStartup);
orbit_visual_compute.SetFloat("standard_gravitational_parameter", mu);
orbit_visual_compute.Dispatch(index, 180, 1, 1);
positions_buffer.GetData(positions);
positions_buffer.Release();
line.SetPositions(positions);
}
Anyone? I'm having no luck with google
https://docs.unity3d.com/ScriptReference/ComputeShader.FindKernel.html
Looking at this, your line 3 should be causing the error
Yep, that's the line
Have you seen this thread already? https://forum.unity.com/threads/compute-shader-object-can-not-find-kernel-unity-exception.460274/
So the shader code is here: http://pastebin.com/Tbgu7UvH
And the script is here: http://pastebin.com/r19BV1Rh
If I try to find the only kernel that I...
Someone says it might be a compilation issue
Or, you know... LOL
That might be your best bet lol
assuming it works with a simpler shader?
Hey there, does anyone know how i could create and set a custom NavMeshPath to an agent? I'm generating paths inside a parallel job and have a list of corners but there does not seem to be a built in way to make a custom path.
however, unity docs state
Additionally, a path created from user code can be set for the agent to follow in the usual way.
the docs for NavMeshPath are conflicting, and say
These points are not set directly from user scripts
I'm trying to convert an array of colors into a Texture2D and then into a sprite. But I'm getting this error. Despite my code being in the start function(I've also tried the awake function) any help would be greatly appreciated.
This is the error:
UnityException: SupportsTextureFormatNative is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'SpellWorks' on game object 'DefaultSpell'.
See "Script Serialization" page in the Unity Manual for further details.
And this is the code in the "SpellWorks" script
Oh no there's a couple other scripts, but this is the only one with the issue it seems
I mean inside this class, that is everything in the class?
Yep
Well besides the class declaration and variables
Aight 2 sec
Here's the complete class
Hmm
I can't seem to find any info online, and I've checked the documentation but tbh i don't understand it
don't create things in the constructor. In this case, the problem is you're initializing the SpellTexture field
no, constructors aren't necessarily called on the main thread and Unity API isn't thread safe
so no accessing any Unity API or creating unity objects in field initializers
Yep. No error. Thanks so much, been at this for almost 2 days now lmao
I have this code in my entitiesmanager class.
I have also bunch of calls to separate singletons on my entitiesmanager.entitydestroy method.
To avoid this, should I just make event entitydestroyed or something, and then invoke the event in the entitydestroy method so all classes can decide what they do and don't have to worry about this shit here?
public void EntityDestroy(int uid)
{
Entity ent = GetEntityByUid(uid);
if (MoneyManager.instance.prefabName_purchaseableItemData.ContainsKey(ent.shortPrefabName))
{
PurchaseableItemData data = MoneyManager.instance.prefabName_purchaseableItemData[ent.shortPrefabName];
if (data.type == PurchaseableItemType.TROOP)
{
Server.clients[ent.ownerPlayerId].armySize -= data.increaseArmySizeBy;
}
}
if (ent.buildingPiece != null)
CastleBuild.instance.UpdateNavmesh();
Destroy(ent.gameObject);
bool success = entityList.Remove(ent);
if (!success)
Debug.LogError("Couldn't remove entity!");
int ownerPlayerId = GetEntityByUid(uid).ownerPlayerId;
uidEntitylookupDict.Remove(uid);
if (Server.clients.ContainsKey(ownerPlayerId))
{
Server.clients[ownerPlayerId].clientIdOwnedTroopsLookupTable.Remove(ent);
if (ent.shortPrefabName == "House_01")
{
Server.clients[ownerPlayerId].armySize -= Config.HOUSE01_ARMY_INCREASE_AMOUNT;
}
}
else if (ownerPlayerId != -1)
Debug.LogError("wtf ownerPlayer does not exist");
ServerSend.EntityDestroy(uid);
}
I am pretty sure that would be the best way but I want to hear someone's words who is wiser.
I would, because you're mixing multiple concerns here. I would split this into several methods at the least
Yeah so instead of going there to add new functionality everytime, I could just subscribe to the method
event'
If you're missing semicolons and not immediately getting errors as you move to the next line you need to configure your IDE using the instructions in #854851968446365696 .
Also please don't use this channel to post basic questions.
Does your code actually Lag, or just execute slowly? GetNextTileInPath is an IEnumerator that only executes once per frame, and it's recursive, so even if the code executes quickly, a 200x200 world size would probably take at least 10 seconds to execute
Each frame you defer in a yield return null is the same as a frame referred to in "FPS". You're typical 3d shooter games might top out at 100 FPS - you're running 10s of thousands of instructions (each possible route in your 2d grid), one frame at a time, essentially pausing for the majority of a frame before moving on to the next iteration. So your processing speed is fundamentally being limited to Unity's FPS max and saddling your computation speed with the overhead of the entire project.
Hey! I don't know if I'm in the right place to ask, but I wanted to import this DLL from VirtualBox, I can import and use the DLL on a regular windows form and everything works as expected, however in unity, I can reference the DLL in Visual Studio and it acts nice, but Unity itself complains of a missing directive / assembly reference. I have tried putting the DLL in a "Plugins" folder, root folder, etc, but nothing is working. The DLL is pretty complex and I'm not sure if extern will help me much here
The DLL comes from VirtualBox and is named VBoxC.dll (I can send it if needed)
Here is an example that works in Visual Studio when I import the DLL as a reference: https://gist.github.com/NotBMan/3c4d4cc0ce362fffdb5baa7f2ad0d0e6
does List and LinkedList work similarly?
Does the List traverse through nodes (node.next) like LinkedList?
I don't believe so; as far as I know List<T> is just a dynamically resizable array. Walks are performed by indexing, insertion is performed by copying later values forward to make room.
Whereas, as you say, LinkedList is a proper linked list.
I think there is some other issues with the code as well tbh, but what you're saying makes sense now that I think about it.
is there anyway that I can do this different? it really needs to be quite quick @golden saddle
if I try to run them all at the exact same time with no wait of any sort it'll wind up crashing
What size grid are we talking about?
I'm not 100% sure what the full size is gonna wind up being.. but it's gonna be at least 500x500 for the map
it can take time to load at the start of the script, that's fine
but for when the pathing happens it needs to be quick
I would implement straight up classic A* pathfinding. Tried and true, 500x500 is big but doable.
but 100,000% you cannot use Coroutines/IEnumerators for this.
so just the act of running an IEnumetator will wind up taking a frame? I thought that was the whole point of Coroutines, to run many things at the same time or thereabouts
no, the exact opposite
wha?
ienumerators break operation for a frame, which can be useful for waiting for player input, for eg.
French? no.
I'm an old.
all good
probably got a lot of coding knowledge then
so yeah, basically my understanding of coroutines is completely wrong?
Just starting out. But I watch a lot unity and C# videos.
tbh what you're saying makes sense, looking at it objectively
because it allows the rest of the script to run while waiting for the code in the coroutine to execute
I've misunderstood the point of them
I am trying to make a game but I would really like for me to be able to actually understand how the pathfinding works and how it gets there. been trying to not just copy paste things and just try and understand concepts
on that note, do void()s take a frame to run as well?
well now I'm even more confused
At the start of each frame, all Update of active objects run each in turn, then all coroutines that are due to run are executed, each in turn. That's all there is to them.
(with some additional details that are irrelevant here)
The thing with all things computer science is that, if you go deep enough, everything is built from exceedingly simple principles. It is far easier to understand how to write a driver for a given chip than it is to write a game. All the complexity comes from people with their limited understanding combining them into overly complex systems. Pathfinding is extremely simple at the core, so are coroutines. If you encounter any concept in CS, and you find it difficult to understand⦠dig deeper and you will find a really simple concept from that the complexity derives.
Hi, is there any way to change packages source code? I found a bug on HDRP and i wanna fix it, but every time i change script it'll reset to previews data... it's because it's cache temp files... is there anyway to make them change?
You can clone packages and fix those
like you make i make a copy and paste it in assets folder?
unity will try to keep packages validated with their source (upm, git, local source folder) and assum they donāt change between versions
That is one way, or add the cloned one as a package⦠you will have to change its signature however
how can i make it clone?
i don't want to do this way
Copy it to a new folder
Bugs donāt care What you want
but isn't gonna that be a problem in future... i mean i'm always keep updating it !
can i update to new HDRP version for example ?
yes, thatās why people donāt fork the render pipelines
Only my manually merging changes int your cloned package
if you found a bug, have unity fix it
hmmm i've got... so after copying it to a new folder... i just need to add it to assets folders and then remove the original one from packagemanager right?
unity is gonna fix it on 2021.2.8 they sad
In theory
but i can't wait anymore... i can fix that by my self, i found the solution
For sanity sake, try to not depend on fancy features outside LTS releases
also donāt use stuff that has bugs
you're right... it was so stupid of me that i changed my main project version to those versions
HDRP in LTS was fine... i updated because i wanted to add new futures...
Iād be very reluctant to depend on anything in the SRPs too heavily⦠they arenāt done yet
if you look at the asset store⦠URP is a way more popular SRP
i know... but High Definition of graphic is important in my game... so i choose HDRP as my first PC game, and it really looks good... when anybody sees it, they think i made it in unreal...š
you can do great graphics in URP too
itās more about art direction than render features in the end
can i have raytracing in URP too?
No
nobody can afford raytracing GPUs
And boy is HDRP driving me crazy!
You still can use a 1660 Ti
yesi know... but it's good to put it as an option in your game
Iām using RTX in my game
Thatās what Iām saying
First make a great game, then add rt
HDRP is driving me crazy!
you're right... but i found out that i love realistic graphics... that's why i really keep working with HDRP...
Hello Twin Me! š¤
Hi thereš
Hdrp is great for deferred lighting, not much use for anything else imo
i have come to love the lighting limits of forward rendering
Keeps my projects focused on whatās important
Does anyone know how to fix an issue where volumetric clouds is causing everything to break?
Like when switching scenes
From one that has it to one that doesnāt and back?
you're right... that good if you have some really good skills on game designing... but i worked with Unity since Unity v.3, so i decided to make my last game in my life, after this i probably just focus on materials and lighting... you say very right my friend, thanks to you
hmmm, i didn't have any issue with it...
Itās the first time it is happening
12.1.2
Thanks
Thatās also important, doing what you like and are good at
pre unity 5, life was simpler
did you try using different priority ?
that is true
in unity 1/2/3 we were just happy to have something render in 3d at all
i was so happy with shadowing š
hmmm weird... i just had it in one volume and there were no issues... try to make it again, just volume i mean, it mae be a cache problem...
Wait let me try disabling one of the volumes
I forgot to mention I got this error in the built too, it was working fine yesterday!
Nopes still doesnāt do it
I found however disabling the volumetric clouds at runtime Iāve tried does indeed āfixā the issue
Somehow like disabling and re enabling it
it's the ordering... sounds like you have two objects or volumes that may be the same property... and it's get bugs
just like some of my lights... they had two Light data due to prefab workflow bugs
Well I do have 3 volumes that are simile but only 1 is active at any given time
Do you have any fix?
hmmm, i wish i could fix it, but i don't know how exactly your game is... the algorithm i mean... i have multiple volumes too, but no errors
this is my visual environment
and this is the cloud
Like the problem happens when i switch scenes
i mean if i go on the scene with all those effects and restarts unity
everything will be good
but if i switch scenes and go to another without it, then go back to this one, it will break
wired... i switches too...
maybe it's because you enabled local clouds?
idk, let me try without it
and i was going to release the game too š š©
big lesson... never leave the LTS version
this is my result without local cloud and it's better i guess
Does that help to know that i am actually instantiating the whole scene with the effects at runtime?
like the whole scene is a prefab
(For loading time, i have it instantiated, so it takes up less time to load and the game doesnt freeze)
well prefabs are making problems most of times
i just told you that i had lights with two different LightData component
and it's all because of prefab
don't make your volume as a prefab
ok let me try
yes i guess, it may fixs
prefab got still bugs with overrides components... i think that's the problem...
wait, testing rn
yups in fact it did work!
thanls
but im having my lights flickering now
let me restart unity
Wait
but that doesnt explain why when i switch scenes it breaks everything
i have unpacked everything and is is causing similar problems
what happend?
I unpacked everything from the prefab to the scene
and the scene goes like as if i have increased the exposure by 10 or 20
i enabled Local Clouds then disabled and enabled the volumetric clouds again and it fixes everything
problem
normal
if i do not restart the volumetric clouds after enabling local clouds
in this pic, sounds like the sky got so brighter for exposure...
what about sky options...
Wait I am recording something to show you the problem
#archived-hdrp btw
when you made them in prefab, it may broke some data, and unpacking them... well i don't think it's gonna fix them, i bet after unpacking they must re register again
noone is replying there lol
ohhhh i found out the problem... i have the same... but not like you... i mean i don't get the exposure issue... i can see it a little in my scene
Oh really?
š¢
You are a life saver!
lol yh, even on unity's forum noone is responding
look when you loading a scene, the coulds need to re bake as lighting in your scene lighting... try use static lighting, it may fix the issue
wait let me see
Do you guys know any way i can speed up scene loading? Ill have to find another one since instantiatign the whole scene at runtime is causing HDRP to break
that's happen because it's bakes the lighting, not that kind baking thou... i mean, it's like physically based sky
look, separate the RTX override components from main global volume, and assign your main global volume to this environment profile volume, i don't know if it fixes but i guess this is the standard way of developing
if you wanna add RTX components to your game try to add them in different volume
and also different HDRP pipline asset
they are on different ones
am trying this
i'm sure your problem is the environment lighting, just try to find out to bake clouds first before anything...
wait
hmmm... also try use static ambient mode in visual environment component, it may fix
hmmm i don't know anymore... what you think of URP š š
I have to submit that game by today midnight!š«
For a jam!
i'm sure you can fix it, if it didn't fixed at all, try to disable and enable the volume to rebake the lighting by script
found somethind
or with an time line animation or something...
Then my lights was flickering. Could be because of prefab... I tried it before unpacking
told ya, it's ambient lighting...
so it's HDRP's bug then...
order of bake... hhmmmm.
if it can fixed by disabling and enabling, that use some code or animation to do it in play mode, i guess this is the only way for now
yh let me try that
no your not dead, at least you can don't use clouds right?š„²
well... my unity just crashed with DX12 š
lol
Does anyone else has a fix to this?
Why is it happening only when switches from scenes that has this effect to other that donāt tho. I mean itās strange
And why now! This morning everything was fine!
š
is this supposed to only work on build version? but it's not... so what am i missing?
why don't you just screenshot
Yhhhā¦.. I actually was on my phone my badš
why don't you just copy paste?
My ActionStep class is being serialized but the ActionStep_Part class i drag into it is not being serialized. Any idea why?
on phone. convincing.....
Nopes
Yhā¦ā¦
does it have the serializable attribute?
Yep
monobhevaiours do not need serializable btw
i added the monobehaviour so i can actually drag it into the inspector. Is there another way I can do it?
A class should not be deriving from MB if you don't intend on attaching it to a GameObject directly.
that's probably not what you want if you don't actually have it attached to a GO. use a scriptable object instead
if i use scriptable object, can i change the values individually in this inspector and not affect the original scriptable object?
This is what it looks like without Monobehaviour. I want to be able to drag in different subclasses to this list that all derive from the same base class.
or if you just want data, just use a simple class
then you don't need to drag anything cause that wouldn't even make sense to do
But they each need to be different. for instance:
they all have the base class "spell", but i drag in the different parts that all derive from the class "spell", such as Spell : Travel, Spell : Prefab etc
Every spell is different, so i want to be able to only drag in the parts i need
uhhh, you probably want to look at the decorator pattern and i am confident that you will definitely have to write a custom inspector for that
decorator pattern. Thanks for the tip! I had no idea where to look next
Can anyone help me decipher this line? I am using this as reference for my custom editor but i can't figure out what this line does. It has an error in VS for me:
actions = (ActionSeries)target;
particularly, I cant figure out what 'target' is
it casts target to ActionSeries and assigns it to actions
And what is target to begin with?
Why is that line necessary?
When i remove it, the code breaks, so i know its for something.
target is the instance of the type which you are building your editor for
you know. the target
which you are targetting
ah! okay. And so it just needs a reference somewhere.
Where should that reference go? at the top of this script?
wdym?
Its in error state
whats the error?
I assume because target isn't referenced anywhere
Hi, I've been trying to get a compute shader to calculate points in an orbit to display on a LineRenderer. I'm getting a bunch of errors:
- Invalid worldAABB. Object is too large or too far away from the origin.
- Invalid localAABB. Object transform is corrupt.
- Assertion failed on expression: 'IsFinite(outDistanceForSort)'
- Assertion failed on expression: 'IsFinite(outDistanceAlongView)'
- Invalid AABB a
Here's my compute shader: https://pastebin.com/a0GzHrzy
And here's my C# method: https://pastebin.com/1SdrXjKn
Ping me if you notice what's causing it to only output NaN, thanks
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.
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.
you have a calculation wrong somewhere which leads to your distanceforsort and distancealongview to be infinite length
target exists already. it's just telling you that it can't convert it to actionseries
How do i find where target is initialized? or am i not understanding at all
I kinda know, I'm just at a loss trying to find the bad math. Is there a way to print to the log so that I can effectively debug?
it literally tells you. it's a property of the base class
i don't think so. compute shaders live on the gpu, so you can't log to something on the cpu
oh!!!!! I see it now.thank you. I thought target was a thing he made up. Editor has target built into it
Is there any possible way of finding the problem? I've scoured it and re-written it like 4 times already
Getting really frustrated that there's no good way of debugging compute shaders
Fixed it thank you
If anyone knows a good way to debug compute shaders let me know
maybe that can help you