#archived-code-advanced
1 messages · Page 114 of 1
Not related to your question but something I figure is worth bringing up due to the channel we're in: System.Numerics.Vector4 is almost universally better to use than UnityEngine.Vector4 in code that is going to run under Mono. It is the only type other than Vector and Vector<T> that has support for SIMD at the JIT level in Unity's version of Mono, so it will typically perform better than equivalent code using Unity's Vector4
When you don't need tightly packed data it therefore can make sense to use that instead of Vector3 even, sometimes
If i have a folder with asmdef, then inside the folder there is also a subfolder with asmdef, does the top asmdf automatically refer the asmdf inside the subfolder
nope!
okay thanks
Whats the difference between assembly definition asset and assembly definition reference asset ? If i can refer other asmdef using assembly definition asset, why do i need assembly definition reference asset ?
Why does script outside folder with asmdf able to reference dll inside folder with asmdef despite not adding assembly definition reference ? does that imply asmdef only cover cs and not dll ?
auto referenced option was unchecked
assembly definitions are for source files yeah
plugins have their own reference settings
is there a way to check if a object is copied by my artist?
i have an GUID system that an object get a certaint guid when you make them only problem if you copy the object the guid will also be copy't
how to i check if a guid of objects is not the same when the artist copy the object or if the object is copyt
ok, heres the video, i had to put it in youtube, cuz it passed the discord upload limit
does [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] run only on the first scene load or on each scene load? 🤔
First
Do I have a fancy thing like that that runs on every scene load? 🥺
I guess I could hook myself to my own scenemanager after all 🤔
SceneManager.activeSceneChanged also works 🤔
Or sceneLoaded
Hi, is there any way to increase the NavMeshAgents priority level above 99? I need it for making an RTS with hundreds or thousands of units on screen. I want to use it to make units not overlap in various situations. 100 positions is also very bizarre, it's and Integer, so why only 100 values?
I have made various systems such as moving in formations or keeping group shapes, moving around corners with a random distance for big groups, etc...
But it's still not enough. For example a group of units attacking a single unit ends up having all units overlapping pretty hard. If units that are closer to the target had a higher priority, it would reduce the overlap significantly. But I need to have 100.000 to 1.000.000 priority levels to an achieve this.
Thanks for your time!
@undone gust Don't cross-post and also wrong channel. #🔎┃find-a-channel
Ok sry I wasnt sure which of the two channels to post it to so I did both just in case
is there a way to create a prefab stage like environment without making a prefab stage? like another way to open a gameobject in isolation
You mean in the editor?
I don’t see why you couldn’t just make it a prefab and then apply it. Alternatively, you can lock and hide everything else
a game object cannot be "opened", but you can hide everything in the scene and only leave one object visible.
yeah ive resorted to this programmatically, create a prefab asset and open it but feels kinda silly to need to delete it on cleanup just to "view" an asset in isolation
I want to make a object placement script.. in which object instantiate at the front of the camera on the ground... and there are two categories... one remains on the ground and move where raycast hit.. and other are place on the another object... i can't achieve the placement on the another object
maybe this doesn't do everything you need but there's shift-H to toggle isolation on the selected object
appreciate it, though was just looking to do this for non scene things
Cool, thanks. I ended up considering it for a while and ultimately just rolling my own struct that's got the stuff I need from the numerics library and will play nicely with unity. Ultimately I'm going to need tightly packed here - the use case is a Location that's gonna have a lot of low latency requirements (ie, realtime ships). It's for an MMO so the better I can pack down the data, the more people (or smaller tick rate) I can support.
Tentatively my plan is to use a combination of "big location" (vector3 ints - ie, which cube within a map the player is in) and "small location" (vector3 floats - what x, y, z within the cube they're at). Only small location needs to be small and packed, so I'll roll my own for that struct and just do whatever for the big one.
I feel semi confident this belongs in this chat lol.
I'm working on a "game", for lack of better descriptor, that's gonna run on the Quest 3 standalone, effectively phone hardware. The game's main gimmick is placing a bunch of individual objects with unique data in pre-determined locations across a giant map, which is procedurally generated for performance. The thing that determines the location of these objects is a large dataset, each datapoint having a set of coordinates.
Here's the issue, though. There's almost 700k data points. That's almost 700k gameobjects.
I have zero clue where to begin on how to make this work. Any guidance would be a blessing.
In what kind of density
this is what the distribution looks like
from a quick and dirty python scripted plot lol
but they need to be separated enough for the player to be able to interact with them individually
when you say standalone will the device have any network connectivity at all?
It can, but I need this in a demo-able state before the point I assume I'd be able to get any networking set up with this
(about 2-4 weeks)
the dataset is only about 75MB
as a .parquet, at least
how many objects do you envisage being active at any one time
however many the headset can handle without noticeable performance costs, I think an important part of the experience is gonna be looking out into the horizon and seeing a bunch of em
maybe 1-2k at any given point, depending on how tuned in I can get the LOD
as well as depending on how many are in a given area, of course
the game is moreso meant to be a form of glorified data visualization
do you know the film Tron?
classic
yeh
I'm trying to visualize the kind of data visualization you're talking about
I'm guessing that thousands of objects rendering at the same time on a quest won't fly, so you'll need to figure out some tricks to render things. Can't really give advice since we have no idea what kind of obejcts you're rendering. Or whether htey need to be interactable
it's not super complicated honestly, the vast majority of the experience is just a ton of the same plant sprawled out across a desert
There's some obvious things you can do like putting things in a quadtree, figure out where the player is and only render close objects
they do need to be interactible, yeah
I have done something which I think is similar in concept before but I used a backend data processor and used the frontend purely for rendering. That obviously wont work for your prototype
Mmh, upon looking up what a quadtree is, that does seem handy. I'll try to look for some examples of this being implemented in Unity, if you don't already have any handy
Yeah fair. Latency would def be an issue as well
All objects are interactable?
Mhm, the idea is that the player will be able to go up to any of them and view the information pertaining to that specific datapoint
Latency should only be a problem if your 'player' is moving fast
Fair yeah
I would go for a k-d tree if we just need n closest points
you can fine tune the rendering using object pooling and a lod calculation
Oh, you mean like reusing the same gameobjects for different datapoints based on what's in view
exactly
true yeah, that is already what I'm doing for terrain as well
https://www.youtube.com/watch?v=f9uueg_AUZs
this video came in clutch for the terrain generation
Download Link: https://drive.google.com/open?id=1B_IwrJKX9sQishwyrUbmWYCZrmhUwJTb
The project is using Unity 2017.3.0. Just FYI.
Update: Unity 2017.2.0 introduced the Vector2Int class. It doesn't make a difference, but it makes more sense to use it to keep track of tiles. It didn't exist when I originally made it...
they have a means of placing objects with the thing in this video as well, but they're entirely random as far as I can tell
In my experience quest 3 can handle around 300k-500k tris so your objects will have to be simple
Also chunking them into a single mesh for furthest lod will help
do you know how well the Quest handles multi threading?
sounds about right, I'll have to pull some neat tricks in blender lol
not off the top of my head lol
We haven’t done serious cpu work on a quest. The bottleneck is always the gpu. But we have used the job system for certain task and it handled it very well
that is gonna be very important, coz you're gonna be doing a lot of it to keep it performant
We have run a custom jobified hlod on the quest 2 even
dang nice
understandably
good thing about data visualization is it doesn't need to be complex meshes, generally you can get away with a few primitive shapes
The main bottlenecks on a quest are draw calls and fragment shaders
True true. When I was first handed this project, the mesh they were using was a photoscan of a real aloe plant
forget it
yeah that thing's going asap
dude the terrain was even worse
it was a single 110k tri mesh with a rigidbody
rofl, some people think we live in a ScFi world
Honestly with the GRD in Unity 6 and decent enough lods you can probably run it
I have thought about upgrading the project to Unity 6
I might once I have the thing working first lol
I think you are going to be stuck with whatever the Quest sdk supports
True, I've yet to hear of anyone testing that yet
I know one of the hand physics assets I use recently added support for Unity 6
Honestly I would go with Unity 6 off the bat and make use of the new tech. The time ghost terrain demo with the millions of grass bjects is exactly what you want to do
I think you should forget about the rendering side of things atm, that can be fine tuned later. I would concentrate on answering the question, 'How fast can I calculate which objects are in view'
Makes sense
I'm guessing the Quest has the standard 30 fps as Android
oh goodness no, that'd be awful lol
120
75/90/120
then you are definitely gonna have to time slice
mhm, this is definitely a hell of a challenge lol
so, the two methods I've heard of going about this so far are k-d trees and quadtrees, how would implementing either of those work?
doing it in itself is not a problem, making it realistically performant definitely is
right yeah
the definition of being easy on paper lol
wait so from what I can tell, k-d trees are basically just 3D quadtrees
or is that wrong?
actually I would use an octree
does it need to be 3D? The plants could just be projected onto the terrain mesh, no?
you will need it to be 3d to get the lod calc correct
It depends on your terrain, you can likely get away with a quad tree or kd tree if your terrain is mostly flat
currently, it's procedurally generated with perlin noise
That doesn't mean much
you're thinking of doing an xz representation?
I think the customer will want some height variation
occasional sand dunes might make culling easier as well
So you mght need something 3d, but you probably want to project your data points onto the terrain ahead of time
So that you don't need to do all that crap at runtime
because your data is static, a serialized, chunked octree is probably the best data structure. Unfortunately it's also the most complicated to implement
that can def be done
(since your datapoints are only 2d)
hopefully someone in a forum post 10 years ago has already done the work for me lol
unlikely
We use the kd tree from here https://github.com/Unity-Technologies/Megacity-2019/tree/master/Assets/Scripts/Utils/KDTree
Oh nice
One thing I'm also concerned about is how actually accessing the data associated with the datapoint is gonna work
cuz I assume these are just to store coordinates
Just strings, yeah
Idk how the above kd tree works but it likely allows for custom data
well, strings and ints
So you can likely just make a class that contains your stuff and put it in there
Or have some identifier that you can then look up somewhere else
yeah I was thinking something along the lines of just assigning it an ID corresponding to it's datapoint, just not knowledgable on the logistics of that
Not sure there's anything special to it?
I think you've got a lot of research and experimenting to do. 2-4 weeks is gonna be pushing it to get even a proof of concept working
yeah no kidding
nerves are high, won't lie
especially since they're gonna use this to apply for a grant
which, if they get the grant, they get the means to hire people, and I'd be their first candidate
So what do they actually want
Because it's a lot easier to do something smaller scale
I.e. without 1000s of objects
a proof-of-concept that uses the full main dataset, as far as I can tell
With some lightweight objects, culling, etc, you can get a few hundred objects without issues likely
up until recently they've been using a different dataset of about 20k datapoints for prototyping
Hell, it might be worth just throwing everything at it and testing performance
(with aggressive culling and LODs)
true, and yeah to a point lmao
I have to say even having done this kind of stuff before, a 2-4 weeks time frame is totally unrealistic
I didn't just start on this necessarily, ideally we'd have the full semester to work on it
and ideally I'd have a full group of 5 members to help me out
If the data is known ahead of time, you don't need any of the tree data structures. Just have a grid instead, splitting your entire space into cells and putting each object into the cell it belongs.
Those tree structures are good when you need to modify the data at runtime (insert/delete/etc), which is not your case. Grid is so much easier to implement and has better performance, especially so if you carefully choose your cell size.
but the odds are kinda stacked against me lol
that helps
fair, though the data distribution makes that a bit difficult
as far as I can tell at least
It does not matter
there'd be a lot of empty cells lol
Which is a non factor unless you are worried about running out of memory.
what is your actual map size?
undetermined yet, but it'll probably be massive given the density of the middle area
thus why I implemted the infinite procedural terrain thing
we've got about 8GB to work with I think
@scenic forge suggestion is workable, but you would need to calculate the memory requirements
you only need 1 bit per grid cell and if you can chunk the grid you get the benefits of both size management and speed
That does sound appealing
You can do some napkin math to see if your entire world fits in memory or not, but even if it doesn't, the good thing about grid is that you can easily stream it rather than having to load the entire thing in memory.
I assume having the terrain be procedural definitely helps in that regard
procedural as in in editor or at runtime?
runtime
prolly wouldn't be infinite otherwise
not a benefit, that will consume a lot of your fps
does it need to be infinite given that your data points are static
Probably not in theory, but I only know that the generated terrain stuff I got from the video I sent earlier performs vastly better than any of my own attempts lol
it's less so generating meshes more than it is just modifying pooled ones
it's just a single continuous perlin noise thing for the heightmap, and the vertices are kinda just projected onto it
I think the only performance it would eat up is when moving
I'm guessing that performance is your major concern so the less you can do at runtime the better, so a predefined chunked terrain would work better
again, you can fine tune the chunk size for performance
That's fair. I guess I would need to figure out how to have that many chunks already in the editor while getting performance as good as what this current thing has
you need to look at implementing your own serialization system
gotcha, hmm
https://assetstore.unity.com/packages/tools/input-management/terrain-serializer-100434
I did just find this lol
well, this would only kinda work
actually honestly seems like this would be worse
it doesn't serialize meshes, only stuff like terrain component data and heightmaps
which also implies having hundreds of heightmaps
that looks like rubbish
which I think was why my previous attempts at runtime terrain generation went so poorly, but maybe that's just because I was generating the heightmaps
fair lol
One thing I should mention as well for the sake of futureproofing I suppose, one idea the customer really likes the idea of is having a way of tracing paths between all of the datapoints that players move to and from, and updating the terrain textures accordingly for all players
that I obviously don't need to implement soon, but if that impacts any of this, I assume it's worth accounting for
nah, detail, not important
I'll take your word for it then lol
lol, I've already written half the system in my head whilst we've been having this conversation

man this is why I regret doing university so often
I would know so much more about Unity and programming in general had I spent the past 4 years actually doing Unity stuff instead of random irrelevant classes
like good lord I could've already had 4 years of experience doing nothing but unity
full disclosure, I have been doing this stuff for 50 years
valid lmao
it is an interesting task, the data structures required are fairly simple. The problem arises with scale and it will be how you handle that scaling that will make or break the project
I agree that it's interesting lol, funny how these kind of things can be so simple conceptually and yet so semantically challenging
the devil is in the detail, as always
also worth mentioning, idk how much it matters with this obv running on my PC, but like with the terrain sprawled out about 200m in every direction, I'm still getting 600fps
I screenshotted a low frame apparently
yeah fair
so there's a good thing to start with. Build that to the Quest and see what you actually get. that will give you a benchmark to work with
good point, I'll do that rn
..man I forgot how long these take to build
usually only the initial build, patch builds are a lot faster
that'd explain a lot lol
alright got it going now
..and also realizing I don't have a way to benchmark the quest 3 performance when running directly on the headset
the most I can say is that it feels butter smooth lol
but also the terrain generation isn't working, so uh, maybe that means nothing
well kinda
that is definitely something you're going to have to work on
it's not generating anything after the initial generation
in which case it is meaningless, it is precisely the procedural chunk generation that could kill your fps
hmm.. it's still working in the editor
oh wait I know why
it's cuz of how vr tracking offsets are set up
ez fix
he says, naively
okay the player recentering is kinda buggy with VR but that's earning itself a //TODO:
yeah I don't notice any framedrops
lemme find a way to properly test this tho
alright here we go
It's locked to 72 fps cuz I have something misconfigured I think but the drops are there
Just, really tiny
that ain't good, not going to give you much wiggle room
it needs to. this is the simplest part of what you want to do. the cpu intensive stuff has to be added
Yeah fair
forget the CPU/GPU usage FPS is ALL that counts
even more so with AR/VR than desktop/mobile
Right, I'm just saying the cap is currently 72, which it's hitting easily lol
gotta mess with some configs to enable higher fps https://discussions.unity.com/t/quest-2-how-to-get-90-or-120-fps/898840/4
do it, get the max possible you can
URI said you should be able to get 120 so that has to be your aim
damn it, can't figure out why this isn't working
ah well, I'ma call it in for the night. I'll start up on this again tomorrow
it's like 6am lmao
you're East Coast USA?
Mhm!
I don't know if this is the right place to ask, but I have a multiplayer unity project. In my project, on a single client, I have a texture that I draw to at about 60fps. I need to take that texture data and somehow provide that data to every other client. I'm using Unity's netcode for gameobjects at the moment but I'm open to other tools.
Unfortunately, the code I'm running to calculate the data for the texture cannot be simulated on other clients.
I know Unity isn't really optimized for streaming textures across the network (let alone multiple textures which I'll eventually need to be able to scale to), but are you aware of any tools / packages that might offer some help with this.
Unfortunately, the code I'm running to calculate the data for the texture cannot be simulated on other clients.
This is almost definitely the right approach. Why can't it be simulated on the clients?
Otherwise you're basically just talking about streaming video.
Althought this seems to exist:
https://docs.unity3d.com/Packages/com.unity.renderstreaming@3.1/manual/video-streaming.html
so maybe that's what you want
Yeah, I'm aware that not being able to simulate the code on other clients isn't ideal. If I could then that would make things a lot simpler. It's a bit too complex to go into, but I am actively trying to figure out a work around as video streaming is a last result. Thanks for linking the resource. Do you know roughly how network / bandwidth intensive the video streaming will be? The textures are about 250 pixels in width and height, updating at about 60fps. Also, I appreciate that this is just theory right now, but do you have an idea on how well this could scale for streaming multiple textures?
I literally just discovered this package 2 minutes ago so I know as much as you
That's fair enough. Thanks anyway, I'll take a look into it. All of the resources I found while googling were for paid assets (which I don't mind), that weren't actually relevant to my situation
Hey friends, I'm trying to add an external DLL in my project in assets/plugins. My project is 2022.3.36f1 and the DLL targets .NET 3.5
I am not able to reference anything from the DLL in my project so I am wondering if it's due to the DLL not being valid?
Due to targeting net3.5
I don't see any errors in the editor, it just seems to not be adding references to the DLL in my csproj when it generates it
targeting .Net 3.5 is fine
Hmmm, it is set to auto reference so I'm not sure why I can't use it at all
screenshot show your project view and the inspector of the dll
I was fiddling with platform settings but i assume the default is ideal. In any case i don't seem to be able to reference anything from it regardless
you have it set to be excluded in the editor
also that looks like it it may be a Win Forms dll which wont work in Unity anyway
Where does it mention winforms there?
it doesn't, but I can extrapolate from the part of the name that you didn't redact
Oh, I think that's just meant to be windows. There are versions of this DLL for every platform like iOS etc
It's meant to be a wrapper for a native DLL
dll's are platform agnostic, so if it has WIN in the name that generally means it is using Win Forms specific code which wont run in Unity
Idk, I have a folder for each platform with a DLL for that platform which uses a naming scheme
Like the ps5 one ends with _PS5.dll so the 64 bit windows ending with _WIN isn't surprising for me
dlls are platform agnostic if they contain code that is platform agnostic. since the dlls are already compiled then things wrapped in platform specific preprocessor directives would be compiled out when targeting specific platforms. so it makes perfect sense that there might be separate dlls for the separate platforms if it contains platform specific code
you are not seriously trying to teach your grandfather to suck eggs I hope
you're the one who made the incorrect claim 🤷♂️
In this case I have about 9 different DLLs for various platforms
not an incorrect claim at all, read what I actually wrote
I personally didn't make these but they each have platform specific logic I'm pretty sure
And I don't think they use winforms
They are meant to be managed wrapper DLLs for native DLLs
Maybe it's an issue with the native DLLs or something?
the dll you showed was not included in the editor so it wouldn't be accessible within the editor, only in standalone windows build. there's likely a dll somewhere in that asset that would be intended for use in the editor
I changed it back to standalone but no dice 😦
steve had just made a wild assumption that it was a winforms dll just because it had "WIN" in its name, you can disregard that assumption
wdym you changed it back to standalone?
In platform settings it has editor and standalone
you really did not read what I actually wrote did you
If I change it to all platforms it doesn't seem to help either
i did. you were just wrong
hmm 'that looks like it it may be a Win Forms dll'
and yet it wasn't. it was a dll that had been compiled specifically for the windows platform.
Oh I got it working
I had to make it work for all platforms
Seems wrong but I'll figure that out later
are you certain that was even the one you should have been modifying the import settings for? either way, you probably need to exclude the other platforms rather than making it available on all (if you're not actually building for any other platforms then it wouldn't really be a problem if you don't do this, but it is definitely recommended to do so just in case)
when you are using dll's and you have multiple platform specifc ones.
- They should each be in a distinct folder under a Plugins folder
- They should all have the same name
I'm testing on x64 and using just Standalone didn't seem to work
because x64 is for a build not in editor
Editor being included must have done the trick
so just to confirm, what you've actually done is just remove the Editor from the excluded platforms, rather than going and including all of the others in the box further down, right? because that was what was pointed out when it was said you have the editor excluded
What would an implementation of streaming datapoints look like in this context?
the editor is only x64 now. so including the windows x64 platform while not excluding the editor platform is what fixes it. they are likely just being confusing with how they've worded what they've done
that is not whst those settings mean but I sure you have vast experience using dll;s so I wont argue with you
I'm sure in your 1000 years of using computers you've come across one or two dlls that perhaps were compiled for specific platforms. and those settings are to tell the editor which platforms to actually use those dlls on. which you would naturally know if you'd stop being so arrogant and maybe read the docs or something
https://docs.unity3d.com/6000.0/Documentation/Manual/plug-in-inspector.html
Store them on disk, only load the nearby chunks.
I get it conceptually, I mean like literally, what is the setup for that lol
Like is there specific scripts I should be writing or a certain thing I need to mess with in the editor or something?
It's not much different from reading/writing a game save.
Any mesh experts around? I'm trying to make two pieces of terrain and stitch them together manually. I'm just looking for technique suggestions.
If you have a question just ask it
I.. have yet to get far enough into a project to actually add this, admittedly
I'll look up some guides for that tho, thanks
Anyone here an Mlagents expert and can take a look at an AI I’m currently training?
Can the clints be a second or a few seconds behind? does every single texture need to be delivered to everysingle client?
Hey, I'm trying to use the gpu Sparse uploader to write to a graphics buffer that holds hit positions for a shield vfx. Like so ``` public unsafe void RegisterHit(int id,float3 pos)
{
float4 newHit = new float4(pos, 1);
m_gpuUploadOperations.Add(new GpuUploadOperation
{
Src = &newHit,
DstOffset = id + _iterators[id/k_MaxHitsPerShield],
Size = k_sizeOffloat4
});
_iterators[id / k_MaxHitsPerShield] = (_iterators[id / k_MaxHitsPerShield] + 1) % k_MaxHitsPerShield;
}``` Problem is I'm getting the wrong data in the buffer. I think I might have done an error with the pointer that needs to go in Src but I’m not sure.
Are you sure it's not just a case of the variable going out of scope when it's accessed by the GPU(or copied to the GPU buffer)? newHit is on the stack, so as soon as this method returns, Src would be pointing to an arbitrary memory address that could be containing anything.
Try making it a class field(assuming that object lives long enough) and see if that fixes the issue.
My god I think you are right
@untold moth that was it. Thank you. This is what I get for using unsafe code while sick. 😄
Hahah. You get sensitive about this kind of things when working with C++ every day. Glad that fixed it.
Maybe you can help me further. You see my problem right now is that Register hit can be called multiple times per frame. I need to somehow store the hits in a array and then create a upload operation with the pointer to each hit.
Why you are not using SparseUploader directly? It has nice AddUpload API that copies data internally.
Use SparseUploader.AddUpload and it will store data automatically, so you can call it whatever number of times you want.
I’m not sure I will have to check. Right now I also have to manually calculate the total and biggest uploads and supply that to the sparse uploader
Can you show me an example of the api ?
To be honest, I've never used that API, so better try what Rukhanka suggested.
Hm, I thought you are using it already. Give me a minute, I will show you.
I was gonna suggest to just add the hits to a list and then flush all the hits later in the frame, while clearing the list(might need 2 lists or an array + list for a sort of double buffering).
I was thinking the same I would just need to do &allHits[i] right ? Sorry my pointers have gotten hella rusty
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using Unity.Rendering;
using UnityEngine;
public class SparseUploaderDemo : MonoBehaviour
{
SparseUploader sparseUploader;
GraphicsBuffer gb;
void Start()
{
gb = new GraphicsBuffer(GraphicsBuffer.Target.Raw, GraphicsBuffer.UsageFlags.None, 0xffff, UnsafeUtility.SizeOf<float4>());
sparseUploader = new SparseUploader(gb);
}
void Update()
{
var uploadOperationsCount = 10;
var valueSize = UnsafeUtility.SizeOf<float4>();
var threadedSparseUploader = sparseUploader.Begin(uploadOperationsCount * valueSize, valueSize, uploadOperationsCount);
for (int i = 0; i < uploadOperationsCount; ++i)
{
var uploadedValue = new float4(i, i, i, i);
threadedSparseUploader.AddUpload(uploadedValue, i * valueSize);
}
sparseUploader.EndAndCommit(threadedSparseUploader);
// Now graphics buffer will have updated data, and can be used in shaders
}
void OnDestroy()
{
sparseUploader.Dispose();
gb.Dispose();
}
}
Something like this
This seems much simpler than what I’m doing I will have to give a try thank you❤️
Hrm, if I need a threadsafe read/write to an array - how do I do that in ecs?
like if I want to increment a value in an nativearray<int> - in a parallel job, how can I do that reliably?
(forgive me if there is a dots/ecs channel im not using)
Gonna be hard to explain properly what I'm trying to figure out so bare with me here.
Basically, I'm trying to read .parquet files in Unity. To do so, I'm following this tutorial for figuring out how to read/write game data. https://www.youtube.com/watch?v=mntS45g8OK4
However, this tutorial is for messing with .json files, using the Newtonsoft Json Unity package. As far as I know, Unity doesn't have an equivalent package for parquet, so I had to use this (https://github.com/GlitchEnzo/NuGetForUnity) to then install this (https://www.nuget.org/packages/Parquet.net/).
Once that was installed, I modified the tutorial code as best as I could in a way that would allow me to read a roughly 74MB .parquet file currently located in my assets folder. I hit play to see how it ran, and.. it's been stuck at the compilation phase for about 30 minutes.
Learn how to save and load data in Unity - avoiding common mistakes and dangerous serialization techniques many other tutorials will tell you to use!
In this video we'll look at using text-based serialization using JSON and optionally encrypt that data. I also discuss some of the pros/cons for using text-based serialization, and what you should...
Here's all of the code I wrote that relates to this, needs a lot of cleanup so apologies if this is difficult to sift through
@upbeat path @scenic forge y'all know the context of why I'm trying to do this, what do y'all think of how I'm going about this?
Not sure where to ask as I don't see a platform channel for consoles, but does anyone know if Nintendo Switch supports 2D Texture Arrays?
https://docs.unity3d.com/Manual/texture-arrays-introduction.html
https://docs.unity3d.com/ScriptReference/SystemInfo-supports2DArrayTextures.html
it's still trying to compile, been going for about 45 minutes at this point. it's definitely doing something, I see Unity in task manager with about 0.6% CPU usage
Not sure why your compilation seems to be stuck, but is there a particular reason you want to use Parquet?
it's just the format of the dataset being given to me by the customer
How much data is there?
75MB, about 676k datapoints
I'm not familiar with Parquet to know, it does seem like it has some sort of data streaming though rather than having to put the entire thing in memory
Personally the approach I would go for, is to preprocess those data at build time into a format that's more friendly to runtime, and additionally chunk them based on your runtime requirements.
This way you don't need Parquet at runtime at all, and your data can be in a format that's flexible and tailored to your runtime needs.
Is there a specific format you would recommend for that?
Very likely just binary.
How would I go about converting it to binary?
Design some sort of schema, eg "first 4 bytes is a floating point for the X coordinate of the first data point, second 4 bytes is for the Y coordinate, and repeat for all data points" then just read/write to it.
I would need to do that for every element of the datapoints
not just the coordinates
Of course.
You pay for convenience with performance/flexibility. Whether that tradeoff is worth it or not, you need to evaluate yourself since I don't know what Parquet gives you.
I know for sure that if your data is packed in a structured way, you can easily skip to a certain part of the data without needing to have the whole file in memory.
I think the main benefits of parquet are supposed to be performance and file size
There are also more general formats that aims for a middle ground, like FlatBuffers.
anyone can help me figure out why my script is not working on my own ragdoll? I'm trying to control the joint on that part and it works on another ragdoll just not mine 😦
maybe my ragdoll setup is wrong or smth but idk anymore I'm losing my mind
Building off of a previous question: How can I templatize a set of input parameters, given that I don't know what the parameters will be, nor do I know how many there are? [Here's the relevant code snippet](#1304612190887608412 message)
However, ideally I have Func<X, bool>, where X somehow represents, say, <int,float>,<string,int,int>, or whatever it may be
Take a look at network serialization.
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/fastbufferwriter-fastbufferreader/
this one is not in a multiplayer package and is what Unity transport uses
https://docs.unity3d.com/Packages/com.unity.collections@2.2/api/Unity.Collections.DataStreamWriter.html
The serialization and deserialization is done via FastBufferWriter and FastBufferReader. These have methods for serializing individual types and methods for serializing packed numbers, but in particular provide a high-performance method called WriteValue()/ReadValue() (for Writers and Readers, respectively) that can extremely quickly write an en...
If you don’t care about compacting the data in any way, you can just find a c# binary converter
Need help with some movement code: Whenever the player goes up a slope, his speed gets subtracted by the sin of the slope's angle multiplied by a value called slopeUp, but he can still move up the slope because the code that handles movement based on the player's input is still active and incrementing the speed. Same for when he goes down a slope, but then turns around mid descent and goes up. Is there a way to fix this and make the player go down naturally if he can't climb the slope? https://hastebin.skyra.pw/kixedinaro.pgsql
what does this refer to in a unity C# closure?
this in the object that creates the closure or this in the object calls the closure?
What do you mean?
Oh wait, you're refering to the keyword "this"?
What do you mean by "closure"? Can you rephrase your question?
I'm trying to create an event listener as follows
this is the member: public Action<string> OnWord;
Word wordObject = this;
voiceController.OnWord = (string word) =>
{
voiceController.uiText.text = "drawing word";
// wordObject.drawWord(word);
};
this does not work
also drawWord isn't called
I do know that the voice controller works, but for some reason the communication between my objects fails
drawWord is an async function by the way
it is supposed to run without being awaited
You should most likely use a public event Action<string> OnWord instead, this facilitates multicasting (subscribing multiple handler methods to the event), and subscribing with += instead of just assigning the lambda with = (which means you'll also need to unsubscribe with -= when you don't need the handler to be called anymore)
drawWord() is commented out so it effectively will not be called here
Make sure you are invoking the event at some point by placing logs inside the lambda and/or by setting debugger breakpoints
Does anyone have any ideas for this issue?
rigidbody probably.
give your player a raycast downwards from some distsnce away, there you can get hit normal and project your rotated by player quaternion input vector. one issue with it is that random bumps in terrain would make it all not work
i came to fix it with two raycasts, forming slope triangle (right angle SAS triangle )and angled my input up or down depending on the surface angle
persists with rigidbody unfortunately as relative forces applied are pushing it in ground and out of it depending on slope
i will draw this one up, gimme sec
It will make your slope problem a simple trigonometry
here is how raycasts(green) would look like on player(gray) on the slope (white)
hypothenuse can also be got by substracting world coords of two ray hits and getting its magnitude
so its more of SSS triangle in this case
Thanks
(less math heavy option would try to get rotated in wolrd coords player eulers forward vector and get vector3 angle with hit normal but i have not yet tested)
Is there any reason why you would not use the normal of the object with a single raycast ?
Oh, I see, you did explained that.
What I can say, is that I have used the normal for a lot of gameplay feature like that and it works well.
for me it sadly just stops working at high slopes even with correct project onto plane, i did mutliple passes on it and it was not resolved so i just went with second best option-custom projection
though it does create some heavy math(its atan functions which are while not the most costly thing i did in update, are not welcome guests)
So, the previous suggestion given to me didn't work for me, so I still need help with that
Again, when climbing on a slope, speed is decreased as intended, but it's immediately incremented by the code that handles movement based on player input, which causes it to never reach zero and continue to crawl up the slope
nmv i forgot to save all project
Set a minimum velocity and only move if your target velocity is above
if(targetVelocity <= minimumVelocity) targetVelocity = 0f;```
I need the player to go down the slope when it happens
Again, when climbing on a slope, speed
Set their movement state to falling with a different animation.
Your falling state is probably good enough to handle sliding down most of the time.
turns out I was way way overcomplicating reading Parquet files lol
apparently there was already stuff built in for it. C# public async Task<DataFrame> LoadParquet<T>(string parquetFilePath) { DataFrame df; using (System.IO.FileStream stream = System.IO.File.OpenRead(parquetFilePath)) { df = await stream.ReadParquetAsDataFrameAsync(); } return df; }
You could also look into reverse engineering this behaviour from this addon.
Any elegant way to chain a bunch of method calls until a value is not null?
Value v = might_be_null_1();
if (v==null) { v = might_be_null_2();}
if (v==null) { v = might_be_null_3();}
if (v==null) { v = fallback();}
// ...
Ideally, I'd like something like:
Value v = might_be_null_1(
).might_be_null_2(
).might_be_null_3(
).fallback()
Value v = a() ?? b() ?? c() ?? d();```
The only thing is
this only works if Value is not derived from UnityEngine.Object
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
okay, interesting, good to know
that looks sexy, thank you
How many chunks would it be realistic to have?
the whole dataset is s spread across values from about -20 to 25 on both x and y, but they're so dense in the middle that even a 0.5 by 0.5 section has over 3k datapoints
and a 1x1 area has over 10k
assuming my math isn't wrong, that would mean that to have world chunks that don't have more than 1k datapoints, we would need about 32400 chunks
which sounds.. extremely unrealistic
I have issues with my Unity Online Code... I am trying to rename the player objects that spawn with the player name they input so that when everyone else joins, names register
Chunking is not about density. If in the denser part of the world, player still needs to see all those data points, then it's irrelevant whether you put it in one chunk or ten: you still need to load them all anyways.
Chunk size matters in a few ways:
- If player needs to access one single corner of a chunk, the entire chunk has to be loaded. This means that if you think of player's view, all the chunks have to cover it, and there will be parts that player can't see but you still have to load into memory and process. The smaller your chunk size, the less wasted space you have to load.
- On the other hand, if you have a large chunk size, then player can move around for longer without crossing a chunk border and game has to load/unload more chunks. Since loading/unloading chunks is disk IO, it will be slow and you want to minimize this.
- Depends on what's in each chunk, for example if you have objects that have real physical dimensions, then an object can be in two different chunks at the same time if it's on a chunk border, which means when loading chunks you need to then remove duplicates. The smaller your chunk is, the more duplicates there are and more processing is needed.
You have to balance all these factors to find a good chunk size.
loading all of them is exactly the problem lol
What I was talking about earlier was in the context of how many objects the Quest 3 is able to handle at once
In order to have chunks that only contain as many objects as the Quest 3 is gonna handle, if my math earlier was right, that would total to 32400 chunks
the actual physical scale of each individual chunk will still be massive
all of these objects have to be at least spread out enough to be able to be interacted with individually
My concern isn't the density of the chunks loaded in moreso than the sheer number of chunks that would need to be stored
How many objects you can show at once is not relevant to how you chunk them.
what's the point of the chunking, then?
So that you don't need to have the entire world (not just the part player is currently seeing) in memory.
There's no point in loading objects that are 1000 meters away if the player can only see 10 meters.
How many objects player can see within that 10 meters, doesn't really matter.
I don't think we're on the same page lol
I'm not concerned about chunking the actual terrain itself
I assumed the reason why chunking was brought up was as a means of loading and unloading the objects in each chunk
Yeah that might be where the communication failed. Chunking is just an optimization for not having to load the entire world in memory and only the parts player can see.
Right. I'm just trying to figure out the best way to not load in almost 700k objects simultaneously lol
Is the player seeing 700k objects at once?
No, but the goal is to allow them to see as many as possible extending towards the horizon
as many as the Quest 3 can handle
Well the horizon is infinitely far away, so it would include literally every single object in that direction.
I'll also have a fog effect at a certain point, of course
That doesn't mean it's useful to the player, player cannot realistically manipulate an object so far away that it's only one pixel on the screen.
At a certain point you still say "okay this is far enough away that even if the objects were visible, players can't use it anyways"
the point of the game is that visual, communicating the sheer volume of data
but I get what you mean
Exactly, once you set a parameter like "player can only see objects within 10 meters" then chunking comes back into the situation, allowing you to only load parts of the world that's 10 meters around the player, rather than the entier world and 700k objects.
that's what I was talking about earlier
if we were to use that method in a way that would actually be effective for performance, that would mean having tens of thousands of chunks
No your calculation is based on density, which is irrelevant to how you should choose your chunk size.
Is density not the core problem?
No.
See this.
None of these factors are directly affected by density of objects inside each chunk.
I feel like this conversation is starting to circle
I'll try to explain this the best I can
My current issue is that I need to figure out the best way to load as many objects in the player's view as the Quest 3 can handle, and nothing more, because it can't handle much.
If the loading and unloading of objects happens with the loading and unloading of chunks, then the logical consequence of that is that chunks with a higher density of objects loads in more objects. So, in order to prevent any chunk from loading in too many objects, the number of chunks that make up the world would need to be increased.
That's less of a code issue and more of a design issue. Let's say in player's view, there is no object except 1 that's so far away that it's basically unusable by the player, would you still load that? Or let's say player is currently standing in the densest part of the map and surrounding by way more objects than the hardware can handle, would you only load just the amount of objects the hardware can handle, to the point where player can't see objects a few feet away because it exceeded the limit (and player walk a step forward then suddenly they pop up in front of them)?
You need to solve this design issue first before thinking about code, especially the latter case, that wouldn't be good player experience.
Objects are only gonna be useable when you walk right up in front of them. This game is meant to be a form of data visualization, so making sure the player can see objects too far away to use is still important.
The density of chunks in a given area would be accounted for by just making the overall world larger, spreading out the distance between every object
It should be mentioned that this world is going to have a massive physical scale
that's why my current terrain implementation procedurally generates infinite terrain at runtime, because while the world technically isn't infinite, from the player's perspective it might as well be
"Making the world larger" is the same as making the maximum view distance smaller for the player, so you've taken the approach that "limiting maximum view distance of the player such that visble objects at any given time can never exceed what hardware can handle"
And once you figure out that view distance, choosing the chunk size is again no longer related to density.
It would still be related to density for the very reason you mention here lol
high density would be a worse player experience
because all the objects would be right next to you and the rest of the landscape would look empty
but either way, yes, that is what I'm trying to do
My point is that your problem is a two step process, the first step is to "scale the world up"/"limit the view distance" so that visible objects don't exceed hardware capability, and only after that, you do the second step of chunking the world, at which point density is no longer a factor.
But yes I think we are on the same page now.
Yeah, it's just difficult to test when I don't currently have a means of loading in only the objects I need loaded in
changing the scale is trivial honestly, it'd just be multiplying the value of each point's x/y coordinates
what I've been getting at though is that there will still be an absurd amount of chunks that would need to make up the entire world
so many that I'm worried there wouldn't be much benefit to the chunking in terms of quickly loading in the correct objects
where would it go from there, making chunks of chunks?
Like from what I understand, without any optimizations to how only the necessary objects are loaded in, the strategy would be to just read through the coordinates of all 700k datapoints every time the player is moving to check which objects do or don't fall in range of the player.
Chunking helps with that by having a much smaller list of objects to go through for each chunk, but because there would be tens of thousands of chunks, we're right back where we started of having to sort through a massive list every time a player moves, just now with chunks instead of objects
No that's not how chunking works.
Let's say you split your world into 10x10 chunks, and player has a view "radius" of 20, and the player is currently at (45, 55), then the player can see from (25, 35) to (65, 75). So you only load all the chunks that would cover that area, which are chunk (2, 3) (which covers (20, 30) to (30, 40)), (2, 4), etc, all the way up to (6, 7).
You don't load the entire world and then go through one chunk at a time and test if that chunk's objects is within player's view one by one, you only test the objects within the visible chunks.
I already understood that the objects would only be dealt with after the chunks, but I understand now I think. Instead of having to search for all of the chunks in range of the player, you just get the chunks directly because they're indexed
Yes, and that's why earlier I suggested to process your data and stored them in a way that allows random access, so rather than "in order to load chunk (42, 69) I have to find the file that contains in and load that file" you can instead "have all chunks stored in the same file and keep that file open, in order to load a chunk I just need to calculate the offset in that file and go directly to it"
Gotcha, that all makes sense now lol
The only thing left for me to figure out would be actually setting that up
Which is straightforward enough for except how to actually load/unload stuff, since I haven't done a lot of that yet. I do have a bit of a grasp on how serialization works, but I've only seen it in the context of saving information that's made in-game
I'm not sure how you go about having the game start off with the information already in
That's at least the current issue I'm having with loading the .parquet into the game. I am able to get it read in the editor, but it isn't doing the same in the headset
I'm guessing the culprit is the use of filepaths to get the .parquet file, but I'm not sure what the alternative is
Apparently AssetBundles are a thing can be used in this case I think, but idk
The problem is reading files in an Android build.
If you build your project with the parquet file in the Streaming Assets folder you can then use UnityWebRequest to read that file and then standard System.IO.File to write it to persistentDataPath where your plugin should be able to access it
tourist from code-beginner here
walking into this channel feels like staring into the sun
just wanted to say that, thxbye
null coalescing is so useful. I hate when unity tells me to not use null operators on gameobjects. Like if I can compare it to null, dont compain when i use those operators!
Whats the actual distinction? Like if its a nullable type (i think they are) why warn us about using that feature
Interesting read
i vote they get rid of it only for my selfish convenience! useful logging info be damned
too bad im 10 years late to the vote
Does anyone have a good way to get consistent frame times within unity
I need to get it as close to 16.7 ms as possible
Should've had a sane design like gameObject.IsAlive rather than this weird magical == null that means something different than is null.
Vsync or setting the target framerate
If there's any logic you need to run at fixed rate, it should be in fixed update btw.
doesn't give accurate enough frame times for me
need some sort of alternative to target frame rate
right now i have a timer running on a seperate thread, but I was wondering if there is something better
That's as accurate as it can get. What is exactly is the purpose of it all?
its for a fighting game, so its important that frame times are as close to 16.7 ms as possible
also i need it to be accurate so i can sleep the game
Why 16.7 and not 16.66?
well actually it's 16.66, but either way I just need some way where i can input a frametime and quickly swap from frame times
The aim is 60 fps, no?
yea its 60
And you're saying that it's not precise?
the one i have is precise atm, but a bit heavy on the CPU
and yes unity target frame rate is not accurate
How is it not accurate? How do you confirm that? What values do you see?
using profiler and by just playing online
What exactly are you looking at in the profiler?
the frametimes
Also, maybe just try printing delta time and seeing what value it has every frame.
Ideally, use fixed update for you logic if you want it to be absolutely precise.
What frame times do you see?
I can give fixedupdate a try
one sec
you can see it here
left is using regular update vs my custom frame lock system
Is that in the editor?
yes this is in editor
If you're gonna be profiling for something precise like that, you should be profiling a build.
i see can do
i'll try swapping over to fixedupdate and see if it makes a difference
yea looking into it a bit more, it needs to be in update
fixedupdate isn't tied to framerate
quick question guys
Why?
Fixed update is specifically for stuff that needs to be executed at fixed rate. Physics run in fixed update for example. And fighting games usually execute their logic in fixed update as well afaik.
You won't get more precise delta time than in fixed updated as it's actually a constant(in the sense that it doesn't change over time).
@untold moth when you finnish with him mind being my mentor for a bit while i get the basics of coding?
Why are you asking about basics of coding in this channel? You can ask in #💻┃code-beginner and not someone specific. Anyone would probably be able to answer your question.
Why?
im not gonna sit here and explain why, the whole game logic breaks if it's not
Then perhaps it's an issue with the logic..? I know fighting games in unity use fixed update, I don't know what else to say here...
i dont know if that's case
im sure there are games that use fixed update for some logic maybe
but its not possible for me to swap over to it atm
i mean you can get fixedupdate to run roughly 60 times a second
that's configurable
no, it's completely separate to framerate
it's a fixed update
framerate isn't fixed
oh i see
it's fixed in deltatime, that's why it's used for physics and timing-sensitive stuff
it's defaulted to 50/s, or 0.02 s per update
i don't have unity open right now so i can't tell you the exact menu, but it's in the physics section in one of the settings menus
oh found it
update is generally for frame-based stuff, like world or rendering changes, or inputs
fixedupdate is for time-based stuff, like physics
just adjusted the times
but yea that makes sense
im sure this gonna break my whole game tho lmao
this is all the different versions
left most is fixedupdate, top right is my framelock, bottom right is update
does not look like it made a difference rip
As I said earlier, you should really profile a build if precision is important.
This data that you get now doesn't tell anything at all.
Also you're confusing several concepts here.
well ill give that a try now
Fixed update would be at constant rate, even if the frame time(whatever you're basing your assumptions off) is not constant.
It wouldn't make a difference in profiler. It would make a difference with the actual game logic.
Decided to ask here because its more about architecture:
I am coming from the web world building UIs and wanted to sanity check the community for options,
If my game is heavily UI dependent, mix of screen space overlay, and world space UI, and need for a bunch of custom widgets is there any must have assets?
I played around with Unity's new UI Toolkit and it was pretty buggy and didnt easily support world space UIs...
basically asking, am I totally good scaling up a system using Canvas and say a UI Manager class or other object oriented design pricniples or is there anything that sticks out as the "React" of Unity for UI?
No, not really. I suggest that you use Unity UI instead of UI Toolkit because as you have seen UI Toolkit is not ready yet for production due to lack of feature and lack of maturity.
MVVM, MVC or even MVP are all applicable, but I usually find them more cumbersome than anything else. That being said, given that you are going for a heavy UI oriented game I do suggest you implement some sort of controller to handle the "gameflow" (What comes after what, React to Game Events like notification, etc.)
got it thanks for the reply, good to hear.
Texture.SetPixel
https://docs.unity3d.com/ScriptReference/Texture2D.SetPixel.html
Just in case: this is obviously not gonna affect the asset itself(not sure if you're asking that or not).
hey everyone, when i execute the following code:
public Texture2D CallTakeSnapshot()
{
Texture2D snapshot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
snapCam.Render();
RenderTexture.active = snapCam.targetTexture;
snapshot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
byte[] bytes = snapshot.EncodeToPNG();
string fileName = SnapshotName();
System.IO.File.WriteAllBytes(fileName, bytes);
Debug.Log("Snapshot taken!");
return snapshot;
}
string SnapshotName()
{
return string.Format("{0}/Snapshots/snap_{1}x{2}_{3}.png",
Application.dataPath,
resWidth,
resHeight,
System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
}
and then i run this code to assign the snapshot to a texture:
spawnedMiniscreen.GetComponent<intelwindow>().optics.texture = GameObject.Find("Camera").GetComponent<campaign_cameraCapture>().CallTakeSnapshot();
it only returns a weird nonexistent texture2D, why is this the case and how do i fix it?
It is not nonexistent. It's just nameless. You can double click it in the inspector to inspect the texture.
the second image is what comes up when i double click it
Then that's your texture.
i have a different texture saved as a file though
is it just an execution order issue? or maybe it takes a bit for the image to load?
I don't see any code assigning the texture to that Raw Image component.
Or is optics the component in question?
yes
If it's saved to a file correctly, I can only assume that it's being reset later on for some reason.
what do you mean by that
Exactly what I said. The contents of the texture are being overwritten after it is saved to a file.
Other than that there isn't really any explanation.
Maybe a format issue.
You can test that by trying a more common format, like rgba16/32 or whatever it is called.
- Are you assigning a renderTexture to the snapCam.TargetTexture camera before calling this code? Not sure if you can just grab targettexture if its rendering to normal buffers.
- You don't seem to be using snapshot.apply() to upload the readPixels back to the GPU?
is there a dedicated channel to talk about Unity Sentis?
can somone guide me making smart ai for my 2d topdown enemies
I'm writing a terrain generation script based on one I found in a tutorial. It works, but it only generates terrain with hard edges on every face. I've been trying for the past 3 hours to adapt this function to generate smooth meshes instead, but I never made any progress. Anyone here know the right way about this?
!code use a paste site
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
the general procedure is to make sure that all the mesh verticles at the same location, have the same (or similar) associated normal vectors. Make sure you dont cal Recompute normals after that tho- this will make them all point directly "out" of each trinagle.
What do you think would be the best approach for calculating that?
need to make sure this stays performant
If every edge is a hard edge it is most likely because every triangle has its own vertices instead of sharing them.
Yeh, I just can't figure out how to make it not do that lol
I understand it conceptually, it's just the logistics that's hard to wrap my head around
Catlikecoding has some great tutorials on mesh generation that I would recommend https://catlikecoding.com/unity/tutorials/procedural-meshes/
They cover sharing vertices and such.
Also a 'terrain' generation tutorial that might help https://catlikecoding.com/unity/tutorials/pseudorandom-surfaces/surface-elevation/
I guess I should say that I'm asking for something more specific to my function, so that I don't have to go rewriting everything this function is built on
like I did when I was following this tutorial https://www.youtube.com/watch?v=NpeYTcS7n-M
Welcome to this series on procedural landmass generation. In this episode we go on a long journey to fix a tiny problem with the mesh normals.
The full source code for this episode can be found here:
https://github.com/SebLague/Procedural-Landmass-Generation
If you'd like to support these videos, I have a Patreon page over here: https://www.p...
You have to re-write the entire function, and how vertices are counted. There is no way around it.
If you already know conceptually what the issue is, I'm not really sure what more I can tell you without just re-writing the code for you. Do you have a more specific question maybe?
I get that the function itself needs to be rewritten, I just don't want to also have to rewrite every single script that's involved in terrain generation lol
At a high level, you want to have a single vertex for each point. And how the indices are normally done is by doing a row of vertices at a time and connecting them with the previous row of vertices.
0, 1, 2,
3, 4, 5,
Start at 3:
0 < 1
v /
3
Then
1
/ ^
3 > 4
That gives you a square, and then increment to 4 and do the same thing
I guess the first step then is to change how the vertices are first made
which I assume would need to have it's own for loop before the loop where they get assigned to triangles
reworking how the mesh is generated will reduce its triangle count and likely a necessary step, but you seem to still not understand the actual problem. You can fix it with your existing solution first
wym?
are you are assigning normals based on the cross product of each triangle. Since every triangle is part of its own quad, there is no smoothing and you get a hard edge
you can use your existing solution where there are multiple vertices at each point with split normals, but both of those normals should match instead and be the average of the normals of the two triangles connected by an edge
Hello, I'm currently coding movements with a Rigidbody for my character. I'm also improving the way I move on a slope. But my problem is that when I'm on a slope, I don't jump as high. I think this is due to the fact that I'm using Vector3.up, but in that case, how can I ensure that the jump height is always the same, regardless of the slope?
Stranger still, when I'm on some steeper inclines than those shown in the video, I can jump even higher than when I'm on flat ground. I'll let you see the two videos demonstrating this.
The only difference I can see is that the second floor is made with ProBuilder and the second with Unity's default cubes.
Thanks in advance to anyone who takes the time to read this!
Not sure if that's an advanced question, but anyways, you'll need to share the relevant code
I wasn't sure myself, but well... 😅
I'm using a StateMachine. Here's the code for the Idle status
IdleState.cs : https://codefile.io/f/6xhWz3cC1Z
Also don't take into account the last and penultimate sentences where I talk about a higher jump when I'm on a slope. I made these videos with the wrong code.
Seeing how you're switching to the air state on the next frame after starting jump, that's probably the one that would have most influence on your jump hight. Share the code of the air state.
Sure! Here it is
AirState.cs : https://codefile.io/f/He7xxi2dHr
AirMovePlayer() and AirMySpeedControl() could potentially be affecting your jump hight.
You should probably be logging values of the forces and velocities they apply(and any other possibly interfering code).
Another option is to remove(comment out) all possible factors that affect the player movement during a jump, confirm that the issue doesn't happen, then start enabling them one by one to find the culprit.
These are basic debugging techniques. You should really know to do this before asking in this channel.
I asked this question because I thought it was a common problem to which there was already a well-known answer, like how to move on slopes.
But if not, ok I'll try that. I had disabled AirMovePlayer() and AirMySpeedControl() but that didn't change anything. I'll have a look at the other parts of the AirState.cs code. Thanks for your help.
While varying jump hight might be a common problem, it could have hundreds of causes, most of which are project specific.
One thing I'd start with is making a fail proof way of measuring the issue. Just relying on the visuals is a very poor way of debugging.
Maybe record the top jump position to calculate the jump hight and log it to the console to see it as an actual number that you can compare.
Oh yes, I hadn't thought of that. Thanks for the tip.
how can i get the instancing id of gpu with mono script ?
I don't think you can. It's also possibly a different value every frame.
What do you need it for anyway?
for control material
Control material? Wdym?
GPU instancing reuses the same mesh, so if you want to modify the vertex buffer or something, that's gonna affect all the instances
btw, i think instancing id remains between frames
i used it in my shader and it keep going on, not jerky so i think it remains
It depends on the rendering implementation that is closed source, so you can't be sure.
It might be changing under different circumstances.
it only change when we add or remove an instanced item
@brave cairn Thank you the AddUpload works beautifully.
I am using SparseUploader extensively in my GPU animation engine, and it is used as a core of Entities.Graphics. Works reliably.
I know Jussi Knuuttila told me about it when I was doing my own BRG renderer. Not sure why he did not mention the add upload thing. I've been using it the "hard way"
I think that for the GRD there is now a more "refined" version of it in core graphics but I need to check
but just look at how simple the code became ```if (hitRequests.Count > 0)
{
var threadedSparseUploader = m_GPUUploader.Begin(hitRequests.Count*k_sizeOffloat4,k_sizeOffloat4,hitRequests.Count);
for (int i = 0; i < hitRequests.Count; i++)
{
var id = hitRequests[i].id;
var hit = hitRequests[i].hit;
threadedSparseUploader.AddUpload(hit, (id + _iterators[id / k_MaxHitsPerShield])*k_sizeOffloat4);
_iterators[id / k_MaxHitsPerShield] = (_iterators[id / k_MaxHitsPerShield] + 1) % k_MaxHitsPerShield;
}
m_GPUUploader.EndAndCommit(threadedSparseUploader);
hitRequests.Clear();
}```
Digging through sources gives some useful insights sometimes 🙂
I think I looked at the entities graphics source to figure out how to use it actually but idk.
With additional bonus - you can schedule your uploads via parallel job (IJobFor, for example)
btw is to safe to dispatch a compute shader to do some work on the buffer after calling m_GPUUploader.EndAndCommit(threadedSparseUploader);
you mean I can call AddUpload from a job right ? EndAndCommit looks pretty main thread stuff to me.
Yes. GPU commands are ordered, and your subsequent calls will come after uploads compute shader dispatches, so data will be actualized.
Yes. Pass threadedSparseUploader object into a job, and you can do parallel AddUpload calls. Then do a job.Complete in a main thread after scheduling, and EndAndCommit in main thread afterwards.
Usually workflow is follows:
- Do all parallel uploads.
- Make jobs.Complete in one point (to reduce syncpoints to one)
- Do the EndAndCommit
- Schedule your compute shaders that depend on uploaded data.
@brave cairn hey one last thing you might know how to solve easy. I'm getting a Attempting to draw with missing bindings because at edit time the buffer for the shader is not bound. How can I fix this ?
For edit mode bind some minimal size dummy GraphicsBuffer:
[ExecuteAlways]
class DummyGBSetter: MonoBehaviour
{
void OnEnable()
{
if (!Application.isPlaying)
{
// Create and set a dummy buffer here
}
}
}
Or, make multi_compile variant with and without ComputeBuffer usage, and switch them between edit and play mode via EnableKeyword
Thanks I already did the first approach guess there isn't anything more sophisticated hah
I doubt you can. Unity draws a mesh with a shader. There is no check of actual usage, it is just a check for required resource descriptor used by shader and if it is none, warning will be log-printed.
I'm trying to convert this python code I made into C# to work with a fighting game I'm making for a school project:
https://github.com/KingBarou13/Fighting-Game-Input-Buffer/blob/main/main.py
And this is what I've managed to come up with https://pastecode.io/s/rspprb8u
I've run into two problems:
- Pressing up twice no matter the space of time between inputs causes Quick Rise to trigger, but no other special moves work
- A white box is appearing instead of the input images assigned in the inspector
I've looked over my code a couple times and can't figure out what's wrong with it since it's supposed to be a direct code conversion and it works perfectly in python
Input Buffer for a fighting game coded using Python - KingBarou13/Fighting-Game-Input-Buffer
What’s the bool dictionary for?
speacialMoveExucuted?
Never mind. I wouldn’t advise you using a dictionary to check the move that has been casted but It’s not the source of the issue.
The problem is that you’re adding to the buffer every frame an input is added, and the way you are checking your inputs makes it so that the additional input breaks the sequence.
how can i set pixel to a texture2d that save as .asset file ?
there is no error, it just not changing anything
you'd have to show what you tried.
i am trying to set pixel to a texture at runtime
[SerializeField] private Color colorToSet;
[SerializeField] private int pixelToSet;
private void Update()
{
matTex.SetPixel(pixelToSet, 0, colorToSet);
matTex.Apply();
}```
just like this
ok and what result are you expecting to have here?
Are you expecting the file to be updated in the project folder?
or just a change at runtime
i want the pixel is changed at runtime
Is the texture cpu read/writeable?
As mentioned here? https://docs.unity3d.com/ScriptReference/Texture2D.SetPixel.html
it is .asset file not png
yes
Ok so how are you confirming that this is not working?
the problem is it is .asset so i can set but it doesn't change
by the object in the scene, just a simple material to show the result apply on it
It can be hard to see a single pixel..
especially with mipmapping and texture filtering
It would be better to do something like:
private void Update()
{
Debug.Log($"Pixel before: {matText.GetPixel(pixelToSet, 0)}");
matTex.SetPixel(pixelToSet, 0, colorToSet);
matTex.Apply();
Debug.Log($"Pixel after: {matText.GetPixel(pixelToSet, 0)}");
}```
thank it set the texture, but the material in the scene doesn't change, i think it because the way unity handle .asset file as texture2d.
That means your material is not using the texture you are changing
it's using a different texture
yeah, i think unity copy or something like that for asset file into material
How are you getting/assigning the texture reference(s)?
assign by hand in hierchy, i didn't make any mistake, if i replace .asset file with the same png file then it work like i want
i dont want to use png file because i want to save value out of 0-1
you can always force your material and your script to use the same exact texture reference at runtime
not sure what's going on with the whole asset texture copy thing
is there any channel for testing questions?
im trying to load a scene in setup, but the scene is not loaded during tests, is there a clean way to manage this?
do you mean you're loading a scene and it isn't working?
im loading a scene in setup, but load operation takes some time, and its not ready when i enter the test function, i could wait for it, but it doesnt seem clean
you should be able to make your Setup method return Task and wait until the scene is loaded before returning
let me see
it seems to work, thank you very much!
also is there a way to find out im in running a test from a method marked with
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Init()
because this is my bootstrapper and does some initializations, i dont want it do to that during tests
hmm if there is i'm not aware of it, but you could always set a static bool or something during tests
that makes sense, thanks
actually
i dont think i can, as [setup] marked test code runs after this [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
oh right, yeah this is RuntimeInitializeOnLoad doing what it says on the tin, it's expected to run before any scene loads including entering play mode to run tests
if there's something you don't want to run until a particular scene loads, you'll need to put it in that scene or do it some other way
Does anybody know if its possible to set the unity assetbundle name after the assetbundle hash has been generated?
My use case involves putting the hash in a specific place <hash>/<assetbundle name>, I've tried using BuildAssetBundleOptions.AppendHashToAssetBundleName but that outputs <assetbundle name>_<hash>
(Originally posted in #archived-code-general before I moved it here because I think it'd be an advanced concept)
hmm i guess i can write a wrapper on the test runner and on click set the static before starting the run too actually
maybe that would be ok, probably bit hacky
Well I figured out a solution that involves duplicate files lol
Build the asset bundle, get the hash, then just build it again with the new name
Hash isnt changed since thats not something that influences the hash
Hi!
I'm making a roguelike and would like to generate maps that look similar to this
anyone have an inkling as to how I could do this?
Prob add X number of Vector2's to a list, always one next to another and with a randomness factor, and then fill the rest of the grid with tiles
Hey! Im making a tweening library from scratch, and I have reached the point where everything left to do is optimize it!
I am currently reaching around 200 fps with 7000 + active tweens, but I do experience lag spikes when multiple tweens are either created or destroyed at the same time. These are the responsible code:
public void AddTween<T>(IPTween tween)
{
TwCount ++;
if(LogLevel > 0)Debug.Log($"Created tween: {tween.Identifier}");
_activeTweens[tween.Identifier] = tween;
_currentActive = System.Linq.Enumerable.ToArray<KeyValuePair<string, IPTween>>(System.Linq.Enumerable.AsEnumerable( _activeTweens));
}
And the constructor per se:
public Tween(object target, string id, T startV, T endV, float time, Action<T> tweenUpdate)
{
if(time <= 0f)
{
throw new IndexOutOfRangeException($"Cannot Tween a value out of bounds ({time} is less or equal to 0)");
}
Target = target;
Identifier = id;
_startVal = startV;
_endVal = endV;
_time = time;
_onTweenUpdate = tweenUpdate;
PatoTween.I.AddTween<T>(this);
}
That's a lot of tweens. Any reason you can't just reuse them instead of destroying?
Please read channels description, and https://learn.unity.com/tutorial/introduction-to-tilemaps
https://bost.ocks.org/mike/algorithms/#maze-generation
Useful resource too to generate then sticking it onto a tilemap (but yeah wrong channel)
Ah sorry, wasnt sure where to ask for help on pcg
https://www.roguebasin.com/index.php/Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels
Roguebasin has some good stuff to if you look around
Thanks! Ill look into it
They may affect different game objects, and may have both different parameters and execution time
And don't get me wrong, I'm pretty happy with the performance, but if I can push it a little bit further, I'll do, just it case
Did anyone here tried to upload Unity 6 debugging symbols to firebase crashlytics?
I keep having this issue https://github.com/firebase/firebase-tools/issues/7867
But havent got any response anywhere
By any chance you're recreating the whole _currentActive array when adding/removing tween? (I don't really use Linq methods much but it sounds like it)
Is it just me or has Unity 6 broken much of the URP render feature/pass functionality?
After my render system stopped working, I have gone back to the docs to find the examples there don't seem to work either
specifically this one: https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@16.0/manual/renderer-features/how-to-fullscreen-blit.html full screen blit effect making a colour effect
I'm working on a game for Quest 3 standalone that loads in a local .parquet database and stores terrain chunk info on disk. Currently, the framerate when loading in the dataset initially is pretty rough, and there's slight frame drops whenever loading in terrain chunks. I want to make the experience smoother by loading these things slower and in the background, but apparently there's no way to do multithreading on the Quest 3, at least easily. How would I go about doing all of this on the main thread without framedrops?
I'm recreating the ToArray() function, because I read somewhere that the namespace LinQ can add compile time, so I just called the specific methods without importing the whole namespace
rofl. you touch one single variable in a dll and the whole dll is loaded
and anything to do with linq is a) slow and b) generates a lot of garbage
Oh, didn't knew that
Damnit
Then, I'll have to either remake the method myself or search another way to do it
So, came up with this
private string tw;
private string[] _currentActive;
private void Update()
{
for(int i = 0; i < _activeTweens.Count; i++)
{
tw = _currentActive[i];
IPTween tween = _activeTweens[tw];
tween.Update();
if(tween.WasKilled)
{
RemoveTween(tw);
}
if(tween.IsComplete)
{
tween.onComplete?.Invoke();
RemoveTween(tw);
}
}
}
public void AddTween<T>(IPTween tween)
{
TwCount ++;
if(LogLevel > 0)Debug.Log($"Created tween: {tween.Identifier}");
_activeTweens[tween.Identifier] = tween;
_currentActive = null;
_activeTweens.Keys.CopyTo(_currentActive, 0);
}
By removing all the Linq methods, and making it rely just on Dictionaries base methods, it should be faster, no?
I don't see the need for _currentActive at all, why not just itterate through the dictionary?
I'm not even sure why you use a dictionary instead of a List based on that code
The dictionary contains an string as an ID and the proper tween
And since you cant iterate with Index for dictionaries, I have a helper array to do so
I am modifiying the dictionary while I iterate throught it
again why dictionary?
I cant use foreach, it throws errors if the origin collection is modified
why do you need a Key
I do access it to check non repeated tweens get added
Like, trying to tween the same object's property at the same time
And with a Dictionary I am completely sure that it does not contain multiple instances.
The other option would be creating a List and checking it every time I add a tween, but this seemed more intuitive, I dont really know which option is better
Ok. what I would do is forget the array.
foreach on the Dictionary and make a List of those Tweens to remove
after the foreach, loop on the List to remove them from the Dict
no
Using a List instead of an Array
not at all, use a List to hold the Tweens to Remove not all of them
I'm assuming the problem stems from resizing this array if that's what you're doing cause that's a lot of tweens to be remaking one for. List/Dictionary sounds like the idea
Hashset even
Otherwise create a buffer size for the array and only extend it when it exceeds a few hundred
performant enough to be in the standard library
usually it's just 0(1) like any other hashset
(it's notated with an O, not a 0, fyi)
Θ
that's a different metric
but there's no metric that uses zero, afaik
best case is capital greek omega
average case is capital greek theta
worst case is capital latin o
i mean it is, but it's typically not referred to
forgotten middle child moment
Alright! Remade that piece of code and it works like a charm!
Reduced a bit the execution time
Also, is there any way I can do something like this withouth relying on local variables?
The alocation is taking a significant amount of time
yeah why not just use the methods directly
you could just cast instead of the extra variable, but im not seeing why you would need this method to begin with
it's not very generic since you're hardcoding each case anyways
generics are for treating different types in the same way
this isn't a usecase for generics
And all that boxing and unboxing, horrible
@nova ridge Not wishing to be rude but for someone posting in #archived-code-advanced you seem to be lacking a lot of knowledge of C# internals
Yeah, the point was expanding it further reached the point, but as you pointed out
I am using the individual lerps after all xd
sorry then, Ill switch channels if you want me too
Since my initial thoughs were for optimization I guessed this was the place
not at all, what I rather meant that before doing this kind of stuff it's worth while diving into the C# Docs to see the consequences of your actions
do you really need optimization here? computers are fast, and what's more important here is readablity and maintainability
if anything that code unoptimises things already optimised. Don't confuse writing less code with writing faster/better code
Yeye, thats why I am asking
definitely read up on boxing and unboxing
I rather be corrected than believe to be in the right way
Will do, ty!
Not really, but I am working on this library for myself, and I plan to maintain it/ add things as I need
So in extreme cases it may be needed
don't optimize because it "may" be needed, do profiling to see if it's actually needed or not
otherwise you're just adding more work for premature optimizations
in all likelyhood a single if-else tree with 2 allocations and 2 casts, while ugly, is not a bottleneck
Its the most resource heavy method in 2000 + lines of (very straightforward) code
Im using 2 allocations per tick per tween, so It slows the whole thing down quite a bit
2 allocations is not much
have you profiled it to actually verify that it's the bottleneck? (although i mean those allocations can be removed anyways by just not using this method)
Yeah, thats why I am saying so
(currently removing them XD)
Alright, done it! Didnt get that much difference but Its fine regardless
Btw, I have been coding for almost a decade now, but I have never needed to use complex/advanced techniques, is there any way where I can fully learn all those?
Don't use arrays ;)
Or some of them, out of pure curiosity tbh
JSAJSAJ
I read somewhere taht they were faster than regular list, so, I said to myself why not
The C# Docs are a good place to start
I would expect c#'s list to be similar to that of an array, assuming you initialize it with a size. You just have the benefit of resizing a list without having to remake the whole container.
I guess a little more overhead, but doubt it matters that much today
Yeah, but I get the point
Depends on what you mean by advanced techniques. If it's just API, then documentation. Overall, reading other people's code and understanding it is a good way too.
This code is meant to read a .parquet from the StreamingAssets folder on both android and desktop, but it's only working on desktop, even though I'm using BetterStreamingAssets. What's wrong with my implementation?
Share !code properly:
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
it's only 30 lines lol
oh I guess you can't expand it cuz you're on mobile, oof
Yes. It displays as a downloadable file.
The code seems to be pretty straightforward. I don't know much about the third party libraries that you're using, but it's likely an issue with them. You'll need to check their docs or maybe contact their support.
It seems like better streaming assets is open source, so you should be able to debug it. Start with stepping through the code and seeing if the stream is opening the correct file and contains any data.
I'm not sure how to go about doing that while it's running on my Quest
Is it android based? If so, you should be able to attach to it normally as to an Android device. There should be instructiona in Quest docs on how to debug it.
I see, thank you!
has anyone used gxash-csharp? i see it uses hardware intrisincs and those aren't available in 2022
Can't seem to find anything on Google about gxash-sharp. What is that? A typo maybe?
Oh, gxhash, not gxash. I see.
Wdym when you say that the hardware intrinsincs are not available in 2022? I don't think that's something unity version affects.
I thought so to, that hw intrinsincs were available for a while but you can try it, it won't work.
Does it throw errors or something?
it lights up like a christmass tree 😄 all using intrinsinc turn red
That could just be an issue with the ide. Are there actual compile errors in unity console?
I'd assume that the issue is with dotnet version. The intrinsics class seems to only be compatible with Core 3.0, Core 3.1, 5, 6, 7, 8, 9, while unity doesn't support any of these yet.
If you find a C++ library for the hash, it should probably work
6 hours of debugging and I'm nowhere closer to understanding how to make a file stream to a .parquet at runtime on android 
Did you manage to attach the debugger and step through the code?
yeah, the only thing I can figure out is that it's not finding the file on the android side
It's possible that the asset doesn't support oculus. As in, oculus might be storing the file differently from normal android builds.
If you can check the device storage and see where the streaming assets files go on it and compare with the file path from the debugger, you might figure something out.
I.. actually can't find my .parquet file anywhere in here, actually. hmmm
hello guys, I'm trying to learn ml agents so that i can import the "brain" into a real life robot, its my second ever ml agents script, would you guys be able to review the code and tell me if there are things that i can improve about it ?, ill add all the details when i send the code (model, what does it do etc..)
(if im in the wrong chat topic could you also please redirect me to the correct one)
at the moment i feel like its very inefficient in how it works...
Then perhaps the issue is that it's not uploaded to the device at all.
Probably better ask in #1202574086115557446
oh okay thanks
Unless it's not specifically ml related question
would something prevent the StreamingAssets folder from uploading?
i mean its kinda an everything question because i just started using unity and the fusion360 models are also giving me alot of lag hmmm
thanks eitherway, ill go in that chat
I'm not really sure how streaming assets work, so can't answer that. You should check the docs on how and when they are uploaded.
I gave you the answer to this some days ago
#archived-code-advanced message @slate spoke
You also need to profile what exactly is causing the frame skips. If it's IO, you can use async which won't block main thread; if it's CPU code that doesn't have to run on the main thread like expensive computation, you can move that to a different thread; if it's code that has to be run on main thread like creating the game objects, then you can spread out the workload over multiple frames.
Always profile first to understand the problem before optimizing.
does anyone has here problems with the scrollview?
the strange thing is it worked on the xbox controller i did nothing with the component and its suddently broken.
not the only time the scroll view suddeltly break on me.
Do you guys also experience this?
and you are posting in #archived-code-advanced why?
aa sorry wrong channel
Does anyone know if disposing like this needs to be completed in the same frame or if it can be allowed to finish on its own?
JobHandle meshTrigsDisposeHandle = meshTrigs.Dispose(vertexCompileHandle);
Couldn't find anything online or in the documentation
You should not dispose the handle until the job is done
You should dispose the handle after the job is done
What do you mean by dispose the handle?
I'm asking whether I need to complete that job immediately or if I can just allow it to complete on its own time
I think we're missing some context. But you should also probably ask in #1064581837055348857
I'm using the dispose overload that schedules a job to dispose instead of disposing immediately
But i'll ask there thanks
Can anyone help explain this, My stats window shows my CPU is causing far more latency, But my profiler is showing that GFX.WaitForPresentGFXThread is costing the most which typically means the CPU is waiting on GPU to finish, Which one is causing the bottleneck?
That looks like vsync. You can see it jumping between 60 and 30.
As far as I know, render thread is still CPU works. It is the time that takes to send all the command to the GPU.
Hey there! I'm trying to add mod support for my game. I'd like to allow the user to pretty much do whatever modification they want to the game including custom code.
I first thought about a manifest approach with a json file to store the metadata of the mod and then other json files to describe all the new assets. But I don't think it'd work out well with custom code.
On the other hand, there is Harmony that would bring a full control to modders over the game BUT it's also very dependent on the code itself (Update 1.6 of Stardew Valley broke a bunch of mods)
Is there any alternative I might have missed?
To do actual mod support you'd need to include a scripting engine in your game with high level bindings to almost everything in your game (i.e. MoonSharp LUA for example). Alternatively you can just not worry about it and rely on people using BepinEx
Yo i need help i have 2 triggers one for coke and one for cake and i have 4 ui text 1 bro before and after one mom before and after so i want to make the mom before disable and after enable if it detects cake trigger in the console and if it detects coke trigger do the same with bro
so how do i do it
That question is impossible to understand. Maybe rephrase it. Also it's probably not an advanced question. More like #💻┃code-beginner
Yes I made it thnx
NV,
Nvm
<@&502884371011731486> Spam
UnityException: Transform child out of bounds
UnitSelectionManager.TriggerSelectionIndicator (UnityEngine.GameObject unit, System.Boolean isVisible) (at Assets/UnitSelectionManager.cs:128)
UnitSelectionManager.SelectByClicking (UnityEngine.GameObject unit) (at Assets/UnitSelectionManager.cs:117)
UnitSelectionManager.Update () (at Assets/UnitSelectionManager.cs:53)
do not cross post, you are already being helped in another channel
i think the code was to advanced so i moved it up
not advanced at all, #💻┃code-beginner
oh no
homie could i slip a 20 under the table🤓 and then you could help me
yikes, no
please bro just help me I'm dumb as hell just help
:yikes"🤓 bro helpp
have you even tried googling the error
yea and chatgting and copiloting
yeah, avoid the latter 2
what did you gather from googling?
did you, perhaps, find this
https://discussions.unity.com/t/unityexception-transform-child-out-of-bounds/224974/2
yea like cheching if i have assigned the right child
the stacktrace also points you to the exact line where it's happening
Assets/UnitSelectionManager.cs:128
unit.transform.GetChild(0).gameObject.SetActive(isVisible);
sounitdoesn't have any children
that's all
but it does
then you're probably looking at the wrong one
and how do you know that that is the Unit being used in the code? Did you check?
yea
do you have the layermask set up correctly?
think so yea
have you tried debugging to see what gameobject is being detected at all?
don't settle at that, go check.
yea like wait let me send you something
you clearly have not checked anything in that vein in the code
it is this one
there is no sign of debugging in that code whatsoever, why are you wasting our time?
is the raycast picking that up though?
how do you know it isn't, say, picking up that indicator
yea it works everthing does but when i click on Unit it breaks
ok
try logging out unit.name and unit.transform.childCount
what does that mean🦧
dont forget unit.GetInstanceId()
ok i did
but it debugs
until like i want to do it the on the second or third
then it breaks
ok, how so
"it breaks" doesn't give us any usable info
look at the logs
are they correct
how do i send a video
though i link so that i can shwo you
or can i call you and screenshare
bro like i click and then the error comes up
did you put the logs before the GetChild?
are you getting the logs before the error
yep
ok, read the logs
bro i just put the log to read sigma
are they the results you expect
yea but it still breaks
and it's showing transform.childCount as 1?
yirp
Since this is probably going to take a while and has nothing advanced about it, let's move this back to #💻┃code-beginner