#archived-code-advanced

1 messages ยท Page 105 of 1

wet sail
#

maybe someone else knows

upbeat path
#

Odin might, don't know

#

generally anything which needs to be seen in the inspector needs to be at least Serializable

#

otherwise what is the point?

wet sail
#

ofc

#

because i have stuff like class Character { Pathfinder pathfinder; }

#

and the pathfinder has many maaany params

upbeat path
#

tbh it's easy enough to write a generic solution using Reflection

wet sail
#

need to edit them in inspector and see them

#

true. but it probably will contain so many bugs. and need to learn unity editor UI and all...

#

weird that no one did this before. or we just cant find a lib

upbeat path
#

well, this is code advanced, you should have those skils

wet sail
#

it takes time. its not about performing, just too much headache. maybe someone knows a better way

craggy spear
wet sail
#

i mean its an option, just postponed

upbeat path
#

The question remains, even if you could visualize the class, if it's not serializable, how and where are you going to save the data?

wet sail
#

maybe i could implement a poller or something to save the data etc..

#

let's solve it 1 by 1. seeing it in the inspector is a prio

#

i dont know

#

im open to a better solution that all of this?

sly grove
#

Yes this is all exactly what the Grid component is for. Play with it a little and check out the scripting documentation for it.

glacial sentinel
#

have this scene which works fine in the editor but when building I get this parsing error , I went to look at the file in code and it looks just fine at those lines. I've tried re-importing the scene and rebuilding libraries but nothing seems to work.

#

I found a forum post of years ago where people had it due to a missing script somewhere but I ran a script to check for that and it ain't the case for me
but it makes me think that it's probably not an actual syntax error (also since I looked and I don't see anything wrong with it), but some unknown underlying reason

misty glade
sly grove
#

yaml things!

misty glade
#

yet another expletive

#

PB: Any experience with unity cloud save? ๐Ÿ‘ ? ๐Ÿ‘Ž ?

#

Debating uploading saves to it for customer support reasons (if you recall the convo last week)

#

might just be easier for my CS staff to edit JSON directly on the UGS cloud side

sly grove
#

Was this the convo about embedding reward vouchers in a token without a central database?

misty glade
#

yap

#

i went a bit down that route and realized that the enumeration of "things" i wanted to be able to change on a players account was getting... big

#

"set their progress on level xxx to xxx" etc

#

I was roughly thinking that I'd ... serialize the player file as binary, stuff it in a KVP and have admins have a tool that could unpack it to JSON, edit the JSON, repack it, and upload it back to UGS.. but.. it's hokey

sly grove
#

I have no reason to believe Unity Cloud Save is not good - but it doesn't sound intrinsically different from any other document-based key/value store

misty glade
#

Yeah.. I mean, I suppose the nice thing is that I already have some UGS infrastructure so integrating the SDK should be trivial

#

(and I don't have to setup any other random services on azure or whatever.. huge bonus, cuz fuck azure)

#

I mean to say.. "The value-add for Microsoft Azure doesn't align with our technical direction and financial infrastructure at this time."

glacial sentinel
misty glade
#

do you have any weirdly named directory structure stuff? ie, things with spaces, special characters (other than _) etc?

glacial sentinel
#

Weirdly enough my colleagues (project is shared through github), they also got the error but they can actually build

misty glade
#

I had some build problems years ago with android and directory structures that had spaces in them

#

oh!

#

are you in a directory structure that's very long?

#

like c:\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\blahblahblah\assets

glacial sentinel
#

C:\Users\robin\Curiosmos\Project\Curiosmos\curiosmos_unity\Assets\Scenes

misty glade
#

there's some issues with windows and long directory structures

glacial sentinel
#

not too long

misty glade
#

ok

#

any virtual directories there? like your c:\users\robin dir mapped to another drive or something natively in windows?

glacial sentinel
#

it's also fair to note that the error randomely started appearing while the project and scene had been working months prior to it

misty glade
#

๐Ÿค”

#

Backup software? (backblaze/etc)

glacial sentinel
#

just github and github desktop for me locallly

#

the others use gitKraken I beleive but shouldn't really matter

misty glade
#

hm... and not using LFS or anything that might mangle a file going in/out?

#

yeah, git shouldn't be the cause

#

(personally I hate problems like these - these are the ones that make for frustrating days)

glacial sentinel
misty glade
#

gimme a logic bug any day of the week

glacial sentinel
#

yea ikr, it's preventing me from builds which is an actual problem, luckily my colleagues can build for now and test it that way but it still annoying

#

I just feel like the actual error message is not related to the actual problem which makes it very hard to find the cause

misty glade
#

Yeah.. if they can build it it's likely unrelated to unity directly, and probably something obscure going on with your OS or setup

#

You mentioned that you already rebuild the libraries and stuff.. I mean, I know it's a pain in the ass but the nuclear option also exists - fully re-clone the project from git

glacial sentinel
#

but they do also get that error message when they open unity, it just doesn't stop them from building

misty glade
#

like to a new directory

#

oh, well, that's interesting

#

maybe comb through your project for missing scripts / broken game objects? i can't recall how to find them or why it happens, but sometimes gameobjects get the missing script/component thing (ie, the unity file is pointing to a guid that doesn't exist) and it doesn't fix itself cleanly

glacial sentinel
#

also, the scene has been udpated today and the error jumped lines too and too completely different ones

#

Like suddenly it's line 314

glacial sentinel
misty glade
#

As much of a pain it is - depending on how big your scene is, maybe literally just go through every game object and ensure all the components are in place.. that script might only find missing scripts, whereas you might have missing components, depending on the packages/libraries you're using, or something else going on fucky with unity itself

#

But i'm sorta grasping at straws now.. all my low hanging solutions have been expended ๐Ÿ™‚

glacial sentinel
#

Yea i'll give it a go later today, gtg for now, but thanks for helping and i'll keep you posted if I find out

misty glade
#

cheers glgl

deep jasper
#

is there a way to remove those three buttons from terrain ui?

bleak citrus
#

this is not a code question, and this also sounds like one hell of an XY problem

#

why are they an issue?

deep jasper
#

it's a custom editor window code question ig

deep jasper
# bleak citrus why are they an issue?

i'm doing a devkit(mod creation kit) for my game, and i want to remove some functionality of editor in this project, so users don't mess up things they don't even need to touch

#

i'm stuck on a terrain creation

#

i want to have 2 things: distant lands and good textures

#

here is a good road texture(1k), a good alpha map(512x512) which doesn't look squared, and also a distant mountain which is 8k units away(and covered with distant exp squared fog)

#

mountain has the lowest heightmap(32) and the lowest alphamap resoltuion cuz it's covered with fog anyways

#

and well, i also removed all layers from the mountain

violet valve
#

@deep jasper For the texture potion of your problem, you'll likely need to do some shader trickery to get one texture to expand out in all directions and avoid artifacting. There are a number of approaches to this: a great starting point is to use depth to smoothstep between different textures at different distances, then adjust the UVs for each of those ranges.

#

Another great way to reduce visual tiling is to take your texture, set it's UV scales to two prime numbers, then blend it with another texture that is rotated to some angle.

deep jasper
#

so while alphamap itself is high-res, player sees low-res basemap instead when he is far away

#

idk if it's even a good apporach tho

violet valve
#

None of that really matters; the default Unity terrain painting system doesn't have much in the way of modern blending. In order to avoid visual tiling, you have to use something else. A good starting place is to just swap out the default lit terrain shader.

deep jasper
#

well, tiling isn't the greatest problem i have

#

it's mostly world size and how do i split the world so i have less objects but same quality

#

rn i build the world out of 9216 small 64x64 chunks

#

and well, project won't even start if i have this amount of chunks

#

so i went for heightmap blending, and reduced total chunks amount on the scene to 144

violet valve
#

Oh, I see. Do you need all of these tiles to be rendered at once?

deep jasper
#

i want "distant horizons"

#

so yeah

#

i'm trying to achieve what games like Outwards, Light no fire and Skyrim achieved

#

In Skyrim you can see the entire map from any point, but ofc LOD version

#

Unity's pixel error seems like a good thing for reducing the amount of triangles you see each frame

#

but it doesn't really help with reducing ram/vram usage on distant chunks

#

since each chunk stores heightmap and alphamap of high resolution

#

9216 objects are exceeding my cpu power

#

9 big objects are exceeding max heightmap/alphamap resolution

#

144 objects are not exceeding cpu power, i can easily spawn 144 terrains and still have high framerate if i manipulate pixel error

#

but blending textures of 8x8 grid of chunks together to a single object is problematic

#

since it results in 144 different 4k heightmaps loaded through the entire game session

#

and well, it's also taking forever to load the scene if i uncomment my blending code...

#

i almost reached 10 crashes due to OutOfMemory or a complete unity freeze

violet valve
#

Ah, in that case you won't be able to manage to see the whole map with that many objects, no matter what. For performance, the terrain should handle tessellation for you.

#

Having fewer larger objects than 64x64 is probably ideal- 64 for a single terrain piece seems very small to me. Have you benchmarked other sizes? @deep jasper

deep jasper
#

well, it's a matter of combining heightmaps

#

if i want to keep good quality, each 64x64 chunk should have at least 512x512 alphamap res

#

so for 128x128 it's 1024 alphamap, and 2304 objects

#

for 256x256 it's 2k alphamap and 576 objects

violet valve
#

Just to be sure, you know your alpha map has a single channel? What format are you using?

deep jasper
#

and for 512x512(i'm currently using it) it's 4k alphamap and 144 objects

deep jasper
#

splatmap

#

or how is it called

#

with layer weights and stuff

violet valve
#

bmp, jpeg, png are formats. A splatmap (or control map) is a method.

deep jasper
#

i just have this

#

images are jpegs

violet valve
#

Ah okay, that's what I was looking for. Thanks.

deep jasper
#

so well, it's either 144 objects which have 4k Control Texture Resolution

#

or 576 with 2k

#

or 2k+ with 1k

#

and well, you are limited to 4 layers in single pass with URP

#

if i have more, fps will probably be halved

#

since it's 2 different textureing stages for all pieces

violet valve
deep jasper
#

hdrp has own shader

#

which supports up to 8 textures in a single pass

#

at least that's what unity docs/forums stated

violet valve
# deep jasper hdrp has own shader

Yeah, because it suddenly allows for multipass rendering. You can go higher if you wanted to - just saying, the renderer doesn't wholely own the terrain system's draw capabilities.

#

Although the gloves are off and you need some shader knowledge to do it. I bring this up just to clarify.

deep jasper
#

so well, is unity even good for making worlds of this scale

#

with large view distance

#

we were testing with a skyrim modder how far you can see objects in skyrim with everything maxed out

#

and i swear we went across the entire map and still saw shapes of distant objects(low-resolution and fogged out, but actual shapes)

#

this view distance is large

violet valve
#

So, I did some basic estimation for texture and regular memory use. For texture memory, you're approaching 700+ MB of texture memory for the terrains, which isn't unsurmountable. If it were like 3x higher, you might have problems lol. That's cutting it close.

deep jasper
#

and well, in case of skyrim they use a cell system, where each cell is around 58x58 unity units

violet valve
#

About 1/6 of that needs to live in RAM in order for the terrain heights to be accessible to other things like physics, etc.

deep jasper
violet valve
#

Yeah, I wanted to check. ๐Ÿ˜„

deep jasper
violet valve
#

So I do have some ideas for how you can get a good result, including borrowing from games like Skyrim for inspiration.

deep jasper
#

dms maybe

violet valve
deep jasper
#

or a branch

violet valve
#

Sure, either sounds good for me.

tranquil terrace
#

How can i achieve perfect determinism within my fighting game? I'm currrently trying to make a replay system, which works pretty well sometimes, but i keep getting slight discrepancies in velocity and position that can eventually end in a catastrophic desync that ruins the entire replay.

My system runs on fixedupdate, which i have moved to 60 ticks a second.
Every tick in the match, i record an input packet, that stores the buttons that the player inputted.
It also records the positions and velocities of each player within the replay.
At the start of the match, the matchmanager generates a new random from unity.mathematics and generates a seed that is saved in the replay.
Anything that is random references this seed, which should generate perfect recreation of random events in the replay. from testing, random events, such as random spawning and rotations, are replayed well.

I'm using kinematic character controllers for anything that needs to move, which is also simulated in fixed update.

I've also set a strict script execution order for things relevant to simulation.

I'm just confused as to what i could possibly be missing that could be causing this desyncs. Any advice is appreciated ๐Ÿ˜„

misty glade
#

if you have floats and physics in your game, you're gonna have a bad time with determinism

#

you'll have to do away with a lot of the physics in the replay and instead just keep track of each entity's position (not velocity)

tranquil terrace
#

I have witnessed perfect recreations sometimes, but other times shit just breaks

misty glade
#

one thing I did for a project in the past was make this very large "equals" override for the entire game state, and checked it when network packets arrived or were sent

#

but that was fine for turn based games, it would likely be an untenable amount of data for a real time fighting game

tranquil terrace
misty glade
#

ie -

GameState beforeFrame = ... // copy game state
... modify game state a bunch
GameState afterFrameFromSaveFile = ... // from save file

if (!currentState.Equals(afterFrameFromSaveFile)) ... // log why
#

it'll be a huge drain on CPU and your save files will be thousands of times larger, but for debugging desyncs, it'll work... it helped me find a bunch of network desync issues

tranquil terrace
# misty glade ie - ```cs GameState beforeFrame = ... // copy game state ... modify game stat...

i have a (generated) playback recorder which basically does the same thing.

private void FixedUpdate()
    {
        if (activated && started)
        {
            simulatedState = new GameState
            {
                playerPositions = new(),
                playerVelocities = new()
            };
            foreach (var rep in picList)
            {
                simulatedState.playerPositions.Add(rep.player.transform.position);
                simulatedState.playerVelocities.Add(rep.player.MoveVector);
            }
            recordedState = replay.stateList[frameIndex];
            
            // Compare the new game state with the recorded game state
            if (simulatedState.Equals(recordedState))
            {
                print("Game state match!");
            }
            else
            {
                Debug.LogWarning("Game state mismatch!");

                // Log differences in player positions
                if (simulatedState.playerPositions.Count != recordedState.playerPositions.Count)
                {
                    Debug.LogWarning($"Player positions count mismatch! Expected {recordedState.playerPositions.Count}, but got {simulatedState.playerPositions.Count}.");
                }
                else
                {
                    for (int i = 0; i < simulatedState.playerPositions.Count; i++)
                    {
                        if (!simulatedState.playerPositions[i].Equals(recordedState.playerPositions[i]))
                        {
                            Debug.LogWarning($"Player position mismatch at index {i}. Expected {recordedState.playerPositions[i]}, but got {simulatedState.playerPositions[i]}.");
                        }
                    }
                }

                // Log differences in player velocities
                if (simulatedState.playerVelocities.Count != recordedState.playerVelocities.Count)
                {
                    Debug.LogWarning($"Player velocities count mismatch! Expected {recordedState.playerVelocities.Count}, but got {simulatedState.playerVelocities.Count}.");
                }
                else
                {
                    for (int i = 0; i < simulatedState.playerVelocities.Count; i++)
                    {
                        if (!simulatedState.playerVelocities[i].Equals(recordedState.playerVelocities[i]))
                        {
                            Debug.LogWarning($"Player velocity mismatch at index {i}. Expected {recordedState.playerVelocities[i]}, but got {simulatedState.playerVelocities[i]}.");
                        }
                    }
                }
            }

            frameIndex++;
        }
    }
misty glade
#

(I was able to find attempted cheaters in my particular app too - people trying to hack their local game state in memory, send it to the server as authoritative)

#

are your velocities ints/longs/shorts? or floats/doubles

tranquil terrace
misty glade
#

well there's your problem ๐Ÿ˜‰

tranquil terrace
#

unless i missed some things, which is why i wanted to ask here

misty glade
#

I mean.. this one's pretty tough because you're using transform.position which is not entirely under your control.. it's sort of a difficult problem to solve given the architecture

tranquil terrace
misty glade
#

A different way to do this if you really wanted replay/netplay would be to have a fixed number of positions (like 1cm apart in the game world) and each frame a player has a numbered position (which is an integer) and everything physics/movement/velocity/position is handled by you, deterministically

tranquil terrace
misty glade
#

yeah i mean, that's another problem - you don't have complete control over that since it's not your library.. that might not be a problem in terms of gameplay, but .. for getting absolute deterministic precision.. you'd really need to know a lot of the inner workings of it to know if it's even possible (which i certianly don't)

#

why would it look janky? if the positions are too far apart, make them smaller

#

make them 1mm or whatever the smallest granularity you care about is

tranquil terrace
#

I suppose, im just not sure how i'd implement something like that

misty glade
#

i dunno if your game is purely linear left/right or in a 3d space, but if it's linear left/right it would be fine

tranquil terrace
#

its left/right

misty glade
#
public class Player
{
  public int Position {get; set;} 
}

Done! ๐Ÿ˜›

#

(but honest, that's the basics.. you just have a specific integer based position)

tranquil terrace
#

but then how would i translate that to a position in the world?

misty glade
#

if you need to render as a float or use that other library, that's still fine, generate a float from that integer position but everything in your "engine" would be based on that integer position

tranquil terrace
#

i see

#

that could be good

misty glade
#

however you want... maybe

public Vector2 GetWorldPosition(int intPositionIndex) => new(0.001f * intPositionIndex, 0f);
#

do the rendering strictly as an output of the integer based position, but do all your game logic/math/velocity/determinism/state based on the integer position, which will always be identical on subsequent runs

tranquil terrace
#

i see

#

that should be interesting

misty glade
#

you can even do debris physics in the float/vector2/unity space since that wouldn't impact the integer position

#

just an idea, i'm sure there's others/betters

tranquil terrace
#

will definitely take into account

misty glade
#

but trying to do determinism with floats, especially those not 100% under your control is gonna be a bad time

tranquil terrace
#

to summarise, you want me to use a integer position system instead of using the default transform system

misty glade
#

just an idea, you can do whatever you wish, i'm not a cop. ๐Ÿ™‚ but if you're looking for determinism/replays, you're gonna have a much better time if everything is under your control (and an integer)

tranquil terrace
misty glade
#

don't let other pieces of code touch them ๐Ÿ™‚

tranquil terrace
#

oh right ๐Ÿ˜ญ

misty glade
#

you're "borrowing" transform.position from unity, and any other libraries that use it.. you don't really have 100% control over it and know what it's doing under the hood, especially when it comes to timing, physics, velocity, colliders, rigidbodies, CPU architecture etc.. it's "mostly" correct all the time but there might be differences that are just invisible or out of your control

tranquil terrace
misty glade
#

not sure how to answer that

#

2nd question: the same way you move anything, but your "location" is no longer transform.position, but rather your own coordinate location (that you would render by mapping on to the world)

violet valve
violet valve
tranquil terrace
violet valve
#

Doubles assign equal memory for the large and small parts, so the part f(x) = 10^0 doesn't move. The resolution available for expressing the big and small parts are locked.

tranquil terrace
violet valve
#

https://en.wikipedia.org/wiki/Single-precision_floating-point_format This might help. Floats sort of store values in much the same way as scientific number format works, except it's all in base 2.

Single-precision floating-point format (sometimes called FP32 or float32) is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.
A floating-point variable can represent a wider range of numbers than a fixed-point variable of the same bit wid...

#

Determinism involves more than this, but you'll find that the major flaw when using floats is that they tend to cut off small parts of a number as the part larger than 1 grows. They're pretty brilliant for what they do, but are ill-suited to scientific use.

#

This is the part to look at. We typically call the red part here the mantissa.

#

This also means that the eather upon which stored numbers lose their accuracy grows as you approach the largest and smallest possible numbers. @tranquil terrace

#
Omi

In this video, we get right into all the fundamental (primitive) data types used in C#.

00:00 Intro
00:17 What is Primitive Data?
01:25 Integrals (Integers)
11:03 Initiation and Default Values
12:38 Nullable Types
13:36 Integrals Not Covered
15:18 Floating Point Numbers (Reals)
18:12 Precision Demonstration (In Unity)
22:37 Char Type
23:46 Tupl...

โ–ถ Play video
#

Check the timestamp - I have a demonstration of this inaccuracy at work.

tranquil terrace
#

especialyl for multiple objects, as i plan to use this system for projectiles too

violet valve
#

When converting your work back to unity coordinates, as in, assigning positions to the transform component, you'll dance with precision issues as demonstrated in that video. For a deterministic system of positional data, you'll never want to sample transform.position. Your homebrew coordinate system will always have to be the source of truth for where something lives.

tranquil terrace
violet valve
tranquil terrace
violet valve
#

However, different hardware may introduce different results for basic things such as dividing vectors by each other, which your number format won't solve. There are scientific libraries designed for this purpose, which you may want to reference into your project for most of the heavy lifting.

violet valve
#

The casting operation will lose precision or determinism, so don't grab that data back to process again. If you need to store a continuous position over the lifetime of an object, then manage a custom transform component and never read from Unity's own transform component, only write to it.

tranquil terrace
#

idk if im saying it right

violet valve
tranquil terrace
violet valve
tranquil terrace
violet valve
tranquil terrace
violet valve
tranquil terrace
violet valve
tranquil terrace
# violet valve Ah, my man(/woman)! Input buffers are a ton of fun to write.

lmao yeah, i've made a system where every fixed update it saves a copy of this input packet struct i wrote, and it plays it back completely fine, but its just the positions that are getting messed up (man btw)

[Serializable]
public struct InputPacket
{
    public List<ButtonState> buttonList;
    public List<MoveState> moveList;
    public bool LTPressed;
    public bool RTPressed;

    public InputPacket(InputPacket packet)
    {
        buttonList = new List<ButtonState>(packet.buttonList);
        moveList = new List<MoveState>(packet.moveList);
        LTPressed = packet.LTPressed;
        RTPressed = packet.RTPressed;
    }
}
#

so you can see the moves are replaying right, but the positions are just getting a bit janky.

#

velocities are literally IDENTICAL, i have no idea whats causing the positions to go out of whack from the recording im pulling my hair out ๐Ÿ˜ญ

violet valve
#

My gut feeling is that this shouldn't be a determinism problem at this scale.

#

Oh, nm, it could be. Using integers (or longs) should go a long way to solving this.

sly grove
tranquil terrace
sly grove
#

For that matter

#

how are you recording them

tranquil terrace
sly grove
#

Are you using Rigidbodies?

tranquil terrace
sly grove
tranquil terrace
sly grove
#

Also what's going on with transform position? Are you doing interpolation?

#

If not - how do you handle the "jittering" you would get from simulating in FixedUpdate

#

As an example - what I'm getting at here is when you use interpolation on a Rigidbody - the Rigidbody position is not always the same as the Transform position

#

Ok I'm reading the code here so - it seems like you're only reading the input data

#

when you replay

#

nothing else?

#

What's the PlayerInputController FixedUpdate look like

tranquil terrace
tranquil terrace
# sly grove What's the PlayerInputController FixedUpdate look like
protected virtual void FixedUpdate()
    {
        if (!player) {return;}
        player.currentButtonState = currentInputPacket.buttonList.Count > 0 ? currentInputPacket.buttonList[0] : ButtonState.None;
        player.currentMoveState = currentInputPacket.moveList.Count > 0 ? currentInputPacket.moveList[0] : MoveState.None;
        player.LTPressed = currentInputPacket.LTPressed;
        player.RTPressed = currentInputPacket.RTPressed;
    }
sly grove
#

how do you normally populate currentInputPacket

tranquil terrace
#

ignore the select ones

#

they are for something esle

untold moth
#

How are you telling if there's a desync?

quasi pecan
#

Hi! Newbie question but I'm currently trying to setup Playmode tests w/o setting up asmdef files. I believe Unity rolled out a Test Framework 2.0 - not sure if there's some support now for tests that reference the default C-Sharp.asmdef, or a way to avoid assemblies entirely?
Have Unit tests (EditMode) setup for now at the very least

mighty canopy
#

Hello, Can anyone tell me why I'm getting this error,

Happens when I try to build my project for android, I have deleted my library folder and let unity reinstall it 3 times now, not very sure what to do as there isn't much info online for this.

System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at Mono.Cecil.PE.ImageReader.ReadImage()
at Mono.Cecil.PE.ImageReader.ReadImage(Disposable1 stream, String file_name) at Mono.Cecil.ModuleDefinition.ReadModule(Disposable1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at ApiUpdater.MovedFromOptimizer.Program.CollectMovedFromTypeNamesFromAssembly(String assemblyPath, StreamWriter outputFile, IAPIUpdaterListener logger)
at ApiUpdater.MovedFromOptimizer.Program.RealMain(String[] args)
at ApiUpdater.MovedFromOptimizer.Program.Main(String[] args)

I have ILC2PP On, I have my target API Level set to API level 34.

Any help is appreciated.

tranquil terrace
# untold moth How are you telling if there's a desync?

At some point, something will happen and the players in the replay will just start doing stuff completely wrong. Like the inputs are being put in the right spot, but they're doing things in the wrong place which leads to players running off the side of the map or whatever

upbeat path
untold moth
tranquil terrace
# untold moth So you don't know where exactly the desync happens?

no, its different every time. I try to record the original and replayed on unity record and overlay them on top of each other and its how i was able to figure out some things like using random and stuff which greatly helped, but now im unsure whats causing it. im going to have to record more games and check, clearly

tranquil terrace
#

recorded a comparison video. as you can see, it seems to get a bit desynced when you hit the floor?

icy field
#

hey can someone help me with my silly lil problem i have for months now (pls i can't do this anymore)
if you are good with rotations and stuff pls help i am losing my sanity

tiny wagon
#

Hello guys! I've heard of ML-Agents and I wanted to know if it's possible for the training to occur while the player is playing

#

Because I wanted to make an infinite game where overtime the enemies starting learning strats against the player

tiny wagon
#

oh, sorry

#

forgot that exists ๐Ÿ™‚

wide mulch
#

How can I give a billboard sprite thickness like was done in the Paper Mario TTYD remake?

unkempt stirrup
tranquil terrace
unkempt stirrup
#

well, there you have the culprint.

you cannot make floating point operations deterministic in c#, neither same system (though there is debate on this) and especially not cross system+cross architecture. You have to use integers or fixed point maths (integer with funny hat) and do all floating point operations in software.

You can wrangle c++ to do cross platform + cross architecture deterministic floating point math (supreme commander relies on that) but we do not have access to the low level compiler instructions to make that happen.

If you need physics, you need to write your own

There are fixed point math libraries around for c#, use one of those as a starting point (or set up your own, I did that before, it's an afternoon at best to get it running)

You can try to replace all unity types with a deterministic datatype and see if that helps.

#

getting things from a deterministic source is a good start, but for getting anything deterministic (in unity, but also generally) it's highly recommended to completely decouple simulation and rendering, so you only ever send unity data to render to screen, but not do any calculations or state retention (i.e. you never read from gameobject.transform.position but only write to it. The true state should be isolated in your deterministic world and only updated downstream from your inputstruct)

tranquil terrace
unkempt stirrup
#

no doubles, no floats, only integers

#

double is just a floating point number with more bits

tranquil terrace
#

oh i see, i think someone else recommended that to me earlier

#

so like 1 int would be 1 mm for example?

unkempt stirrup
#

unless I am really dumb right now

#

nah, double: big float - long: big int

unkempt stirrup
tranquil terrace
unkempt stirrup
#

it's just a transform when you write data out from your simulation space to render space/unity space

#

in my system (I have a currently shelved fighting game prototype with rollback) I save all my positions only in the deterministic side, and build a toolchain to set up the data

tranquil terrace
unkempt stirrup
#

ah, mistunderstood you on that

#

that again, depends on how you scale things

#

is one unity unit a meter for you and one simulation unit a milimeter? well, *1e3 will do the trick

#

and you write that data out from your simulation every sumulation tick

tranquil terrace
# unkempt stirrup is one unity unit a meter for you and one simulation unit a milimeter? well, *1e...

yeah, okay. will have a look at one of these fixed point math libraries, then. another thing i'm worried about, though, is collisions and stuff. my current system uses the kinematic character controller to determine the point of collision, as well as the normal between collision points which makes things so much easier for me to calculate bouncing. I'm not sure how i'd calculate collisions using the new fixed-point library

unkempt stirrup
#

if you have full source access: replace every single floating point number with the deterministic counterpart from the library

#

if you don't have access to that, you have to write your own physics engine + collission detection + collission response

tranquil terrace
unkempt stirrup
#

yes

tranquil terrace
#

okay

#

i will have to do that then. seems like i've got a lot of work cut out for me ๐Ÿ˜…

tranquil terrace
# unkempt stirrup yes

can i just do that, though? just replace the values and everything works out of the box? i hihgly doubit it

unkempt stirrup
#

writing a deterministic game is only one of the hardest things you can do, glhf!

unkempt stirrup
#

or rather, the same algorithm

#

BUT

#

if it calls out to unity physics anywhere, you need to hook into your own deterministic physics solution

tranquil terrace
#

shite

#

well lets hope not, then

tranquil terrace
#

should be a good learning oppurtinuty

tranquil terrace
#

or do i need to make my own check stuff

unkempt stirrup
#

you need to roll your own

#

๐Ÿ‘Œ

tranquil terrace
#

shiteeeee

#

surely cant be too hard

unkempt stirrup
#

aabb is 5 lines of code

tranquil terrace
#

aabb?

unkempt stirrup
#

axis aligned bounding boxes

#

a type of collider

tranquil terrace
# unkempt stirrup axis aligned bounding boxes

someone on a different server recommended me to use time.fixeddeltatime for my physics calculations. so before i make the big leap of literally writing my own physics engine im going to try that and see what the results are

thin mesa
#

if you're doing this stuff inside of FixedUpdate then Time.deltaTime will return the value of Time.fixedDeltaTime already so that change is unnecessary

tranquil terrace
thin mesa
tranquil terrace
#

if im running unlocked fps surely that would be different than the fixed update

tranquil terrace
thin mesa
#

the engine controls when those methods are called. so presumably it just assigns fixedDeltaTime to deltaTime during the physics step then changes it back to the actual frame delta on the update step

tranquil terrace
#

okay

#

well i guess i have no choice then

#

i thought that might had been my saving grace to try and just keep unity physics stuff but guess not

unkempt stirrup
#

it's a float

tranquil terrace
#

can anyone here recommend any fixed point math libraries i can use?

tranquil terrace
unkempt stirrup
#

nope

#

you cannot use anything from unity's physics if determinism is the goal

tranquil terrace
obsidian stump
unkempt stirrup
#

๐Ÿ‘

tranquil terrace
unkempt stirrup
#

my fighting game engine prototype only support point in aabb and aabb aabb collission

#

a collission detection algorithm

tranquil terrace
#

I see

#

I'm gonna do some final checks before I start this new implementation

#

Because my velocities are perfectly identical and are using floats, so my positions should be indentical too. No idea why they aren't

tranquil terrace
#

anyone recommend any fixed point libraries?

spice sage
#

Hi, I downloaded for the first time and I can't open a new project

dull raft
upbeat path
spice sage
zealous summit
#

I'm doing a simple GetMethods on a class and everything works as intended as long as I don't add the binding flags as the parameter. When I debug it without any flags it lists all public methods as expected. If I add any flags parameter I logs nothing. Tried with Default binding flags, NonPublic, Public, DecleredOnly. Do you know what might be causing it?

        BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly;

        foreach (var methodInfo in networkBehaviour.GetType().GetMethods(flags))
            Debug.Log(methodInfo.Name);
small latch
zealous summit
#

thanks, works now. Thought that BindingFlags.Default already contained instances

small latch
#

Default is basically "find nothing" LUL

tranquil terrace
#

anyone know any tutorials for making custom fixed point physics systems?

sage radish
tranquil terrace
quasi sentinel
#

i know photon quantum has that but... that's a whole networking solution

tranquil terrace
#

i plan on using coherence for my networking

sage radish
tranquil terrace
gleaming onyx
#

Someone could help me with a terrain generation?

vapid cargo
#

Is anyone here good at kinematics?

#

nvm

half swan
vapid cargo
half swan
#

There is a whole website explaining why to never do that

vapid cargo
#

WHY IS THAT A WEBSITE DOMAIN XD

half swan
#

Because it is a common thing people do, which no one should ever do

vapid cargo
#

Alright

vapid cargo
#

I'm in an entirely different game using an entirely different system, but the ratios of making a foot move like a foot should be the same

half swan
#

Well, it takes time for people to answer usually.

#

But I need more explanation. First, what do you mean "different game... different system"?

vapid cargo
half swan
#

I could recommend anything from using IK to the animator... oh

half swan
#

Because it will not be the same. It will work pretty differently

vapid cargo
half swan
#

In Unity you use unity components (or assets like IK), generally not just math

vapid cargo
humble leaf
#

This isn't the place for non-Unity related questions.

humble leaf
vapid cargo
#

Unity has relation to math

humble leaf
#

You're not going to win an argument of technicalities. If you have a Unity specific question, you can ask it in context.

#

But given that you've already made it clear this isn't a Unity specific issue, your question doesn't belong here. Regardless if the wiremod server is dead.

vapid cargo
humble leaf
#

Move on, this conversation has finished.

vapid cargo
#

Cool

merry tree
#

I posted a talk on low level memory access in C#/Unity, and show how, if you know how to use it, you could get more performance using it, than you can with ECS by default. https://www.youtube.com/watch?v=U81B7g_vzx4

Take advantage of C style memory access in C#, with a new found understanding of why it matters and how to make an impact. Depending on what you are doing you could easily see a 2500x performance improvement. (at least in memory time)

ECS is great, but I wouldn't want to support its ever changing structure that can't support version changes and...

โ–ถ Play video
drifting escarp
#

Does Unity has a method of running code in sync? I want to execute my Code on the Unity Mainthread because I ran into issues loading and unloading scenes async. This is my Code i had before:

public class ScheduleUtils : MonoBehaviour
    {
        public static ScheduleUtils Instance { get; private set; }

        private ConcurrentQueue<Action> _backlog = new();

        private void Awake()
        {
            Instance = this;
        }

        private void Update()
        {
            if (_backlog.Count == 0)
            {
                return;
            }

            _backlog.TryDequeue(out var action);
            if (action == null)
            {
                return;
            }

            action.Invoke();
        }

        public void RunOnMainThread(Action action)
        {
            lock (_backlog)
            {
                _backlog.Enqueue(action);
            }
        }
    }

In the future i wanna test things without depending on this script being added to the test scene. Thats why I want to make it either static or run code from the Unity API.

upbeat path
drifting escarp
upbeat path
drifting escarp
#

Different question: Is there any real reason of having multiple scenes in most games? Because you could also put them all in one scene.

The only benefit i see is working with multiple people on the same scene. But for one person only it doesnt make a difference right?

upbeat path
#

Actually, yes it does. You could, of course put the whole game into one scene but, I imagine the load time would be a problem and the control mechanisms would be horrible to implement

drifting escarp
#

good point

upbeat path
#

I generally use, for a simple game
Loading Scene->Menu Scene->Game Scene->GameOver Scene.
Of course these can be loaded individually or additivly depending on your requirements

flint sage
#

If you want to do db syncs, calculations, or io on a different thread that works just fine

#

You just can't use unity apis on other threads

upbeat path
drifting escarp
#

I currently have:

Boot Scene -> Global Scene (always loaded)

and then additionally depending on the player state:

Option 1: MainMenu Scene + MainMenu UI Scene
Option 2: Lobby World Scene + Lobby UI Scene + Lobby Manager Scene
same as Option2 but also for a Racing state

flint sage
#

Yes if your target platform doesn't support threading then obviously you can't do threading

upbeat path
drifting escarp
craggy spear
#

This is a channel for questions about code you're writing, delete and move the question to #๐Ÿ’ปโ”ƒunity-talk (but don't expect an answer.. be better to post on the forums)

drifting escarp
#

I have seen that ScriptableObjects might serve as independent Managers. But the awake and onEnable only call in the Game Editor. Is there some callback when the game started or stopped?

So Events that work in editor and also when the game is built

upbeat path
drifting escarp
#

when i hit play, they are not called. They are only called when i change something in the code or when i create it again

#

monobehaviors are called when they are enabled in the scene. I need my ScriptableObject to call the onEnable when the game starts

upbeat path
#

do you have domain reload turned off?

drifting escarp
#

yes

upbeat path
#

there you are then, don't

drifting escarp
#

but i cant live with the huge loading times, how can i manually get a callback on start then?

upbeat path
drifting escarp
upbeat path
drifting escarp
#

its Unity, hope they finally improve that in the future

upbeat path
#

huge project is no reason to have huge domain reloading times

drifting escarp
#

my project take with domain reloads etc. around 30s to reload

#

i have several hundred of scripts and classes including lots of assets i use in the project

upbeat path
#

and have you implemented a single asmdef or dll?

drifting escarp
#

yes, i split them in different assembly definitions, but still not fast enough

#

even when i open an empty project, it also has loading times of 10 sec

upbeat path
#

so the problem is your computer not Unity

drifting escarp
#

you mean my Macbook m3 max is the issue?

upbeat path
#

if it takes 10 secs to load an empty project, absolutely

drifting escarp
#

I am not even the only one. But you seem to be the only one where you hit play and your game runs instantly and the project boots up in a millisecond

flint sage
#

What even is this conversation

upbeat path
flint sage
#

It went from how do I do x to blaming them?

flint sage
flint sage
#

It's editor only so you need to exclude it from builds

drifting escarp
#

Ah I see

flint sage
#

It's the reality of having no domain reload unfortunately

drifting escarp
#

hmm, maybe I just stick to my Monobehaviors and find a way of testing things independently, ScriptableObjects does not to work well for my case

flint sage
#

Yeah that's fair

drifting escarp
flint sage
#

It's very much a thing that works, until it doesn't and it's a chunk of effort to work around it

sage radish
drifting escarp
deep jasper
#

hi guys

#

i decided to do some tricks for my terrains to work properly

#

So well, by default i have a base terrain data with base heightmap

sage radish
deep jasper
#

Then i get the "modded" heightmap where this terrain got a small hill in the middle

#

i replace the final chunk heightmap with modded one, and then proceed to mod#2

#

when processing second "modded" heightmap, on which i placed a hill on top-right corner of the chunk, i want to blend it's changes to the heightmap which has middle hill

bleak citrus
deep jasper
#

is that possible?

drifting escarp
deep jasper
#

That's what i have with no mods(just a flat chunk)

bleak citrus
#

I would compute deltas from the original terrain data

#

then just sum up the deltas

deep jasper
#

yeah yeah that's what i'm thinking of

#

don't merge stuff which is untouched

bleak citrus
#

You could also be more efficient by only recording areas that were changed

#

especially if the modifications are small

deep jasper
#

i mean it's all painted using terrain brush

bleak citrus
#

ah, in the editor?

#

I was thinking you could store a Bounds object that covers the areas you touched. But I'm not sure how you'd figure that out from the terrain painting tools.

deep jasper
#

yeah, so i can save those changes as a separate binary file or smth

bleak citrus
#

I guess you could just compute the bounds afterwards

deep jasper
#

to then be able to load them and apply to the piece

bleak citrus
#

For every pixel that differs, grow the bounds to cover that pixel

#

Now you have a region that the modification covers

deep jasper
#

does terrain provide some kind of way to track changes

bleak citrus
#

you can use BoundsInt for that

deep jasper
#

like "TerrainPaintedEvent"

bleak citrus
#

no. you'd just do this once at the end, when you're saving your modification

deep jasper
#

alr, so that means i have some kind of bounds representing the change

#

but i also need to store what actually happended there

#

was it retexturing or hill/hole addition

#

and then when i install the "mod", i need to get the change itself and the bound of it, and then blend the base game data with the mod's data

fossil abyss
#

Does anyone know how to make a curve in your own script? I want to make one similar to the curve in the particle system so I can edit it in the inspector :

bleak citrus
#

You can use AnimationCurve for something similar -- I don't know about using the particle system's curve editor, though

glacial sentinel
thorny mortar
#

Hi guys, any one could help me get through the android TV support learning? Where I should start and if there a clear complete guide for that (ping me please)

earnest heron
#

Hey,
I'm working on a minigame which should update the UI each frame. I want to write a logic in a separate class and update the UI with new values of parameters from that class. Using message bus makes sense when I want to update the UI not in each frame but I think it could be heavy for each frame. What do you think ? Any suggestion ?

tired fog
#

How can I dinamically create a texture array? Im creating and destroying textures quickly, and I would like to have them available inside a shader, however, I need to call Graphics.CopyPixels (or the exact name to copy texture to a texturearrray) and it's slow, is there any faster way?

untold moth
tired fog
# untold moth I think the whole idea of creating and destroying textures quickly is not great....

That's true. I don't really create and destroy textures quickly, but rather I need to quickly switch between available textures on the graphics side of thing. Basically I made a procedural generator, and It outputs (apart from the mesh and more things) a Height Map texture and NormalMap texture. I wanted to use those textures inside a shader to sample some data.

Basically the system is i want to place a tree (actually thousands) inside a mesh, in a compute shader I calculate info about the position and more similar data, and then draw instanced that tree. I want to now use Normal Blending on the assets that are being drawn. I can sample the normal map of the texture when calculating the point (which is trivial and easy) However that would only give me one normal for the whole asset.

Sine the draw instanced works regardless of the mesh/world (the positions are calculated and then it alls gets collected for a single draw call) I cannot sample the normal map anymore unless all the available normals maps are in the shader, aka, texture array

#

I don't know if I explained myself?

#

Steps:
1 - Go through each chunk, get the texture and sample position (can pass one texture and sample it)
2- Collect all points
3- Draw all points in a single call, regardless of chunk (would need for each instance the index of the initial chunk, and some way to access that texture)

#

A solution is having a draw call per chunk, but maybe I can avoid that, so that's why the question

untold moth
#

With buffers, you would only ever need one and avoid the pain of working with textures.

tired fog
#

and then compact them together into one single buffer that can be sampled

#

How can I bind the resources tho? I have a texture2d (which I understand is only on the cpu side) so i need to get that data into the GPU and be able to read it

#

Also, having the data first in the cpu is preferable because I have way more space (Ram) there than on the gpu since i have many textures, being resued, but still there are quite a lot of chunks

untold moth
ivory latch
#

any of you guys know where i can find unity version 2017.4.9f1

tired fog
untold moth
tired fog
#

There's the graphics.copy pixels that i used, but maybe i can just store the native arrays and pass that directly into a compute buffer and scratch textures all along

#

Aah, no i see what you mean, so apply actually copies it already in the gpu, aka, i already have the data there

#

Then how can I bind it without a texture array?

#

I guess i would have to create a gpu buffer with pointers to the textures in the gpu, but no clue how to do that, or how it would even work

sage radish
ivory latch
scenic pine
#

Hello, i dont understand the behavior of Vector3.project at all.
I wrote this part of code:
Vector3 forceAppliedOnRight = Vector3.Project(forceApplied, transform.right);
Debug.Log("forceApplied=" + forceApplied);
Debug.Log("transform.right=" + transform.right);
Debug.Log("forceAppliedOnRight=" + forceAppliedOnRight);
And i get this kind of results:
forceApplied=(910.64, 2956.38, 521.29)
transform.right=(0.87, -0.40, -0.30)
forceAppliedOnRight=(-468.80, 214.66, 161.71)

The result should be a much bigger scale of the given normal (transform.right), and have a much bigger magnitude in that case, as explained in the documentation
Is there something i misunderstood?

untold moth
scenic pine
#

yes, but not as much as it should

untold moth
#

Did you do the math on paper to confirm that?

scenic pine
#

it should be close to either 910 or -910 for the x value, since the rigidbody is initially pushed from left to right (and forward a bit), and i gave transform.right as the normal

tired fog
untold moth
untold moth
tired fog
#

Unless I create a texture array at every frame, which is the problem I was comenting, it's slow

scenic pine
untold moth
#

It wouldn't work with a texture array either. It needs to be of defined size.

tired fog
#

The shader needs a declaration of "TextureX" to be used

tired fog
untold moth
tired fog
untold moth
untold moth
tired fog
tired fog
untold moth
tired fog
#

I lose some fancy features like an easy to use sample, but I will just have to create my own

tired fog
untold moth
tired fog
#

I can create the texture array itself as a fixed size, but what it gets slow is not the creation, but the copying of the data into the array

untold moth
tired fog
# untold moth How are you creating the data? Can't you generate it on the gpu?

Not really, i have a pretty big system built in jobs for mesh creation, and the textures comes from copying the data from some of the steps of a native array into a texture. I can indeed instead of copying it into a texture, copying it into a buffer directly and then compact the buffers into one every frame for later sampling. I would be skiping the creation of textures all around

untold moth
#

I mean, in the end the issue is that you need to transfer data from CPU to GPU. Buffers are not immune to that, although there might be slightly less overhead for them.

#

You shouldn't need to copy large amounts of data to the GPU every frame. Or be prepared that it would eat some CPU time.

tired fog
#

Yup sorry, I meant copy to one buffer once(CPU to GPU), and then compact all used buffers into one at every frame (GPU to GPU)

untold moth
#

wdym by "compact"?

scenic pine
tired fog
#

so, array1, array2, array3 becomes array123 = [array1, array2, array3]

#

and I can use an offset index to access every sub array

untold moth
tired fog
#

The solution to not being able to declare n unknown buffer, but I can declare one singular big buffer

untold moth
#

It's still probably better than dealing with textures though

tired fog
#

I can calculate how big the buffer could potentially be in the CPU and initialize that buffer once. But i wouldn't be modifying the buffer in the CPU, or at least I don't see how

untold moth
#

If you're not gonna modify it, then that's fine.

tired fog
#

i will see, yeah, because I had another solution that, instead of doing that, i could calculate four normals and do some interpolation between them if it's even necessary. But thanks! I will be keeping that Idea in mind! Compacting it could be a solution to get more precision

#

four normals being calculated during the initial process and then passing that directly to the shader being drawn (the idea of having the texture is to do some direct texture sampling per vertex)

untold moth
tired fog
#

Nono, they are the terrain vertex normals, and i want other objects on the scene to sample them so that they can blend together with the ground

hexed meteor
#

Found a unity bug In this while block the lerping simply does not work, the color C is always equivalent to the defaultTint value. Long live Unity, best game engine ever

sly grove
#

especially t

#

and maskTint and defaultTint

olive cipher
#

5 bucks on t is (almost) instantly greater 1

sly grove
#

yeah I would guess phaseDuration is tiny or 0

#

or elapsedTime is never being reset

hexed meteor
#

doing that already it's definitely broken

#

inb4 ban for posting image instead of typing

untold moth
#

And not just the final value but all other involved variables as well.

hexed meteor
#

I swear what is wrong with Unity that such basic stuff is broken...

#

unbelievable

#

business as usual though

humble leaf
#

Don't start

frozen imp
untold moth
#

It's not broken until you can confirm it.

frozen imp
#

Open material in debug inspector mode and confirm correct property

untold moth
humble leaf
#

@hexed meteor can continue this conversation in #๐Ÿ’ปโ”ƒcode-beginner where it belongs, as they've been told in the past.

And I will also remind you your negativty isn't welcomed here. You are one more away from being removed from this server as you have been told in the past.

hexed meteor
#

Bug report is bugged lmao Unity gonna Unity

hexed meteor
humble leaf
#

!mute 516295730928025613 1w Again, we don't need the attitude. Next is a ban.

thorn flintBOT
#

dynoSuccess matgabriel was muted.

untold moth
humble leaf
#

They've been stuck on beginner level questions for over a year. They're not interested into doing anything but complaining, as is common for beginners to make themselves feel like they're making progress. If they complain, it must mean they have knowledge of the subject.

devout hare
#

Should also be noted that every time they complained about "Unity broken" it turned out to be a (basic) user error

#

and it's exhausting to try to help in those cases because you first have to convince them to get past that mentality to do any debugging

somber swift
#

Calling a non-functioning code Unity bug is kinda crazy. That's all just the four most basic operations in math and computers don't go wrong with those. If you knew how to properly debug your program, you could pinpoint where the "bug" exactly is, realize you did something wrong and not end up writing nonsense here.

misty glade
#

Topic change is in order! ๐Ÿฟ

Interested in thoughts/experiences with prefabs for UI/UX. Back story is that I've just come off an app and we didn't use a lot of prefabs for UI/UX (buttons, sliders, dialogs, etc), and by the time we got to the end of dev, we were hurting as a result - inconsistent application of dialogs, sound effects for button presses, sliders with varying details..

I was thinking that it would be good to make all the UI/UX elements prefabs, but there's so much custom behaviour in every element that it gets difficult to know which "features" should exist in the prefab and which should exist as modifications. Example - some of our buttons have particle effects while awaiting a secondary action. Other buttons have text in various places. Still others have icons depending on the state of the button, etc.

I'm mostly just interested in hearing how y'all generally proceed for structuring your apps and prefabs for UI. Do you set out at the beginning and design/build a bunch of prefabs for building blocks and then try to use those prefabs as much as possible? Or are you generally of the mind that "each UI element will be special in its own way" and try to move away from the prefab-based approach?

Also.. text/fonts.. At some point our design team decided they wanted a light gradient on all the "white" text, which was a tremendous pain in the ass. Do you use a prefab for various text sizes and then use those everywhere in the app (so that changing font faces or sizes later in the project is easy)?

bleak citrus
#

Almost all of my game's UI is prefabbed (including things that aren't being generated via script)

#

One issue I ran into was trying to use inheritance to make more specific kinds of menu items

#

For example, I have an Entry prefab. It represents anything that displays a value for the user to edit.

#

I then created variants like Float Entry and Choice Entry

#

I put some common behaviors -- such as showing a description when you mouse over the entry -- into an Entry class

#

My first thought was to subclass it with FloatEntry and ChoiceEntry.

#

However, this doesn't work: you can't "replace" the Entry component on the base prefab with a FloatEntry component

#

So I went with composition instead.

misty glade
#

Yeah - I mean, my games don't have a lot of "data entry" per se, but that's similar to the issue I've run into.. buttons and sliders all have various applications that are slightly different

bleak citrus
#

oops, I'm in the middle of a build right now, so I can't show you how it looks...

misty glade
#

Like some buttons (delete/destroy) might require a second confirmation click.. should that be included in the prefab or .. what

#

No worries

bleak citrus
#

The actual behavior can be added with more components.

#

I have a base "menu button" prefab that's just a functionless button component with some text on it

misty glade
#

I get the idea, though.. I'm just struggling with thinking about how much to prefab out (like would it make sense to have a SmallText MediumText LargeText that's everywhere in the app?)

bleak citrus
#

rather than having prefabs for "small text" and "big text", you should have prefabs for kinds of text

misty glade
#

most of our text is white with a drop shadow:

bleak citrus
#

almost like how you'd do CSS classes

misty glade
#

but when it's not.. it'd be a pain in the ass to change:

bleak citrus
#

I don't go so far as to have a base "text" prefab or something

#

that'd be a bit much

misty glade
#

Perhaps but as it stands.. we've floated the idea of changing the typeface (again) and we've written it off because it would be a monumental amount of work

#

probably 1000+ instances of a textmeshprougui item

#

also the sizing is all kinds of inconsistent.. so just a simple "make the text a bit larger everywhere" is almost impossible to execute

bleak citrus
sage radish
#

uitk, my beloved

bleak citrus
#

UIToolkit would definitely make that much easier

misty glade
#

is UITK that .. uh.. xml-ish thing?

bleak citrus
#

since you'd have actual cascading stylesheets

sage radish
bleak citrus
misty glade
#

I thought it was all layout stuff.. I admit I don't know a lot about it but I still prefer to do the layout myself

bleak citrus
misty glade
#

but just... some datapoints I want to inherit

bleak citrus
#

I recently did this so that I can update [SerializeReference] fields after renaming a class

misty glade
#

I'm .. not sure that would be successful.. like, there's dozens of different font atlasses for each font size

bleak citrus
#

oh, I was thinking of just changing the font size of your text components

misty glade
#

I'd have to find all of the analog sizes and .. yeah, I dunno, I suppose it could work but it might be fiddly

#

well, some of the text is autosized, some is specifically sized, etc.. it's part of the problem, i think

#

anyway, just some rambles.. appreciate the feedback

bleak citrus
#

but yeah -- prefabbing whatever you can get away with is very helpful

obsidian stump
#

I am seeing interstitial ad instead of rewarded ad does anyone know the reason.

formal smelt
#

I have some questions about nav mesh, I understand how to bake a surface mesh and agents etc, i just dont understand how to set certain walkable slopes, or if i want an agent to be able to fall off the side of something

untold moth
somber tendon
wide mulch
#

What version of mono/dotnet does Unity 6 Preview use?

wide mulch
#

๐Ÿ˜” no file-scoped namespace

scenic forge
#

Still C# 9 ๐Ÿ˜”

#

Core migration can't come sooner.

steel snow
#

i suspect it will take another year yet

languid sequoia
#

Hey! I'm using Unity's netcode for GameObjects, as well as it's multiplayer package. When I try to join a p2p network as a client on a clone editor, I get this error:

#
Unity.Netcode.NetworkConnectionManager.ApproveConnection (Unity.Netcode.ConnectionRequestMessage& connectionRequestMessage, Unity.Netcode.NetworkContext& context) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Connection/NetworkConnectionManager.cs:667)
Unity.Netcode.ConnectionRequestMessage.Handle (Unity.Netcode.NetworkContext& context) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Messaging/Messages/ConnectionRequestMessage.cs:147)
Unity.Netcode.NetworkMessageManager.ReceiveMessage[T] (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context, Unity.Netcode.NetworkMessageManager manager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Messaging/NetworkMessageManager.cs:582)
Unity.Netcode.NetworkMessageManager.HandleMessage (Unity.Netcode.NetworkMessageHeader& header, Unity.Netcode.FastBufferReader reader, System.UInt64 senderId, System.Single timestamp, System.Int32 serializedHeaderSize) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Messaging/NetworkMessageManager.cs:446)
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.NetworkMessageManager:HandleMessage(NetworkMessageHeader&, FastBufferReader, UInt64, Single, Int32) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Messaging/NetworkMessageManager.cs:450)
Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Messaging/NetworkMessageManager.cs:472)
Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkManager.cs:49)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkUpdateLoop.cs:192)
#

Object reference not set to an instance of an object

Have a feeling it's something to do with the player, but could be very wrong.

outer adder
#

Where does that NRE happen?

#

oh

#

Normal connection works fine?

languid sequoia
#

No longer having that issue, but now getting

NetworkConnectionManager.Shutdown() -> IsListening && NetworkTransport != null -> NetworkTransport.Shutdown()

The second a client launches

languid sequoia
outer adder
#

What about the client

languid sequoia
#

The second I attempt to join in another editor as client I get that error and get disconnected.

#

NetworkConnectionManager.Shutdown() -> IsListening && NetworkTransport != null -> NetworkTransport.Shutdown()

outer adder
#

This is confusing

languid sequoia
#

Agreed

outer adder
#

I never used Netcode with P2P Network, I have no idea

#

Or is it some sort of bug on their end

languid sequoia
#

Says Client Connected then instantly shuts the client down

languid sequoia
#

Guess I haven't tried building it yet let me do taht

#

After building, getting

No ConnectionApproval callback defined. Connection approval will timeout

outer adder
#

With every new connection, Netcode for GameObjects performs a handshake in addition to handshakes done by the transport. This ensures that the NetworkConfig on the client matches the server's NetworkConfig. You can enable ConnectionApproval in the NetworkManager or via code by setting NetworkManager.NetworkConfig.ConnectionApproval to true. Conn...

languid sequoia
#

Ah, I see. I enabled the connection approval because I wanted to see if a player should be able to join or not and forgot to add something to approve the connection.

indigo needle
#

im having a problem, i followed the brackeys tutorial using player controller for 3d player movement, https://gdl.space/vuborozike.cpp this is my code, but the problem is when i go backwards then its kindof funky, and when i jump backwards and move my mouse downwards then i go really high, and when i point my mouse down then i cant jump at all

bleak citrus
#

Double crosspost. Don't do that.

indigo needle
#

my bad

plush hare
#

    public static T instance {
        get {
            if (instance == null) { instance = new T(); }
            return instance;
        }
        private set { instance = value; }
    }

}```
#

if (instance == null)
this part causes unity to freeze. why?

#

if it gets new'd before anything, it works fine. but getting that instance while null anywhere in the program locks the entire editor up

plush hare
austere jewel
#

instance_get() <---- 0
if (instance == null) <---- 1
instance_get() <---- 2
if (instance == null) <---- 3
instance_get() <---- 4
....and so on

plush hare
#

oh, duh

#

thanks

austere jewel
#

To be clear you need a backing field

#

private set { instance = value; } is also an infinite loop for the exact same reason

plush hare
#

thanks

lyric meadow
#

I know XR/VR is another channel, but I haven't had any luck, and I think my issue is to do with my calculations in UpdateRotation so nothing crazy with VR.
I'm somewhat new to Unity, but I've modified the XRKnob script in the XRI Toolkit to allow for two hand steering, but I've had this one issue for a while and can't fix it. Sometimes when steering the knob value stays the same. Not sure when/why it happens it could be from turning to fast or something. Got some examples in the video after about halfway, you can see it kind of stutter.
https://youtu.be/wLjAb5dXhNE
https://paste.ofcode.org/357VzNUQbdECG9SPZPsCb69

upbeat path
#

!code

thorn flintBOT
tender summit
#

oh i feel like doing that would be harder to read than just using discords built in code reader though, isnt that just if you're copy and pasting?

upbeat path
#

it's up to you of course but, I would suggest that if you want help you conform to the norms of the server

frozen imp
tender summit
#

Im making a rhythm game and want to use osu mania's chart files so i dont have to build my own charting system. I made a script to parse through the chart file and store all the note data into a dictionary, the only problem is it takes quite a bit of time for the song to load. Songs in my game take 10-15sec to load which is way longer than osu's 1-2sec. Is there a way to optimize this more or should I just go for a different method of loading note data?
https://paste.ofcode.org/SKMKYpHRDMwaFKbzNB7Qy

upbeat path
tender summit
#

by data file do you mean one of the osu charts?

upbeat path
#

whatever is in the TextAsset beatmap

tender summit
fresh salmon
#

You're doing quite the amount of substrings in there. Are you familiar with StringReader? It allows you to read a string sequentially (line by line or even character by character) and might speed up the whole process

upbeat path
#

I was going to suggest, forget TextAsset completely and use the System.IO.File class

fresh salmon
#

Yeah that too, if you can read it from a file and open a Stream to it, it'd be the best

upbeat path
#

indeed with a stream and stringbuilder

flint sage
#

Span<T> โœจ

tender summit
#

alright i'll look into that stuff ty, it is only my second time building a parser so i've probably got quite a bit to learn still

fresh salmon
#

Stream and StreamReader if using a file, StringReader if you're keeping the text asset.
That class should also not be a MonoBehaviour imo, separate the parser from actual game logic

upbeat path
flint sage
#

I doubt allocating a tuple is more expensive than allocating an array

tender summit
#

if thats even what you meant lol

fresh salmon
#

Depends if you're keeping the TextAsset or not.
If you're planning on letting the user select one of their own beatmaps, I wouldn't use a TextAsset to begin with, as these are bundled into the game files on build

tender summit
#

yeah i was going to switch it to selecting a file later on, i was just using the textasset for testing purposes

little cosmos
#

Hello, there is a bug with UnityWebRequests that makes some audio files show incorrect audio length. This is already fixed, but the fix hasn't made it into LTS yet. I have a big project and don't want to migrate to some unstable version, is there a usable workaround for this?

versed coyote
#

I am a bit confused here. I have a Texture2D that I'd like to convert to a PNG via script.
However I am unable to read the Texture2D because of the shown error message. The error says I should adjust the Importer Settings for it to work - I did via the script but it did not help.

Any idea how I can access this Texture2D's bytes now?

Here is the error:

ArgumentException: Texture 'human_male_albedo' is not readable. For this reason, scripts cannot access the memory allocated to it. You can make this texture readable in the Texture Import Settings.

This is the script:

  public static void Convert()
        {
            if (Selection.objects.Length != 1) return;

            var texture2D = (Texture2D)Selection.objects[0];
            var assetPath = AssetDatabase.GetAssetPath(texture2D);
            var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;

            if (textureImporter != null && !textureImporter.isReadable)
            {
                textureImporter.isReadable = true;
                textureImporter.SaveAndReimport();
            }

            var directory = Path.GetDirectoryName(assetPath);
            var fileName = Path.GetFileNameWithoutExtension(assetPath);
            var pngPath = Path.Combine(directory, fileName + ".png");
            var bytes = ImageConversion.EncodeToPNG(texture2D); // <<< Causing Error

            File.WriteAllBytes(pngPath, bytes);
            Debug.Log("Converted Texture2D into PNG at " + pngPath);
            AssetDatabase.Refresh();
        }
small latch
#

You can make this texture readable in the Texture Import Settings.

#

Oh I see you have that, why is it missing stuff

#

Looks like a subasset. Not sure if textures that come along with a model internally are able to be read. Might need it as a normal texture instead.

versed coyote
last kindle
#

I'm having trouble with a door force issue when it's breached. I use forceDirection = other.impulse.normalized; to set the direction, but sometimes the door opens in the opposite direction out of the blue. At first, multiplying forceDirection by -1 fixes it for a bit, but then it flips back again. Removing the -1 works fine for a few hours or a day, then it flips again. I'm completely stumped on what could be causing this.

#

then I do this to apply the force
rb.AddForce(forceDirection.normalized * magnitude);

#

this is the full code

    protected virtual void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag(targetTag))
        {
            LastImpulse = other.impulse.magnitude;
            var forceMet = LastImpulse > ForceThreshold;

            if (forceMet)
            {
                forceDirection = other.impulse.normalized * -1;
                //Debug.Log("Force Direction: " + forceDirection);

                collisionObject = other.gameObject;
                if (collisionObject != null)
                {
                    conn = collisionObject.GetComponent<NetworkObject>().Owner;
                    //Debug.Log("Collision Object: " + collisionObject);
                    RPCDoorTakeover(conn);
                }
                else
                {
                    Debug.LogWarning("Breach failed!");
                }
            }
        }
    }

//...other functions (RPCDoorTakeover calls Breach and breach calls AddForce)

    public void AddForce(float magnitude)
    {
        rb.AddForce(forceDirection * magnitude);
    }
upbeat path
#

please do not cross post

half swan
#

Should probably delete the messages here and another channel. Have it in only one

obsidian stump
obsidian stump
#

And those collegemates got big salary jobs because they used to write lengthy lines of codes like 100 using linked list pointers arrays stacks hash tables etc for a single string instantiation. As it can be done string str = "string"; here in India if you write lengthy lines of code you get job fast.

half swan
#

What are you even saying, and how is it supposed to contribute to anything?

tall ferry
obsidian stump
tall ferry
obsidian stump
half swan
plush hare
#

how should code generators be handled in a massive project?

would you have like one code generated file per "module"? surely you wouldn't try to cram everything into one massive file right?

#

vague question I know. just looking for opinions since code gen is a pita especially to have multiple of them. right now I basically have multiple visual studio projects for each of my separate code generators.

scenic forge
#

cram everything into one massive file
Are you asking about the generator projects, or are you asking about the generated code?

plush hare
#

the generated output file

scenic forge
#

If it's about the generators, then yes one generator per project is the way to go.

#

Oh, there's generally no particular reason why you have to shove everything into one generated file or how much you want to split them up, it's whatever you find convenient.

plush hare
#

actually my initial question was asking about both now that I think about it ๐Ÿ™‚

#

I appreciate the response though, thanks

hot gale
#

So after following the tutorial for Lightweight Portals and reworking it for Universal Render Pipeline; I was wondering if anyone knows how to make the portals recursive? Or has any ideas on how to go about implementing resurive display?

#

My one idea would be to make a bunch of cameras instead of 1 per portal that offset themselves by the next object in the chain. (first camera with offset (2, 0, 2) would result in a second camera offset by (4, 0, 4) etc) and then simply rendering to the render texture from the view of each camera starting from (i believe) the back of the chain.

#

You can see right now it doesn't really do a recursive render, just does like a ghosting effect with the portal texture from the previous frame.

quaint dew
hot gale
#

Yeah that works for 3 or more portals rendering each other but

#

I'm talking about 2 portals rendering each other multiple times

dusty wigeon
#

The one from the portal perspective.

hot gale
#

But that doesn't change the angle that it's view from.

#

If you just reapply the texture you get a repeating linear projection that might not always be correct

#

Unless I shift the singular camera, snapshot the texture, then repeat for the incursion limit

dusty wigeon
#

I mean, you have perspective inbetween your portal and your applied texture

#

It wont be linear

hot gale
#

Hmm, I'll look into that, thanks for the pointer ๐Ÿ˜„

#

If I could get my hands on the Lightweight Portals sample project that is no longer available to download I feel like this is in there somewhere.

#

But the link in the description is broken.

humble walrus
#

As far as I can tell, it's already mostly 3D, and what I'd need to do is figure out a way to assign Depth to the pixels created, based on the distance from the camera that they're being rendered at?

swift orchid
#

Hi, who know is it possible to get purchase price without Initializing IStoreListener , I don't need to manually initialize it because I already filled all purchase in editor, maybe must be way to get IStoreController without manual initialization of IStoreListener

somber swift
# humble walrus As far as I can tell, it's already mostly 3D, and what I'd need to do is figure ...

I'm sorry but I think otherwise. In theory 2D in Unity is always just flat 3D so in that sense it's kinda close but the method used simply doesn't work for 3D. They use single quad for the mesh and in the shader code they figure out whether given pixel inside the quad should be inside the line/s or not. For 3D lines an actual 3D mesh line (constructed procedurally with C# script or in the vertex shader itself) combined with a shader is the preferred solution which Unitys LineRenderer does already which makes me wonder why can't you use that?

humble walrus
mortal patio
#

Hi, I want to get access of the username of a player in the server side, which is stored in the cloud save: player data but to get access I need to log in with an admin account, I tested the ServiceAccount but there is no documentation about how to connect to the service account. I tested this method: ServerAuthenticationService.Instance.SignInWithServiceAccountAsync(); but I have this error: ServerAuthenticationException: HTTP/1.1 400 Bad Request

somber swift
humble walrus
somber swift
#

Oh I see...

humble walrus
#

Because Unity's line-renderer is using a mesh, it cannot create pixel perfect lines (by default)

somber swift
humble walrus
#

I use a blend of Propixelizer, Depth-based outlines, Color Grading, Cel-Shading, Palette-forcing, Render Texture Downscaling, and other tools to create a pixel-art style.

Here's an example Gif:

#

As you can see, there are depth based pixel-perfect outlines and colors forced to comply with a palette.

somber swift
humble walrus
#

Always one pixel thick. I can always use a mesh-line underlaying the pixel line, if I need "up close" shots.

somber swift
humble walrus
somber swift
# humble walrus Whichever is simpler to code. Even if it only creates one straight line, I can ...

I'd start from single line but I'm bit stuck trying to figure out which way would be the easiest/best way to do that. I think even unitys Line Renderer could be made to work with right shader but custom solution could be easier. Essentially the idea is to create rectangular shape like this to draw the line to and apply a shader that draws a pixel line from start to end. That shader could even use the same Bresenham algorithm that you linked in the original post

humble walrus
#

What I might do is something like...

Draw a line, using the Line Renderer, but using a shader with an HLSL that discards wrong pixels (I.E, if a pixel has a neighbor in both a row and a column, that pixel is discarded)

#

So it can be an imperfect line, but it gets "cleaned up" afterwards.

somber swift
humble walrus
somber swift
fringe root
#

Hey, im trying to use xNode which a graph tool to build a tool for skill trees. What i want to do is to change a scriptable object inside another scriptable object in Edit mode. I already have a function from the deepest SO running in edit mode, i tried calling EditorUtility.SetDirty(SO insideAnotherSO) but it doesnt change anything

sly grove
steady hornet
#

Looking for some advice.

I am creating a multiplayer game thats a simplified League of Legends. My issue on 1 thing that I may be overthinking on is what should be the best way that I implement each different kind of logic for weapon types (ex. sword, bow, wand). They would only have very simple logic like one attack button kind of deal. I lookup online and everyone has different kinds of methods but can't seem to find the right one that may suit me. Ive seen ones where it uses scriptableobjects, individual scripts, interfaces, as such. My question is, how should I go about making different logic for each different kind of weapon if the logic is simple and the amount of different weapons are like less than 5?

Edit: Another thing to mention is that maybe each weapon logic should be a script of its own to utilize those scripts being networked but I have also thought if the players script should be a manager over them being scriptableobjects and instead use networked commands from the player. I'm just so lost

untold moth
#

I'm not sure why scriptable objects are even coming up in your response. They are used for immutable data. If you had for example many items of the same type with different parameters, it would've been a good use case for SOs. Their logic however is better be put in a plain class or a MonoBehaviour.

autumn basalt
#

I'm making a multiplayer idle game with UGS C# Cloud Code Module (non-persistent server)
My idea was to make all combat logic execute on the server, to prevent cheating, but turns out that's going to be pretty hard and expensive, since I will be loading way too much stuff on the server.
I could swap to a persistent server, but I don't have the knowledge to do so right now.
I could just rework everything and keep my combat client side, using the server to do some checks for cheating.

My goal is to eventually grow my game to 10k+ active players per month, so it needs to scale well.

Any ideas or suggestions?
How big of a cheating problem am I going to have? One of the main features is going to be multiplayer trading, so having hundreds of cheaters just selling the best items in the game would be a huge issue.

scenic forge
#

Consider any code executed on the client to be already compromised, and any data coming from the client is malicious.

autumn basalt
tropic vigil
# steady hornet Looking for some advice. I am creating a multiplayer game thats a simplified Le...

If the number of weapons is small and each is unique enough to make it hard to share code, then I would go for a solution that is quick to implement. I would probably use inheritance to make sure you can call the logic of every weapon the same way, but the rest is up to you.

Everyone uses different solutions because different solutions usually fit different problems. Interfaces are great if inheritance isn't enough. Scriptable Objects are great if you want the game to be modular and easy to configure via the editor. Individual scripts are mostly for making the code (and project) clean. But for small project anything can do the job, but you will regret some solutions if you decide to increase the project scope.

scenic forge
# autumn basalt Obviously I already know that, otherwise there would be no talk about server sid...

I don't think anyone can give you an estimate without knowing all the ins and outs of your game. Giant game companies with practically infinite money hasn't solved cheating, it's not a simple problem to solve. My original comment was meant to make sure you really know the implications of moving server side code to client side, because a cheap solution that prevents 90% of the ways to cheat is still useless, people are going to cheat with that 10%.

tropic vigil
# autumn basalt I'm making a multiplayer idle game with UGS C# Cloud Code Module (non-persistent...

Server validation is the safest way, but it requires servers that can handle plenty of games. The most popular way of dealing with cheaters for big titles is to install anti-cheat on the user devices, but people have mixed feelings about those and it will also require decent knowledge about the topic (so you will most likely hire someone who knows a lot about cheating/hacking). Another solution is to store replay, and validate every match that was reported by players. It would still require capable servers, but it would be less costly (and also less effective, since you won't catch players who don't get reported).

tropic vigil
hardy jacinth
# hot gale I'm talking about 2 portals rendering each other multiple times

Developers who created the game Portal discuss problems they faced and how they solved them.

This beginner's course teaches the foundations of game development. This video is lecture 11 of CS50's Intro to Game Development from Harvard University.

Check out the full course playlist: https://www.youtube.com/playlist?list=PLWKjhJtqVAbluXJKKbCIb4x...

โ–ถ Play video
#

this is a talk by original portal devs

#

they explain how they render the portals with recursion

#

tldr: render 1 or two recursion steps, then render that to a texture and reapply

#

There will be some rendering artifacts as if the portals were "bending"

#

mentioned at 21:18

#

and they talk exactly that "it is a problem that if they spent a bunch of time they probably could fix, but in gamedev you sometimes just call it good enough and move on"

fringe root
grizzled valve
#

Hi everyone, does anybody here know if there is a way to check if there are script changes pending compilation when i have disabled "Auto Refresh" disabled in preferences? i know i can just CTRL + R to recompile but i would like some check if it can be recompiled to show me some warning in editor.

teal verge
#

hello all, i recently updated the TMPro package, i did it today, but now the scrippts gives errors, " No monobehaviour scripts in the file"

upbeat path
teal verge
# upbeat path At a guess you have a compile error somewhere

i fixed the issue, i was on 3.0.6 but updated to 3.0.9, got the errors of the monobehavior not found, then luckily i had a backup of my game so then i copyed the texmesh pro folder over from the back up to my game and renamed the version from 3.0.6 to 3.0.9

#

i even tried re installing the text mesh pro and it didnt work

upbeat path
teal verge
#

i copied from my backup folder, Library/PackageCache

#

and it works now

teal verge
upbeat path
teal verge
#

oh

#

but id have to reimport all my packages?

upbeat path
#

no

teal verge
#

huh

teal verge
#

not the .vs

upbeat path
#

see what I mean by 'knowing EXACTLY what you are doing'

upbeat path
teal verge
teal verge
#

but anyway, thanks for the info i got it to work again without having to delete anything

upbeat path
#

well you should have done, at min the TMP Essentials in your assets folder

teal verge
#

like delet the essentials folder?

upbeat path
#

yes, and reimport it using the modified version of TMP

teal verge
#

oh

#

but i had the problem of the script **Inside **the **Packages **folder

#

like isnt the essentials package non requiring?

upbeat path
#

that does not mean that that is where the problem originated. Also does it make sense to you to have 2 different versions for the TMP package and the TMP Essentials that uses it

teal verge
#

because i opened the Tmp essentials import package inside the Tmp Packages

upbeat path
#

yes, of course, if you change the version of TMP you should also change the Essentials version

teal verge
#

but it didnt resolve

teal verge
near otter
#

Hello all. I am struggling on what I should do to make this possible. I want to have a gameObject that is a mounted LMG and the player can press F to interact with it. When this LMG gets interacted with by a player, the player will be locked in place (in this case, it will set FPSController's canMove bool to false) BUT the player's main camera will become a child of the LMG and simultaneously the LMG will be a child of the player's hands, which is a child of the player's main camera. Whenever the player looks around with their mouse, the LMG will also follow. Or rather, the player's camera is "mounted" on the LMG so wherever the LMG points at is where the player camera looks at. I think my line of thinking here is wrong and there is definitely a way that's 1000% better than what I have in mind. I need help regardless

Here's all the code I have so far:
MountedLMGTest https://hastebin.com/share/uzegeworow.cpp
Interactable interface https://hastebin.com/share/hequpeyera.csharp
FPSController https://hastebin.com/share/sowexutaga.csharp

I changed channels because I'm pretty sure this is advanced coding? No idea

sly grove
compact ingot
#

Youโ€™d only make the gun mode a feature of your walk-controller if they are very tightly integrated in terms of gameplay, say if you can pick up a heavy gun that overrides a bunch of movement options. But even then, your controller should represent that as an explicit state internally with the explicit state-enter/-exit actions

#

If you do this, then you can bind gameobject hierarchy activations and individual objects to these states. Instead of changing parenting, youโ€™d rather switch out the entire walk-player avatar for a gun-avatar. This should make it easier to change those avatars without always having to make changes work in all states, and without hacks to achieve this compatibility

languid sequoia
#

Having a really weird issue that Copilot seems unable to solve. I am running through a CSV file using script CSVHandlerScript and calling on the CreateUnit function in the CSVHandlerScript with this code:

using System.Collections.Generic;
using UnityEngine;

public class WearySoldierBtn : MonoBehaviour
{
    CSVUnitHandler handler = new CSVUnitHandler();

    // This function gets called when the button is clicked
    public void OnButtonClick()
    {
        // Create a unit with ID 1 at position (0, 0, 0)
        handler.CreateUnit(2, new Vector3(0, 0, 0));
    }
}```

I don't see an issue with this, as I have a model located in the correct folder with the name "2", as well as a unit in the CSV file (second row) with an ID of 2.

Here's the CSV file. To what I can tell, there's no issue with it, but maybe a more attentive eye can spot one:
#
Lousy Soldier,2,Attack,90,90,80,7,90,50,0,0,0,35
Fragile Soldier,3,Attack,20,120,100,6,60,35,0,0,0,30
Mediocre Medic,4,Medical,20,0,40,8,90,50,0,0,0,30
Balanced Soldier,5,Attack,120,100,80,8,120,80,0,0,0,40
Brute Soldier,6,Attack,150,50,90,5,150,85,0,0,0,50
Archer Soldier,7,Attack,50,150,140,8,80,60,0,0,0,50
Mechanic,8,Medical,80,20,60,9,130,100,0,0,0,60
Medic,9,Medical,80,20,60,10,120,100,0,0,0,60
Valorant Soldier,10,Attack,140,120,120,8,130,80,0,0,0,60
Nimble Soldier,11,Attack,100,100,200,12,60,80,0,0,0,50
Giant Soldier,12,Attack,200,0,80,5,220,200,0,0,0,120
Gunman,13,Attack,90,160,160,8,120,100,0,0,0,60
Wizard,14,Attack,80,100,100,8,100,100,0,0,0,120
Cloaked Soldier,15,Attack,120,90,140,12,80,100,0,0,0,120
Trade Camel,16,Transport,0,0,0,7,150,50,0,0,0,50
Donkey,17,Transport,0,0,0,10,200,40,0,0,0,30
Horse,18,Transport,0,0,0,18,250,75,0,0,0,60
Elephant,19,Transport,50,0,0,8,350,200,0,0,0,120
Cannon,20,Siege,80,0,0,4,100,0,300,100,100,80
Flaming Pellet Launcher,21,Siege,20,0,0,6,120,0,500,150,150,100
Catapult,22,Siege,100,0,0,3,250,0,600,200,150,120
Battering Ram,23,Siege,200,0,0,5,400,0,600,300,0,120
Villager,24,Villager,50,0,50,8,60,30,0,0,0,30```
#

Here's the CSVHandlerScript code as well:

using System.Collections.Generic;
using System.Text;
using System.IO;
using UnityEngine;

public class CSVUnitHandler : MonoBehaviour
{
    public GameObject UnitPrefab;
    public Dictionary<int, GameObject> unitModels = new Dictionary<int, GameObject>(); // Holds models
    private Dictionary<int, string[]> unitData = new Dictionary<int, string[]>(); // Holds Unit ID as key and Attributes as String[] arrays
    public int unitCount = 0;

    void Start()
    {
        GameObject[] models = Resources.LoadAll<GameObject>("/_Models/UnitModels");

        // Add each prefab to the dictionary
        foreach (Gam```
#
            int id = int.Parse(model.name);
            Debug.Log("Loaded model with ID: " + id);
            unitModels[id] = model;
        }

        string filePath = Application.dataPath + "/GameData/UnitData/units.CSV";
        StreamReader reader = new StreamReader(filePath, Encoding.Default);

        while (!reader.EndOfStream){
            string line = reader.ReadLine();
            string[] values = line.Split(',');

            //Store the data in the dictionary with the ID as the key
            int id = int.Parse(values[1]);
            unitData[id] = values;
        }

        reader.Close();

        if (unitData.Count > 0)
        {
            Debug.Log("Unit data has been loaded.");
            foreach (KeyValuePair<int, string[]> entry in unitData)
            {
                int id = entry.Key;
                Debug.Log($"Loaded data for unit with ID ({id}): {string.Join(", ", entry.Value)}");
            }
        }
        else
        {
            Debug.Log("Unit data was not succesfully loaded.");
        }
    }

    public (int[], float) GetCostAndTime(int id){
        // Get the data for the unit with this ID
        string[] data = unitData[id];```
#
        int[] cost = new int[] { int.Parse(data[9]), int.Parse(data[10]), int.Parse(data[11]), int.Parse(data[12]) };
        float time = float.Parse(data[8]);

        // Return the cost as an array of ints and the time as a float
        return (cost, time);
    }

    public void CreateUnit(int id, Vector3 position){
        if (!unitData.ContainsKey(id)){ // Ensures there's a unit with the ID provided
            Debug.LogError("No data found for unit with ID: " + id);
            return;
        }

        if (!unitModels.ContainsKey(id)) // Ensures there's a model for the unit trying to be made
        {
            Debug.LogError("No model found for unit with ID: " + id);
            return;
        }

        // Get the data for the unit with this ID
        string[] data = unitData[id];
        Debug.Log($"Data for unit with ID {id}: {string.Join(", ", data)}");

        GameObject unitObject = Instantiate(UnitPrefab, position, Quaternion.identity); // Instantiate the prefab

        Unit unit = unitObject.GetComponent<Unit>(); // Get the Unit script attached the the game object

        GameObject model = unitModels[id]; // Get the correct model for this unit
        GameObject modelInstance = Instantiate(model, unitObject.transform); // Assigns model to new Unit as child

        // Set the name of the modelInstance to match the ID of the Unit
        modelInstance.name = id.ToString();

        // Set the attributes of the game object based on the data
        unit.name = data[0] + " (" + unitCount + ")";
        unit.ID = int.Parse(data[1]);
        unit.type = data[2];
        unit.melee = int.Parse(data[3]);
        unit.ranged = int.Parse(data[4]);
        unit.atkSpd = int.Parse(data[5]);
        unit.speed = int.Parse(data[6]);
        unit.health = int.Parse(data[7]);
        unit.unitCount = unitCount;
        unit.team = 1;
        unitCount++;
    }
}```
#

For additional context, the debuggers show that each unit is being loaded correctly and with all of it's data. I then get the debugger No model found for unit with ID: " + id, with the ID being whatever the btn calls on (when I click the button that calls on the WearySoldierBtn script).

Issue persists after trying different IDs. No clue why it isn't able to read from the dictionary when it's populated correctly. Any help is greatly appreciated.

languid sequoia
#

Something's got to be wrong with this portion of the code:

        if (!unitData.ContainsKey(id)){ // Ensures there's a unit with the ID provided
            Debug.LogError("No unit with ID: " + id + " found.");
            return;
        }```

Or it has to do with the dictionary not being populated correctly, even though it seems like it is.
compact ingot
languid sequoia
compact ingot
#

Nvm, not gonna fix AI generated code issues

languid sequoia
#

Isn't able to find a key in the dictionary equal to 1

languid sequoia
#

I said I asked copilot to fix it

#

It wasn't able to

#

Unbelievable

tall ferry
# languid sequoia Isn't able to find a key in the dictionary equal to 1

Honestly I dont even see what the question is when reading through everything you wrote. Seems like the only thing is "there's an issue" but you have no clue what. You should be able to directly see what the dictionary contains with the debugger, are you actually using the debugger because based on your words it sounds like you're just using debug.log but calling it the debugger.
This is most definitely not a #archived-code-advanced issue.

languid sequoia
#

There's no issue with the CSV, and I added a debugger to list each unit when it's added and it also looks perfectly fine.

fresh salmon
#

It can make sense if CreateUnit is called before Start is executed, ie. you have an execution order issue

languid sequoia
#

It isn't, the debug.log listing all added units gets called, then I click the button.

tall ferry
languid sequoia
#

I have went over this multiple times, followed it through the process and added debug.log for each step. It makes zero sense how it can't find a key in unitData with the value of 1 or 2. Capitalization also seems perfectly fine in all instances when referencing unitData, nor do I see any syntax errors, and there are zero compiler or runtime errors.

#

Not expecting anyone to do the work for me, but this has been my last resort and even tried Copilot, but no luck.

untold moth
#

I'd also say that it's not an advanced issue. The fact that ai is not being able to solve doesn't make it an advanced issues. AI is pretty far from being an advanced programmer at the moment.

wide mulch
#

Is there a way to run a piece of code when a value is changed in the editor

dark orbit
#

Rule Proposal: if you don't know how (and aren't willing to learn how) to use debugger, your question can't go in #archived-code-advanced.

#

@languid sequoia without an exact replica of your project we have no way of knowing what interactions are happening outside of snippets of code you provide. But you probably have two instances of your CSV handler class and one has not been initialised. Start runs on one and not on the other, and your query happens against the one that has not been initialised.

Given you do this...

CSVUnitHandler handler = new CSVUnitHandler(); (instantiate a MonoBehaviour with new)

... it seems quite likely.

Instantiating a class this way wouldn't invoke the Start method, so it is probably another instance in the scene that is doing the initialisation and showing you your log statements.

autumn basalt
#

I'm sure some people will still be able to find it, but it should discourage most beginners?

#

I kinda still wanna split up _encryptedValue into two variables that you need to add together

scenic forge
#

Finding it is still easy, the same changed/unchanged filtering will find it easy enough. Modifying the values will be harder unless cheater knows the algorithm, but even without knowing the algorithm they can still cheat by freezing the values, so they can never lose (or gain) health, money, whatever.

#

This will also probably slow down your game quite a lot and create a ton of GC pressure.

autumn basalt
#

You think performance will be an issue with this? It's not like I'm using the variable 50 times, probably just like 4-5 of them in my game

sly grove
#

How often are they used and for what

autumn basalt
#

I will also update the offset and multiplier in the Update() function regularly, so you cannot just look for non-changed values

scenic forge
#

Every read and write to your hidden int will create tons of garbage.

autumn basalt
sly grove
#

Also how and where does your game use the decrypted value and what stops the cheater from simply changing that?

scenic forge
#

_encryptedValue.ToString() creates garbage, concating the strings creates garbage, SHA256.Create() creates garbage, Encoding.UTF8.GetBytes, sha256.ComputeHash, Convert.ToBase64String, all create a ton of garbage.

#

GC will be working overtime with this.

tall ferry
#

This is definitely not performant, but if we're talking 4-5 values changing per second then yea you wont notice anything tbh. But this solves nothing for cheating

autumn basalt
scenic forge
#

Yeah the performance hit by itself isn't really the problem, but the GC pressure is very dangerous. When GC can't keep up with allocations and have to pause the world to clean up, that's how you get frame skips and stutters every few seconds of your game.

tall ferry
#

I assume this was the "client side anticheat" part rather than a server doing this per user

autumn basalt
#

it's a 2d game and not really that visual since it's an idle game, there's no characters running around or anything, just basically a character attacking monsters once per second

autumn basalt
scenic forge
#

But yeah this doesn't prevent cheating like at all, find the memory location using the changed/unchanged technique, freeze the values, buy a bunch of stuffs, unfreeze the values, sell the stuffs you bought, and boom cheaters have infinite money.

autumn basalt
tall ferry
autumn basalt
#

and I will add a monitor function that if the health suddenly changes in a weird way then I can tag the player as a possible/probable cheater
since it will be hard for them to find the right variable to edit exactly the right way

#

I hate this as much as you do btw ๐Ÿ˜ญ
But I just need to get my game done and the server stuff is too complex for me at this time

scenic forge
#

The moment it changes, pause the game (as in not your in game pause, but using CE to pause your entire process), and search for changed values. Unpause and then immediately pause again before the value changes, now you can search for unchanged values.
Now you might say, okay I'll also check for system time and detect if there's any time skip, and IIRC CE also has way to scan for continuously increasing values.
Ultimately you are just going down a rabbit hole, at some point you have to draw the line and say "yep I can't do this anymore and anyone made it past this point will just cheat."

tall ferry
autumn basalt
autumn basalt
scenic forge
#

Is multiplayer/economy an integral part of your game, can you pivot and release your game as single player at the start? Since you do not have the resources to build one right now, it might be worth considering just doing that, and if single player is successful, add multiplayer and economy afterwards while you are already making money from the single player version to sustain your development.

autumn basalt
#

and as my game gets bigger I will most likely invest in something like Easy Anti Cheat or something similar
you got any ideas of pricing for that?

scenic forge
#

Okay then if you are going that plan, then just focus on single player and no anti cheat at all because who cares about cheating in single player.

#

When you develop the multiplayer version, do it properly with server logic and don't go down the client side anti cheat rabbit hole.

tall ferry
# autumn basalt obviously I'm not going to add an auto-ban to an untested method I might just ta...

With what you're doing, its not even protecting against beginners. Its just preventing against the cases you can think of. Like someone modifying this encrypted value rather than the actual value, yet you said there will only be 4-5 uses of this around. People will try it on like every single value they want.
Also i never said untested, i am talking about logic flaws. You would be silly to think your game wont have any. Massive games like league of legends has them pretty much every day (literally)

scenic forge
#

With single player already released and you have a sustained income, you won't be forced to take shortcuts and make bad decisions regarding multiplayer's development and can do it right.

autumn basalt
#

only the encrypted value is stored to memory

autumn basalt
tall ferry
# autumn basalt only the encrypted value is stored to memory

That doesnt matter, I am saying people will try editing literally every value for fun. If you mean that you're literally only storing 4-5 ints in the entire game then I guess thats different. But surely with a trading system, you're already having more than that

autumn basalt
#

items will still be stored on the server, not on the client

#

and the server will validate them

tall ferry
#

A ton of games start single player then go multiplayer. You should really just consider taking a step back because this goal cant just be accomplished through pure willpower. If the economy is ruined by cheaters at the start, you wont have a game to expand on. And you definitely wont have players if you reset the economy when you finally implement a proper solution

autumn basalt
#

I'm planning to work with seasons of a few months (4-6) anyway, so resettting the economy won't be an issue

#

I'll think about going pure single player

sly grove
autumn basalt
scenic forge
#

They would have to use HiddenInt.Value every time they want to access it. Storing the value into variable on stack is fine and will avoid some performance penalty.

flint sage
unborn otter
#

any less stupid way to collect internal id from texture that is set to multiple sprite mode ?

#

i tried searching for internal function / variables to retrive the interal ids but no luck

unborn otter
#

life saver ! thanks bro

tired fog
ashen yoke
#

Hi the other day I went down the rabbit hole of Events keeping references to classes that have subscribed to them unless they unhook their delegate in the finalizer or OnDestroy for MB. Seems Microsoft realised this was a shortcoming of C# and introduced a WeakEventManager in Windows/WPF!! Also found a list of C# ppl discussing if it could be part of C# in future but it seems they only exists in various forms in github. So has anyone used a system for events/delegates that avoids the need to unhook listeners?

#

(not very Unity)

scenic forge
#

Oh I was like this conversation seems familiar, and it turns out it was you that asked about it earlier. I've answered you with an approach in the other channel that doesn't involve a reactivity system, but here's one that does: #archived-code-advanced message

ashen yoke
scenic forge
#

Last time I looked into weak reference related stuffs, they were either not available in Unity, or have issues with IL2Cpp.

ashen yoke
#

OK yes that kinda follows the pattern I was working toward - I mean unsubscribing in OnDestroy was my starting point and fixed any scene to scene issues I had!

midnight shell
#

Hey, I have this async method that breaks Unity and build. Generally, what happens, is that if I enter play mode, run this method, exit play mode and try entering play mode again - Unity gets stuck on reloading domain, for about eternity. In build, when I try to close the game, after running this method, the app just freezes and goes white. Here's the code:

    public async void NATPunch()
    {

        var discoverer = new NatDiscoverer();
        using (var cts = new CancellationTokenSource(2000))
        {
            var device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
            if(device == null)
            {
                using (var cts2 = new CancellationTokenSource(2000))
                {
                    device = await discoverer.DiscoverDeviceAsync(PortMapper.Pmp, cts2);
                }
            }
            if (device != null)
            {
                await device.CreatePortMapAsync(new Mapping(Protocol.Tcp, port, port, "Game"));
                await device.CreatePortMapAsync(new Mapping(Protocol.Udp, port, port, "Game"));
            }
        }
        Debug.Log("TEST");

        return;
    }```
Of course, the function gets to the end, it prints "TEST", so I understand it should finish normally... yet it causes problems.
Any ideas what might be wrong?
sly grove
midnight shell
#

Windows

sly grove
#

Probably something like the first run is grabbing and holding onto the ports or connections

midnight shell
#

there is also a function for closing ports, and they are closed, as i've checked

sly grove
#

things can get weird with threading

#

are these Devices also IDisposable?

midnight shell
#

from what I see, it's an abstract class

#

I am using Open.Nat here, doing all according to their tutorials (and trying otherwise too)

midnight shell
dapper cave
#

we have RaycastCommand to batch a bunch of raycast in a job, do we have similar things for Overlapsphere and ClosestPoint? (without using Unity.Physics ๐Ÿ˜‰

dapper cave
sick rapids
#

Anyone use perforce with unity before? I've got two streams, a main and a dev, and I was wondering since I need a workspace for each, does that mean I need a unique unity project for each stream/workspace?

untold moth
sick rapids
#

Have you ever run into issues where certain project settings (like input system) or maybe even asset store assets (like odin) aren't properly committed/shared across users in perforce?

Must be a p4ignore issue?

untold moth
sick rapids
untold moth
# sick rapids Do you mind sharing your workflow? I was attempting to setup a sort of Release ...

It's not really "my" workflow, but at work we have different streams for dev, prod, qa. Changes from dev get merged to qa and later to prod.
That being said, we only use perforce for assets and for code Plastic. I should note that it's not a unity project. It's using a custom engine, so we have the the assets separate from code. I'm not that how feasible such an approach would be with a unity project.

To be honest, I wouldn't really use perforce for source code.

supple magnet
#

I'm trying to convert this breadth-first search algorithm I have been using from vanilla C# into Unity Jobs. From I can gather in the docs, the Jobs System should be scheduled inside Update() and the result can then be used in FixedUpdate(). Does that mean the job will always take at least 1 frame to finish? I assume this is the intended workflow for Jobs?

Or can I just do Schedule() then Complete() from anywhere in the main thread (not necessarily inside Update())?

rugged radish
#

it's not required to call schedule or complete inside Update

#

you can also Complete immediately if you want

tropic vigil
# supple magnet I'm trying to convert this breadth-first search algorithm I have been using from...

The duration of an asynchronous job depends on how much work it has to do. In a pessimistic scenario, it could take more than 1 frame to finish. You can call it wherever you want, as long you're in the main thread.

Also keep in mind, that FixedUpdate isn't synced with Updates. Update is called once per frame, FixedUpdate is called once per whatever interval you have set in your settings. I think using Update and LateUpdate would make more sense (since both are called once per frame). But still, with async tasks you can't be sure that they will be finished on time.

vestal condor
#

does anyone have some guidelines for how to use LocalizedString without introducing too much coupling
i feel like adding a GetLocalizedString() method for a bunch of classes will add a lot of coupling between my classes and the localization package

dusty wigeon
spring sleet
#

I'm trying to make a map similar to slay the spire by following this tutorial https://medium.com/@1basudevpatel/random-paths-in-gamedev-beatdown-a913a1d8c5e6

I've done the first step of creating nodes, now I should weld the nodes but its not working as i expected

public void WeldColumns()
{

    int randomColumn = Random.Range(0, nodesInColumns.Count);

    List<Node> chosenColumn = nodesInColumns[randomColumn];

    if (chosenColumn.Count <= 1)
    {
        Debug.LogWarning("Not enough nodes in the chosen column to perform welding.");
        return;
    }

    int randomRow = Random.Range(0, chosenColumn.Count - 1); 
    Node node1 = chosenColumn[randomRow];
    Node node2 = chosenColumn[randomRow + 1];

    // Average the positions
    Vector2 newPosition = 0.5f * (node1.position + node2.position);
    node1.position = newPosition;

    
    // Remove node2 from the column
    chosenColumn.RemoveAt(randomRow + 1);
}
#

that's what i have after calling WeldColumns() like 10 times

#

Here is what im trying to achieve

dusty wigeon
spring sleet
#

while my intention was this, I'm probably messing up some some column indexes but i have no clue

spring sleet
#

Ok turns out i was holding rows in my nodesInColumns list.

tropic vigil
#

I'm trying to make my code more generic.

public class AttributeType <T> : AttributeType
{
  public virtual T ModifyAttributeValue()
  {
    // Does something
    // Returns some value as T
  }
}

Is it possible to run ModifyAttributeValue from AttributeType without knowing its generic type beforehand?

upbeat path
#

you can cast the returned T to object

tropic vigil
upbeat path
tropic vigil
scenic forge
#

What is AttributeType?

upbeat path
#

of course you can

AttributeType at = new AttributeType<MyClass>();
---
object o = (object)at.ModifyAttributeValue();

I would be tempted to have a Convert method like this

public T Convert(object o) {
   if (o is typeof(T)) return (T)o;
   return default(T);
}

then you can convert back when you do know the T

tropic vigil