#archived-code-advanced
1 messages ยท Page 135 of 1
ahaha right on, i just need to take a look at shaders more then
thank u so far man
im still quite noob at everything, hacking my way thru step by step
shaders don't like loops, thats all
and you know almost nothing about your neighboring pixels without paying for it
ouch
also, if you can solve your problems with fully opaque objects. you'll have an easier time.
yea i can see that xD
you can make a shader system that outputs a composition of many transparent elements (like the UI system), handling the sorting internally with complex effects, blend modes etc. so long as you don't plan on mixing that with regular transparent materials you can achieve a lot
any links of that use case you can provide?
alright ill go look at some shader stuff
there are 100s of tiles drawn to screen at one time as the player moves so how computationally expensive would that be
depends on the nature of the tiles
if they all Update() each frame for a 256 x 256 grid that would be 65k updates each frame...
for reference: Humankind (screenshot above) has 150x88 tiles in a "huge" map
games like broforce/terraria/noita... use mostly passive tiles with some clever onDemand activation to make them destructible/simulated, also aggressively culling off-screen stuff ... they get away with 1000s of tiles.... but the whole game happens in a separate data structure with custom updates and not in "game objects"
ive got all my chunking and culling working
but chunks are drawn around the player
so say 8x8 chunks drawing around 3-6 a time as the player moves
render performance is probably a non-issue
yea definitely not at this stage
i have an infinite world and its running at 1ms
with 2-3 batch calls
draw
and only 1-5k verts
and thats permanent no matter how far i walk
which will be even more sped up by the time i add serialization of chunks
im just wondering if as it calculates a chunk to be drawn
it bitmasks all the corner tiles
and then does the transparent shader layering
is that going to cause any hiccups do u reckon
i spose serialized chunks wont be
but when drawing new ones, as player walks in a direction at max speed
hicups occur when you push too much data between GPU/CPU, allocate a lof of garbage or create/activate lots of objects in the same frame.
it could potentially cause jars every time it tries to draw the max new chunks in that direction (especially diagonally)
yea gotcha, thats definitely the case
at the moment when i populate a chunk i use new Tile
would it be wiser to initialize all the varying tiles (grassTile etc) in the Tile class for runtime
if (noise function > x)
Tile t = new GrassTile
so as a chunk is generated it is allocated 8x8 tiles in memory
and as a player moves it can be generating say 3-6 chunks at a time
i'm unsure about the unity tile system... i've always built my own... usually unity has problems with initialization of objects that you can't controll, i.e. when loading new stuff... if everything is loaded... you can fix most hicups by better code and spreading initialization over multiple frames
i dont use the unity tile system
mine is custom
from meshes, tris to quads
and then uvs
thats why it runs so fast x)
i have a tile class not inheriting from monobehaviour
and a chunk class also not
which when populating based on the noise function
definatley create all the instances before hand
yea i was going to optimise that today or tomorrow lol
i saw it was in minecraft code
and theres my making new tiles
xD
he uses new on the tile class itself
so i can only guess thats instantiating the memory only once
rather than 8x8 tiles x3-6 chunks every second
which surprisingly works blazing fast even with all those objects created
its the generating of chunks too quickly that i fear will get all bogged up
and how shader performance will be impacted when implementing that
so i need to squeeze every drop i can out now
im an overoptimizer but it makes sense in a game handling 1000s of tiles and entities
for a minecraft world you don't actually need to use any game objects... you could just push a 3D texture with positions and material-bits to the GPU and have it draw the meshes procedurally... should work because the geometry is so homogeneous
i have a code that destroys the game objects after they are instantiated
but it actually created more jarring to have them deleted than not
destroys the gameobjects of every individual tile (inside each chunk after creation)
but the destroy command being run 64 times x 3-6 chunks
is quite taxing
in terms of generating
has little hiccups
then memory stays in place, no garbage
and load from that or
pool the tiles
im aware of pooling for projectiles
so my knowledge on implementation is lacking at best
easiest would be to spawn the whole map at Start() and just activate/deactivate the tiles you can see...
other way would be to reuse a grid of tiles that fill the screen and change their appearance
i have serialization to take care of non previously visited chunks
how would pooling fit in that model
third way would be to pool sets of each type of tile and pull them from the set if you ever need an instance and palace it where you need it
its already deleting chunks the player has visited after a 3000 tick
serialization as in "getting stuff from disk"?
yea
thats only good for loading stuff at initialization... should be way too slow during Update()
you should only load/unload if you run out of memory
well im going to look at some shaders and pooling and see how they'll fit my model
thanks for the chat
yw
have a good night (i may be back)
good luck !
what is this red dead redemption 3?
this is what a decal is. a Terrain material is a layered texture with N maps of blending, so is like a more generalized version of a decal.
ah yes i see
this is what the existing unity tilemap does
im not using unitys tile map unfortunately
mesh generated
i agree that it is similar to a decal system kind of deal
a transparent texture on top another
usually if you want to exceed unity's mesh generation performance and still use unity, you have to master Unity Jobs or compute shaders
the performance is not an issue right now
really depends on what your objective is
ive optimized the crap out of it
the ceremony of recreating unity tiles?
less overhead
ive got my own tile and chunk system in less than 300-400 lines of code
but that means im having to learn each step programmatically
on what, my computer with 24GB of VRAM and 16 cores?
im on 8 cores old 4790k
or on a super nintendo..?
getting 700fps
agreed
guess no one can help you with that
i just need to add these "decal" tiles
good luck out there
as a blend
i doubt that my friend
u can do anything in less code
if u know the right code
thats why im asking xD
google and forums only take u so far
thanks for the guidance regardless
its not about writing engine code, its about superceding the qualities unity does not have while also using its best features such as vectors, the editor, game view, profiler etc.
unity has tons of overhead and lots of boxing all over the place
if u plan to add many items in a game (such as factorio)
then every optimization counts
i mean this is the advanced code section after all x)
yet there are companies out there giving you the best experience and performance in Unity :)
C# generally had unavoidable overheads but you can still remain within the budget
unity is coded in c++
and c# is built on c
so if you are bitwise with optimizations
and watch out for c#'s gc
u can easily be just as fast
not really. they're moving to c# for most new packages like new input system, addressable, srps, etc
it seems so but there's no clear announcement for it
i wudnt be suprised
gotcha
not a roadmap thing
anyway yea, if u understand where the memory is going c# can be just as rapid
thats why c++ is usually the king
u have to allocate everything
i can only help with goals that make sense or if you want to do something just for the sake of intellectual stimulation that's good too
if you want to recreate unity tiles you should look at the source and do it
it's similar to textmesh pro too
if i had to make an infinite x-y tile world, terraria style, i'd just load in big chunks of the world
so once you go into zone T you load the adjacent zones
and that' sort of it
and it could just be regular unity tilemap
because it doesn't matter if there's no culling when the hardware can render millions of tris
1000x1000 = 2m tries
you can afford to use 9 300x300 chunks*
i don't think the physics engine will have trouble either
probably can't update() all 1000x1000 tiles though... and if you just need a picture of the tiles, you can just paint them into a texture and don't use tiles... reality is somewhere in between
im already doing that
i have an infinite world generating and deleting chunks around the player at 1ms
even assassins creed odyssey is just a big tilemap ๐
im talking about marching square bs and transparent 'texture merging'
x)
this is a visual thing but calculated procedurally
and because of the optimized mesh route, i am forced to hand code it
its not about being smart or not using unity
lol
i appreciate suggestions and ideas
but this is a trivial matter done since the 80s
on frickin 4mb systems
this is supposedly the advanced coder section
and we're still talking about using unity editor x)
there was no alpha mapping in the 80s though
maybe 1bit alpha... which would be clipping
its not alpha
its just removing bits of color
ofcourse alpha came way later
but thats what im saying
i was hoping i'd run into someone who knew how to do it
but i guess thats quite a stretch
ive got plenty of documentation to autotile corners
but i found one thread on waybackmachine
10+ years ago and even they were suggesting the transparency method
can you draw a picture of how it should look like?
hmmm potentially
descriptively, if you have grass and water next to each other
u get corners
but that means u have to hand draw a 'mixed' tile of water and grass
and if u have 20 materials thats alot of extra tiles
so one suggestion around that is to ignore that by making one tile overlap another
so corners will always be corners no matter which tiles are bordering each other
i mean its quite elementary what im after
but with textureuvs and meshes
in unity
thats my specificity
how do you solve the z-sorting?
so all tiles of a material are on the same layer/z-depth?
im going to implement z later in the other sense but yea this trick is for flat maps mainly
i plan to add 10-20 or more types of tiles
and i dont plan on hand drawing all the inbetween tiles
otherwise u end up with a huge texture atlas
that means u have to split ur atlas into several atlases
which makes the draw calls fly up
in the first instance yes
i will test for true z-depth later
not my concern right now but im interested in z tilting
u dont learn anything from quickly retreating from fixing one way of doing things
and just drawing oversized quads that overlap doesn't work for you?
i want the overlapping
but the mesh.uv code
can be supplied 4 coordinates (uvs)
yes, but i dont see your problem
i want it to have two on top of each other basically
why does the mesh have to be continous?
why?
load times
they dont
but i dont get tearing issues from this method
so i need no overlap
thats not my issue
im talking about
layering one textureuv directly ontop of another while muting out a color aka 0x00
i will find a way rawrrr
im trying not to cheat here
maybe mesh.setpixel
or someshit
its basic sprite over sprite action baby
if i was not using an engine and not using the mesh/uvs method
i would simply draw the pixels ontop of it
it sound like a total non-issue to me... just do it in one of the 100 ways thats doable
you can do it with a custom shader/post processing effect.
someone else suggested shaders
@compact ingot
im just wondering if generating hundreds of tiles as the player moves
would lag with those shader commands
its the drawing of tiles that is the problem, need to keep computations down
my footprint is already near 0
I'm jumping into the conversation, so I might not know the whole context. But it sounded like that.
endless possibilities, generate overlapping quad mesh, particles, decals, abuse the terrain engine, custom shader, ui system, basic sprites...
if you want proper blend modes (overlay, multipy and such) you need custom render passes or handle it all inside a shader
so basically, lets say my chunk generates 8x8 tiles (made from meshrenderer and mesh.uvs) on the fly, around the player every second he moves. the noise constantly generates the map and that map draws all those tiles in the update method. now the world is basic squares at the moment in this stage. just grass and water. i use a bitmask to detect all 8 directions and then swap the texture uvs to the correct corner. all easy so far. now here im looking to use the fake height principle to allow each layer to pass under the other on the corners (which have transparent edges), so when grass corners overlap the water will be underneath. here i did not need to draw any extra tiles or factor in drawing any specific adjoining tile. so i can have any type of water or land at every corner with the same set of tiles
im stuck with meshrenderer and textureuvs so it needs to be something relating to that which is performant
any links to documentation or videos would be appreciated if you know any regarding
so have a second 'grid'
Too much information mixed together. I personally don't understand the issue. Maybe demonstrate with screenshots/video?
simplifying it: i have quads (tiles) which have 4 coords (uvs) which points to the texture in the atlas.
i want to draw one on top of the other, with the top one being transparent
(sorry for the hassle) lol
he wants a stack-shader, like a terrain shader
i get what yall are saying, shaders is my next route to look at
my knowledge is limited as fuck ive only been properly programming for a bit
its getting to the point where i can pick up concepts faster but there is so many blanks in my knowledge
u have to forgive me
So write a shader that does that..?
i was expecting the shader route to perform maybe a bit laggy
if its drawing 100s of tiles every second
Meshes are all good and dandy, but shaders are what actually drawing your textures on the mesh.
this is where i lack the knowledge
It's not supposed to draw tiles.
shaders are the fastest pieces of code ever invented
the mesh is renderer
It just "shades" them.
then the filter is rendered
using the material
and the textureuvs assign a position in an atlas
for which 'tile' to draw over the quad
u can see why im looking for an easy solution
And material is actually a shader
Or rather a set of properties for a shader.
there is also a second atlas slot on there if i recall
has potential
i was kind of hoping for a combineuvs method or smth
lmao
like combinemesh
or some way to precompute
you seriously need to learn to build shaders... its a total non-issue what you are describing. just do it
This is whatever you define in your shader. You can have as many textures as you want(provided the hardware supports it)
(what is the typical limit for lesser hardwares)
say a phone or switch
for a texture atlas the phone has a 2kx2k limit
as opposed to the 4k 4k
500k triangles per frame on a current iphone, 2000k for VR, 20000k for high-end PCs. those are ballparks... milage may vary a lot
so u can see why im not interested in drawing hundreds of tiles
to ruin my draw call count
x)
are shaders computational expensive to run 100s of times and generate hundreds of times while in an update method
this is what worries me currently
Draw calls are not related to shaders.
nooo separate issue
sorry im adhd brain
im talking about like 2-3 things at once
cant help it
if they share the same mesh and material, they get batched into 1
yep thats why im using meshes and textureuvs
my performance rn is incredible lol
one textureatlas so far zips
thats why im opting for the transparent decal method
i can keep many tiles in the max 4k*4k sheet
so my draw calls and batches are incredibly low
but thats not alot of space anyhow
fills up way too quickly
even at 32x32
im gonna swap to 16x16 probs
i know ill have to have other sheets for characters etc but im saving the bulk of the optimization on the world
so then i can go crazy on other areas
the player is 1000 parts so far
1000 frames all sliced up in parts
sorry im yammering
if u guys think of anything else lmk ima hit shaders later on
regular water/terrain-tile 3-material blending
yes ik its just 2d tile worlds only work on x and y
ty
im talking like this style one sec
this is the marching square type thingy
yes
to achieve this effect, i need to draw a mixture of the two tiles at some point
so u can see why i want the transparent version
it will draw water first, then a transparent corner
and voila
i can then use any texture i want without drawing an inbetween tile for every single tile type
which makes the atlas enormous
and is alot of work
The simple way is using several layers of tilemaps
i assumed that was an option
what will performance be like running two dya reckon
some computation on when to show the other
and what about any weird blending issue
where in unity they exist in the same place in the world
x,y,z
since the high performance comes from a single mesh quad
if only unity had a blenduvs method ๐
probably not gonna be a big deal since it's 2d.
Not sure what you mean by that.
ok so running a second map and also shaders are potentials here
Can use sorting layers
afaik unity renders tilemaps as a single mesh. Could be wrong though.
I'm not sure what you mean by that? You can manipulate uvs however you want via code.
so in my uvs
it points to the coordinates of say grass
now what if i want to layer one on top of the other when the other has some transparent section
say a chunk of grass over a water tile
Then several meshes with difference on z axis would work.
so i could "draw" this combination tile
but what im after is a superimposed 'grasstile' over the water tile
combinations and transition tiles are cut to a minimum
does that make sense?
so if my grass tile tests for water above and to the right, it would pick this coordinate
Not really.
which selects a tile that has both grass and water in it
you could either use several meshes or a custom shader.
unity tilemaps have some feature that allows that if I remember correctly.
im not using unity tilemaps
wish i had those features
x)
the white is transparent
so instead of drawing a tile that includes both
now i dont have a permanent 'water/grass corner' tile
so it will border any tile not just water (B)
?
blablebloobla
just put the grass layer above B or any other layer that's supposed to be behind it.
can i have layers when the mesh is assigning one coordinate in the uvs
one coordinate?
No, that's what I was trying to explain the whole time: have a separate mesh for each layer.
water mesh, grass mesh, sand mesh, etc.
then just order them in the desired order
so u r saying
sorry dont mind me i have to conceptualize it first
have multiple arrays of meshes
empty in the spaces that are not of its type
something like that
so quad(x,y) at 1,1 is empty on the grass mesh but full on the water mesh
kind of ting
Yes, something like this. Didn't you have an algorithm that generates the terrain?
wont there be some like weird interlacing when two meshes are stacked ontop of each other and visible
yea it generates it all to one mesh
which means im limited to selecting one texture uv per 'quad'
You don't have to stack them on the same z position.
true that
is it not noticeable?
say a flat map of z=0
then a tile on z=1
wont the pixels suddenly kinda not line up
If it's orthographic camera, z position doesn't make any difference aside from rendering order.
wait so
a tile at z=100
above another tile at z=0
wont show any difference in size?
If we're still talking about orthographic camera, then no. It does not account for perspective. That's the whole point of it.
i have to experiment with that
sounds useful!
i was gonna do some fake height stuff
but if it works that well then i can just use the real z
^this is why im gonna make all my unity projects from now on in 3d lmao 2d is such a mess when it comes to that
unity is always 3d regardless ๐
orthographic camera and x,y axis appears to be 2d
i have no issue with that
the z height trick can get a bit mess with 2d games ofcourse
yep
but why bother with the 2d preset when you will want to change it into 3d midway
I'm not sure it's related to the preset at project creation...๐
basically i dont want to setup my game to be revolved around 2d so when i have a problem i have to resort to funky z buisness
but yeah idk this chat is not for me imma stop embarrassing myself
i tumble in head first
u cant embarass urself more than i do myself x)
im trying to learn
nah dude 99% of the time when i look at this chat i have no idea whats going on
LOL
u just gotta find the right way to do it
and sit there on it for ages
not accepting the easy way out
and dedication
you definitly have the hunger for it tho
i do too sometimes
i think im close to there
lol
ive been trying to figure out a good way to implement generic card effects for a month now, reading a blog and just not understanding it, really just have to grind it and walk through breakpoints i think at this point
thanks for the conversation man @distant kernel
๐ด breakpoints ftw
(youtube and google everything to do with it and surrounding it. middle click every link and watch them all)
i did
<insert adv. code>
litterally went through like 10 github repositories but its always soo complex
bunch of events on events
0x6f6b & 0xff
kind of looks like Total Annihilation
this is probably the right approach if it has to be huge
not sure what kind of gameplay needs Update() on 1m tiles/s, human being can't process maybe 200 simultaneous gameplay elements of any significance
if you need that kind of gameplay write your game as a compute shader
you mean the layered card effects? there's an asset
thx @urban warren @misty glade
i looked into that too,
- only found paid assets
- im trying to get better and build my own systems, not use apis
if you have a speicfic one you think is good you can send me either way maybe itll give me an idea
im trying to serialize a script so that i can edit one of its values in a prefab from the inspector
using a custom class
[SerializeField] public StatChange health;
this was my first instinct but obviously it didnt work because statchange isnt serializablke
however,
public float internalMultiplier = 1;
public float additive = 0;
public float externalMultiplier = 1; } ```
this is statChange: how can i make it so i can edit health.internalMultiplier from the inspector?
Is the class marked as [System.Serializable]?
So I just threw together a pooling system and made a dumb mistake. I'm using a Dictionary<GameObject, Pool> where the GameObject Key is the Prefab. My mistake was when I retrieve an instantiated object from the pool and then try to return it, this doesn't work :
recyclerDictionary[prefabObjInstance].Return(prefabObjInstance);
So... is there a solution here? Does anyone have any ideas on how to get an instance of an object to 'point' back to its prefab? Maybe there is something else I can use as the Key that both the Prefab and Instances share?
The simplest way would be to keep a reference to the prefab somewhere.
Yeah thats what I'm leaning towards as well... seems like an easy solution but also slightly annoying.
could keep another dictionary of instantiated objects <instantiatedGO, prefab>
Yeah that could work too.
or <prefab, List<gos>>
hmm I could always just give the instance a ref to the pool its contained in and bypass the dictionary when I want to return it. I think if I rework my Pool to store "RecycledObject" components instead of GameObject I can then pass the pool itself into the RecycledObject when an instance of the prefab is created.
What's a good way to find the point where two direction vectors intersect?
if they intersect.
Thanks!!!
https://i.gyazo.com/244ca7976de59712198e6cd671c8094c.mp4
How would i go about replicating this right mouse button pinch zoom from Maya. I have been struggling on this for quite a bit now...
OnMouseDown, track the start position, OnDrag check the current position and if it's right/up from the start position zoom in by some amount, if it's left/down, zoom out by some amount, and OnMouseUp stop
@silk hare
I get that, but the whole calculation with how much i am supposed to zoom is the hard part...
When you zoom far in or out the speed also becomes slower, you can't zoom past some point (to prevent inverting camera) etc.
Yeah, devil's in the details, right? It looks like they're doing some sort of % zoom but it's scaled so that you don't zoom "faster" as the % gets small.. You'll probably need to figure out that part yourself and experiment with the scalar multipliers to ensure it feels right
Someone's likely spent a few days/weeks on exactly that feature, getting it to feel right and work correctly... it's not a trivial answer, I don't think
What i am doing currently is taking the dot product between an orientation vector and the mouse vector relative the the zoom origin, then multiplying that by the distance between the origin and the cursor.
Like you probably want the first 3 inches of mouse movement to translate to a relatively small amount of zoom, but then the middle "amount" of movement to start zooming more and more (percentage-wize)
Then you probably cap the zoom % in the "most" mouse movement away from the "click origin"
I don't think that will work - won't that make the zoom "blow up" really big as you get farther away from the origin?
how to use DOTS + MLAPI?
You don't
yeah, i need to multiply my current zoom factor with some kind of limiter calculation.
is there netcode for that?
I think you want to ... assign some sort of gradient for zoom "scalar" based on the distance the mouse has dragged - at the start, it's pretty low, allowing the user to zoom in and out "a little bit", but towards the higher end (the max being your game or screen width/2 or so?) then you can zoom "a lot" allowing the user to massively change the zoom
I don't know much about DOTS, but it uses the Entity Component System right?
yes
I think this might be it, not 100% sure though
They're renaming MLAPI to Netcode for GameObjects at some point, to avoid confusion
seems like one another ecs framework for unity
?
Architecture question: I have a number of .. "things" that I use between my client (unity) and server (.net C# app) that I'm currently copying and duplicating between visual studio solutions. Obviously this sucks. What's the best approach here?
I'm thinking that I have a third solution that has all of the shared stuff (data objects, logging libraries, etc) and compile that into an assembly that can be used between both applications? Or something?
Followup - is there a tool that I can build both applications and deploy them easily? I don't have a lot of experience with automation in builds but my build process is currently something like:
- Build the unity app.
- Build the server app.
- Zip the unity app and upload it to a specific google drive folder for sharing with the team.
- Zip the server app and upload it to google drive.
- Stop the server on an Azure VM.
- Upload the server app via RDP to the azure VM.
- Start the server on Azure.
It would be great if the above ^ could be automated
Anybody has experience on this? Unity 2020.3.14f1 with OpenXR. Only does this on Android build, no problem PC build. Logs are clean, no errors whatsoever.
Damn. Somehow after I start removing a lot of package some error messages surfaced and it was an assembly definition that was excluded from Android build... D'oh. ๐
Hey, does anyone know how I can create a temporary Unity project using command line?
From documentation:
Returns true if the current project was created as a temporary project.
A temporary project is one that was created using the "-temporary" command line argument. It is located in a temporary location in the filesystem (e.g. the user's TEMP or TMPDIR folder), and when closing the project the user will be prompted to select a permanent location for the project that it will be moved to.
OK nvm I actually figured it out ๐
you would do it like so: C:\UNITYs\2020.3.17f1\Editor> Unity.exe -createProject C:\newtest -temporary
you'd have to use a build tool. i use gradle
the only other multi-platform build tool with good unity support is bazel
i use this pattern in both my big unity-multiplatform projects. in one case i use gradle to build a library using dotnet and install it into the right place in the unity assets folder and check it into source control. in another case i create a c# solution and add a package.json so i can reference it via a relative path in Unity's manifest.json
you will have to use the dotnet approach if you have nuget dependencies that need to be copied into unity
you would use dotnet publish
there are a lot of conflicts, for example, system.text.json, you need to deal with explicitly
@misty glade
data objects, logging libraries, etc
this is a lot of nuget stuff. you can copy in netstandard2 targeting dlls from the publish output directly into unity, in my experience with logging it compiles, i don't use Microsoft.Logging in Unity though
the managed C# protobuf library does NOT work in unity for example because it is netstandard2.1
the unmanaged one does
@misty glade here is an example gradle task that builds and copies a dll into unity
@misty glade here is an example gradle task that deploys a server https://github.com/hiddenswitch/Spellsource/blob/master/spellsource-server-deployment/build.gradle
and here's an example gradle task that builds Android, iOS, webGL, and steam pc/macos fully automated
https://github.com/hiddenswitch/Spellsource/blob/master/spellsource-client/build.gradle
gradle is very powerful, it's the only game in town besides bazel which i personally find harder to use
if you use windows, the biggest headache is trying to automate using any of built-in windows scripting, like cmd or powershell. they are bad
personally, i suggest using busybox64.exe to get conventional bash (really ash + bashisms) scripting on windows and something that is compatible with linux & mac
that's if gradle is way too intimidating
(reading all of this btw - just in another meeting atm)
check in busybox64.exe into source code, and just use it
i use a wpf application since i already know c# if i need to automate things in windows don't know how helpful that is
unfortunately in spellsource the guts of the unity build process is in the private submodules ๐ฆ in another project i have separated it out and written it in pure java for gradle, but it will be pretty inscrutable
the bash script is nice because then you can use it inside a docker container or whatever, something with all your dependencies
my process looks like
everything i need is checked into source code
-> a docker image contains my whole build environment and
-> gradle deploy inside the docker image
with the source directory bind-mounted to a known location in docker
then you can do docker run -v $(pwd):/git -w /git doctorpangloss/my-build-environment gradle deploy
it can be pretty painful to run docker inside a container if you don't Know Certain Things About Licensing
it's totally fine to just do it on a machine
if you know you only have to build on macOS it's easier
if you need to build on both windows and macOS you just have to deal with dependencies
Thanks re: gradle, @undone coral . As you mention, cmd/powershell is less than ideal.. it's actually what I'm using now and had intended to use, but I don't have the ability to easily upload files to remote systems, etc. What I'd really like to be able to do is build from git(hub) and specify the latest dev branches or whatever.. it sounds like gradle can handle all of that
This is exactly what I want
that could also just be a bash script if you'd like
the trick is using busybox on windows
I'm not doing dev in a docker container or anything else (yet) but I eventually intend to at least have a build server that can/should just pull from git and build
not many people know you can get all the useful stuff like zipping and file uploads and whatever with busybox
What's busybox? a bash emulator?
it's bash + coreutils, like grep and awk
gotcha
it's super stripped down most common parts of all the linux userspace, and it is used for things like routers
Right now I'm ... going with the "shared project" approach and generating a DLL that I can use on both the server and client, but there's some.. hiccups
alternatively, you can use git-for-windows-sdk which in my experience is the best native windows development environment when you have windows and linux targets
WSL2 is a waste of time
so for example a build on a dinwos machine would look like
Like, for example I want to use a common logging library so I've moved that to my shared project and injecting the output mechanism so that i can use the library in both unity (Debug.Log) and server (Console.WriteLine, or eventually writing logging to the database) but it's.. clunky
busybox64.exe bash my_deploy_script.sh
on linux or inside al inux container it would be ./my_deploy_script.sh
dinwos ha
as an alternative to gradle
yes i use something similar to what i linked to achieve that
you can set up a visual studio solution to do that
but it's painful
it doesn't advance your goals
gradle is similar levels of painful, but it works everywhere, not just on windows
dotnet works well
OK - i'll have a think on it.. i'm not sure if I want to scaffold up too much technology at the same time... like having a shell script to handle builds - at this point in time i'm still 100% windows (pc client, android client generated from unity windows; server is windows console + sql server on azure vm).. but i'm not sure what direction I want to go for long term build engineering
yeah my visual studio "solution" (to solutions) is ... painful now
it's just easier than powershell and batch
you can get a super luxe bash environment from git-for-windows-sdk or use busybox64. both work with the guides you'll find online
I'm also using a library that generates CS code.. which has an intermediate step that needs to be completed prior to unity builds, since runtime code generation is verboten in unity
so I'm already sort of tied to the dotnet.exe environment
that sort of stuff is easiest to express in gradle because it is a build tool
it has caching, it keeps track of what is already done
etc. etc.
(which is one point against going to .sh)
it parallelizes build tasks
hm.. cool
you would invoke dotnet from your bash script
i've never actually used gradle
bazel is also well supported and has specific unity stuff
gradle and jenkins have a lot in common - jenkins you also author build scripts in groovy
the weird programming language that is a superset of java you use
at the end of the day I just want the build to be automated, and as resilient as possible.. we're going to bring on another couple devs soon and i don't want them ... fucking up the builds, but also I don't want them to have to learn a zillion things just to be able to push a build to our dev VM
(or their own VM)
you can look through the spellsource gradle scripts (anything that ends in .gradle) to get a sense for a big mature multiplayer game
what it looks like
the build runners on github and travis are too anemic to build a unity binary
but in principle yes, if you set up the whole environment
it is very hard to do that
unless you know The Workaround For Licensing, you will never get it to work
it will be painful and full of surprises
@undone coral
I just started my first game, and I am making a bar at the bottom that display items in your belt, however, I am having issues with scaling.
sounds like a #๐ปโcode-beginner question!
Also.. don't @ people for questions, just ask. ๐
I had pmed his prior, did not know you couldnt pm
well you don't have the equivalent of LateUpdate
also why would you need to recreate the render loop
to pause the game or something?
oh i see
that was correct
Hi all I'm new here and im pretty stuck. I am building a world generator function like in minecraft. This is a large # of calculations so I want these generator algorthims to be run over multiple frames and try to keep the framerate as smooth as possible [or at least show a loading bar].
I currently call a courtine generateworld that looks something like this
if(CPU_LIMIT()) yield return null; //I've also tried yield return new WaitForSeconds and WaitForSecondsRealtime
foreach(Action a in generatingWorldFunctions){
if(CPU_LIMIT()) yield return null;
a();
}```
CPU_LIMIT is a function that checks if a System.Diagonstic.Stopwatch has ellapsed time longer than 1 frame should take (16.67 ms).
This works sometimes. Often on the first time your computer loads this data [into the ram?] After that I just get a frozen game for 2 seconds until everything loads.
Any ideas?
what's a()
I'm surprised yield null compiles, it should be yield return null to delay execution until next frame.
maybe that's why it isn't working lol
Confirmation, yield null does not compile.
sorry yeah that should be yield return null.
a() is a chunk of functions that is used in generation the world. Spawning platforms, enemies treasure etc etc.
possibly a single invocation of a() is taking 2+ seconds
That's where debugging and profiling comes into play
Even if did in theory that would mean that the System.Diaganostic.Stopwatch would see that the ellapsed time has been 2seconds > 16.67ms and it should pause for a frame because of the yield return null? That just never seems to happen
how the heck would that happen
the stopwatch stuff happens outside of a()
if a() itself takes 2 seconds how would it have a chance to happen?
The proper way (imo) to approach this would be to offload the work on another thread you create yourself, and raise an event when the whole thing has finished generating. Careful with that though, as Unity will kill any thread if it tries to access anything that was created on the main Unity thread. Accessing scene objects and editor stuff will kill it
Exactly thats the problem!
I can't instantiate any of the objects on anything other than the main thread
@stone slate Why are you not just using the profiler to figure out what exactly is causing the slowdown?
@urban warren I can do it for sure, but the problem is none of the functions need optimization I've done a lot of work in that respect with object pooling and multithreading calculations.
The problem is my computer never takes a "breather". It runs everything back to back to back despite having some yield nulls.
I assume you've already eliminated the obvious and checked if CPU_LIMIT() is working the way you think it is
If it's not taking a breather between actions then your CPU_LIMIT() logic is faulty.
could also consider making generatingWorldFunctions have more discrete operations - like instead of generating items by type, generate a small chunk of items with one call to it
@sly grove ```bool _CPU_LIMIT = false;
bool loading = false;
Stopwatch time = new Stopwatch();
public bool CPU_LIMIT(){
bool val = _CPU_LIMIT || time.ElapsedMilliseconds > maxFrameDuration;
if (val && !_CPU_LIMIT) WaitToDo(.1f, updateCPULimit);
return _CPU_LIMIT = val;
}
void updateCPULimit()
{
_CPU_LIMIT = false;
time.Reset();
time.Start();
}
public Coroutine WaitToDo(float time, Action f)
{
return mono.StartCoroutine(waitToDo(time, f));
}
IEnumerator waitToDo(float time, Action f)
{
yield return new WaitForSeconds(time);
f();
}
This snippet wouldnt work? I guess I am unsure of how to check and see if the Stopwatch.ellapsed time is updating even while running calculations
You're never starting the WaitToDo(.1f, updateCPULimit); coroutine
but also why is it so complicated and uses coroutines?
yes this is ugly and insane
simply doing
heh, you'll get it, as long as you don't mind a little dose of "that's insane" ๐
why is it not just like:
bool toReturn = time.ElapsedMilliseconds > maxFrameDuration;
if (toReturn) {
time.Reset();
}
return toReturn;
what's with all that coroutine stuff
because it wasn't working so i wanted to guarentee it'd take a break
but it litterally wont*
simplify
truu
When it's not working the solution isn't "throw an extra monkey wrench bandaid in", it's debug it and see why it's not working
time.ElapsedMilliseconds yea this does not increase while its doing calculations
thanks for the help i just gotta figure out a replacement
Just to double check, you do start it right?
when the updateCPULimit function was called it should be doing that and that was getting called after .1s after the ellapsedTime > maxFrameDuration and that was never happening
except it would never get called because the frame never ends
your coroutine will not get past the first yield statement until some later frame
ello guys do u have any idea how to make this:
if lets say 23 got ready the right side would be
020
023
and after 020 is picked up the 023 would be moved up... and 020 gets deleted
do u guys have any idea
how to make this
lets say with cubes
or what is this thing even called? xD
You'll need a vertical layout panel. That will stack the child objects vertically. Have two of those layout panels, one for the left, one for the right. Populate the child objects as you want, using two lists for example
for the left i think it's a grid layout
Are you asking about the UI or the logic here
because the numbers stack on the x too
because the logic literally just seems to be two lists
As for the UI part: #๐ฒโui-ux
ui
but still
what would that kind of "motion" be called
what motion
use unity jobs
it sounds like what you want is
IEnumerator LongJob() {
while (...) {
if (TakingTooLong()) { yield return null; }
yield return StartCoroutine(DoSomeWork());
if (TakingTooLong()) { yield return null; }
yield return StartCoroutine(DoSomeOtherWork());
}
}
IEnumerator DoSomeWork() {
while (...) {
SomeCSharpStatement();
if (TakingTooLong()) { yield return null; }
SomeOtherCSharpStatement();
if (TakingTooLong()) { yield return null; }
}
}
do you see how this is just threads?
that's what multithreading is
if you just wanna say, "oh you've spend too long on this, go do something else," if you don't have opinions on when that happens, use threads
He can't instantiate GameObjects in threads or jobs though
if you interact with the Unity scene, you have to "batch" all of your changes at the "end" of the work you're doing
which is what the tasks are
yeah
so it goes
right now it's poorly written, i assume, of the form
IEnumerator LongJob() {
for (var i = 0; i < 1000; i++) {
var resultOfWork = DoATonOfWork();
var gameObject = new GameObject();
var meshFilter = gameObject.AddComponent<MeshFilter>();
meshFilter.mesh = resultOfWork.mesh;
}
}
which is too toxic of a way to do things, it has to be
IEnumerator LongJob() {
var results = new List<Result>();
for (var i = 0; i < 1000; i++) {
var resultOfWork = DoATonOfWork();
results.Add(resultOfWork);
}
foreach (var resultOfWork in results) {
var gameObject = new GameObject();
var meshFilter = gameObject.AddComponent<MeshFilter>();
meshFilter.mesh = resultOfWork.mesh;
}
}
@stone slate
then it should be obvious you can do the first half in the job
you can even make every item in the loop a job, and limit the number of API changes at the end
per frame
Guys, is it possible to somehow pass array of Collider to IJob? Maybe by reference, pointer?..
in a word: no
You can pass vertices (or generate them) if that's the info you need though
what data do you need from the collider
well not sure about testing points inside colliders but that are a few things you can do like https://docs.unity3d.com/ScriptReference/RaycastCommand.html
https://docs.unity3d.com/ScriptReference/SpherecastCommand.html
Thanks, I'll take a look!
with UniTask, you can do
UniTask.Void(async () => {
await UniTask.SwitchToTaskPool();
DoATonOfWork();
await UniTask.SwitchToMainThread();
var gameObject = new GameObject();
await UniTask.SwitchToTaskPool();
...
});
@stone slate this is the most idiomatic way to turn an existing C# thing without jobs into something that runs in the background until for a few things, it needs to write to the scene
interesting. I haven't come up with a proper fix so i'll try it out
c'mon @sly grove even with your hardened heart you can admit that is really cool
it's multithreaded!
you can dispatch tasks each on a distinct thread in th the pool using unitask
almost as idiomatically
it's pretty good though
unitask is really great
Unitask is one of those things I've seen a lot, but never actually get a chance to try out;
i like that you have an editor window that shows you what tasks are running
that makes it safe to model gameplay stuff as conventional C# tasks
instead of coroutines
I just spent the entire day refactoring all the utilities I've written out of my unity application into a new visual studio library, and removing all the (now-unneeded) packages/plugins from my unity app and... IT WORKS. I have a project that is exactly as functional as yesterday and it feels amazing. That is all.
I spent all day working and nothing changed huzzah!
๐
It's like playing poker and coming back home +/- $0 after being down thousands. It feels great! Drinks on me, everybody!
i deployed all my new demos but my llama one doesn't work
and it was the only one i cared about
llama is fixed
I demand to see this llama
it's a secret llama
Is it possible to set a field to the property/field type? In this case displaying a bool, or if I selected the position display a vector 3 field?
private void GetMemberType() {
member = property.Attributes.GetTypeCode();
}
This is the closest thing I was able to find
I'm using IEnumerable<PropertyInfo> to get all the properties of the type defined in the 2nd column, I initially tried <FieldInfo> but that didn't seem to be what I needed
what am i looking at?
Reflection for an editor tool
I have a type that you define a compatible type for, then use reflection to get properties of that type as a requirement (for another tool), and the last bit to the entire system is defining what that property requirement's state should be.
not 100% sure i understand the question. It looks like you're listing the type next to the property/field name already
so you'd use that type to decide what kind of editor to draw
is that what you're asking? How to draw a checkbox for a bool and a number field for a float etc
Yezzir
I'm a bit confused though because that's kinda... what the normal Unity inspector does
Same with anything else, let's say the property takes an enum, I need to display a dropdown of the possible enum values
This is for telling another editor tool how to search for compatible objects in the scene
It has to be a dynamic field since nothing is known ahead of time about what is going on with the other parts. I might want to search by rigidbodies, and 1 level deeper than that I might want to search by a property requirement; rb's that are kinematic only
What I have rn doesn't seem to work correctly even as far as getting what type the property takes, it tells me a bool and vector3 are an Int32 - and it's just a dropdown of basic types, not actually displaying a bool field for a bool or a vector3 field for a vector3. Btw that's the PropertyInfo.Attributes.GetTypeCode(), I've looked through the intellisense suggestions and couldn't figure out what'd get me to my destination
What's wrong with just PropertyInfo.PropertyType?
.Attributes is a PropertyAttributes, which is an enum : int. Calling GetTypeCode on it is irrelevant to the property itself.
Hey people so here is my issue. I want to make a simple unity tool which will access a list of 3D models then assign them a material form another list. But i am finding it hard to access that embedded material if that is what it is called. Has any one got any good documentation on this or even has a material assigner tool of there own thanks.
Pretty sure I tried that, 1 sec
Yeah not what I need
While this does give me the type it's not a field that I can fill in
Opps I just saw there a input-system thread. ๐
i want to implement a camping system similar to darkest dungeon in that the rules are completely different and im thinking the best way to do this is in a different scene
ie my player can't move for example
what do you guys think the best way to implement this is?
its an open world game
when they click the "camp out" button, should i save my player's position in the world and their stats and stuff, unload the scene, load the camping scene
and when they're done with that load a new version of the open world (so that its a new day?)
That's one way, sure. You will need to save all that anyway.
I would probably do that myself really. Especially if the camping scene is completely different and doesn't really need any gameplay.
yeah
obviously im not copying darkest dungeon but to give you an idea of the situation im talking about
normally the game has like combat and everything and walking around
but for camping it looks like this, they just sit there and you assign out buffs and then tell them to sleep
so diff scene you think?
If it's a completely isolated event, then yeah, a seperate scene would keep it that way. You'll need to manage crossing data though, if you want to change things like the background based on where they are.
But that could be saved as well.
Or non-saved information can be managed by a root scene manager object too.
how do you think i could appraoch crossing data?
a data reservoir object that stores it all in a DontDestroyOnLoad scene?
and then after crossing just unpack the data from the object
For one game, I had a Root scene which contains all my managers. Then the current scene is loaded on top. You can have multiple scenes loaded.
ah sweet so you just put that crossing stuff in there?
that's cool
well ty for the help that's certainly made this less daunting ^^
Just be aware, there's always multiple ways. But it depends on your own game and how it works.
hey, which one would u recommend ? why ?
looking
the one on the right
i always do the one on the right because afaim its a teensy bit more performant but genuinely its up to you
iirc computers can do 5 billion calculations per second or something now
or like
mayve 500 million?
either way thats not a big difference between those two in that perspective
Depends on your GHZ clock speed for CPU
so if you have a 5Ghz cpu, yes you can do 5 billion cycles a second
Exceptions are expensive and should not be used for control flow
Day 5, hello ๐
I have an aim assist problem. If i dont rotate and just aim at an enemy... Its Generally fine. But if i do a 360 in any direction, it completely breaks. I'm out of optioned, i've tried everything i can try. Does anyone know how to make an aim assist or can help fix my current one? Thank you!
Camera Controller: https://mystb.in/ShopzillaContraryVocal.csharp
Aim Assist: https://mystb.in/ChartBatmanVital.csharp
@frigid cliff @modest lintel thanks guys!
there's also that extra pointer we create in the right one. a pointer is what, like 4 bytes ? so that could also be a bad point of manual checking. though as u suggested it's a bit more performant and tbh we have no clue how many pointers C# generates in a try/catch behind the scenes so im not sure if the left one makes less pointers
hellooooo ๐ Wow funky stuff happening with your aim. Kinda hard to figure out on a discord chat. Did you try isolating the problem on a simpler setup and building up from there ? I would also add A LOT of debug draw stuff, to make sure every vector and angles and such are what I expect
i can see they're not, I dont really know quaternions at all
i think its a losing battle
i'm bad with quaternions too. That's why I usually debug draw nearly every step to make sure i build up on a working base. Then keep adding step by step. yeah it's tedious but pain is in the head xD
I;ve not looked at it, Im working with Vectors so that might be the problem, but i dont know how to refactor it to purely use Quaternions
I could be gimblelock... but i dont know, Ive never seen this behaviour before
Hey guys, need help with something that's been drivin me a bit crazy..
I'm trying to make a frame rate AND time scale independant camera move function with Vector3.SmoothDamp
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime, float.MaxValue, Time.unscaledTime);```
However, when testing with different frame rates with Application.targetFrameRate the result will be VERY different, any suggestions?
u can turn your Vectors to Quaternion and wise versa. it's really the practical way ๐
Never mind me, I'm an idiot... Time.unscaledDeltaTime!! not Time.unscaledTime ๐คฆโโ๏ธ
hey guys, do partial classes work if I was to turn them into DLL?
if my project has 2 DLLs each having 1 part of the partial class, do they merge when compiling?
I just don't know how
Unity does the complex part itself. why would you manually do that?
also, I think the answer to your question would be No.
it's better to google it. like Unity Vector to Quaternion , or maybe just type Quaternion and put a dot ( . ) in Visual Studio and see what Visual studio hints you to do.
to tell u the answer :
Quaternion quat = Quaternion.Euler(vector);
quat.w += 0.5f;
vector = quat.eulerAngles;
I'm tring to make the following code appear in the inspector of the script, before it's instanced.
public List<GameEvent> _onSlowUpdate = new List<GameEvent>(5);
Any hint on how to do it? MyObject is a ScriptableObject, so it says "Default references will only be applied in edit mode".
The list must have exactly five elements since I'm trying to create five time slices for my update manager, so each runs once every 0.1s
I know I can do them individually, but then the code doesn't get as elegant.
_onSlowUpdate[_timeSlice].Raise(); _timeSlice = (_timeSlice + 1) % 5;
That's what I'm trying to do.
Well, I ended up making separate variables then adding to a list during start. Please, mark me or pm if someone got a better solution.
In OnValidate() maybe?
is anyone here familiar with state design patterns
Never ask to ask a question or if someone knows something. Simply ask the question and if someone knows and is free they will answer. It will save everyone time ๐
but the validity of the answer on my question will depend on how much one's understanding in state design pattern
who're you to judge if someone else's level of understanding is enough to have their answer valid for you? you should probably read this
https://dontasktoask.com/
When creating a hack and slash game like "Devil may cry" or "Nioh" what kind of system triple a game companies use to create player character controller?
most likely an observer, to control the states with events
i would add that just because a AAA game company uses a particular method(which is probably custom for their game), doesnt mean it's a good fit for your use case
the only people who can answer your question with 100% certainty are people who actually worked on those games
also, you should ask yourself what kind of controller is more adequate for your game, if using agents, physics or root motion
I mean not just those two games but in general when working with complex player controller like zelda controller or metal gear rising revengeance. with so many complex moves if it is not state machine what else kind of ways are there.
you can, for example, have an observer that interacts with the input system and sets events like "OnDirectionalPressed", holding the state of the direction as a Vector2. Then you can send that Direction to an agent, or to physics, or any system
Is that good enough? It depends on the game.
I like to have a reference holding the direction of my movement, so I can easily change this reference from player input, AI or anything like that.
That allows to use the same movement controller for every single object that moves, independent of which AI it uses
You can definitely incorporate a state machine in your controller. I'm currently using an asset from the store called Ultimate Character Controller. It's pretty amazing in terms of features, and most of their objects(abilities, different parts of the controller) are based on small state machines.
But to say that it's impossible without state machines is an overstatement.
I like to use scriptable objects as states for complex movement systems
Yeah, my input system is based on scriptable objects, with signals for every action, as well as the current state
The good thing is that I can easily import to other projects
So state machine is the way to go for complex character controller for a game like zelda breath of the wilde
just a tip: if you implement your own event manager, don't use List to store listeners. Lots of people do that because of a video that got popular from unite 2017, but it's a stupid idea
instead, use a hashset, because removing elements in arbitrary positions will make the list lag
i am creatign a player controller using state design pattern learning from this: http://gameprogrammingpatterns.com/state.html
You talking about the one from Ryan Hipple?
yeah
I didn't make the tests, but I'm 100% sure Lists are worse than HashSets as a collection of listeners, because the removals from objects being disabled will happen in arbitrary positions, not always by the end.
It was a really good talk, and think it opened a lot of peoples eyes on how to use SO well. But there are definitely things that that could be better about. (I am still using SOs for events and variables, though a bit different)
Yeah, I would think that is the case. HashSets are insanely fast.
I'm not saying his speech was bad, just pointing out that his solution could be improved in that specific point. His architecture is really good.
This is not a programming question but I don't think that there is another ideal channel. Anyway, when you create a custom package you have to follow some rules regarding the folders , include manifest and asmdefs. The question is , what happens with other package dependencies ? for example what if a script in my package is using a script from another package ?
You add the other package as a dependency...? I'm not quite sure what you're asking.
I have to include every dependency in the manifest ?
you can separate common dependencies into a different package, so you don't need to load the entire thing
like an utility package
If you mean when you add a package to a project that has dependencies, yeah, ya gotta add the packages it depends on too. I don't think that the PackageManager can automatically add custom packages that are dependencies yet. (Someone can correct me if I'm wrong)
I mean , when creating a custom package (not automatically with the export tool) but following these :
https://docs.unity3d.com/Manual/CustomPackages.html
I know, I was talking about when you add a custom package to a project.
My aim is to create a custom package, but I m not sure how to handle the dependencies yet
I think I have to write every dependency in the package's manifest
Ah, yeah. If it has a dependency then ya need to put it in it's package file.
And then unity will import it automatically, right ? (the dependency package not the one created by me).
Yeah if the dependency are default Unity packages. I don't think that it will if they are custom pacakges though.
I will try and find out. Anyway, thank you for your time !
Anyone know how to fix this? ๐ญ
Yesterday I refactored my code and extracted a bunch of stuff to another visual studio project, which I compiled as a DLL and imported into my [Unity] project as a Plugin. It seems like it works fine but I get this error:
TypeLoadException: Could not resolve type with token 01000021 (from typeref, class/assembly System.Threading.CancellationToken, System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
KaimiraGames.ISG.NetworkManager.PollConnectionAttempt () (at Assets/Scripts/Managers/NetworkManager.cs:223)
KaimiraGames.ISG.NetworkManager.Update () (at Assets/Scripts/Managers/NetworkManager.cs:287)
Which ... doesn't seem to tell me much? The line of code in question has no errors, and the application still compiles and runs normally, it seems. Is this.. a problem?
(the line of code in question likely won't be helpful but I can paste and explain it if you think it's useful)
Disclaimer, I'm actually not very good with vector and quaterion math. With that said though, I believe your problem is with your SmoothDamp in your AddAimAssist. Your rotation is something like 380, and the direction of the enemy is like 18. I could be 100% wrong on this.
try out mathf.lerpangle instead of normal lerp
Yea, im at a loss, i've exhausted my knowledge, re-written it 4 times so far, and none of them helped
I'll try lerp angle now
@magic hill Rah it works pretty much. there camera sort of goes crazy for a couple frames when it locks on
It also wont let me lock-off if i try to move my camera away from the enemy
I can get a new video of the behaviour with LerpAngle?
If the custom package is hosted on a scoped registry, Unity will install the dependency automatically
just uploading video now
Good to know thanks!
Addendum to the above question - the other VS project DLL targets .net core 5.. would that be a problem down the line? It seems to work fine for Windows PC builds
https://streamable.com/5x5wo1 @magic hill
It starts going crazy / shaking if i try and pull away from looking at them
I think I agree with @urban warren 's assessment, that you have some "wrapping" issues when comparing/lerping across the boundary
(370 degrees to 10 degrees, etc)
LerpAngle solved that it looks like
and you're sure you're "not autoaiming" anymore once you stop zooming (like the "ready pose")?
seems like something maybe unrelated to the autoaim is tainting your normal movement
he's just got parkinson's it's fine
Hey guys, any way to launch Unity's gradle with parameter ? I'ld like to use --scan to detect why it takes so long
Additionally, my gradle build seems to download the android gradle tool I set in the gradle properties any time. How can I just dl it the first time and then use the cache ?
Addressables. I thought the following code would mean that the object essentially doesn't spawn, since it's removed right after but this doesn't seem to be the case at all and I just can't figure addressables out to save my life
private void SpawnProp(AssetReference _propAssetRef, int _evenIndex, float _horizontalPos)
{
var op = _propAssetRef.InstantiateAsync();
if (op.IsDone == true)
{
GameObject a = op.Result;
a.transform.position = SOMEPOS;
Addressables.ReleaseInstance(a);
_propAssetRef.ReleaseInstance(a);
}
}
Also before this in another script I do (bit out of context)
propAssetRef.LoadAssetAsync<GameObject>();
Instead what happens is the props spawn in, and just stay there, like they own the place, taunting me
you're checking the async operation result immediately after starting it. It is very unlikely to be done by then. Therefore your whole if (op.IsDone == true) block might as well not be there
pretty sure that is always true if you loadassetasync before hand
in any case, it's always true in my testing
you're doing InstantiateAsync, not LoadAsync
in the second case
no I mentioned in the second block of code above
but either way, you can think of that if statement as just being true since it sets the position correctly, though the releaseinstance doesn't work
that's weird. this is suggestive that NetworkManager was not built against netstandard2.0
what is your objective?
NetworkManager is my own code...
would there be any reason that project is netcore3.0 instead of netstandard2.0?
hm.. there's a dependency in it to ruffles rUDP, but I haven't had issues with that in the past
when it shows a number that means it's a different runtime versus compile assembly
an error that also occurs sometimes in java
i don't know what version of System.Runtime unity runs with (which has CancellationToken) but if it's 4.0.0.0 instead of 5.0.0.0, that's your problem
hm.
Not sure how to fix, or if it's even a problem..? The entire app (including the networking components) seem to still work properly
yeah
Unless something runtime is going to blow up later when there's a call to a method that has a different signature
mysterious
(or maybe just doesn't exist in 4.0)
it's a real exception
so whatever happened there in pollconnectionattempt, it is throwing for real
Yeah.. I'm a little shaky on knowing the details of ... targetted frameworks, .net framework/core, etc
ruffles rUDP also isn't my code .. it's Albin's (who works for unity now but moved off of Ruffles to support their new netcode library project.. i forget what it's called)
MLAPI or something, maybe?
OK so maybe I've fucked something up with how I'm using Ruffles. It seems as if I've just whole-sale imported the source code into my Assembly-CSharp assets/scripts folder and I'm compiling his code into my app. I'm wondering if I should break it out, compile it into it's own DLL and import it into my project as a Plugin?
Having his source code is nice because I could make little edits to it but.. I haven't imported it as a unity package or anything - just a straight source code drop-in
I have no idea how to "install" this as a best practice.. and his github readme is a little light on documentation (and FWIW he's a little resistant in general to documentation)
I think I'm just going to extract it and compile it to a DLL and target core and see what happens
i don't expect that to improve things
if it's already imported whole-sale source it's building with the right stuff
somethign else is going on
hm
i don't think it's necessarily that code that is causing hte error
(I mean, at a minimum, I'd like to since it's a lot of unnecessary recompilation on domain reload)
you'd have to set the breakpoint and see what's really going on
i mean it's throwing the error but just because that's the line number doesn't mean it's responsible for this weird type issue
OK lemme step through it and see if I can see where it's blowing up (and maybe optionally why the error is just getting soaked without any observable issues)
Yeah, hm, something's definitely broke. ๐
Curl error 56: Receiving data failed with unitytls error code 1048578
0x00007ff71ab450dc (Unity) StackWalker::GetCurrentCallstack
0x00007ff71ab4b279 (Unity) StackWalker::ShowCallstack
0x00007ff71b33dd83 (Unity) GetStacktrace
0x00007ff71c23a7ca (Unity) DebugStringToFile
0x00007ff71bd6886a (Unity) TransformCurlErrorToWebError
0x00007ff71bd6617f (Unity) CurlExecutor::CurlExecute
0x00007ff71a77d360 (Unity) JobQueue::Exec
0x00007ff71a77f291 (Unity) JobQueue::Steal
0x00007ff71a77d6f0 (Unity) JobQueue::ExecuteJobFromQueue
0x00007ff71a77dbbb (Unity) JobQueue::ProcessJobs
0x00007ff71a77fbcf (Unity) JobQueue::WorkLoop
0x00007ff71a93ac3e (Unity) Thread::RunThreadWrapper
0x00007ffbe0907034 (KERNEL32) BaseThreadInitThunk
0x00007ffbe0e02651 (ntdll) RtlUserThreadStart
๐คฏ
OK, I think the error is actually in my code that I sliced off and put in it's own library yesterday. Question - if I have a standalone .NET Framework project that I export a DLL to the plugins folder of Unity - that particular DLL can still be written with .net5 without causing issues, can't it? Or does the DLL need to target the same framework unity does?
hm... something weird is going on..
assembly info: Targets .net 4.x
but i'm clearly building it for .net 5
It's going to try and run it on .NET 4.x even if it was compiled for another platform
It's a Unity thing
You'll need to compile your library for the .NET 4.x Unity uses, or the base .NET Standard version Unity also supports
hm.. ok
not going to lie.. the branding around the .net versions is utterly confusing
.net framework? .net core? ugh
I don't even think I can easily change this project from 5 to 4...
.NET standard is the base of it all
.NET Core 2.0 > Core 2.1 > .. > .NET 5
.NET Framework 1.0 > ... > 4.8
That's the 3 main branches
Yeah.. I need a good infographic with the version numbers and names of the frameworks that I can post on something obvious, like.. my head
and unity uses .net framework (4.7.2?) and .. requires plugins to be targetted at that version/framework as well?
By default yes. You can change that in your project settings to switch to Standard 2.1 or something
it's too bad, there's a lot of language features in c# 8+ that i wanted to use in my shared library
and sorry, what's standard? that's the older .net, right?
That's the code base the other frameworks are built on
If I'm understanding this, I won't be able to use c# 8+ language features even if it's in a precompiled DLL?
since those are only supported in .NET core and .NET (5.0 and 6.0)
Compiled DLLs are already compiled, so that shouldn't interfere. What restricts is the embedded metadata in the DLL that tells on which version it got compiled, and for which versions it's compatible with
OK.. and .. how do I get unity to accept that the DLL was compiled against 5.0? that seems to be my issue, maybe?
Beacuse you won't have the same version of mscorlib.dll (the System namespace) between FX 4.x and Core 2.1 for example
You can't. Unity devs are lazy and isn't compatible with .NET5
So.. when you say "that shouldn't interfere" I'm not sure what you mean.. Can I use my .NET5 DLL as a unity plugin?
I mean, it seeeeeeeems like it's working, although it's throwing the runtime error
Hm... googling this seems to indicate this is a hot topic
(ie - unity support for .net 5 and 6)
Yeah it seems so, but runtime errors due to library incompatibilities are nasty if not detected by the engine before it loads the DLL.
And yes, for .NET5+ support there's a lot of things going on
damn I'm really disappointed
I'm really leaning into a lot of the new features in c# 8 and up
.NET and Mono will be unified under .NET 6 that would be released in November 2021
Hope maybe? We'll probably have to wait, as always
like even today I wrote a dispatch function of the style:
public void ProcessTurn(PlayerAction pa)
{
switch (pa)
{
case PlayerActionSkipTurn playerActionSkipTurn:
ProcessSkipTurn(playerActionSkipTurn.HowManyTurns);
break;
case PlayerActionUseActiveAbility playerActionUseActiveAbility:
ProcessPlayerUseActiveAbility(playerActionUseActiveAbility.ActiveAbilityType);
break;
default:
break;
}
}
This just straight up doesn't work in c# 7 .. I can do it another way but .. it's not as nice as this is, I think
(like declaring and using a subclass type as a pattern matched expression in a switch statement)
i forget what it's called