#archived-code-advanced

1 messages ยท Page 135 of 1

compact ingot
#

sure you can... thats what shaders do

distant kernel
#

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

compact ingot
#

shaders don't like loops, thats all

distant kernel
#

asking tons of questions

#

ahhh

compact ingot
#

and you know almost nothing about your neighboring pixels without paying for it

distant kernel
#

ouch

compact ingot
#

also, if you can solve your problems with fully opaque objects. you'll have an easier time.

distant kernel
#

yea i can see that xD

compact ingot
#

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

distant kernel
#

any links of that use case you can provide?

compact ingot
#

well, every shader basically

#

the UnityEngine.UI is such a system

distant kernel
#

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

compact ingot
#

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"

distant kernel
#

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

compact ingot
#

render performance is probably a non-issue

distant kernel
#

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

compact ingot
#

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.

distant kernel
#

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

compact ingot
#

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

distant kernel
#

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

compact ingot
#

definatley create all the instances before hand

distant kernel
#

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

compact ingot
#

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

distant kernel
#

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

compact ingot
#

yeah, dont destory/create

#

pooling is the way to go

distant kernel
#

hmmm

#

so pool the chunks in memory some how?

compact ingot
#

then memory stays in place, no garbage

distant kernel
#

and load from that or

#

pool the tiles

#

im aware of pooling for projectiles

#

so my knowledge on implementation is lacking at best

compact ingot
#

easiest would be to spawn the whole map at Start() and just activate/deactivate the tiles you can see...

distant kernel
#

the issue is the world generates as the player moves

#

its infinite

compact ingot
#

other way would be to reuse a grid of tiles that fill the screen and change their appearance

distant kernel
#

i have serialization to take care of non previously visited chunks

#

how would pooling fit in that model

compact ingot
#

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

distant kernel
#

its already deleting chunks the player has visited after a 3000 tick

compact ingot
distant kernel
#

yea

compact ingot
#

thats only good for loading stuff at initialization... should be way too slow during Update()

distant kernel
#

it only happens once on non-visited chunks

#

and when changes happen

compact ingot
#

you should only load/unload if you run out of memory

distant kernel
#

well im going to look at some shaders and pooling and see how they'll fit my model

#

thanks for the chat

compact ingot
#

yw

distant kernel
#

have a good night (i may be back)

compact ingot
#

good luck !

undone coral
#

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.

distant kernel
#

ah yes i see

undone coral
#

this is what the existing unity tilemap does

distant kernel
#

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

undone coral
#

usually if you want to exceed unity's mesh generation performance and still use unity, you have to master Unity Jobs or compute shaders

distant kernel
#

the performance is not an issue right now

undone coral
#

really depends on what your objective is

distant kernel
#

ive optimized the crap out of it

undone coral
#

the ceremony of recreating unity tiles?

distant kernel
#

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

undone coral
#

on what, my computer with 24GB of VRAM and 16 cores?

distant kernel
#

im on 8 cores old 4790k

undone coral
#

or on a super nintendo..?

distant kernel
#

getting 700fps

undone coral
#

right, seems like it is

#

mostly about writing engine code

distant kernel
#

agreed

undone coral
#

guess no one can help you with that

distant kernel
#

i just need to add these "decal" tiles

undone coral
#

good luck out there

distant kernel
#

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

distant kernel
#

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)

tough tulip
distant kernel
#

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

tough tulip
#

not really. they're moving to c# for most new packages like new input system, addressable, srps, etc

distant kernel
#

unity is?

#

it has both if i recall

tough tulip
#

it seems so but there's no clear announcement for it

distant kernel
#

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

undone coral
#

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

compact ingot
#

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

distant kernel
#

i have an infinite world generating and deleting chunks around the player at 1ms

compact ingot
#

even assassins creed odyssey is just a big tilemap ๐Ÿ˜‰

distant kernel
#

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)

compact ingot
#

there was no alpha mapping in the 80s though

distant kernel
#

sure there was

#

bitmasking

compact ingot
#

maybe 1bit alpha... which would be clipping

distant kernel
#

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

compact ingot
#

can you draw a picture of how it should look like?

distant kernel
#

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

compact ingot
#

how do you solve the z-sorting?

distant kernel
#

fake height

#

z

#

not a real z

#

which is a possibility ofcourse

#

z tilting

compact ingot
#

so all tiles of a material are on the same layer/z-depth?

distant kernel
#

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

compact ingot
#

ok

#

but what about the question?

distant kernel
#

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

compact ingot
#

and just drawing oversized quads that overlap doesn't work for you?

distant kernel
#

i want the overlapping

#

but the mesh.uv code

#

can be supplied 4 coordinates (uvs)

compact ingot
#

yes, but i dont see your problem

distant kernel
#

i want it to have two on top of each other basically

compact ingot
#

why does the mesh have to be continous?

distant kernel
#

it does

#

or it is

compact ingot
#

why?

distant kernel
#

a mesh

#

of tris, quads, tiles, chunks

#

that combines meshes

compact ingot
#

why continuous

#

why do quads have to share edges

distant kernel
#

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

compact ingot
#

it sound like a total non-issue to me... just do it in one of the 100 ways thats doable

untold moth
distant kernel
#

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

untold moth
#

I'm jumping into the conversation, so I might not know the whole context. But it sounded like that.

compact ingot
#

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

distant kernel
#

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

distant kernel
#

any links to documentation or videos would be appreciated if you know any regarding

#

so have a second 'grid'

untold moth
distant kernel
#

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

compact ingot
distant kernel
#

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

untold moth
distant kernel
#

i was expecting the shader route to perform maybe a bit laggy

#

if its drawing 100s of tiles every second

untold moth
#

Meshes are all good and dandy, but shaders are what actually drawing your textures on the mesh.

distant kernel
#

this is where i lack the knowledge

untold moth
#

It's not supposed to draw tiles.

distant kernel
#

many areas (fml)

#

no i get that

compact ingot
#

shaders are the fastest pieces of code ever invented

distant kernel
#

the mesh is renderer

untold moth
#

It just "shades" them.

distant kernel
#

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

untold moth
#

And material is actually a shader

distant kernel
#

to blend two texture uvs on the fly

#

yea you're right i see that

untold moth
#

Or rather a set of properties for a shader.

distant kernel
#

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

compact ingot
#

you seriously need to learn to build shaders... its a total non-issue what you are describing. just do it

untold moth
#

This is whatever you define in your shader. You can have as many textures as you want(provided the hardware supports it)

distant kernel
#

(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

compact ingot
#

500k triangles per frame on a current iphone, 2000k for VR, 20000k for high-end PCs. those are ballparks... milage may vary a lot

distant kernel
#

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

untold moth
#

Draw calls are not related to shaders.

distant kernel
#

nooo separate issue

#

sorry im adhd brain

#

im talking about like 2-3 things at once

#

cant help it

compact ingot
#

if they share the same mesh and material, they get batched into 1

distant kernel
#

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

compact ingot
distant kernel
#

shaders?

#

any 2d contexts about at all

compact ingot
#

everything in unity is 3D

#

2D version for ya

distant kernel
#

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

compact ingot
#

yes

distant kernel
#

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

untold moth
#

The simple way is using several layers of tilemaps

distant kernel
#

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 ๐Ÿ˜›

untold moth
untold moth
distant kernel
#

ok so running a second map and also shaders are potentials here

untold moth
untold moth
distant kernel
#

im not using unitys tilemaps

#

just pure meshes

untold moth
distant kernel
#

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

untold moth
distant kernel
#

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

untold moth
distant kernel
#

which selects a tile that has both grass and water in it

untold moth
#

you could either use several meshes or a custom shader.

untold moth
distant kernel
#

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)

untold moth
#

?

distant kernel
#

blablebloobla

untold moth
#

just put the grass layer above B or any other layer that's supposed to be behind it.

distant kernel
#

can i have layers when the mesh is assigning one coordinate in the uvs

untold moth
#

one coordinate?

distant kernel
#

quads/uvs

#

it assigns one square from the atlas to the quad (made of two tris)

untold moth
#

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

distant kernel
#

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

untold moth
#

Yes, something like this. Didn't you have an algorithm that generates the terrain?

distant kernel
#

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'

untold moth
distant kernel
#

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

untold moth
#

If it's orthographic camera, z position doesn't make any difference aside from rendering order.

distant kernel
#

wait so

#

a tile at z=100

#

above another tile at z=0

#

wont show any difference in size?

untold moth
#

If we're still talking about orthographic camera, then no. It does not account for perspective. That's the whole point of it.

distant kernel
#

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

carmine ermine
#

^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

distant kernel
#

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

carmine ermine
#

yep

#

but why bother with the 2d preset when you will want to change it into 3d midway

untold moth
#

I'm not sure it's related to the preset at project creation...๐Ÿ˜…

carmine ermine
#

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

distant kernel
#

u cant embarass urself more than i do myself x)

#

im trying to learn

carmine ermine
#

lmao

#

u know more than me thats for sure

distant kernel
#

noooo

#

i know fuck all

#

lol

#

all i know is

#

u can always do something

carmine ermine
#

nah dude 99% of the time when i look at this chat i have no idea whats going on

#

LOL

distant kernel
#

u just gotta find the right way to do it

#

and sit there on it for ages

#

not accepting the easy way out

carmine ermine
#

im trying

#

yeah makes sense

#

yup

#

just have to believe

distant kernel
#

dont give up hope, just logic the fuck out of it

#

and grind on it

carmine ermine
#

and dedication

#

you definitly have the hunger for it tho

#

i do too sometimes

#

i think im close to there

distant kernel
#

update and optimize and reclass things

#

one tiny detail at a time

solid roost
#

jus saying ๐Ÿ˜…

distant kernel
#

lol

carmine ermine
#

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

solid roost
#

๐Ÿ”ด breakpoints ftw

distant kernel
#

(youtube and google everything to do with it and surrounding it. middle click every link and watch them all)

carmine ermine
#

i did

distant kernel
#

<insert adv. code>

carmine ermine
#

litterally went through like 10 github repositories but its always soo complex

#

bunch of events on events

distant kernel
#

public static byte[] pew;

#

((start smaller))

carmine ermine
#

i will

#

soontm next hearthstone out on steam

#

no cap

#

im joking

urban warren
#

Lets keep things on topic if we can. There is always DMs too. ๐Ÿ™‚

distant kernel
#

0x6f6b & 0xff

undone coral
undone coral
#

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

undone coral
sturdy tartan
#

thx @urban warren @misty glade

carmine ermine
#

if you have a speicfic one you think is good you can send me either way maybe itll give me an idea

frigid cliff
#

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?

shadow seal
#

Is the class marked as [System.Serializable]?

frigid cliff
#

nope ill try that

#

that works splendidly ty

crude isle
#

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?

untold moth
#

The simplest way would be to keep a reference to the prefab somewhere.

crude isle
#

Yeah thats what I'm leaning towards as well... seems like an easy solution but also slightly annoying.

untold moth
#

could keep another dictionary of instantiated objects <instantiatedGO, prefab>

crude isle
#

Yeah that could work too.

untold moth
#

or <prefab, List<gos>>

crude isle
#

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.

lofty falcon
#

What's a good way to find the point where two direction vectors intersect?

silk hare
misty glade
#

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

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.

misty glade
#

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

silk hare
#

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.

misty glade
#

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?

copper nexus
#

how to use DOTS + MLAPI?

shadow seal
#

You don't

silk hare
shadow seal
#

MLAPI is Netcode for GameObjects

#

There is Netcode for Entities or something though

copper nexus
misty glade
#

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

shadow seal
shadow seal
#

I think this might be it, not 100% sure though

#

They're renaming MLAPI to Netcode for GameObjects at some point, to avoid confusion

copper nexus
#

seems like one another ecs framework for unity

shadow seal
#

?

misty glade
#

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

fierce marsh
#

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.

fierce marsh
daring pelican
#

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

undone coral
#

the only other multi-platform build tool with good unity support is bazel

undone coral
#

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

undone coral
#

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

misty glade
#

(reading all of this btw - just in another meeting atm)

undone coral
#

check in busybox64.exe into source code, and just use it

tropic lake
#

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

undone coral
#

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

misty glade
#

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

undone coral
#

that could also just be a bash script if you'd like

#

the trick is using busybox on windows

misty glade
#

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

undone coral
#

not many people know you can get all the useful stuff like zipping and file uploads and whatever with busybox

misty glade
#

What's busybox? a bash emulator?

undone coral
#

it's bash + coreutils, like grep and awk

misty glade
#

gotcha

undone coral
#

it's super stripped down most common parts of all the linux userspace, and it is used for things like routers

misty glade
#

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

undone coral
#

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

misty glade
#

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

undone coral
#

busybox64.exe bash my_deploy_script.sh

#

on linux or inside al inux container it would be ./my_deploy_script.sh

misty glade
#

dinwos ha

undone coral
#

as an alternative to gradle

undone coral
#

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

misty glade
#

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

undone coral
#

got it

#

using bash scripting is prob your best bet then

misty glade
#

yeah my visual studio "solution" (to solutions) is ... painful now

undone coral
#

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

misty glade
#

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

undone coral
#

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.

misty glade
#

(which is one point against going to .sh)

undone coral
#

it parallelizes build tasks

misty glade
#

hm.. cool

undone coral
#

you would invoke dotnet from your bash script

misty glade
#

i've never actually used gradle

undone coral
#

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

misty glade
#

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)

undone coral
#

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

misty glade
#

jenkins and gradle can trigger automatically on github pushes, yes?

#

ie - true CI

undone coral
#

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

regal olive
#

@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.

misty glade
#

Also.. don't @ people for questions, just ask. ๐Ÿ™‚

regal olive
#

I had pmed his prior, did not know you couldnt pm

misty glade
elfin tundra
#

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

undone coral
#

that was correct

stone slate
#

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?
elfin tundra
#

what's a()

fresh salmon
#

I'm surprised yield null compiles, it should be yield return null to delay execution until next frame.

elfin tundra
#

maybe that's why it isn't working lol

fresh salmon
#

Confirmation, yield null does not compile.

stone slate
#

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.

sly grove
fresh salmon
#

That's where debugging and profiling comes into play

stone slate
#

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

sly grove
#

the stopwatch stuff happens outside of a()

#

if a() itself takes 2 seconds how would it have a chance to happen?

fresh salmon
#

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

stone slate
#

Exactly thats the problem!

#

I can't instantiate any of the objects on anything other than the main thread

urban warren
#

@stone slate Why are you not just using the profiler to figure out what exactly is causing the slowdown?

stone slate
#

@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.

long ivy
#

I assume you've already eliminated the obvious and checked if CPU_LIMIT() is working the way you think it is

sly grove
misty glade
#

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

stone slate
#

@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
sly grove
#

but also why is it so complicated and uses coroutines?

long ivy
#

yes this is ugly and insane

stone slate
#

Capital W calls lowercase w

#

I am asking for help lol

urban warren
#

simply doing

misty glade
#

heh, you'll get it, as long as you don't mind a little dose of "that's insane" ๐Ÿ™‚

sly grove
#

why is it not just like:

bool toReturn = time.ElapsedMilliseconds > maxFrameDuration;
if (toReturn) {
  time.Reset();
}

return toReturn;
#

what's with all that coroutine stuff

stone slate
#

because it wasn't working so i wanted to guarentee it'd take a break

#

but it litterally wont*

sly grove
#

simplify

stone slate
#

truu

sly grove
#

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

stone slate
#

time.ElapsedMilliseconds yea this does not increase while its doing calculations

#

thanks for the help i just gotta figure out a replacement

urban warren
stone slate
#

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

sly grove
#

your coroutine will not get past the first yield statement until some later frame

sharp rune
#

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

fresh salmon
#

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

tropic lake
#

for the left i think it's a grid layout

sly grove
tropic lake
#

because the numbers stack on the x too

sly grove
#

because the logic literally just seems to be two lists

sharp rune
#

but still

#

what would that kind of "motion" be called

sly grove
#

what motion

sharp rune
#

like

#

the thing

#

how the values/blocks/whatever

#

move

#

ah nvm

sly grove
#

Well i mean you shared a still image

#

hard to say

undone coral
# stone slate <@!179367739574583296> ```bool _CPU_LIMIT = false; bool loading = false; ...

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

sly grove
#

He can't instantiate GameObjects in threads or jobs though

undone coral
#

if you interact with the Unity scene, you have to "batch" all of your changes at the "end" of the work you're doing

sly grove
#

which is what the tasks are

undone coral
#

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

lime vine
#

Guys, is it possible to somehow pass array of Collider to IJob? Maybe by reference, pointer?..

long ivy
#

in a word: no
You can pass vertices (or generate them) if that's the info you need though

sly grove
lime vine
#

I need to test the point to be inside of it

#

Like, thousands times

sly grove
lime vine
#

Thanks, I'll take a look!

undone coral
# sly grove He can't instantiate GameObjects in threads or jobs though

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

stone slate
#

interesting. I haven't come up with a proper fix so i'll try it out

undone coral
#

c'mon @sly grove even with your hardened heart you can admit that is really cool

sly grove
#

lol

#

it's cute

#

but I like writing multithreaded code ๐Ÿ™‚

undone coral
#

it's multithreaded!

sly grove
#

I mean

#

I like doing the orchestration myself

#

I'm a curmudgeon

undone coral
#

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

queen plover
#

Unitask is one of those things I've seen a lot, but never actually get a chance to try out;

undone coral
#

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

misty glade
#

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.

sly grove
#

๐Ÿ˜†

misty glade
#

It's like playing poker and coming back home +/- $0 after being down thousands. It feels great! Drinks on me, everybody!

undone coral
#

i deployed all my new demos but my llama one doesn't work

#

and it was the only one i cared about

undone coral
#

llama is fixed

stone slate
#

I demand to see this llama

undone coral
glossy apex
#

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

glossy apex
#

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.

sly grove
#

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

sly grove
#

I'm a bit confused though because that's kinda... what the normal Unity inspector does

glossy apex
#

Same with anything else, let's say the property takes an enum, I need to display a dropdown of the possible enum values

glossy apex
#

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

glossy apex
# sly grove not 100% sure i understand the question. It looks like you're listing the type n...

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

austere jewel
#

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.

near coyote
#

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.

glossy apex
#

Yeah not what I need

glossy apex
# glossy apex

While this does give me the type it's not a field that I can fill in

untold temple
#

Opps I just saw there a input-system thread. ๐Ÿ˜›

frigid cliff
#

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?)

humble leaf
#

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.

frigid cliff
#

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?

humble leaf
#

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.

frigid cliff
#

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

humble leaf
#

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.

frigid cliff
#

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 ^^

humble leaf
#

Just be aware, there's always multiple ways. But it depends on your own game and how it works.

real blaze
#

hey, which one would u recommend ? why ?

frigid cliff
#

looking

modest lintel
frigid cliff
#

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

zenith ginkgo
#

Depends on your GHZ clock speed for CPU

#

so if you have a 5Ghz cpu, yes you can do 5 billion cycles a second

flint sage
#

Exceptions are expensive and should not be used for control flow

zenith ginkgo
#

https://streamable.com/4fr2xz

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

real blaze
#

@frigid cliff @modest lintel thanks guys!

real blaze
broken socket
zenith ginkgo
#

i can see they're not, I dont really know quaternions at all

#

i think its a losing battle

broken socket
#

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

zenith ginkgo
#

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

mortal slate
#

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?
real blaze
mortal slate
fervent parcel
#

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?

real blaze
#

also, I think the answer to your question would be No.

real blaze
# zenith ginkgo I just don't know how

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; 
harsh current
#

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.

harsh current
#

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.

fallen halo
#

is anyone here familiar with state design patterns

urban warren
fallen halo
#

but the validity of the answer on my question will depend on how much one's understanding in state design pattern

sturdy edge
fallen halo
#

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?

harsh current
#

most likely an observer, to control the states with events

sturdy edge
#

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

harsh current
#

also, you should ask yourself what kind of controller is more adequate for your game, if using agents, physics or root motion

fallen halo
#

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.

harsh current
#

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

untold moth
#

But to say that it's impossible without state machines is an overstatement.

magic hill
#

I like to use scriptable objects as states for complex movement systems

harsh current
#

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

fallen halo
#

So state machine is the way to go for complex character controller for a game like zelda breath of the wilde

harsh current
#

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

fallen halo
urban warren
harsh current
#

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.

urban warren
#

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.

harsh current
stark sail
#

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 ?

urban warren
stark sail
harsh current
#

you can separate common dependencies into a different package, so you don't need to load the entire thing

#

like an utility package

urban warren
# stark sail I have to include every dependency in the manifest ?

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)

stark sail
urban warren
stark sail
#

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

urban warren
stark sail
#

And then unity will import it automatically, right ? (the dependency package not the one created by me).

urban warren
stark sail
zenith ginkgo
misty glade
#

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)

urban warren
# zenith ginkgo Anyone know how to fix this? ๐Ÿ˜ญ

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.

magic hill
zenith ginkgo
#

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?

static marsh
zenith ginkgo
#

just uploading video now

misty glade
zenith ginkgo
#

It starts going crazy / shaking if i try and pull away from looking at them

misty glade
#

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)

zenith ginkgo
#

LerpAngle solved that it looks like

misty glade
#

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

zenith ginkgo
#

it works fine once i stop aiming

#

since this is an aim assist, its the root cause

hollow garden
zenith ginkgo
#

๐Ÿ˜ญ

#

So close yet so far

ivory dome
#

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 ?

magic acorn
#

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

sly grove
magic acorn
#

in any case, it's always true in my testing

sly grove
#

in the second case

magic acorn
#

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

undone coral
misty glade
#

NetworkManager is my own code...

undone coral
misty glade
#

hm.. there's a dependency in it to ruffles rUDP, but I haven't had issues with that in the past

undone coral
#

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

misty glade
#

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

undone coral
#

yeah

misty glade
#

Unless something runtime is going to blow up later when there's a call to a method that has a different signature

undone coral
#

mysterious

misty glade
#

(or maybe just doesn't exist in 4.0)

undone coral
#

it's a real exception

#

so whatever happened there in pollconnectionattempt, it is throwing for real

misty glade
#

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

undone coral
#

if it's already imported whole-sale source it's building with the right stuff

#

somethign else is going on

misty glade
#

hm

undone coral
#

i don't think it's necessarily that code that is causing hte error

misty glade
#

(I mean, at a minimum, I'd like to since it's a lot of unnecessary recompilation on domain reload)

undone coral
#

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

misty glade
#

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

fresh salmon
#

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

misty glade
#

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...

fresh salmon
#

.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

misty glade
#

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?

fresh salmon
#

By default yes. You can change that in your project settings to switch to Standard 2.1 or something

misty glade
#

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?

fresh salmon
#

That's the code base the other frameworks are built on

misty glade
#

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)

fresh salmon
#

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

misty glade
#

OK.. and .. how do I get unity to accept that the DLL was compiled against 5.0? that seems to be my issue, maybe?

fresh salmon
#

Beacuse you won't have the same version of mscorlib.dll (the System namespace) between FX 4.x and Core 2.1 for example

fresh salmon
misty glade
#

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)

fresh salmon
#

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

misty glade
#

damn I'm really disappointed

#

I'm really leaning into a lot of the new features in c# 8 and up

fresh salmon
#

.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

misty glade
#

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