#archived-code-advanced
1 messages ยท Page 105 of 1
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?
ofc
because i have stuff like class Character { Pathfinder pathfinder; }
and the pathfinder has many maaany params
tbh it's easy enough to write a generic solution using Reflection
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
well, this is code advanced, you should have those skils
it takes time. its not about performing, just too much headache. maybe someone knows a better way
Join the Odin Discord server and ask if their asset does it
i mean its an option, just postponed
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?
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?
Yes this is all exactly what the Grid component is for. Play with it a little and check out the scripting documentation for it.
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
I saw you post this yesterday or day before and was rolling it over in my head.. I don't think it should be the case, but maybe the directory names having underscores _ in them is causing issues with the compiler? Seems unlikely, but... ๐คทโโ๏ธ
yaml things!
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
Was this the convo about embedding reward vouchers in a token without a central database?
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
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
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."
Gave it a try but that wasn't the issue, thanks for thinking along though!
do you have any weirdly named directory structure stuff? ie, things with spaces, special characters (other than _) etc?
Weirdly enough my colleagues (project is shared through github), they also got the error but they can actually build
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
C:\Users\robin\Curiosmos\Project\Curiosmos\curiosmos_unity\Assets\Scenes
there's some issues with windows and long directory structures
not too long
ok
any virtual directories there? like your c:\users\robin dir mapped to another drive or something natively in windows?
no everything straight on the C drive
it's also fair to note that the error randomely started appearing while the project and scene had been working months prior to it
just github and github desktop for me locallly
the others use gitKraken I beleive but shouldn't really matter
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)
no , nothing I can think of
gimme a logic bug any day of the week
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
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
but they do also get that error message when they open unity, it just doesn't stop them from building
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
also, the scene has been udpated today and the error jumped lines too and too completely different ones
Like suddenly it's line 314
Yea I read on a forum with people having the same issue and a missing script was causing it, I've used a script to find any missing scripts in the project but there's non present
Hi,
we are experiencing a problem with a MonoBehaviour with LocalizeStringEvent on it. On loading the scene, Unity reports an error in the console:...
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 ๐
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
cheers glgl
is there a way to remove those three buttons from terrain ui?
this is not a code question, and this also sounds like one hell of an XY problem
why are they an issue?
it's a custom editor window code question ig
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
@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.
right now i just use tons of small terrains, and i play with base map resolution
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
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.
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
Oh, I see. Do you need all of these tiles to be rendered at once?
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
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
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
Just to be sure, you know your alpha map has a single channel? What format are you using?
and for 512x512(i'm currently using it) it's 4k alphamap and 144 objects
i mean
splatmap
or how is it called
with layer weights and stuff
bmp, jpeg, png are formats. A splatmap (or control map) is a method.
Ah okay, that's what I was looking for. Thanks.
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
Just to be clear, that's not a URP restriction, that's a terrain system restriction. You can get around it.
hdrp has own shader
which supports up to 8 textures in a single pass
at least that's what unity docs/forums stated
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.
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
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.
and well, in case of skyrim they use a cell system, where each cell is around 58x58 unity units
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.
i have 10 instances of calc running for a month now
Yeah, I wanted to check. ๐
well, shouldn't it stay in ram/vram in order to be rendered?
So I do have some ideas for how you can get a good result, including borrowing from games like Skyrim for inspiration.
dms maybe
Heightmap ultimately affects CPU things while control (VRAM) is just graphics.
or a branch
Sure, either sounds good for me.
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 ๐
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)
I'm not using any rigidbody stuff, I'm only using stuff i've created myself
I have witnessed perfect recreations sometimes, but other times shit just breaks
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
(and the kinematic character controller from the asset store, but the actual simulation stuff was made myuself)
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
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++;
}
}
(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
I've got something which stores the player states and velocities here. as you can see theyre floats, and theyre similar but not perfect
well there's your problem ๐
im not sure how to solve it, though ๐ญ i've done all i can to ensure things are the same
unless i missed some things, which is why i wanted to ask here
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
I'm using a package called the KinematicCharacterController, which has a "motor" of sorts which i use to simulate things.
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
could be good, but then wouldn't it look super janky?
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
I suppose, im just not sure how i'd implement something like that
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
its left/right
public class Player
{
public int Position {get; set;}
}
Done! ๐
(but honest, that's the basics.. you just have a specific integer based position)
but then how would i translate that to a position in the world?
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
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
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
will definitely take into account
but trying to do determinism with floats, especially those not 100% under your control is gonna be a bad time
to summarise, you want me to use a integer position system instead of using the default transform system
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)
okay, thanks for your insight! definitely something i'll put on my board, as I want to get into the world of online networking and was recommended making a replay system as a good precursor. Out of curiosity, do you know how it could be possible to take more control of floats?
don't let other pieces of code touch them ๐
oh right ๐ญ
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
Would you say it will be tough to transfer to an integer coordinate system? And how would I actually use that to move the rendered player?
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)
I think your best bet is to assign whatever position value you work with back to the object's transform, and ultimately that's the best you can get. There are libraries out there that promise deterministic computation using custom data types, but they certainly come at a cost to use.
using something like this?
#archived-code-advanced message
Using integers is a good solution, but won't provide as much value space as floats (or doubles). Many people have tackled this problem with doubles with success. If this solution works for you, I'd go for longs. Good luck!
thanks! may i ask why floating numbers have this issue and doubles and longs don't?
Sure! It has foundation in why we call a float a float. It means "floating point number", meaning the place where the decimal point can shift and so the format can either represent large numbers, small numbers (as factors) or a combination between the two.
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.
ah i see. I thought floats were bad because computers were bad with precisions with high decimal point values or something
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
https://youtu.be/exqlMRLTESA?t=918 @tranquil terrace
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...
Check the timestamp - I have a demonstration of this inaccuracy at work.
thanks! will watch in a second. Wouldn't storing the positions as doubles cost a little more, though?
especialyl for multiple objects, as i plan to use this system for projectiles too
It's not a big deal in most cases. A lot of games use doubles for spacial coordinates (such as Star Citizen) because it's required for their purpose. This doesn't entirely solve determinism, mind you, just tackles a common piont of failure where things often go off the rails.
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.
interesting! shouldnt be too hard i think to use doubles. then again, im not really sure where to start lmao ๐
For vector use, consider using the System.Numerics namespace instead of the UnityEngine one for most of your maths. The former does use doubles internally.
i see. I'm just confused as to how i would start initially. maybe convert the vector3 to a vector 3 double at start and then use that from then on?
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.
Assign transform.position = myScientificPosition and never the other way around.
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.
i see. I meant like just at the start, grab the transform, turn it into a vector 3 double, and then use that as the calculations to set the transform position
idk if im saying it right
Ideally, assign to your own component and have an editorscript write to the transform.
whats an editorscript, sorry?
These are C# scripts that control how objects act in edit mode in the unity editor rather than in play mode.
See https://learn.unity.com/tutorial/editor-scripting and also #โ๏ธโeditor-extensions for specific help.
i see. I'm just confused as to how this helps calculate the starting position, though?
If you don't need a deterministic read for starting points, you can copy the transform position to your own system on awake if you want.
Yeah i probably don't need the starting points done deterministically, as they'll always start at a predesignated point.
If you can save/load positions, that could require a bit more care, just saying.
its a fighting game, so im not doing stuff like that
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 ๐ญ
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.
Are we talking about the positions that come out when you replay the recording? Or are you talking about trying to do the same thing twice from some base state and the numbers are coming out differently each time?
Yeah, this.
positions are coming out differently when i replay the recording. the recorded state is the original game that i played and the simulated state is whats happening in the replay currently.
So how are you replaying the recording? What's that code look like
For that matter
how are you recording them
let me break out the pastebin one sec
Are you using Rigidbodies?
no, theyre all kinematic
does your typical object movement happen in Update or FixedUpdate
i've made a conscious effort to put literally everything simulation specific into fixed update
Are you controlling the execution order here?
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
yeah. im trying to make perfect replays as a precursor for online multiplayer
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;
}
how do you normally populate currentInputPacket
using the new input system here
https://gdl.space/enesikonuc.cs
ignore the select ones
they are for something esle
How are you telling if there's a desync?
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
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.
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
iirc this happend when you installed IAP. So there is obviously an incompatible .dll file in the IAP you installed. try to locate which one it is
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
recorded a comparison video. as you can see, it seems to get a bit desynced when you hit the floor?
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
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
How can I give a billboard sprite thickness like was done in the Paper Mario TTYD remake?
use a mesh
what system are you using to perform character movement?
I only skimmed through this, but from the looks you're going for lockstep netplay/replay to drive the game?
basically, yeah. I'm using this kinematic character controller that i found on the asset store, and im manually deciding how characters move by augmenting a vector3 using this static class i made.
https://gdl.space/fizomamije.cs
most/all of the methosd takes the current velocity as the first parameter and then augments it.
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)
i see. thanks for this insight, i'll start on that later ๐ just taking a break from the game to play the elden ring DLC
so what your suggesting is calculating my own physics stuff using doubles or whatever? and setting those values into the transform afterwards?
no doubles, no floats, only integers
double is just a floating point number with more bits
oh i see, i think someone else recommended that to me earlier
so like 1 int would be 1 mm for example?
would be one way to think about it, or one pixel, or .1mm, really depends on how you want to scale it
my only issue is that im not sure how i would calculate the starting point of the simulation. maybe i'd turn the float into an int or whatever? i'm just thinking maybe, from 0,0,0 , 100,000 would be equal to 1 in the game space or something
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
whats a toolchain sorry? and i just thought of a way to calculate the starting point i'd just calculate it in my simulation space to start with lol
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
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
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
i should have full source access, if by that you mean access to every script or whatever? the asset is open source
yes
okay
i will have to do that then. seems like i've got a lot of work cut out for me ๐
can i just do that, though? just replace the values and everything works out of the box? i hihgly doubit it
writing a deterministic game is only one of the hardest things you can do, glhf!
it's the same math
or rather, the same algorithm
BUT
if it calls out to unity physics anywhere, you need to hook into your own deterministic physics solution
great ๐ญ I didn't realise i was putting myself through this, but im up for the challenge
should be a good learning oppurtinuty
just realised, im using Physics.Checkbox to check for the ground, surely that wont be a problem right ๐ญ
or do i need to make my own check stuff
aabb is 5 lines of code
aabb?
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
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
๐ญ let me try anyway and see what happens, isnt deltaTime time between frames?
https://docs.unity3d.com/ScriptReference/Time-deltaTime.html
When this is called from inside MonoBehaviour.FixedUpdate, it returns Time.fixedDeltaTime.
if im running unlocked fps surely that would be different than the fixed update
ah shite. How does it know its being run inside fixed update?
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
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
you cannot use that
it's a float
can anyone here recommend any fixed point math libraries i can use?
im assuming i cant use standard physics colliders or whatever
damn it man ๐ญ how am i meant to do stuff like mesh colliders then
If determinism is the goal.
you aren't unless you want to implement gjk
๐
What's that?
my fighting game engine prototype only support point in aabb and aabb aabb collission
a collission detection algorithm
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
anyone recommend any fixed point libraries?
Hi, I downloaded for the first time and I can't open a new project
This isn't a coding question - #๐ปโunity-talk would be a more appropriate channel. But you should check if the specified executable is in the detailed path - if it's not, you might uninstall and reinstall the editor
not a code question and please do not cross post
I know it's just frustrating that it doesn't work,sorry
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);
Add BindingFlags.Instance if you want instance functions, and/or BindingFlags.Static if you want static functions. Otherwise it won't find either.
thanks, works now. Thought that BindingFlags.Default already contained instances
Default is basically "find nothing" 
anyone know any tutorials for making custom fixed point physics systems?
Those are separate things. You wouldn't implement a physics system differently with fixed point vs floating point. It's the same math and problem solving, just a different numerical representation.
okay, well are there any fixed point libraries you'd recommend?
i know photon quantum has that but... that's a whole networking solution
i plan on using coherence for my networking
No. There aren't many out there for C#.
It's hard to implement optimized math functions like sqrt, sin, etc. with fixed point numbers. At least when you compare it to float, which has dedicated FPU hardware instructions for everything.
thats annoying. Im trying to make deterministic simulations for my fighting game for networking / replay system
Someone could help me with a terrain generation?
Is anyone here good at kinematics?
Oh, wait, there's a #โ๏ธโphysics channel
nvm
Actually ask the question there, instead of asking if anyone is good at it
Well when someone answers the first question then I can ask them the question I had
Don't do that
There is a whole website explaining why to never do that
WHY IS THAT A WEBSITE DOMAIN XD
Because it is a common thing people do, which no one should ever do
Alright
i've learnt from it
I don't think anyones in #โ๏ธโphysics, do you know how to make a foot move like a foot?
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
Well, it takes time for people to answer usually.
But I need more explanation. First, what do you mean "different game... different system"?
I'm in Garry's Mod using Wiremod
I could recommend anything from using IK to the animator... oh
Oh, well this is the wrong server then
Because it will not be the same. It will work pretty differently
The server for wiremod is dead, it's just using math and basic functions
Well, that is not how it works in unity
In Unity you use unity components (or assets like IK), generally not just math
The idea of components transfers to Gmod pretty well with entities
This isn't the place for non-Unity related questions.
Alright, I'm moving it to #โ๏ธโphysics
This entire server is not the place for non-Unity related questions.
It's a math question
Unity has relation to math
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.
Well why are you arguing when I asked a question?
Move on, this conversation has finished.
Cool
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...
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.
Unity is, by default, single threaded, so EVERYTHING runs on the main thread
I have database requests and responses that should load scenes afterwards. How do I handle that?
On the basis of that information, you don't
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?
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
good point
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
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
Not if you are building to WebGL
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
Yes if your target platform doesn't support threading then obviously you can't do threading
https://github.com/Cysharp/UniTask is a common utility to help with threading things
you do not need to keep a complete scene loaded, you can use DDOL objects to persist states between scenes without the overhead
boot and global scenes are only containing ddol objects. does not has overhead
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)
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
wdym, OnEnable and OnDisable work for So's
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
do you have domain reload turned off?
yes
there you are then, don't
but i cant live with the huge loading times, how can i manually get a callback on start then?
Seriously? 'I want Unity to run for my convenience but I dont want to deal with the consequences of doing so'
it said that i just have to handle it on my own. Thats what i asked for, the way of how to handle it on my own
I would suggest you address the root cause of the problem. Why do you have 'huge loading times' in the first place?
because i have a huge project. There is no point in optimizing it
its Unity, hope they finally improve that in the future
huge project is no reason to have huge domain reloading times
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
and have you implemented a single asmdef or dll?
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
so the problem is your computer not Unity
you mean my Macbook m3 max is the issue?
if it takes 10 secs to load an empty project, absolutely
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
What even is this conversation
I'm not sure I ever claimed that but I do know how to configure my hardware, OS and software environment for optimal use in development
It went from how do I do x to blaming them?
I'd try to use the play mode changed callback to invoke some method on game start
how do you register that?
Ah I see
It's the reality of having no domain reload unfortunately
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
Yeah that's fair
didnt thought that its such a huge thing ๐
It's very much a thing that works, until it doesn't and it's a chunk of effort to work around it
At what point in the project did you disable domain reload? If you have a lot of code written with domain reload enabled and have only since disabled it, it's possible there are many more hidden bugs.
I fixed all of them already, i either handle them on my own and get more performance out of it
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
Oh, okay. I wish I could have your confidence. The nature of the domain reload bugs is that it can be difficult to spot, doesn't necessarily lead to errors in the console. And since you just said you didn't know disabling domain reload was "such a huge thing", it worries me that you're not aware of this.
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
Yes, it's not something you can do lightly!
is that possible?
since today i had no real issue with disabling that, my game is working fine technically so yea ๐
i'll show it graphically
That's what i have with no mods(just a flat chunk)
You could also be more efficient by only recording areas that were changed
especially if the modifications are small
if only i knew how to keep the changed areas
i mean it's all painted using terrain brush
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.
yeah, so i can save those changes as a separate binary file or smth
I guess you could just compute the bounds afterwards
to then be able to load them and apply to the piece
how tho
For every pixel that differs, grow the bounds to cover that pixel
Now you have a region that the modification covers
does terrain provide some kind of way to track changes
you can use BoundsInt for that
like "TerrainPaintedEvent"
no. you'd just do this once at the end, when you're saving your modification
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
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 :
You can use AnimationCurve for something similar -- I don't know about using the particle system's curve editor, though
I found the solution, I had to apply all these changes
Something like this?
https://docs.unity3d.com/ScriptReference/EditorGUILayout.CurveField.html
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)
not a code question. #๐ฑโmobile
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 ?
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?
I think the whole idea of creating and destroying textures quickly is not great. Why do you need that?
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
Sounds like maybe a buffer would be better if it's just one normal per object?
Anyways, binding resources(textures and buffers) is very cheap. Creating the resources is expensive. You can have several sets of buffers/textures that you bind to the shader.
With buffers, you would only ever need one and avoid the pain of working with textures.
So you mean instead of having multiple textures, having the data as a buffer?
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
Buffers and textures are always on the GPU side. They can also be on the CPU side optionally. That being said, if you set the color data in C#, it's probably CPU side data. It needs to be applied to be copied to the GPU.
any of you guys know where i can find unity version 2017.4.9f1
Exactly, I'm creating the texture inside a Job (because the data is calculated and stored in Native Arrays)
I don't remember for sure, but I think there's API in the Shader or Graphics class.
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
It should be listed in the Unity download archive, but it looks like it's missing since they revamped the webpage.
You can still find it through the Wayback Machine:
https://web.archive.org/web/20230316023641/https://unity.com/releases/editor/archive
thanks mate, ive been looking for ages
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?
- It is bigger and does have bigger magnitude than transform.right though.
yes, but not as much as it should
Did you do the math on paper to confirm that?
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
Yees yes, i know about those. The probelm is thatI have an unknown amount of textures that could be used in a single draw call
Why should it be close to 910? I think you misunderstand how projection works.
Surely you know the number when you want to bind them?
But the shader needs to have a reference for each one of the textures individually
Unless I create a texture array at every frame, which is the problem I was comenting, it's slow
yes, maybe i misunderstood. In the documentation, there is this schema, and the projection is matching the Y of the vector, why isnt it the same thing in my case for my normal?
You can bind indefinite amout of data to a shader. It needs to be known at the time of the draw call
It wouldn't work with a texture array either. It needs to be of defined size.
The shader needs a declaration of "TextureX" to be used
Can I somehow use a texture without a declaration?
Because their normal is aligned with the y axis. In your case you have vectors oriented differently. It's likely that they're even facing close to opposite directions.
yeahn, I could create the texture array with all the textures, be declared in the shader, and then use an index to select the right one
No.
Well, in d3d12, there are bindless resources, which kinda provide a level of indirection in accessing resources, but I don't think it's exposed via unity API.
Yeah, that would work.
Why not use a buffer as I suggested?
But then there's the problem of creating the texture array which is slow
Yeah, that's what Im starting to think its the best option
Just don't create it every frame. Create it once during the level start or game start.
I lose some fancy features like an easy to use sample, but I will just have to create my own
can't do because the textures will be generated in runtime, so i don't know how many are going to be used until the draw call is dispatched,
For example imagine if the vector is perpendicular to the normal. The result would be a zero vector.
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
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
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.
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)
wdym by "compact"?
I understand, i need to think about it, i just wanted to find a way to cancel force applied to sides of my object, and Vector.project seemed a good choice.
Thanks for your help.
so, array1, array2, array3 becomes array123 = [array1, array2, array3]
and I can use an offset index to access every sub array
You could use Dot product or something to get a multiplier of how close your force to the sides.
The solution to not being able to declare n unknown buffer, but I can declare one singular big buffer
Ok, thanks, i will look at it
I think you still have the initial problem. Modifying the buffer on the CPU would still need the data to be copied over to the GPU, potentially, the whole buffer.
It's still probably better than dealing with textures though
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
If you're not gonna modify it, then that's fine.
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)
Are they vertex normals? Why are they not included with the vertex data then?
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
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
Please log t
Log everything
especially t
and maskTint and defaultTint
5 bucks on t is (almost) instantly greater 1
doing that already it's definitely broken
inb4 ban for posting image instead of typing
Debug log in the coroutine to be sure.
And not just the final value but all other involved variables as well.
I swear what is wrong with Unity that such basic stuff is broken...
unbelievable
business as usual though
Don't start
Did you make sure you are using the correct color property in the first place?
It's not broken until you can confirm it.
Open material in debug inspector mode and confirm correct property
Besides, what part exactly is broken? Can you pinpoint what part exactly goes wrong?
@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.
Bug report is bugged lmao Unity gonna Unity
Appreciate the efforts but takes too much time to type it all out.
!mute 516295730928025613 1w Again, we don't need the attitude. Next is a ban.
matgabriel was muted.
You do realize, your confirmation method is very unreliable? If you're too lazy to add logs, you can use the debugger. It doesn't take any typing.
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.
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
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.
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)?
I use prefabs everywhere
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.
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
oops, I'm in the middle of a build right now, so I can't show you how it looks...
Like some buttons (delete/destroy) might require a second confirmation click.. should that be included in the prefab or .. what
No worries
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
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?)
rather than having prefabs for "small text" and "big text", you should have prefabs for kinds of text
most of our text is white with a drop shadow:
almost like how you'd do CSS classes
I don't go so far as to have a base "text" prefab or something
that'd be a bit much
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
These are all of my UI prefabs
uitk, my beloved
UIToolkit would definitely make that much easier
is UITK that .. uh.. xml-ish thing?
since you'd have actual cascading stylesheets
HTML CSS ish thing
that's how the ui is serialized, at least
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
there's always the evil option: rewrite the serialized data directly
but just... some datapoints I want to inherit
I recently did this so that I can update [SerializeReference] fields after renaming a class
I'm .. not sure that would be successful.. like, there's dozens of different font atlasses for each font size
oh, I was thinking of just changing the font size of your text components
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
but yeah -- prefabbing whatever you can get away with is very helpful
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
Objects controlled by a navmesh agent can't "fall". You'll need to implement a system that is switching between or combines navmesh navigation and physics.
you can make it 'fall' by using navmesh link, but that would need a lot of links
or just simply disable the agent and send him off the ledge
as for the walkable slopes, I think you can set it here
What version of mono/dotnet does Unity 6 Preview use?
๐ no file-scoped namespace
i suspect it will take another year yet
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.
No longer having that issue, but now getting
NetworkConnectionManager.Shutdown() -> IsListening && NetworkTransport != null -> NetworkTransport.Shutdown()
The second a client launches
If you're talking about the host, yes it works perfectly fine
What about the client
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()
This is confusing
Agreed
I never used Netcode with P2P Network, I have no idea
Or is it some sort of bug on their end
Says Client Connected then instantly shuts the client down
Could be I have no clue
Guess I haven't tried building it yet let me do taht
After building, getting
No ConnectionApproval callback defined. Connection approval will timeout
https://docs-multiplayer.unity3d.com/netcode/current/basics/connection-approval/ I think you should read this then
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...
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.
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
Double crosspost. Don't do that.
my bad
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
I don't see how my code is causing an infinite loop. can you point out the obvious to me?
instance_get() <---- 0
if (instance == null) <---- 1
instance_get() <---- 2
if (instance == null) <---- 3
instance_get() <---- 4
....and so on
To be clear you need a backing field
private set { instance = value; } is also an infinite loop for the exact same reason
thanks
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
!code
๐ Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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?
it's up to you of course but, I would suggest that if you want help you conform to the norms of the server
People on mobile devices can't view those without downloading
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
can you please post a copy of a data file, also to a paste site
by data file do you mean one of the osu charts?
whatever is in the TextAsset beatmap
alright heres an example of one of the charts im speaking of
https://paste.ofcode.org/5Bb7Ux4945yVV4S2frYKac
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
I was going to suggest, forget TextAsset completely and use the System.IO.File class
Yeah that too, if you can read it from a file and open a Stream to it, it'd be the best
indeed with a stream and stringbuilder
Span<T> โจ
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
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
Also
public Dictionary<int, string[])> notes
I doubt allocating a tuple is more expensive than allocating an array
what class would work best in this case?
if thats even what you meant lol
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
yeah i was going to switch it to selecting a file later on, i was just using the textasset for testing purposes
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?
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();
}
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.
Yeah it came from an GLTF importer something. I solved the problem by adding the readonly texture2D to a Renderer and then read the bytes out of it again. A bit hacky but it works lel
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);
}
please do not cross post
Should probably delete the messages here and another channel. Have it in only one
That's unnecessary code out there. My collegemates used to do this type of coding so that others don't understand.
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.
What are you even saying, and how is it supposed to contribute to anything?
This is the advanced channel, if you dont fully understand basic syntax then maybe it's not worth commenting on it for other users issues.
I was just saying not commenting that on other users. If you see I didn't replied that to anyone.
It looks like you're doing multiplayer stuff, I suggest adding more debugs or stuff like debug draw ray because maybe not all these values get set properly for the host.
The issue could be a lot of things when it comes to multiplayer, so you should at least try to prove to yourself if it's the code or not
You clearly did
That's the previous one are you blind.
How about just stop with the nonsense?
And the second message was even less on-topic
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.
cram everything into one massive file
Are you asking about the generator projects, or are you asking about the generated code?
the generated output file
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.
actually my initial question was asking about both now that I think about it ๐
I appreciate the response though, thanks
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.
Ey, I'm also working on a portal system. And currently im just checking all the other portals, if they are visible from eahchothers portals, if they are, then just render it from the deepest portal (within a limit to not make an infinite loop ofc)
Yeah that works for 3 or more portals rendering each other but
I'm talking about 2 portals rendering each other multiple times
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
I mean, you have perspective inbetween your portal and your applied texture
It wont be linear
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.
Learn how to create a portal effect in Unity's Lightweight Render Pipeline and Shader Graph.
Download the free sample project here: https://ole.unity.com/lightweightportals
But the link in the description is broken.
https://github.com/QThund/LineRenderer2D
So, I've been poking through this resource, since it seems like it would be REALLY useful to me, but I'm struggling to conceptualize a good way to make something like this in 3D. Anyone here have any thoughts on this?
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?
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
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?
Unity's Line Renderer doesn't create pixel perfect lines, however, which makes it unsuitable for applications attempting to emulate a Pixel Art style.
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
what you mean by pixel perfect in this case?
https://miro.medium.com/v2/resize:fit:1400/1*_JM0k_Lz4VatDI2bZ6ViMg.png
Here is a visual example. In Pixel Art, the general rule of thumb is that pixels in a line can share a row or a collumn in a given 3x3 grid, but not both.
Oh I see...
Because Unity's line-renderer is using a mesh, it cannot create pixel perfect lines (by default)
What type of effect are you trying to achieve? Why you need pixel perfect 3D lines? How do you achieve the Pixel Art style in your game given it's a 3D game (or is it?)? Downscaled render?
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.
I see. Sow how do you want the line to behvae? Should it have perspective (thicker closer up)? Always that 1 pixel thickness or something more?
Always one pixel thick. I can always use a mesh-line underlaying the pixel line, if I need "up close" shots.
Do you need one line from start to end point or line composed of multiple lines?
Whichever is simpler to code. Even if it only creates one straight line, I can always just use a Line Renderer/Spline as an intermediary to create curved lines out of multiple line segments.
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
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.
The line renderer idea could work but cleaning the line up afterwards isn't really possible with a fragment shader. There's likely some algorithm to figure out which pixels to draw to begin with on the fly though
Well, really, it'd be more like a post-processing effect. In theory, I could go in on making the lines their own layer, and apply a post-processing effect to it. I'd have to investigate that.
That would be indeed possible but that sounds like it might be way too expensive for what it achieves
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
Can you be more specific about what you mean by "inside another ScriptableObject"?
So you just mean referenced from another object? Or that you are putting them both in the same file or something?
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
If the amount of different weapons is small enough, you can just hardcode it. Have separate classes for each weapon type that have their own logic. They can inherit from a base type or implement an interface so that you can handle them in an abstract fashion.
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.
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.
Consider any code executed on the client to be already compromised, and any data coming from the client is malicious.
Obviously I already know that, otherwise there would be no talk about server side combat?
I'm looking for pros & cons on client vs server side.
Like is the huge extra cost, for 10k players / month we're talking โฌ500/1000 worth it?
How much effort is it going to be combatting cheaters and keeping my game playable?
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.
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%.
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).
If the game is very profitable, then it might be worth it.
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...
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"
Just referenced, sorry for the confusion
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.
hello all, i recently updated the TMPro package, i did it today, but now the scrippts gives errors, " No monobehaviour scripts in the file"
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
That makes absolutely no sense. TMP is a package which will be copied from the global package cache everytime you open your project.
huh
i copied from my backup folder, Library/PackageCache
and it works now
i reimported and re opened my project ind still works ๐คทโโ๏ธ
you could have just deleted your Library folder and let Unity rebuild it, when you start messing around with the contents of the Library folder without knowing EXACTLY what you are doing you are only potentially opening yourself up to a world of pain
no
huh
see what I mean by 'knowing EXACTLY what you are doing'
yes
well, i knew i had to downgrade my version and it worked
oh
but anyway, thanks for the info i got it to work again without having to delete anything
well you should have done, at min the TMP Essentials in your assets folder
wdym
like delet the essentials folder?
yes, and reimport it using the modified version of TMP
oh
but i had the problem of the script **Inside **the **Packages **folder
like isnt the essentials package non requiring?
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
well, if im not mistaken you mean deleting and upgrading the sessentials?
because i opened the Tmp essentials import package inside the Tmp Packages
yes, of course, if you change the version of TMP you should also change the Essentials version
but it didnt resolve
i opened the essenstials import file of the updated tho
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
More of a #archived-code-general question
Without reference to your particular code. You probably want a state machine the explicitly triggers all the little changes you need to make to your controller/camera/gameplay when in gun-mode. Then treat each of these states (walk, gun, others) as entirely separate, with their own controllers
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
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.
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.
Whatโs not working?
Scroll up
Nvm, not gonna fix AI generated code issues
Isn't able to find a key in the dictionary equal to 1
Who said it was AI generated?
I said I asked copilot to fix it
It wasn't able to
Unbelievable
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.
The dictionary is populated with each unit and it's data. CreateUnit gets called on with what is now an int of 1. It looks through the unitData diciontary for a key equal to 1, and cannot find it, which makes zero sense.
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.
It can make sense if CreateUnit is called before Start is executed, ie. you have an execution order issue
It isn't, the debug.log listing all added units gets called, then I click the button.
Im mostly confident you arent using the debugger. You are using debug.log
This is true, my bad. Not sure why I'm calling it that
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.
Did you try stepping through the code with the debugger?
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.
Is there a way to run a piece of code when a value is changed in the editor
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.
@scenic forge would something like this work to prevent EASY access/altering with Cheat Engine?
https://gdl.space/ibosezidet.cs
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
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.
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
How often are they used and for what
I will also update the offset and multiplier in the Update() function regularly, so you cannot just look for non-changed values
Every read and write to your hidden int will create tons of garbage.
like once per second?
Also how and where does your game use the decrypted value and what stops the cheater from simply changing that?
_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.
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
it's not meant to solve cheating, it's meant to stop people who watched a 10 minute YouTube video on Cheat Engine
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.
I assume this was the "client side anticheat" part rather than a server doing this per user
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
My priority is to get my game ready and playable as fast as possible
I currently do not have the knowledge to build a server, nor do I have the time to learn it right now
I agree it sucks, but getting a game out that can be cheating in >>>>>>>> not getting my game out anytime soon
So I'm settling for it that people can cheat in my game, I will do what I can to stop them though
It would be quite irrelevant for server tbh, because you wouldn't even need it.
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.
but they won't find it with changed/unchanged, since the values will also be changed at random times in Update()
oh sorry i thought your message above was about if some server was doing this (im tired). Client side i dont think there would really be stuttering, with incremental gc
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
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."
you shouldnt honestly abandon the mentality that this is possible. One logic flaw in your "anticheat" which is really just seeming like hardcode at this point means that a ton of users get false flagged. Boom you suddenly lost a massive audience and people lose respect
yeah I know, that's exactly what I'm doing, just trying to make it a little bit harder so not every single person who just installs Cheat Engine can hack my game
I'm ok (well I hate it, but it is what it is) that more advanced hackers will be able to cheat in my game (easily)
obviously I'm not going to add an auto-ban to an untested method
I might just tag them as possible cheaters and investigate further for example
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.
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?
yeah that's sort of the plan
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.
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)
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.
there is no actual value saved anywhere?
only the encrypted value is stored to memory
well the plan is more to keep it multiplayer but not worry about cheaters ruining the economy
a big part of the game is "single player" but the multiplayer trading is an integral part of the game, but it's fine that the economy is trash at the start
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
items will still be stored on the server, not on the client
and the server will validate them
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
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
How can your game even use it then? You need to decrypt at some point, in memory, to use this variable
wouldn't the value I use be removed from memory straight away by GC?
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.
Not really, depends on a lot of things. Besides the client can decode it so you can easily reverse engineer it
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
life saver ! thanks bro
Has anyone ever coincidentally used this repo? https://github.com/b0nes164/GPUSorting
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)
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
Oh I probably did talk about it here before! But I got further in reading up on it! Well I will look at that thanks
Last time I looked into weak reference related stuffs, they were either not available in Unity, or have issues with IL2Cpp.
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!
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?
What's the target platform for your build?
Windows
Probably something like the first run is grabbing and holding onto the ports or connections
there is also a function for closing ports, and they are closed, as i've checked
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)
Fixed this issue by replacing Open.Nat with Mono.Nat. The latter one is actually being maintained. Now the function (after some rewritting to fit the new library) works well, no issues.
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 ๐
Yes for the first one https://docs.unity3d.com/ScriptReference/OverlapSphereCommand.html
Oh both actually
https://docs.unity3d.com/ScriptReference/ClosestPointCommand.html
thanks! these are actually 2 good reasons to upgrade to 2022...
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?
Yes. If you really need to have the 2 of the streams locally at the same time.
I guess in reality you only need to open main stream/project when you need to publish a build from it?
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?
Assuming the users are using the same stream, the changes are either not committed, or not pulled by the user. Which could be caused by an ignore file, yes.
Do you mind sharing your workflow?
I was attempting to setup a sort of Release -> Main -> Dev workflow, where anyone working is working on the dev branch, and when features or milestones are complete they get copied up to Main.
But I was thinking maybe each person should also have a stream below Dev.
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.
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())?
it's not required to call schedule or complete inside Update
you can also Complete immediately if you want
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.
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
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
Any reason why you do not test calling it once ?
one call makes this
while my intention was this, I'm probably messing up some some column indexes but i have no clue
Ok turns out i was holding rows in my nodesInColumns list.
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?
you can cast the returned T to object
Hoped for something better, but I will stick with changing the return type to object. Thanks.
I would not do that tbh because even if you do know the T you will need to cast back
But without that, I can't use ModifyAttributeValue when having a variable of type AttributeType.
What is AttributeType?
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
My custom class.