#archived-code-advanced
1 messages ยท Page 112 of 1
https://hatebin.com/uhvmlkkdyn is this code right
huh?
move to #๐ปโcode-beginner
okay
it seems like using URP , the whole cmaera layerCullDistances doesnt work / works different, but i cant find info how different lol
why would it be visible beyond 3k if your far clip plane is 3k? You can set smaller distances, not larger ones
no you missunderstand
my camera farClip is 1000.
I have an object i want to always be visible, its visible at farClip 5000
I want only THAT OBJECT to be at that distance, so i set it to a specific Layer, since you can adjust layer cull distances.
But it doesnt work.
I found a free asset that works now but it still has some quirks, something related to URP and outdated info on unity documentation
it's currently visible at 5000 units away? Or your far clip is 1k, object is 5k, object not visible? Because the second thing would be the expected behavior here
i can not write it simpler for you
object visible at 5000
my farclip distance 1000
you can set specific layer cull distances.
i put the object on a specific layer and set that distance to 8000
object still not visible.
while it probably shouldn't work this way (if it does), have you tried to see if the farclip is a sort of "global max" value that's limiting the layers' effective values?
e.g. if you set the "global" farclip to 8000, set everything in the scene (except your distant object) to be on a default layer that's set to 1000, then the "always visible" object could be on a layer that's set to 8000 (or just no layer at all, so it uses the default)
obviously not viable if there's no way to automatically assign objects to one of those layers by default since you'd have to manually assign everything in the scene, but testing that out would at least give you an idea of what's going on i guess
just a wild guess, more or less
you can set specific layer cull distances that are smaller than the farClipPlane https://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html
anyone can run this sample ?
https://medium.com/@pushkarevmm/mesh-shaders-in-unity-with-direct-3d-12-50aaceefddb6
it crash the editor
maybe because I;ve 1060
Just wanted to ask what the purpose behind the "player project" is when enabling the option shown in screenshot. I know it gives you an additional assembly you can swap between but it does look almost entirely the same. In rider, it seems to not pay attention to things like conditionals showing things that would have been stripped as still present, but can't find any documentation on it, any help?
Hmm surprised I didn't manage to find this online. Thought I'd share what I created. It's a Script/Method which scales a RectTransform to anothers' dimensions with a specific aspect ratio. It's quite similar to the AspectRatioFitters component but with differences. It's good for UI systems which need re-scaling instantly programmatically (this works in 1 frame), where the AspectRatioFitter component doesn't. I can also choose the return type for centered or stretched elements. The Rect to rescale also does not need to be a child of the target ๐
What's the fastest/cheapest way to run code every X seconds?
Performancewise: Is there a better way than Update and checking to see if enough time has passed? ๐ค
If it is an issue, you should look into DOTS.
Basically Update with a timer, but do you have many objects doing this or what?
I have this code, where on right click on an element on UI, I show a menu
it works fine
but I can't figure out, how to destroy the instantiated menus if the right click or left click were outside any element on the canvas
meaning
clicking on the canvas but on an empty place
any help?
public class CanvasManager : MonoBehaviour, IPointerClickHandler
{
public GraphicRaycaster graphicRaycaster;
public EventSystem eventSystem;
public GameObject _menu;
private List<GameObject> _instantiatedMenus = new();
public void OnPointerClick(PointerEventData eventData)
{
//these Debug.Log statements only work if you click an actual gameObject inside Canvas, what if I click in an empty place?
if(eventData.button == PointerEventData.InputButton.Right)
{
Debug.Log("RCLICK");
ResetMenus();
CheckRightClickOnChild();
}
if (eventData.button == PointerEventData.InputButton.Left)
{
ResetMenus();
Debug.Log("LCLICK");
}
}
}
Make a script that closes all open right click menus 2 frames after a right or left click was detected, UNLESS a right click menu was opened within that timeframe
Or close all menus except the freshly opened one
Check for right-click inside a normal update function in that script
And interrupt it from OnPointerClick
Or just make a right or left click close all menus anyway, and just open a new one if applicable
I like to just make a giant invisible UI image in the background of everything and put a script on that
I need help. Does anyone knows why when I export a package and then i import it to another proyect resourced get placed where they want?
For example, if i already have folder called scripts then the current scripts from the plugin get placed into that other folder
@upbeat path you could probably help me with that... I've already talked with you about exporting assets ways and you've already created lots of them
tbh you would be much better having Assets/AvacadoShark/ etc rather than haviing the plugins folder because then you can export/import AvacadoShark and it wont conflict with anything else
yeah? you mean not using the plugins folder? but that will make the user assets to look kinda messy, no?
that is the standard for the Asset Store, the user can move the assets if they wish so your code should be able to support that
Oh, thanks!
Bear in mind as well that Plugins is a reservered folder name and should only be used to hold dll's.
This is the structure I use for one of my assets
This shit is what is currently happenning me even doing what you said me...
(Most of the plugins resources get placed wherever they want when importing it into another proyect)
that looks like a version control problem not an export/import one
hmm, yeah?
Start with a clean project and import the .unitypackage you just made in that vid
cause it's really breaking my head and @ember drift ones
perfect, let me try
you really need to think about your project organization right from the start coz with version control and moving stuff around things can get very messy and unpredictable
would that probably happen me with most asset store packages I import while using unity version control?
if you import then commit then move, yes
problem with Unity is when you move something in a project it does a OS level move for the .meta files but a delete/create for everything else so this can really screw up version control
It works correctly when importing that into an empty proyect
Oh, so the problem is due to how unity manage .mete files in uvc?
as I knew it would, lol
not so much the meta files, they're ok, it's the delete/create that messes with VC
and this only happens if you move something after you have done a commit to VC of that asset
hmm not getting this part. The changeset was empty before importing the asset... so wich would be the right way of importing it into an uvc proyect?
import->move to where you want it->commit
another option is to import->commit->create branch->move->commit->merge branch back to main->commit
But i was not mooving/committing it in any moment
and the chaos was there in the moment i imported it
thats what it looked like in your vid
Oh, done it!
Hi everyone!
I'm working on a 3D sonic physics engine and I want to integrate splines with a player controller, but most of the tutorials Iโve found only show how to use splines for creating mesh paths or moving prop objects along a path. I'm looking to implement more complex mechanics like:
Rail grinding: The player can move along a spline and jump off at any point, with speed carrying over.
Auto-running sections: The player should be able to transition into a spline-based path, but their current speed should carry over instead of being reset.
The player should also be able to jump between splines dynamically.
How can I go about using splines in combination with a player controller? What are the basics I need to know to get started working on it? Are there any specific techniques or best practices for implementing this kind of system?
Follow the spline ? A simple statemachine should be able to handle pretty much every case.
oh yeah that part i get, like having a spline state that locks left and right movement and stuff like that
I mean the actual logic of snapping sonic to the splines and having him move forward and back depending on player input
and being able to accelerate downhill, jump off it, enter from either side, being able to exit and go back to regular control at either end of the spline etc
There is no magic or tricks, you just gotta do it.
Im making impact frames for my game and Im using a render texture with 2 cameras that are setup so that 1 layer renders infront of the other but for some reason the second camera only shows on the render texture after I manually update the camera by changing one of the settings, Ive tried making it automaticly set the setting on start with a script and that did not work, It only seems to work If I do it in the editor
wrong video hold on
hey, im having difficulty getting my RPC to work. I keep getting the error: object ref not set to an instance of an object. Ive tried multiple ways of doing it based off a repo I got but I keep getting the same error and not sure whats up. Ive tried:
ExampleClient.GetInstance().clientNet.CallRPC("Ready", UCNetwork.MessageReceiver.ServerOnly, GetComponent<NetworkSync>().GetId(), true);
//AND
client.clientNet.CallRPC("Ready", UCNetwork.MessageReceiver.ServerOnly, GetComponent<NetworkSync>().GetId(), true);
and at this point, im kinda just tossing around the exampleclient under the inspector to anything I can think of but Im obviously not getting it :/
it's not possible to have a navmeshsurface scale along with the object it's attached to during runtime without rebaking each time is it?
No, rebaking is required to update the navmesh shape. What is it your trying to achieve?
I have a procedurally generated mesh "level" which I'm then calling buildnavmesh on the navmeshsurface attached to it after generation. It works fine and dandy when the level is rotated and moved as the navmesh moves along with it, but changing the "level's" scale leaves the navmesh behind. That makes sense the more I think about it, was just wondering if there was a way to access the navmeshsurface "mesh" and scale that as well when scale changes are made to the parent mesh rather than rebaking the whole thing.
Thanks!
Hmm I expect changing scale would rebake. Sounds like a bug to me
I'm thought-designing a game where I expect there'll be a lot of windows and window management as part of the UI. I was thinking that I was going to roll my own here, but it's daunting - essentially building some sort of XML renderer and custom language.
I'm assuming this is what UI toolkit is good for? Anyone have any other ideas for libraries or tech here?
Some of the functionality I'm looking for are - resizeable windows, docking, saving layouts, windows that might/could be user driven or created(?), data binding (or at least tabular data views - scrolling, sorting, filtering, etc).
Never used UI tool kit at runtime, but it seem that it does everything you are asking for.
Hello guys. Im trying to make some in-editor changes whenever i set a scriptable object reference in the inspector.
this is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class EventHex : HexNode
{
[field: SerializeField] public HexEventSO hexEvent;
private HexEventUI eventUI;
#if UNITY_EDITOR
private void OnValidate()
{
if (hexEvent != null && eventUI == null) {
eventUI = Instantiate(hexEvent.eventUI, transform).GetComponent<HexEventUI>();
if (eventUI == null) Debug.LogError("No HexEventUI component in " + hexEvent.name + " eventUI reference");
else
{
eventUI.SetEvent(hexEvent);
}
}
else
{
if (eventUI != null)
{
DestroyImmediate(eventUI.gameObject);
eventUI = null;
}
}
}
#endif
}
any idea why errors and tells me that destroying gameobjects is not permited during physics/trigger contact, animation event callbacks, etc...
Also im aware that maybe i cant really store the eventUI reference inside OnValidate, but i can change that to get the transform or something
at a guess, setting eventUI from the instantiate triggers the OnValidate again which then tries to Destroy the eventUI just created
debugging your code should expose this
Thanks, i didnt know i could debug editor code to be fair
So... after some searching the solution was to use EditorApplication.DelayCall to be able to destroy stuff like that
so it waits for the call stack to unwind, makes sense. Editor Coroutine would have done the job as well
still kinda of black magic to me, maybe i should dig into how to the editor works
tbh I code all editor stuff using UIToolkit now, IMGUI and OnValidate are crap from the past and best forgotten
yeah, but i wanted to learn DOTS and ECS before UIToolkit. so many things....
Getting a solid understanding of the new ui system will save you time as you build other stuff since it will be faster to produce better uis
wdym, it's only Monday, you should be proficient in all 3 by the end of the week
3 years and counting and i still have no idea what im doing most of the time
and a little idea the rest of it xD
5 years here on and off, im still learning things like protected
You don't get better in coding, you only get better in knowing what to search in google 
Anyone have any experience/ examples of convex hull algorithms? I have a list of 3D points, i need some code which returns the points which are part of the hull
wait until you hear about private protected and protected internal
15 years and counting
If you're doing things right, you'll always feel that way
Okay, strap in because this one's a bit of a journey.
Background: This is an application designed for government use, and it has certain bureaucratic stipulations. We're using Valve's OpenVR and SteamVR, but for the aforementioned reasons, we have to vendor it ourselves instead of using the Unity package manager. We have an internal repository that our Unity Package Managers point to so the process is basically the same, except that we also control the source code that goes into it. Part of that is a clone of the OpenVR repository, with presumably whatever needed to be changed for various red tape reasons.
Problem: OpenVR works fine in the editor, but in a build, there's a DLLNotFound exception for openvr_api.dll. This dll is included in Packages/OpenVR XR Plugin/Runtime/x64 (and also in x86 but who's counting?) and when copied into the [ProjectName]_Data/Managed directory in the build, it works (at least this part works, there's other problems I can move on to fixing after this is sorted).
Question: How can I get this DLL to be included in the build? There is an Assembly Definition in Packages/OpenVR XR Plugin/Runtime that includes the platforms we are targeting, but doesn't directly reference the DLL (it should be contained in it since it's a child directory from what I understand). I'm assuming it has to do with it being in the x64 or x86 directory and it not knowing which one to use for which? Do I just need to add in a separate Assembly Definition inside those directories with only their matching Windows versions selected? (Modifying and re-deploying custom packages is a long process and I've already started it, but I need to wait for someone to approve my credentials to access that repository, so I can't just
yet)
Usually, you just need to play with the following:
At worst, you could always copy it manually. (Shouldnt be needed)
Looks like it has Editor and Standalone checked, and under the PC tab, has x64 checked, which is what I'd expect to see.
I don't understand why copying it to the Managed directory would fix it. OpenVR XR Plugin/Runtime/openvr_api.dll is a native plugin, it should be going in [ProjectName]_Data/Plugins/x86_64
Plugins/x86_64 contains only lib_burst_generated, libvhacd, and ucrtbased
You linked to the main OpenVR repo. I don't see the OpenVR XR Plugin package stored in there. Are you still getting that from UPM?
Or did you fork this?
https://github.com/ValveSoftware/unity-xr-plugin
Ope, wrong repository, it's actually:
https://github.com/ValveSoftware/unity-xr-plugin
And yes, it's a fork
Actually, turns out the plugin had nothing to do with it - at some point, OpenXR was unchecked in the Player Settings and it wasn't loading SteamVR.
Checking that box fixes the issues entirely.
I'm trying to render multiple of the same object using the graphics api but i get two errors:
Converting invalid MinMaxAABB
Property offset falls outside of range for type in GetPropertyData.
this is my code:
//_matrixData[i] :: Matrix4x4[]
_renderer.RenderMeshInstances(_assetID, _matrixData[i], _total, 0);
I ran a test using the non instance render mesh version by looping through the matrices manually and i get no error and they render perfectly fine:
foreach(var m in _matrixData[i])
_renderer.RenderMesh(_assetID, m);
why do i get those errors for the instanced version, what does it mean? I have enabled gpu instancing on my material as the docs says to aswell.
ah i figured it out
_total must be > 0
it should allow 0 imo but nevermind
Would anyone be able to help combine two c-sharp scripts?
They both do similar things, but in different ways, and fall short in some areas as a result. However, I feel like combining them will resolve both issues and create an ultimate version.
I haven't written them, I do Unity as a bit of a hobby and I just don't have the skills to write anything crazy myself. But I do have redamentary knowledge, as I did go through the Unity 2021 Coding course
#๐ปโcode-beginner share the details
Oh I don't have acces to this channel anymore lol, i'll post it in #๐ปโcode-beginner then
i have a 2d ground sprite, that is rotated 35,40,0 degrees. I have a 3d object that needs to move on that ground.
I have this code :
dif.z = 0;
Vector3 forwardsDirection = planeTransform.rotation * dif.normalized;
Vector3 localDirection = planeTransform.InverseTransformDirection(forwardsDirection);
Vector3 moveDirection = forwardsDirection * dir.y + planeTransform.TransformDirection(new Vector3(-localDirection.y,localDirection.x,0).normalized) * -dir.x;
moveDirection.Normalize();```
inverse mouse, is the local position of the mouse on the plane(ground) aka : target.
Everything works correctly, forwards movement brings the character closer to to the point, and sideways movement makes the character run circles around the point in the ground. The only problem is, that with sideways movement, the character goes further and further away from the point
So when profiing my game I noticed that this is taking some time of my CPU
I checked and I can't reduce the amount of times it's being called, but is there any way to further reduce the amount each one of those calls takes?
I don't know what I can cache so that it's not so intense
The line that it actually references is me setting a texture2d into a command buffer
basically this
bf.SetComputeTextureParam(compute, kernelIndex, textureMasksID, TextureMasksArray);
bf.SetComputeTextureParam(compute, kernelIndex, terrainHeightNormalID, NormalAndHeight);
bf.SetComputeTextureParam(compute, kernelIndex, densityMapID, texture);
I'm not sure that's the correct method, since you seem to have it in the profiler as well.
Or maybe it's an implicit conversion or something๐ค
Creating an rt identifier... Seeing how it calls equality, it probably tries to find the correct identifier. How many RTs are you using in the project?
imo simplify your math and calls first. Probably help to explain also:
- what is mouse doing
- what is the relationship between (what input) and your orbital movement in the 2d plane space
and finally:
-
dif and dir are similarly named. Probably change that
-
are you using some input like a joystick or something that would cause the orbit to lose distance due to some kind of joystick drift?
-
rename
inverseMousetomousePosOnPlane
it's an implicit conversion from Texture2d to RenderTargetIdentifier
But also storing directly the RenderTargetIdentifier generates it
I noticed that I didn't actually need to call that, so there's no problem anymore, but still weird
Thanks, that will make the code more readable. The purpose of the mouse is for the player to face it and the player to move based on its position.
1.I take a 2d vector input (wasd), assign x and y direction (-1,0 or 1) to dir.
2.dif is the direction vector (mouse position on plane substracted by player position on plane).
3.forwards direction is I basically convert the vector from local plane space, to world space.
4.local direction is probably wrong now that I look at it.
5. I apply the y direction with the forwardDirection, to make object move towards/backwards from the target point (mouse). I then flip the forwardsDirection to the right, normalize it and convert it to world space and multiply it with the x direction, which makes the object move sideways.
6. moveDirection.Normalize() i'm not even sure it's needed
Can you not post the same question in every single channel? This stays in #๐ปโcode-beginner
Well no one is responding to me.
This is not a reason to crosspost, which is against our rules. Stay in one channel please.
Is there any way to copy a list without triggering a GC Alloc?
Pre-allocate a list that you want to copy to
Oh so copy To shouldn't allocate?
I should have checked that before asking lol
ah but I can't copy to a list
only to an array
You can use AddRange to copy a list to a list. If the destination list has enough capacity, there will be no GC allocation. You can ensure it has the capacity beforehand by using List.EnsureCapacity
does the capacity increase with every add range and reduce with every .clear?
AddRange will call EnsureCapacity for you to only allocate once for the whole range, if needed. Clear does not trim the capacity, only TrimExcess does that.
Perfect, thank you!
I either have a Unity 6 specific bug, or something aint right.
"MissingReferenceException: The object of type 'UnityEngine.Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object."
Its pointing to a transform in my script that i change the position of, nothing crazy, the transform exist, the gameobject exist, everything exist and yet, it throws this error nonstop AND outside of playmode.
definetly not null, maybe the line it points me too is wrong? when i click on the error to see it in VS
MissingReferenceException: The object of type 'UnityEngine.Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <adbae017f0374fce9921b97a33a4e8ca>:0)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <adbae017f0374fce9921b97a33a4e8ca>:0)
UnityEngine.Component.get_transform () (at <adbae017f0374fce9921b97a33a4e8ca>:0)
BNG.VREmulator.UpdateControllerPositions () (at Assets/AssetStore/BNG Framework/Scripts/Extras/VREmulator.cs:413)
BNG.VREmulator.OnBeforeRender () (at Assets/AssetStore/BNG Framework/Scripts/Extras/VREmulator.cs:207)
UnityEngine.BeforeRenderHelper.Invoke () (at <adbae017f0374fce9921b97a33a4e8ca>:0)
UnityEngine.Application.InvokeOnBeforeRender () (at <adbae017f0374fce9921b97a33a4e8ca>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
This is the full error message, line 413
leftControllerTranform.transform.localPosition = LeftControllerPosition;
Debugged it, it is infact real and not null lmao
nvm fixed it, was somehow related in onBeforeRender oops
I have a number of objects i want to group based on their proximity. An object should check for neighbors near it, then the neighbor checks for neighbors, etc.. Then every neighbor should know which group they're in. There can be multiple groups. How do i do this?
this is just the island detection graph algorithm
basically you just do a DFS or BFS from each unvisited node and build up a bunch of sets aka islands aka groups
pseudocode:
foreach node:
if node has not been visited:
do BFS or DFS from node and add all visited nodes to a set
mark any node visited as you visit it in the BFS
add that set to a list of sets
thank you
Can anyone help me with Mono Cecil injecting
So i loop over all the methods for each assembly all goes good, i have a MessageAttribute that gets checked if it has it the method gets injected that also works fine. The problem is i want to access the properties in that attribute that are defined and its values when i try to access that i get the AssemblyResolveException saying that it failed to resolve the namespace thats the messageattribute in.
This only occurs in the methods that are outside of the asmdef, if the methods that are being injected in the asmdef than these error doesnt occur.
So a solution would be making it import or something like that, but so far i know there is only the method.Module.ImportReference function which does work for importing methods to run but it doesnt work when trying to import class references
Does anyone know how to fix this?
You can reply in thread to keep things tidy ๐
Does anyone have an example of a good fps movement system which is entirely using transforms? most movement set ups use some form of RB or character controller. Im trying to implement some ServerAuth movement so RB movement makes this a lot more difficult.
do not cross post
Those are input values.
As a self taught developer I've always taken shortcuts. I can see a couple spots that would increase performance but if anyone could take a quick glance at this and tell me what immediately strikes out to them in these profile screenshots that would be great ๐
My terrain generator script loads and unloads chunk around the player using EasySave3 and the cache functionality to save/load directly to/from memory. My main performant issue was saving and loading to disk and that was a huge issue, because waiting on storage and the CPU just doubles the execution time. Loading and saving to memory is a million times faster.
At first I was under the impression once I updated the code to properly use memory instead of the disk, it would be perfectly performant and I was wrong.
I know AstarPathfinding is heavy on performance, and I am not so worried about that. My main concern is the calls to GetComponent and SetTile inside of the generate chunk method.
A quick snippet of the GenerateChunk method
for (int x = 0; x < chunkSize; x++)
{
for (int y = 0; y < chunkSize; y++)
{
// blah blah blah chunk code goes here
#region -- Tree Spawn Rate --
// Check if we should add a tree
if (UnityEngine.Random.value < treeProbability && CanPlaceTree(chunk, offsetX + x, offsetY + y + 0.5f))
{
Vector2 position = new Vector2(offsetX + x, offsetY + y + 0.5f);
GameObject newInstance = Instantiate(GetPrefabFromName("Tree"), position, Quaternion.identity);
newInstance.transform.position = position;
newInstance.gameObject.name = newInstance.gameObject.name + " - chunk X:" + chunk.chunkX + " Y:" + chunk.chunkY;
chunk.gameObjects.Add(newInstance);
//Debug.Log("Adding tree to Chunk " + newInstance.gameObject.name);
}
Is it because its iterating over the chunk size over and over?
Left is a large 40x40 tile chunk right is a 10x10 chunk
I believe because the deep profile SetTile looks a lot less performant
One of these would likely be more performant than individual SetTile calls:
https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.SetTiles.html
https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.SetTilesBlock.html
Thank you I really appreciate it, I will
Also why:
newInstance.gameObject.name = newInstance.gameObject.name + " - chunk X:" + chunk.chunkX + " Y:" + chunk.chunkY;
When it can just be newInstance.name = newInstance.name + ....
random extra .gameObject calls
Good point, overlooked that.
So .gameObject takes away performances as it references the attached gameObject?
newInstance.name = $"{newInstance.gameObject.name} - chunk X:{chunk.chunkX} Y:{chunk.chunkY}";``` might be faster too
Awesome
i mean you're literally calling .gameObject on the GameObject reference
it's completely pointless
it just gives you back itself
newInstance is already a GameObject reference
newInstance.gameObject just returns newInstance
it's extraneous and wasteful
Makes sense, that is true. For some reason I mustve thought it was like var object
var doesn't mean anything
could also potentially wrap the name stuff within #if UNITY_EDITOR if the object name isn't part of gameplay (which it probably shouldn't be)
var just means GameObject or whatever the actual variable type is
var x = new GameObject(); is completely identical to GameObject x = new GameObject();
x is a GameObject reference either way.
Makes sense thank you, I am sure I have more of those mistakes sprinkled in elsewhere in my code. I think I get caught up trying to make sure it works a certain way that I overcomplicate even the most mundane things
https://shz.al/X2Fb Heres a complete method
Going to remove those redundant calls I appreciate the tip
yeahhh you have a ton of unecessary stuff here
tree.transform.GetChild(0).gameObject.GetComponent<TreeInteract>().treeChop0 = seasons.winterObjectSprites[4];```
This can just be:
```cs
tree.transform.GetChild(0).GetComponent<TreeInteract>().treeChop0 = seasons.winderObjectSprites[4];```
But also all of this repeated code is completely unecessary
and numbered variables like treeChop(0-3) should be replaced with an array
Plus why get the componment 3 times??
... very true ๐คฃ
tree.transform.GetChild(0).gameObject.GetComponent<TreeInteract>().treeChop0 = seasons.springObjectSprites[7];
tree.transform.GetChild(0).gameObject.GetComponent<TreeInteract>().treeChop1 = seasons.springObjectSprites[8];
tree.transform.GetChild(0).gameObject.GetComponent<TreeInteract>().treeChop2 = seasons.springObjectSprites[9];```
Is better as:
```cs
TreeInteract ti = tree.transform.GetChild(0).GetComponent<TreeInteract>();
ti.treeChop0 = seasons.springObjectSprites[7];
ti.treeChop1 = seasons.springObjectSprites[8];
ti.treeChop2 = seasons.springObjectSprites[9];```
and so on
there's a million low hanging optimizations here
Thank you it seems really obvious now that you point it out
but yeah this is kinda... yandere-dev code ๐
๐
I'd say the rest is a lot better, integration with bad code from my previous years of working on the project when I was still learning and till now
Need to put time into refactoring old bad controller scripts, like the TreeInteract script
No wonder GetComponent took 30% of a 4000ms CPU time its all the TreeInteracts ๐คฆโโ๏ธ
If you ever find yourself repeating code - don't
Thank you for the advice really appreciate you ๐ @sly grove
Literally fixed the stuttering.
Wow
The obvious optimization for my part would be to stagger the generation on multiple frame. There is no need to generate everything at once.
Also, in term of extensibility, you should rethink the way you add elements.
And, eventually you might want to pool your tree, vegetation and other elements to be able to reuse them.
And if I would say, find an alternative to: GameObject.FindGameObjectsWithTag("Tree");. (Every tree could add itself to a list or whenever you create a tree you do it yourself.)
Overall, it seem good enough. The only really big issue I have would be that nothing is really extensible. Not sure if it is really what you want or simply because you do not know better.
Can you generate a database on AWS with a JSON file?
If two monobehaviors share the same serialized class, are there duplications if unity serialization happens? I remember falling into this issue before and reading this explanation but I tested again and duplication is not happening. I tried the following setup
[Serializable]
public class FooData
{
public int bar = 0;
public Action<int> fooEvent;
public void Raise() => fooEvent?.Invoke(bar);
}
public class Foo : MonoBehaviour
{
public FooData FooData;
private void Awake()
{
FooData.fooEvent += (bar) => Debug.Log($"bar = {bar}");
}
}
public class FooClone:MonoBehaviour
{
public FooData FooData;
public Foo foo;
void copiedEvent(int i) => Debug.Log($"copiedEvent bar {i}");
void selfEvent(int i) => Debug.Log($"SelfEvent bar {i} ");
private void Start()
{
FooData = foo.FooData;
FooData.fooEvent += copiedEvent;
StartCoroutine(baz());
}
IEnumerator baz()
{
for (int i = 0; i < 10; i++)
{
yield return null;
}
FooData.fooEvent += selfEvent;
}
}
But events and FooData.bar and events is synced across monobehaviors. Is it no longer an issue?
Never had issues with this, tbh. You are just pointing at the foodata of the other monobehaviour.
The Action<int> will not be serialized anyway and, you are setting it's value in Start
Ah sorry I also subbed to the event a few frames later with a coroutine. Updated the code.
anyways both the function calls are activating in sync
Well if it doesn't have an issue then that's good. I remember this causing issues several years ago for me atleast. So I wanted to be sure
what you are doing there is pure C# so nothing to do with Unity at all. Perhaps you are confusing the situation with serialized UnityEvents?
Would there be duplication with unityevents?
if they have been serialized using that code, yes
more likely to throw a null ref though
That might've been what I encounted. Still normal fields are being synced though. If I modify Foo.FooData, Foodata serialized class is updated properly at least. Why would unity events be different?
mainly because they do serialize when being set in the inspector, so you can end up with the same event listener in both permanent and runtime sections of the event
Thanks for the clarifications. Just wanted to be sure because large parts of the codebase may depend on sharing refs to serialized classes. Gonna avoid UnityEvents in them for that case.
good plan
Longshot question - but has anyone used Telepathy (https://github.com/MirrorNetworking/Telepathy) and UniTask (https://github.com/Cysharp/UniTask) and converted telepathy's use of system.threading.tasks to unitasks? Telepathy works great for me, but I'm wondering if I should convert all of the telepathy threading code to unitask, and if there's any reason to not do this
there's some minor differences in behaviour/limitations that unitask has compared to regular tasks last i tried it, so it's not guaranteed it'll work as a drop in replacement, although you might get lucky? not sure it would be worth the trouble unless you profiled and found task allocations were a huge performance issue for you
Yeah, I'm mostly just trying to make an effort to "get everything" under unitask on the client.. my implementation of Telepathy involved some modifications to the underlying source, but I certainly don't want to get into learning how the entire library works to port it from task to unitask unless there's good reason.. I could, but ... it's likely to just be a day or two of work and then it might not really have any noticable effect
I've used Telepathy for years (in unity) without much issue so .. might just be a "isn't broke don't fix" kinda thing
You don't need to "convert": you can await a regular Task in an async UniTask method.
You would just write all of you code as UniTask returning methods, and await regular Tasks just fine, whether they come from Telepathy or System.IO or anywhere else.
I meant more that.. since I have all of the source to Telepathy, I'm wondering if it would be worth converting all of the Task use to UniTask in case there's.. performance reasons to do so. TBH I honestly have just always used UniTask "because you're supposed to" in the unity world, but I've never really taken the time to do a rigorous test and comparison
I'm not familiar with Telepathy to know, but from a quick glance of their source code, tasks aren't being used. It's just one long running thread doing its thing.
Oh, interesting, you're right.. I'm on mushrooms apparently. I swear I was looking through one of their files (in my project) and it was loaded down with Tasks in the API
In fact.. I see what's going on. I wrote an interface for the network handler that was shaped more for RufflesUDP back in the day (before the guy who wrote it went to unity... I think he's in here, even) and all of his API surface was task based.. but telepathy wasn't so I see that my interface kinda hacked together an async thing on top of it
New question. I'm building a prototype for a game that has a few 3d models in space, but the UI is largely .. well, UI driven (rather than a world volume). I'm thinking I wanna instantiate items of interest in world space, have cameras on them outputting to render textures, and then have UGUI windows that render those textures. It looks nice for one object.
If I want multiple objects, though, I don't want them in the background of others.
What's a good approach for this?
eg: here's two cameras, rendering to 2 textures:
little hard to make out, but the scene has two ships with a camera pointed at each
I basically don't want one to be in the background of another in case the user has agency over panning around the ship
Well the easiest solution I can think of is using rendering layers
Yeah put the objects on different layers and have their camera only render the respective layer
hm... i'm wondering if that's gonna get complicated if I've got volumes and lighting and settings applied to a layer
This does limit the amount of objects however
although i guess not, since all the rendering stuff can apply to layers as well IIRC?
that's fine - I'm thinking that my game is essentially going to have "me" and "target" for rendering
ie, think of it like.. you've got this nice little view of your ship, and you can zoom in to view a target, but most of the time you're just interacting with UI to navigate and so on.. like the map of the system will essentially be icon based
not really sure yet, I have some loose wireframey sketches.. just sort of exploring what's possible
amazing, that works great!
If you are only ever going to have two models then layers is the way to go
Now if you need more than 16 it will get way more complicated and I do not have a solution off the top of my head
I think that 2 layers is probably gonna be all I'll need for now
just sort of proof of concepting this anyway.. maybe? there'll be some other layers for things like an internal/diagetic view of your ship but that's far off in fantasy land for now
Depending on the amount of objects, you could also let one camera render all objects in a grid and then use the rendertexture with some cropping/masking to get the correct tile out of it to show.
the camera would have to be orthographic tho, to avoid any distortion in perspective
Yeah, probably won't work exactly for what I'm envisioning.. I think I want the player to be able to rotate around the target object themselves, zoom in/out, etc..
I think the layer/rendertexture thing works pretty slick as it is.. it'll be a bit weird doing stuff in the scene view since all the objects will be at 0,0,0 but that's nbd
Ah got it, yeh, then you should be going the path you are already on.
You can try making a waypoint like stuff.
what could possibly be responsible for my public GameObject whatever; to not appear in the inspector window, iven ever had this happen
compilation errors
none
Did you restart unity?
show code
i mean its a 2000 line .cs and other public vars work fine and are visible, but anything i add now isnt
was there a Unity 6 change or anything? even addes SerializeField to test
no diff
Your code didn't compile, your code didn't reload for some reason (e.g. in playmode), your property is not serialized, you have a custom editor that is hiding it
do you have auto compilation/domain reload switched off?
Check editor log
Why would you serialize a public field tho?
to make sure im not crazy
haha, okay ๐
can you close your entire vs and then doubleclick again on your class to open it with a new instance of VS?
yes
the file has been there for weeks xd but im restarting unity rn
But your changes haven't been, reimporting forces Unity to actually update it
Not the first time me thinking, vs and unity are up to date, doing code changes and realise, it was some cached thing and the actual file was an old iteration
they appear in the .cs file if i select it
what the
why are they not in the inspector when i add it to a gameobject
you sure, there is no custom editor laying around?
Sounds like you got a custom editor
how would I know
Search your visual studio for an editor file with typeof(YourClass)
Check your codebase for [CustomEditor(typeof(Grabbable))]
still new to vscode, coming from vs but it shows nothing
That's file search not content search
yw
been working with a vr framework and i feel like 90% of my time is trying to understand it, and work around/with it.
Really considering just going with unitys XR toolkit and writing my own things, but i dont know if that would be an equal waste of time or not 
don't worry, it's only until you get into the UI parts
once you get there, 90% of your time will be spent designing UI ๐
Hey guys I need help with conceptualizing a system for my game. If you know some programming concept that might help with this, please let me know.
The system is called "Spell crafting".
Each spell is made of multiples modules.
A module is a function that has it's own properties and parameters depending on the type.
Different modules have different functionalities, for example a "Create Element" module can take the "Element" parameter, while the "Push" module takes direction and force as parameters.
I don't need help with writing the code nor do I want someone else to write it for me. I need help with the approach/concepts that will help me code this system
I've been thinking about the direction of polymorphism, but there's some missing piece that doesn't let me see the entire picture
Strategy Pattern,
Factory Pattern,
Builder Pattern.
I've briefly looked into these. That's some interesting stuff. Thanks a lot!
Sounds like a good candidate for composition imho
Hi,
I built a game on UWP for Xbox.
Is there any difference between DX11 and DX12 in Unity implementation?
I read this old article:
https://blogs.windows.com/windowsdeveloper/2017/09/15/resources-universal-windows-platform-games-fall-xbox-one-update/
DX12 has access to 100% of the GPU.
Since the advent of consoles, developers have asked for ways to create games for one platform that you could run anywhere. With the release of the Expanded Resources feature in theย Windows Fall Creators Update, we are taking the industry closer to that goal than it has ever been before.ย Now, developers will automatically have access to
12 has more issues on more hardware. 11 is more of a โrock solidโ option.
I check in my project i have 67% more fps on Xbox One uwp dx12
good for you
I want to make an inventory with the ability to drop and pick up items, but the catch is that these items must have different properties, for example, a first aid kit cannot shoot, and only restores HP when used, but weapons are the opposite. And since in my game there are hands for the player that are directly connected to objects (holding them), itโs not entirely clear to me how to make it so that I can pick up several of the same objects without creating a new game object
Why not create a new object? Or rather, instantiate a prefab of the held item? Also, this is really not an advanced question.
because of that hands position needs high accurancy in setting to look great
I don't see how that's related to anything..? You can set the position via code with high accuracy.
if i have over 100 items in game?
Even if you have over 100 items.
i dont think that settings position for every item model is great idea
If they need individual setting, then you can't go around that regardless of what method you're using. Otherwise, if they all(or some) need a specific position, you could set it up for this items group.
and this is reason why i dont want to instantiate it in code
Why not? What's the issue?
i think that a something data in inventory can reference to something model
but idk how to do this
you just typed it upper
No, I didn't. I gave you a solution, not an issue. Doing it via code is the solution
Define several offsets for each item category, then use the correct offset corresponding to the item category to be instantiate. As simple as that.
Multiple ADB server instances found, the following ADB server instance have been terminated due to being run from another SDK. Process paths:
C:\Program Files\Unity\Hub\Editor\2022.3.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\adb.exe
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()
how to fix?
Hello. I am developing multiplayer card game using Unity and Colyseus framework. I've completed basic game logic but after I've integrated multiplayer function, there happens serious errors. when we establish connection, main UI was loaded but I cant see them. I hope the professionals are help it. Looking forward to hearing from you.
#archived-networking also, we do not provide support for 3rd party assets
Anyone tried to use GetAuthTicketForWebApi for auth?
We having issue that it doesnt return tickets in GetTicketForWebApiResponse_t callback for beta app. For main app it works and in both cases users have valid app keys.
Don't cross-post.
Does anyone know what this error means? Something to do with the Editor / Inspector I think. I thought maybe turning off ProBuilder would stop it, but apparently not:
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)```
I've gotten myself a scriptableobject to keep track of the day/night cycle in my game as shown bellow
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "DayNight")]
public class DayNightData : ScriptableObject
{
public float tick; // Increasing the tick, increases second rate
public float seconds;
public int mins;
public int hours;
public int days = 1;
}
I then have a counter that adds to this every in game second and a seperate object using the data (More or less like )
public DayNightData dayNight;
void FixedUpdate()
{
dayNight.seconds += Time.fixedDeltaTime * dayNight.tick;
}
The problem I'm facing is simply that it seems the data get's saved across plays
this makes me concerned I'm writing to disk every frame
I just wanted to check if this'd be the case and if this is the "correct" way to do it?
it works but I'm unsure
modifying the SO is not writing to disk (immediately), but it's getting marked as dirty and will be saved whenever the project is saved. The weird life cycle of SOs is why most people suggest not using them for mutable data. It looks like you might be better served with a singleton here, otherwise one way to do it is to make the runtime fields non-serialized and reset them in editor when exiting or entering play mode
the fact that you have something in the scene modifying it every frame is a strong indication that this should be something that exists in the scene as a singleton instead of one part SO and one part thing-that-updates-SO
Hmmm, yeah that's fair. I'll look into converting to a singleton
Anybody know how can I fix this. I only have this script.
Fix which part exactly? if it's the fact that it's glitchy I only think that can be fixed by lerping the movement
- This is not an advanced question
- The Lerp is not correct. The third parameter is supposed to increase from 0 to 1 over time.
- It seems like you're also fighting with physics over the position of the object - bad idea.
couldnt understand the 3rd
If the rigidbody is non kinematic, it would get moved by physics forces, like gravity. If you try to change the position via the transform, you're gonna mess up the physics. If you're aiming for an active ragdoll kind of setup, you should add forces instead of setting the position.
I will use active ragdoll on my legs
arms have inverse kinematics. They have targets and effectors.
all of the rigidbodys grvity scale is 0
It doesn't matter what gravity is set to, if the rb is dynamic, it would be controlled by physics(or try to, since you're disrupting it).
they have joints should I remove them? I am not thinking of ragdolls for arms
I tried but it broke some things
no it was because of script
Joints are calculated as parts of physics. I'd assume you're using them as a makeshift for your ik setup, so it is gonna break if you remove them.
I got back to my old script without lerp an dit didnt affect anything
what can problem be the reason of this problem here?
I also tried limiting targets vertically but still didnt work and had the same glitchy thing on the highest and lowest point
It's not quite clear what you're doing here in the first place. The code you shared seems to be just a small part of the whole setup.
its really the whole
If it was the whole thing, then you'd just be moving 2 objects/transforms. Doesn't look like that's all that happens to me...
I only set up the ik
How did you setup the ik?
I do those strange things because of https://discussions.unity.com/t/ik-character-help/1534149
sending an ss
I created bones for my sprite
Ok, so you should've started your questions with explaining that you're using the 2d Ik package(https://docs.unity3d.com/Packages/com.unity.2d.ik@3.0/manual/index.html), as it is not obvious to us. It might as well have been a custom solution or a third party asset. I didn't even know there was such a package.
oh sorry I didnt remember its installed manually
I thought it is already in the project when you create it
Then it might be best to ask in the appropriate channel: #๐ผ๏ธโ2d-tools
As most people here probably never even used the package. They would need to go over the manual and guess on the issue without any experience.
That being said, make sure you went over the manual as well, so that you understand how the package works.
Those channels arent very active thats why I asked it here
This is not gonna help if no one here knows how to solve your issue though. And you're locking up the channel from other issues that actually fit here.
I know thats why I tried not to break up a conversation between other
But yeah, it'll probably gonna take a while to get a reply on an issue related to such a niche package. Your best bet is to read the manual and debug it yourself.
https://hatebin.com/qlotbaauhf
have an issue with my BoundingBox code it works just fine can scale and rotate but
cant scale properly after rotating... it does not follow mouse correct or anchor correctly if rotated ๐ฆ at a loss at how to fix or next steps
try using transform.rotation * sizeDelta -- cast to Vector3 if necessary
or might be Transform.InverseTransformVector/Direction(..) that's needed. Play around with transforming different vectors in your code, or do a drawing that'll help
does anyone here have any idea on how to handle portal recursion in URP (like portal 2 does it)
I have a camera that renders what the portal sees at the moment
At the moment I have it where the opposite portal just shows black before the render so bypass portal recursion
and I want it to render let's say 3 frames and display them recursive instead of just 1
you probably have to manually render the cameras in the correct order and apply their result before triggering the next one, if your portals form a cycle, you will always have one a black portal
it's just that I can't control when the cameras are rendering in URP as far as I know
so I do not know if there's a way to do this
all unity tutorials I've seen on the subject are either deprecated or in HDRP
you can call Camera.Render ()
that does nothing
what do you expect it to do?
I have tried it several times b4, what happens is that it signals the camera to render an image as far as I know
the actual rendering is happening at the end of the frame
if a camera has a texture map it will render regardless on wether or not camera.Render is used from what I've seen
I don't even call the function and it renders now, so that might be true
on the other hand I just disable the camera to stop it from rendering
all the renders are synced as well, as the main camera is the last one that renders
well the documentation says
This will render the camera. It will use the camera's clear flags, target texture and all other settings.
The camera will send OnPreCull, OnPreRender and OnPostRender to any scripts attached, and render any eventual image filters.
This is used for taking precise control of render order. To make use of this feature, create a camera and disable it. Then call Render on it.
I can't fit more than 1 render in a frame as far as I know, and it wouldn't be good performance wise to do so
it has nothing to do with "frames"
the disable it part might actually be why it kept rendering for me
you can render a scene 100 times if you like
in one "frame"
what however does happen is that the entire render context is constructed and discarded each time, and in URP this can have significant overhead
okay then I got a different question, as rendering it 3 times per each frame would be horrible performance wise, how would I make it so that I achieve recursivity while rendering them only once per frame
not possible
but you can use a cheaper renderer on the recursions
atm I can run sever portals (like 8-10) concurrently without any significant performance loss
also you can use different culling settings etc.
performance in test setups is usually much better than later in the project when you have actual contexts and problems to consider
well I have a built done and a demo almost done so I know what you mean and I've been through it
just don't expect to render cypberpunk 2077 3x in one frame with raytracing
I'm thinking that portal recursivity might make the experience more immersive, but I don't want to cut too much performance
you could make each recursion cheaper to render and use very aggressive culling
honestly atm I use no culling besides frustum culling that I've coded, still trying to get around figuring out how to bake the culling map or however it's called without objects dissapearing when testing
so If I can actually cull portals when they aren't in the camera frustum AND are behind an object I might actually be able to get away with recursion I think
I have to experiment with this
your portal probably doesn't need a wide angle camera, so your frustum can be narrow and the far clip plane can be close...
atm all cameras have like 50 FOV, I also cull everything that's inbetween portal A and B
@fiery dome Also I've noticed that using unity volumes can be quite expensive performance wise. Using 2 volumes at the same time literally halved performance in my game, I do use plenty of effects I'll give you that much but isn't this too extreme?
depends on what you do in these volumes
like 2 of these
I thought that might be the culprit
motion blur is a setting in my options so I'll just leave it as is
definitely only put motion blur on the global volume
uhh so I have a UI camera and a Main camera and both are using volumes so like the global volume gets double stacked
I should not have done this btw, but only happens in the main menu
any particular reason for your UI camera?
you mean independent from the world bloom etc?
the motion blur on the UI is something I don't want to deal with so any help would be nice
yes
I thank you for praising my skills but I am no where near qualified enough to even attempt what you just mentioned
well, i would recommend to not coerce the unity render features too much into something they werent designed to do
you waste a lot of performance optimizations that way, often in non-obvious ways
nowadays render pipelines often contradict intuitions formed in simpler times
can you elaborate on that one?
one of the casualties of this is camera stacking
you can do it, but its not really the ideal context in which to optimize a frame, so most renderers will want you to basically do eveything inside the camera, not compose cameras
you need to consider all the clever batching features, shader variants and tricks like procedural instancing which need preprocessing
yeah I see what you mean, I tried batching everything I could
did give me like +10 fps
I can run my game on an i5 4460 and GT730 in 40 fps, is that good enough, I do not know
most frames are lost in UI updates ๐
you are very right about that
and I hate the fact that idk what causes that or how to fix it
its tricky, sub-canvasing, no cascading layout updates, don't update large blocks of text, use pooling
Use something other than UGUI
if someone invents a ui framework that doesn't produce tons of garbage we'll be able to do that
UIToolkit (supposedly), NOVA Ui, that new the devs of Odin are developing
i won't be holding my breath
the Odin gui is called PanGui, it'll be very interesting to see what they come up with
don't they say you gotta pick two: performance, simplicity and expressive power? maybe they omitted fast(to market) and cheap and just picked those three instead?
Talking about UI, for native win32 UI in C# , is there any good libraries available that anyone could recommend
!cs
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
With a retained mode layer planned
yeah good - I think Unity binned immediate mode for good reason - hard to do most UIs without a visual layout - not sure if any such tool in PanGui which is curious... Makes it a very code, non visual system
Ive been keeping my eye on it, but its hard to say anything about it until its actually available
Uitk is pretty great imo, despite its short comings, a lot of peopels complaints imo are based around not understanding how to make performant ui
I can not invest time in learning Uitk - too used to UGui which is very moddable and easy to integrate
My current node graph system can smoothy handle a graph with hundreds of nodes
Maybe thousands, haven't actually stress tested it. But the node count should actually not matter
I wish it had a better binding system though
yes doesn't it have magic-string binding!
All binding works that way, but thats not the issue
In other environments with binding, you can bind any/most attributes of a control to a property of your data context or other controls attributes, which makes it easy to build complex responsive uis
In uitk you have a controls that specify a single value that can be bound and its considered a data value
Its very inflexible and forces a lot more code into the scenario, kinda defeating the purpose of binding
yes tbh Unity's UI systems are way behind any other, just got used to ugui and its oddities
Uitk is a great step up, there is a lot to love about it, just not as good as it could have been and they are stuck now
"USS files are text files inspired by Cascading Style Sheets" was all I needed to read to never touch this with a 10ft pole.
Uitk completely change my opinion about css
Css without all the html baggage is nice
is it possible > 50% of unity users will never touch uitk and it will not take off?!
Admittedly css is partially the reason why a flexible binding system doesn't make sense
Guys I am facing a wierd issue.
(int)(1/.2f) is giving me 4 instead of 5. ๐ข
ASP.net is c# and still uses css.
Its still html
I get what you mean but I still heavily dislike CSS, under the basis there is no visual representation.
As in. Once it hits the browser, its just html with a much better framework behind it
Have you actually tried UITK with USS?
Like, a serious try where you don't go in assuming you hate everything about it
Yes. I built a node graph editor using it.
Anyone ?
that is not an advanced code issue - check for floating point error and round
It's a lot better than the editor GUI system, but compared to standard UGUI like what was said above the ease of use and familiarity are too strong for me to switch.
The problem makes no sense tbh
I want to be building my UI in the editor, not in a seperate window.
oops that was meant to be arrow!!
Familiarity makes perfect sense. Use what you're best at
Ive got decades of wpf experience, so uitk is very natural for me other than the css, which I really had to get used to becauee I loathed css from html/css
Ah, I dont want to use a wysiwyg, I dont trust then
But tbh, uibuilder is pretty great
Are you aware of ui builder?
Besides there are far more pressing issues, i.e.
Having to decompile and edit the engines UI code using IL Instructions, just to enable drag-to-scroll because they locked it to mobile rather than adding a toggle
What?
Yeah the scroller has drag to scroll built in, but it's platform dependant.
Make a manipulator
Hell. Ask any llm to make one, dont even gotta do it yourself
The easiest way for me to enable it is to just decompile the DLL and edit the IL instructions so I can recompile it.
O.o
It works perfectly
Until it doesnt
You don't understand it's enabled by default on mobile.
But unity's input system treats the mouse and touch input the same way with UGUI.
I fully understand, but when 6he next version of unity comes out there's every chance that private design will change breaking your code
So it does just work.
Its a brittle solution
I haven't written any code.
I just go into the DLL, remove the if statement which is in the same place, and then recompile.
Which could move when the engine is updated
They are specifically expecting you not to depend on that line so they have no reason not to change it
Especially code inside a method
Generally speaking, forcing things to work how you wished they did will lead to maintenance problems down the line. If you build a direct solution, which is trivial in this case, will be more reliable over the long term.
WYSIWYG website builders have existed for decades, way back in the Dreamweaver days. There are very good reasons why the entire web dev industry has moved away from it.
Absolutely, those all sucked
Modern wysiwyg built for environments which were not a cobbled together mess of competing standards, generally go much better
The only remnants that still exist today are ones that are meant for non technical users.
I still prefer to hand code, but UIBuilder outputs clean concise results
Eh I wouldn't say so, and at least in web dev, typing code and having your changes immediately reflected in your browser in sub milliseconds, is miles better than clumsily dragging with your mouse and clicking buttons.
I dont understand what you "wouldn't say so" about
Uib outputting clean concise results?
Dreamweaver etc also ended up becoming quite irrelevant due to HTML slowly morphing into an output format for layers and layers of frontend frameworks rather than being something you wrote your frontend directly, that hasn't quite happened to UXML yet
All these WYSIWYG editors output suboptimal code, and often not version control friendly.
There is a lot of resistance to uitk
Y4ah thats definitely not the case with UIB
There is no difference really between handwritten and UIB output unless you're more messy in your actions in one format
The left is 2022.12f, the right is 6000.20f
I haven't checked what it's like with UI Builder, but my experience with scene/prefab files is just that you could make the most tiny changes and it ends up being a +200/-200 diff that's impossible to code review.
I understand what your saying. It doesn't change what I said
It's literally just one variable to enable drag scrolling.
Its an unsupported handling, that makes it brittle implicitly
But it is supported.
It's built in.
Modifying that code is not supported
I'm not modifying it, I'm fixing a bug.
Ok
They refuse to add a toggle for some reason so I don't have any options sadly.
Don't complain when UT changes that and breaks your solution, because it will be your fault not theirs
If they change that variable it will be to add a toggle.
And it doesn't break anything
Like, it's unity's default scroller.
It's just really annoying to not have drag scrolling with the mouse when I can have it on android.
Yrah but your conducting an il edit, Any change to that method could break your code
What code?
I only need to remove the check for mouse cursor to enable drag scrolling on mouse cursor.
Literally all it does, and it only does it when it's pressed down anyway.
Unity's input system for handling the UI treats cursor drag and mouse drag exactly the same, but because it's a mouse, they abritrarily disable drag scrolling in scroll view.
That's not the only issue, these WYSIWYG editors also fall apart the moment you need to deal with responsive layout. Oh you have two columns, the left is currently 200px in width, should I output code that has the column as fixed 200px, or should I output code that's 0.5 * screen width - 100px, or anything in between? If I want it as a 3 column layout on desktop, but rows layout on mobile, how do I tell the WYSIWYG editor that?
The answer is just impossible in most cases.
In UIB thats a problem you could handle
if you make a custom control that integrates
Idk what it's like in UI Builder, but in UGUI it's handled the same way as how other WYSIWYG editors, by having you to tweak some properties in a window.
At that point is it really WYSIWYG, or is it just "fill in values in a window and preview"?
Thats kinda an important part of the discussion at hand
Because you can equally do "fill in values in code and preview" and way faster.
Not all wysiwyg are equal, lile HTML/CSS WYSIWYGs had a problem largely because html is a complete and total mess
So they had to output absurd code to make sure things worked across browsers
That's hardly a problem unique to web, C# also has WinForms and WPF, and designers are universally recommended against.
A closed ecosystem like uitk has better chances
Wpfs wysiwyg is... ok ish
I never use it
Its just unreliable really
Its to smart for its own good
Yes, and people will tell you to learn XAML and use hot reload, rather than the designer.
UIB doesn't really have the same problems, it really stands out
Judge it on its merits and flaws, not by association
My point is, WYSIWYG is imo not a successful approach when it comes to UI. It can work as complimentary though if it's good enough.
#if UNITY_ANDROID
androidPanel.SetActive(true)
#else
nonAndroidPanel.SetActive(true)
#endif
They went light enough really, it doesn't try to give you a complete system, it let's you setup layouting and associate elements with uss
And you have a lot of control over how your custom controls integrate into it
It's not really that complicated, you just make an android version of the panel and it's guarenteed to look right.
That's not responsive layout, not all Android has the same screen sizes. An Android tablet may demand very different UI from an Android phone.
Btw if anyone wants to enable drag scrolling on desktop lemme know and I'll walk through how to enable it.
Responsive layout is typically done by screen size breakpoints, not by device/OS type.
Flexbox enables responsive layout
I mean, I use it to enable OS specific settings like resolution etc.
But if you want totally different layouts for different platforms, yeah you'll need to develop a custom layout for each and bind them into your context
Yes and that's exactly my point: if you are opening the flexbox properties window or whatever, and start typing in numbers like "how many pixels until you switch into column/row direction" at that point it's no longer WYSIWYG, you are just writing code but through UI.
Theres nothing like that, but if you made a control that handled that you could integrate it into uib and provide an input that let's you set the transition threshold
Would be a fairly simple control to build once and then use over and over again
Learn ways to improve your understanding of how to design UI in Unity!
URP Examples: https://github.com/Unity-Technologies/UniversalRenderingExamples
Understanding Color: https://www.youtube.com/watch?v=Qj1FK8n7WgY
Designing A Loading Screen: https://www.youtube.com/watch?v=iXWFTgFNRdM
Dynamic Depth of Field: https://www.youtube.com/watch?v=7...
But yeah, its a wysiwyg, it doesn't solve all problems
Yes that's my point, "typing in a transition threshold in a control" is just a worse way of writing code.
Its jsut a tool to help accelerate dev
I watched this like 4 years ago and haven't really needed much else since then to get UI working on multiple platforms.
Har disagree, if you develop the solution you have a reliable tool you can reuse that solves the problem reliably
Not all problems need solving if they're not problems for your players.
And never have to worry about making a mistake implementing it other than putting the wrong value in place
Unless you're working for Studio Atlas it's not really a requirement to have UI that's more percise than an ASML EUV lithograthy machine.
Fundamentally, WYSIWYG promises you to produce what you see, but "what you see" isn't always all what something is. Just like "I'm seeing this column is 200px currently" but the information that "the column should be 0.5 * screen width - 100px and it just happens to be 200px because of the specific screen width I'm current in" cannot easily be encoded visually, and that's where WYSIWYG falls apart.
The moment you need to encode those information, you start to turn it into a worse way of writing out your logic.
I think removing boilerplate code is generally a good thing
Like look at wpf
Mvvm makes you write all this aweful boilerplate code and it takes a lot of time and it adds a ton of bulk, makes code more time consuming to read, introduces extra locations for errors to creep in
If you can eliminate all that the amount it simplifies your code is pretty profound
And it eliminates an entire set of potential bugs
Windows Presentation Foundation?
I don't disagree, nobody likes boilerplate code. But that's not the core of the issue for WYSIWYG, the issue is "what you see" is not always "what it is."
I think uib does ok there, the presentation interface let's you "resize the screen"
So if you had a control that handled that, it should be represented in the preview ui
That's not a bad thing entirely.
Seriously, I think you should give UIb a college try just to see how it actually responds to a lot of the classic issues with WYSIWYGs
You get to skip testing it yourself by just working from the user complaints, then garner trust and a positive reputation for fixing the issues.
Like just implement a control with a UXMLFactory that does the thing you're talking about and see how UIB handles it
I'm not exactly sure how I'd implement it in fairness
I could see spending a decent amount of time making that an abstract able control
Like I still am going to most of my ui work with uitk by hand coding it, but thats really only because of preference
Not because I've run into any limitations in uib or because it produced results i didn't like
And anything you build to be compatible with uib is implicitly able to be hand written in uxml
And in unity, there isn't a big functional difference because you can just have it rendering in your scene or game view and modify the uxml to see it update in real time
That's exactly my point:
- WYSIWYG fundamentally cannot encode every information, only the information you see.
- If you need to encode information you can't see, you have to do it via some other means that's not really WYSIWYG anymore (eg a property window where you type in a number)
- At that point what's the difference between doing that and typing in that number in code?
The first point is a fundamental issue of WYSIWYG in general and not specific to UI Builder.
(The last point, and Unity not having good hot reload, is what makes authoring UI in editor the primary workflow, but that's not due to WYSIWYG being a better workflow, it's merely because Unity doesn't have a choice unless you want to recompile code on every tiny change)
The last point is talking about hot reloading code.
Soon(tm)(2026)
UXML and USS not needing reload is exactly why it's the preferred workflow, but only because code cannot hot reload nicely.
Just gotta build an expression tree system that handles live code modification >.>
Hot reloading is a bit of an issue but that actually goes towards my point not in the opposite direction
If you codify that system into a control you no longer have to suffer domain reloads for that problem
You can adjust the data and have it update automatically
Or, if domain reload wasn't a problem then you wouldn't need such a system to begin with.
I mean sure, but that isn't reality
There's Hot Reload asset for Unity already, but yes that's my point: modifying code suffers the massive downside of having to painfully reload, is the primary reason UI authoring via WYSIWYG in editor is the only option currently. It's not necessarily because WYSIWYG is good, but just it's the only option.
I mean the wysiwyg is good, its exactly what id want a wysiwyg to do as a coder
Its exactly just enough
The problem with domain reload has nothing to do with the wysiwyg, they are separate issues
Either way having a good portable control is beneficial to ui development
Having to write custom code for every situation is not a good place to be
I'm saying having good reload will nudge people towards the code centric workflow where you just press a few keys with autocomplete, rather than painfully dragging things around and then clicking into controls to further type in information that cannot be encoded in a WYSIWYG editor.
I think we both made our points by now, so I'll exit the conversation here.
Id argue if your modifying c# to get your ui just right, something has gone terribly wrong
Hey so has there yet been a way added to index into/get the instance ID of a raytraced object from the RT acceleration structure when intersected using RayQuery in a compute shader?
For future reference, this is hardly an advanced question and definitely not related to code. You'd get a faster answer and less chance to be warned by mods if you ask in the correct channel(or in unity talk if you don't know where the question fits).
I see. I guess they either misunderstood your question or were plainly wrong. Anyways, while it's fine to take advices, use your own head and common sense as well. It should be clear from this channel description what it is for.
No. Just trying to make the server rules clear. Oh and btw, I found who directed you here. It was no other than yourself. Anyways, I made my point, so there's no need to continue this.
He's not wrong - you did ask in unity-talk where to find help but then you just sorta.. decided to come here.. this is a code channel, and .. isn't advanced. #archived-shaders , #โจโvfx-and-particles or #๐ฅโpost-processing seems more like what you're looking for. #๐ปโcode-beginner if you're just trying to get around Unity and "have zero idea where any of that is listed".
the baseless name calling is also a great way to make sure no one wants to help you in the future. You did indeed direct yourself to this channel.
As far as your specific question .. I'm not sure what you're looking to edit on the material? You have a shader graph that has some inputs exposed (that part on the left - the "blackboard"), but it doesn't seem like those are what you're trying to change
@pliant egret You were directed where to look for an appropriate channel, instead decided to pick a random unrelated. No need to throw tantrums here. Use an appropriate channel next time and take a direction.
Move on and don't insult people here.
!mute 475041106657280000 3d ignoring warnings, spam.
pecora was muted.
Anyone familiar with GC/ memory management in unity ?
Describe the bug A clear and concise description of what the bug is. in 2.1 standard apps ( that doesn't use .net 8 ) to be exact (Unity engine) TypeLoadException: VTable setup of type unity.Se...
Anyone here using Content Archives in uECS and able to help answer the following?
https://discussions.unity.com/t/uecs-content-archives-how-do-they-actually-work-under-the-hood-best-practices/1537351
heya! so i was wonder if it was possible to create code/ a coding language within unity that runs similarly to DECORATE/Zscript from doom with its states thing,
where you define a state, and you can give it a sprite definition that it will stay on for a set number of frames and execute code
"SRPTA" being the sprite defintion in this case, 5 is how many frames its gonna hold on that specific frame, and then what comes after in brackets will be functions that it will execute
SPRT A 5 A_Explode;
SPRT BC 7;
stop;```
also how inefficient would it be to use something like ienumerator for this ?
well it's definitely possible, but you'd have to write your own parser and stuff for it
enumerators aren't that inefficient but they come with some upfront GC allocs
hm, figured as much, iam making a 2d fighter and i'd figured it'd be much better for the networking code to sync states than sync animations and events so im trying to see if its possible to adapt the actual systems real 2d fighters use
do you happen to have any useful tutorials or docs for writing parsers and such for unity/c# ?
i'd be lying if i said i had any knowledge in that aspect lol
err i don't have any specific recommendations but i know there's tools out there which you can use like antlr(?) but i think it depends how complicated the syntax will be, some of that stuff might be overkill
i do compiler dev as a side project but i've always just winged it and rolled my own stuff so that doesn't help at all lol
hm, i see, much appreciated for the help either way, i'll give it a shot and see where antlr leads
Mine is 2.5D, and not 2D, but what I do is I make an interface for frame events and contain a collection of each move with the class of the event and the frame it is invoked on. Every update I invoke all frame events with their target frame equal to the current frame
You could probably the illusion of an animation system by adding a โSetSpriteโ frame event that sets the sprite of the player
Hope that helps.
ah my wording was a little off, mine is also 2.5d, GG XRD style if you seen that, i think i understand the basic of this concept but not quite how i'd be able to execute ?
like is this all being done through the normal unity animator or through a custom animator that you wrote ?
It doesnโt matter. I decoupled it from the animation system.
ah alright
Any specific questions? I have my system all built up currently.
main concern was how you'd actually have it run continuously but i missed the update part
I indirectly run it through fixed updates. It is called through other methods, but fixed update is what is on the bottom of the stack.
Do you actually need a programming language?
It seems to me that a configuration is enough. It doesn't matter what format you use, but for example JSON, you could do something like:
{
"states": [
{
"name": "default",
"effects": {
"invincibility": true,
},
"transitionTo": {
"name": "next",
"conditions": [
"takeDamage"
]
}
},
{
"name": "next",
// ...
},
],
"sprites": [
{
"fromFrame": 0,
"toFrame": 2,
"texture": "..."
},
// ...
]
}
You can get very far with a well designed configuration, and you can leverage the existing tooling of whatever format you are using, eg de/serializing JSON is trivial to write code for, and you can write a JSON schema to provide autocomplete and type checking for IDE. Unlike inventing your own programming language, which is going to suck very hard if you are not going to also support things like syntax highlighting, compile errors, etc.
Remember that a huge portion of devops is only configuration and rarely any code, and that runs the world.
To add to Burrito, I personally use scriptable objects and custom editors for mine. You could use Json if you prefer, but I find it hard to edit by hand, especially for polymorphics.
JSON is just a de/serialization format yeah, you can store configuration in any format you want: including scriptable objects.
I mean, you could get away with it if you have a custom editor
Sure, but yeah I mainly just want to point out that configuration is likely enough and a whole programming language is probably not needed. What form the configuration takes, is just an implementation detail.
(FYI JSON is not hard to edit even if polymorphic, you just need to write a JSON schema for it, and any editor that supports JSON schema will give you proper autocomplete and checking, so if say you have "type": "player" then autocomplete will only prompt properties that a player can have. In a way it's just the same as writing custom editor, but way easier)
Poor choice of words on my part. I meanโt โhardโ as in โinconvenientโ instead of difficult
It depends on if you are a programmer or not. JSON with proper autocomplete is lightning fast to type, but obviously if it's for designers then they would much prefer clicking buttons in a UI.
Fair enough. Assuming you serialize and deserialize correctly. Mine look like this when they are serialized:
Yeah typing that with autocomplete would be faster than clicking UIs. The bigger point is that, if you do it in some editor UI, you also gain the ability to immediately see the result, which is especially useful for things that need to be visualized. But for things that can't be or don't need to be visualized (like the state logics in the configuration example above), it would be easier to just use some universal format that can work across client and server, rather than using a technology specific to the client and then work that into the server code.
Fair enough.
Hi - I've run into an issue with a unity package im very dependant on that is creating compiler errors (weirdly out of the blue) and specifically have the need to edit two lines of code in a script in the package. As in, a package gotten through the package manager.
I've never had to do this before and i wasn't aware that you can't simply change a script in a package (any change instantly reverts) Anyone know how i can approach this?
Did you update it Unity or the package?
The package is assuming some things about the rigidbody component based on my unity version, but the assumption is wrong
I didn't update either the package or unity so i'm really confused why that error hasn't been caught before
Essentially its creating two compiler errors assuming unity 2023.1 has rigidbody.linearDamping & rigidbody.angularDamping, but i don't think that's the case for 2023.1
I'm pretty sure that's still rigidbody.drag & rigidbody.angularDrag (changed in unity 6.0 recently)
But i've no idea how to fix it. And no idea what caused this to work for over a month before.
Okay Iโm clueless then
Iโm sorry man I donโt know everything
neat
would it be okay to provide an example of yours ? iam kinda interested to see
I canโt give the full source code due to it having packages, but yeah, after a bit Iโll send snippets.
Idk but looks good
{
"states": {
"minFallMagnitude": 5.0,
"invulnerable": false,
"rights": []
},
"dynamicData": {
"baseHealth": 100.0,
"health": 100.0,
"blood": 100.0,
"regenerationAmount": 2.0,
"bloodRegenerationAmount": 1.0,
"regenerationRate": 1.0
},
"effects": [
{
"effectName": "Divine",
"duration": 5.0,
"value": 2.0
}
],
"vulnerabilities": [
"Bullet",
"Fire"
]
}
I asked chat gpt for example
Cuz I'll add mods system in the future
yeah no
do not
if you have no idea do not try to help using chatgpt
Im not helping I'm just sended it for universe balance
Maybe reread the rules
Donโt post unverified AI-generated responses in questions or answers; check for accuracy, and state whatโs AI-generated.
Donโt post unverified AI-generated responses
posted again
im trying to warn you, before mods do and they dont fk around long Well, you didnt wanted to listen
Is there a way I could generate like a variable chance of something to have a value? Like i want a number from 0 to 1 but i want the chance for a 0 or close to a 0 to be way way higher than the chance for a 1 or close to a one? does this make sense?
weighted rng?
yeah
sure thats possible, there are tons of tutorials
I writed like this cuz I'm in school now
@carmine lion This is your last warning about posting unusable code here. If you can't help properly, don't post. Thanks.
Could also just use an AnimationCurve and evaluate that
If you are calculating between 0-1 you can multiply the value by itself, which would have a curved weighting towards 0
repeat the multiplication to further skew it towards low values
you dont have fine control over that (the animation curve would be better for that) but its simple
I've written a weighted list generator if you want to use it - although it doesn't match your use case exactly (mine is for discrete values - ie, "1, 4 and 15"). If you want a variable chance of something - you're gonna need some calculus, I think. You could make a curve (in unity) and evaluate it with a random number generator
Here's the discrete weighted RNG approach, though: https://github.com/cdanek/KaimiraWeightedList
Hey guys, I've got a strange issue wondering if anyone knows what's up. I've got an image (one .bmp file and one .png file) that read as 2048 * 4096 in editor but when I inspect the images in in the folder outside of unity they read as 2288โรโ4096. This is definitely causing me issues with my system. Does anyone know why it would do this?
If I import the image into Unity from the desktop it reads as 2048 * 4096, but if I import the exact same file using a file viewer into unity while running my app and log the dimensions it's 2288โรโ4096.
I need the image to be 2048 * 4096 so if there is some operation, compression, or format I can set the image to when I open it in unity that would probably fix my issue.
yo boysz anyone here has a idea on how to battle floating points ? i have a map of 2000x4000 km right for now its a invisible map .. that is used by backend logic etc .. but at some point i would like to have it generated procedural but problem within unity is floating points , when character gets 600+ units away from 0 0 0 loc it starts to behave strange .
A typical solution is to move the map instead of the character.
well yeah that i know i had a script that repositions environment root object , but that does not work on navmesh and navmesh agents
rebuilding navmesh on runtime is hella expensive and is nit an option caus egame freezes
One idea is update the positions every so often, making the player the point of origin in the world and repositioning everything relative to them
well that does not solve the problem with navmesh
i did have a limit right when it reatches lik 500 from 0.it resets
but the problem is woth navmesh
it does not reset ๐
nor does navmesh agents
Hi, I'm looking for a specific data structure, and I wonder if it exists so that I don't have to reinvent the wheel. What I'm looking for is:
- A tree structure
- if a node
Nin the graph is destroyed,N's parentPbecomes the parent of each ofN's children
Is this just an n-ary tree? I dont think a tree necessarily has these sorts of self-healing properties, right?
not there by default
implement a custom deletion operation. when a node N is destroyed, you manually update its children to point to N's parent P, effectively reparenting them.
alright, I mean, the implementation is easy enough - I was just hoping for some sort of more specific naming, for the sake of code readability
Is there a way for me to rotate a Vector 3 around a point? like if i have (2,0,0) i want to rotate it 90 degrees to get to (0,2,0), and then i also want to be able to rotate it around (1,0,0) so i can get stuff like (1,1,0)
I'm trying to understand why you need to rebuild the navmesh. It should be baked onto the the terrain mesh, no? If anything, you may need to recalculate the nav agents, but I don't feel like that's needed either, but then again I've not used unity's nav tools much recently.
Reading few posts above about using AnimationCurve for weighted rng. Nice solution when operating on classes, but now I wonder if it is possible to somehow fetch actual formula that stands behind the curve. Like being able to print the formula and move it to HLSL or bursted job for example. I've found some repo for jobs, but idk if I'm still limited to Desmos for easing n stuff in compute shaders
Look up cubic spline interpolation. It's probably what unity uses for their animation curves.
You can really use any function too, just need to be able to calculate its integral.
Also, if you don't need to modify it dynamically, it might be a good idea(and probably easier too) to bake it into a lookup table. Especially if it's for GPU use.
Yes that's what I'm doing rn. I mean my workflow is just about running desmos graph, digging until I get function that looks like I want and make it actual c#/HLSL function. But it's a bit slow workflow
You don't need to trial and error it, just define a function that fits what you want and do the integral. Turn it into a lookup table if performance matters.
If you want a higher weight for rolling 1 than rolling 0, you can do weight(x) = x, or more aggressively weight(x) = x^2, or less aggressive weight(x) = 0.5 + 0.5 * x, whatever.
Right, I'm talking about making functions in general, not specifically the weighting. Eg smooth step with variable slope, or Lagrange interpolation. Idk if there is better way of doing that instead of using the graph
After all you need it as math formula, I just find desmos an easy way to figure it out, was hoping there is better way tho
Well, apparently the limit is "how good you're in doing maths" anyway ;D
It shouldn't be too hard to make something that allows you to interactively edit curves and it spits out the formula, but mostly it's about choosing the right curve that fits what you need.
If you need "given a list of points, give me a curve that goes through these points smoothly" then yeah cubic spline interpolation is a good choice.
But also depends on your requirement, if you just need the curve to be continuous and don't have specific requirements on the slope at connecting points, stitching basic quadratic/cubic/etc easing together can also do the job, since it has a slope of 0 at 0.
yea sticking within computeshader context - i mainly use such things for animating things on gpu. made Utils.hlsl with things like
inline float smoothstep(float x, uint rank) // rank defines steepness of function graph slope.
{
float a = pow(2 * x, (float) rank) / 2;
float b = 1 - pow(2 * (1 - x), (float) rank) / 2;
float k = abs(x - 0.5f) / (2 * (x - 0.5f)) + 0.5f;
return lerp(a, b, k);
}
(probably bad one but fits my needs)
but when my project grows, i will probably need more, more complex funcs. thats why you made me start thinking seriously about doing some tool to visualize the curve in the inspector and print out the formula to copy-paste into hlsl
shame AnimationCurve does not have ToString() to spit out the formula ๐ฅฒ
well try it .. im not telling that you need to rebake it when using navmesh surface from units new ai navaigation package even that freezes the game when terain gets moved or the nav mesh srface gets moved
hey is there an equivalent kind of function like drawmeshinstanced for physics colliders? like creating a bunch of collisions without being attached to a game object? instantiating a bunch of invisible physics collider objects would be really performance heavy right? would be useful even with primitive collider shapes
How many are we talking? In general, especially if you pool them creating a gameobject per collider should not be a problem
and the physics load is the same if there is a gameobject present or not (which I dont believe is possible) ๐
Is there any other way for cloud render other than AWS.
this is a code channel, and that is not a code question - delete and ask in the relevant channel
Where to?.
I would hazard a guess that you won't get a reply to it anywhere on this server though.
If I make a callback in a tween with references to local classes (pointers) - which I might change before the tween is finished - do I have to copy them first? I am having a bit of a braindumb moment
Renderers[entityBehaviour].Move(path, () => ActionCompleteCallback(entityBehaviour, _startedActionBehaviour, targetLocation)); // start the tween - _startedActionBehaviour will be null by the time this tween finishes, but isn't null here
public virtual void Move(List<HexPoint> path, Action moveDoneCallback)
{
Sequence seq = DOTween.Sequence();
... do long tween ...
seq.AppendCallback(() => moveDoneCallback?.Invoke()); // NRE here
seq.Play();
}
yo
scene view picking shader
has anyone had ever success in implementing it?
basically use fragment shader to render object ID to a scene view (in editor), which unity uses when you click with LMB on the scene to select an object
Pretty sure you need to copy. (Not 100% sure) The same way you need to do:
for (int i = 0; i < 10; ++i)
{
int copy = i;
actions.Add(() => Console.WriteLine(copy));
}
That could be as simple as:
...Local Context
{
var myVariable = _startedActionBehaviour;
Renderers[entityBehaviour].Move(path, () => ActionCompleteCallback(entityBehaviour, myVariable , targetLocation));
}
Yeah.. I tried that but .. behaviour wasn't as expected.. I might have another bug obscuring this one
in the Move() method I tried invoking the action on the first line and it didn't get executed.. strangely
that "temp" line doesn't get executed (like, the only reason would be if moveDoneCallback is null)
but... I don't understand why it could be null since I'm defining and passing it in as a parameter?
I'm doing something stupid somewhere but I don't know what yet
OK.. wonderful. I added some debug logging and the bug went away. A few years ago this might piss me off and frustrate me but I'm just gonna say "ok that's enough for me to see here" and walk away and call it fixed.
The classical quantum bug.
I am struggling to find a pattern for storing rewindable data for save states. I want to certain set of variables to be saved so I can load them later. They will simply be cached in memory, so I donโt need to serialize them. All the ideas I had are either bloated or inconvenient. Anyone have any suggestions?
a Stack ?
The problem isn't storing the variables in a collection. The problem is getting / setting the set of variables.
Oh wait stacks are generically typed I forgot.
How would I got about parsing the stored data into the class? Just using indexes?
not sure what you are doing. I would make a struct and fill it with the required data like
Stack<MyStruct>
and
struct MyStruct {
bool myBool;
}
hardly an advanced topic btw
no idea where indexes come into this
So you want me to make a struct containing all the data that the class need to rewind? Fair enough though doing an interface may be annoying.
I don't want you to do anything, you asked a question, I gave you a solution. Make of it what you will
Can you answer me this then: Wouldn't using a struct require a lot of redundant code with the methods due to having to copy each property down individually? For example, I would have to do something like this in the methods:
void LoadSaveState(SaveStateStruct struct)
{
_myBool = struct.MyBool;
_myInt = struct.MyInt;
//etc...
}
And how would you expect to do it without using a deep copy?
I don't know. Hence why I asked.
well, you cannot, hence the use of a struct
Alright. Thank you. :)
btw, if writing a few lines of code is 'annoying' why are you even bothering with dev work?
Just thought there was a smarter way to do it is all
also, you dont want to fill a struct like this
wait, that was loading not saving. but still not a good plan
put the code in the struct not the class
Why? Becasue I would have to encapulate the struct values?
remember a struct is a value type a class is a reference type.
if you put the code in the class you are making copies of the struct all the time
if you put the code in the struct you are just passing a reference of the class to it
Look at records.
Records have value semantics, but it allows you to do var newFoo = oldFoo with { Property = newValue };.
are records even fully supported?
Yes.
I assumed they weren't. Thanks!
Using structs also works btw, since they are value types. But records give you value semantics (comparison and hashing) for free, which is probably going to be very useful when handling save states.
But really having to write mapping code from your serialized data to runtime state, is pretty common. You can just hand write it (with multi cursor editing, it's trivially done), or you can use a mapper library although I wouldn't recommend that.
Just can't use record structs yet in Unity ๐
btw. Unity does not support serializing Records so they are not fully supported
im trying to predict where im going to land, right now im spawning a cube at that location to visualize the predicted landing spot, but it doesnt work(its not accurate and at bigger horizontal speeds it becomes straihght up wrong), im using a custom kinematic rigidbody so im just transforming things around, when i go into the air the i use the initial angle and speed and then use the up vertical and horizontal components of the vector to transform the player forward and upward, the horizontal movement is a constant speed,(for now ideally id have wind resistance) and the horizontal speed is is adjusted by gravity variable. in airrotate im trying to predict where its going to land and in movehalfpipe im moving the player
unrelated but that model looks cool ๐
im trying to predict where im going to
Bit of a weird question: are there any patterns for supplying equations for calculation at runtime? My situation is as follows:
- I'm making a game with combat with
Characters - I have
Castableobjects that can be anything that anICastsmight want to create, e.g. projectiles, hitboxes, terrain, spells, bla bla bla - in the common case, the
Castables will be created with static values: a hitbox withXYZdimensions, a projectile withSSpeed, a spell withDduration ,etc. etc. - however, I would like to extend the implementation such that the
Castable's fields can be calculated from an equation based on the field's properties. For example, maybe I want a projectile's Speed to increase with the Character's speed. So, for example, I might wantspeed=baseSpeed+Character.speed. - Immediately, I would think to extend
Castablefor those particular projectiles and calculate the speed from there. However, I think it would be very likely that I'd have to extendCastabledozens of times as I make more and more coooolCastabledesigns. For example, maybe I want to modify the speed according to theCharacter's HP, armor, etc. etc. - I think it would be better if, instead of setting the
Castable'sspeedas afloat, I could write an equation into my prefab that gets evaluated at runtime.
Is there any way I could achieve this in C#?
passing functions around
You can make your own interpreted expression language, embed lua/lisp, or make some sort of visual programming thing/ui to compose the formulas
but yeah what is asked for is getting close enough to scripting i would just use lua of its for modding, or if its going to only for making the game just pass functions around that can do the modifications needed or like a modifer interface
properly parameterized dont think the amount of them would be that great
it could be multiple components that implement a interface on the same prefab, that are all paramateized operations you apply to a value
easily doable have a look at https://stevesmith.software/lysei/
if you like what you see DM me and I can share the code
could also do something intersting along the same concept with SerializeReference and regular C# objects that do the same. but you would need more custom editor owrk
I'm trying to decide between a shallow folder structure and a deep folder structure and was wondering if anyone has any input on the subject.
I'm currently leaning on going for using a shallow structure. The previous structure was by type (Material, Mesh, Definition, etc.) and it was not working on a complex project as every sub hierarchy was always different from one type to another.
Shallow:
- Character
-- Bob
--- Prefab
--- Mesh
-- Jean
--- Prefab
--- Mesh
- Ability
-- BobSpinAbility
--- Prefab
--- Definition
-- BobJumpAbility
--- Prefab
--- Definition
-- JeanLaserAbility
--- Prefab
--- Definition
Deep:
- Character
-- Bob
--- Avatar
---- Prefab
---- Mesh
--- Ability
---- SpinAbility
----- Prefab
----- Definition
---- JumpAbility
----- Prefab
----- Definition
-- Jean
--- Avatar
---- Prefab
---- Mesh
--- Ability
---- LaserAbility
----- Prefab
----- Definition
I think I'll go with this implementation. I was running into some compatibility issues with some of the other things I looked into, and so far, it seems that this solution will give me the flexibility I want. Now I'm just hoping that it runs reasonably quickly
It's organizing by type vs organizing by feature. Imo organizing by feature scales a lot better than organizing by type.
Not sure what you mean. By type would be having Prefab, Mesh, etc as root
Type doesn't necessarily mean "file type," it could also be what you've shown in the shallow example (all the characters in a folder, all the abilities in a folder, etc)
I see.
Why do you believe it scales better when you are doing it by feature ? Isnt harder to find things when you need to remember the whole feature hierachy ?
By example, if we were to add specialization to each character with their own abilities.
-- Bob
--- Standard
---- Avatar
----- Prefab
----- Mesh
---- Ability
----- Ability A
------ Prefab
------ Definition
--- Specialization A
---- Avatar
----- Prefab
----- Mesh
---- Ability
----- Ability A
------ Prefab
------ Definition
--- Specialization B
---- Avatar
----- Prefab
----- Mesh
---- Ability
----- Ability A
------ Prefab
------ Definition
Organizing by type makes "finding files of the same type" easier, but makes "finding files that achieve a certain feature" harder, because those files are now scattered all across different folders.
For example someone is exploring your code base and want to see how Bob character works, unless they already know Bob has some abilities, they wouldn't even know to go into the ability folder to check. This means that unless you know what you are looking for, you effectively have to look into every single folder to find everything that's related to Bob.
That was mostly the reason why I was looking into doing a deep hierarchy structure. However, while doing it I found myself having to move around a lot of folder, because in the previous example I added the concept of specialization. There is also the fact that doing it this way increase drastically the depth of the project which usually complexify. Finally, I have a hard time to figure out what to do whenever some feature are shared. By example, if Bob and Jean would have the same ability.
Most of those issues are solved by having a shallow structure. But, as you pointed out, it make things less explicit.
In that case you would move that shared ability out to become a sibling of Bob and Jean (or a sibling of characters), because that ability no longer belongs to just Bob or Jean, so it shouldn't be a child folder/file of Bob or Jean.
How would you name such folder
From what I have seen, the best way to handle such case is to have a "common" folder where everything that is shared end up there. However, it feels strange to have common folder on multiple hierarchy level.
Yeah shared/common are pretty common.You can do:
Characters
|- Bob
| |- Abilities
| |- ...
|- Jean
| |- Abilities
| |- ...
|- Shared
|- Abilities
|- ...
Or you can do:
Characters
|- Bob
| |- Abilities
| |- ...
|- Jean
|- Abilities
|- ...
Abilities
|- ...
These two feel like the same thing, but they can have different semantic meanings, eg in the second one it could mean "abilities can be casted by more than just characters, and that's why abilities is its own root folder rather than nested under characters."
Ultimately the way I see it is that, file system structure is also a way to document your project.
When you need to find a specific file, it's never hard to do, IDE/explorer offer many ways for you to locate what you are looking for. What IDE/explorer can't offer, is to tell you the relationship between files, and that's what organizing by feature allows you to put that information.
Do you feel that something like that is appropriate ?
Being that the first shared is for specialization of Bob while the second is between all characters ?
Characters
|- Bob
| |- Shared
| |- Abilities
| |- ...
| |- Standard
| |- Abilities
| |- ...
|- Shared
| |- Abilities
| |- ...
Hmm, not sure if that's a good example.
But take the first example here, where Shared is a sibling folder of Bob and Jean, that itself encodes the information that "Shared is used by Bob and Jean"
If it was only that level, it would not necessary be hard.
Take the following example as well:
- Bob
-- Ability
--- Projectile - Jean
-- Ability
--- Projectile (Same as Bob)
In this example, both ability would use the same projectile. How would you structure this ?
And than, I also have the case where the projectile is share but only in Jean abilities. (Ability A and Ability B use both the same projectile)
I feel that at this point, it might means that where the projectile sort of belong to Bob or Jean indirectly, they are not necessary bound to them. In other words, if the design where to expand I am expecting to have situation where it happens frequently.
One way you can look at it is to ask questions like "can projectiles exist independent of the abilities (eg character can use projectiles as decoration)?" in that case maybe you want:
Characters
Bob
...
Jean
...
Projectiles
...
But maybe a step further, "can projectiles exist independent of characters (eg projectiles just laying on the ground and can interact with the world in other ways than characters)?" then you probably want projectiles as its own root folder.
Or a step closer, maybe the answer is "projectiles can only exist in the context of character's abilities" in which case you might consider something like:
Characters
Bob
...
Jean
...
Shared
Abilities
Projectiles
...
The real answer I get is usually, it could be. So, I'm trying to find a structure that can work in both case without having to redefine to much of the organization whenever it become the case. I'm also trying to think about how much work it is for the person creating the projectile/ability.
Creating the folder projectile would result in having a flatten hierarchy. In fact, we did pretty much the whole mental process I have been doing it for the past days. (Projectile, Ability are not bound to a character/projectile technically. They could potentially be reused for other things such as Environmental or Structural Entity)
It is also worth nothing, that at this stage we are no longer being able to easily track what abilities/projectiles Jean or Bob have if they are shared. Which was one of the main reason to have a deep structure.
Tbf, you couldn't in your shallow structure either.
I think I'll go with [this
Obviously, however this was one of the major reason why I would not go with shallow, but if we are to lose this down the line I'm not sure it is such as a good reason.
That being said, I really appreciate your view point. You helped me consolidate my understanding of the impact of using either organization.
Why this code always throw a error. ``` private async Task CheckAndUpdateAddressables()
{
AsyncOperationHandle<List<string>> checkHandle = default;
AsyncOperationHandle<List<IResourceLocator>> updateHandle = default;
try
{
// Check for catalog updates
checkHandle = Addressables.CheckForCatalogUpdates(true);
await checkHandle.Task;
if (checkHandle.Status == AsyncOperationStatus.Succeeded && checkHandle.Result != null && checkHandle.Result.Count > 0)
{
// Update the catalogs if any updates are found
updateHandle = Addressables.UpdateCatalogs(checkHandle.Result, true);
if (updateHandle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("Update successful.");
}
else
{
Debug.Log("Update failed.");
}
}
else
{
Debug.Log("No updates available or failed to check.");
}
}
catch (System.Exception ex)
{
Debug.LogError($"An error occurred: {ex.Message}");
}
finally
{
StartCoroutine(LoadLevel());
}
}
UnityEngine.Debug:LogError (object)
Authentication/<CheckAndUpdateAddressables>d__42:MoveNext () (at Assets/Scripts/Authentication.cs:333)
UnityEngine.UnitySynchronizationContext:ExecuteTasks ()
you are auto releasing the async operation handle and then trying to use its results after it's released. Don't auto release, or capture result in .Completed callback
Alright, I will try to fix this
It works, I set to auto release false and then in release finally . Thank you so much
Why when i select what save i need to load, the save is not loading
Properly share your !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.
Also, nobody is going to debug that whole file
Considering you posted in #archived-code-advanced, I'm sure you can debug it yourself and pinpoint where it goes wrong. Then share that code specifically and ask for advice
All I can say is, don't use JSONUtility. It's a bad tool for serialization and prone to not work with basic types. Use Newtonsoft instead (there are packages available for it)
why this code is run in editor?
its using unity_server but somehow after entering playmode unity_editor is false?
like code is grayed and it should not work in editor but it does aaa
How are you running the game
just entering playmode in editor
Are you using the multiplay thing
just dedicated server package not this one which you can launch multiple players at once
just added breakpoint in Shutdown.Quit
I do have current profile set to server tho
because Idk how some stuff look on serverside because I see null refs with using unity dedicated package
If Iโm making a multiplayer game and plan to have things like tutorials, singleplayer matches, etc, then using something like Mirror I wouldnโt want the prefabs to be networked in singleplayer.
I know I can host a game locally and still used the same networked prefabs, but this game uses dedicated servers and I donโt want to have players hosting servers.
Whats a good workflow for this? Can I make my player prefabs for example be programmed such that they just work in singleplayer, and then create a prefab variant that networks the player? So the prefab variant would have a network transform, then maybe some classes to network variables, so itโs separated and I can have singleplayer and multiplayer prefabs?
I know that the netcode library knows how to handle singleplayer with multiplayer assets, but I feel like I canโt run a server if theyโre meant to be hosted on a dedicated server
Or
Should I make it so no matter what, you connect to a server? I feel like games such as Valorant do that, since you lag in practice mode.
I feel like the netcode framework should handle all of that for you and do internal stuff for singleplayer only, but Iโm not sure I havenโt looked that much into it. Iโve looked into some code before and saw signs of that, and it feels like the general process, but I donโt see anywhere that Mirror could handle singleplayer without a local server running, so maybe thatโs a limitation in exchange for a simpler development experience
Most netcode frameworks offer "host mode" setup where one of the in players machines serves as the server.
This is the usual approach to single player modes in a networked game
Right, but can I do that if I have dedicated servers?
Mirror I'm not sure about, as it's pretty ancient
Of course
A game like rocket league has dedicated servers, but I feel like their server code is private to keep their processes unknown
Iโm not sure though
Whatโs used now?
Is it Unity 6 multiplayer now or something?
Netcode for GameObjects
Photon Fusion
Fishnet
Mirror is a fork of the defunct Unet which doesn't exist anymore. Unity's modern solution is Netcode for GameObjects
Isnโt fishnet garbage?
Last time I looked at their code I swear they had singletons containing references to singletons
I might go that route then, I recall it looking similar to UNet/Mirror
Is it stable?
Or is it like early access
It's fully released
Okay sweet
Itโs been a while since Iโve done multiplayer so maybe Iโm not thinking right
But wouldnโt a player need to run a local instance of the dedicated server to run hosted mode?
It's all handled by the framework. Check out the docs/samples/manual
I am going out on a limb here . I am quite out of luck on the Fmod forums and google links.
If anyone can assist me with Fmod Event Tracks in Unity Timelines to get the RMS volume for an FMod event that would be AMAZING!
Currently trying to read the waveform from the RMS volume to get the character heads do bob like old school ps1 dialogue scenes
Application.isBatchMode returns true during AssetPostprocessor.OnPostprocessTexture, is that intentional?
I'm trying to only do asset postprocessing while in the editor, not during the CI build pipeline, as that causes issues.
in my own opinion, avoid fishnet.
i've used it. It gave me endless problems.
the goofy name says a lot.
Yes. The hosting player will act as the server. It should all be invisible to the user-developer (you).
keep in mind that mirror doesn't have true clientside prediction yet. they have very basic limited options for CSP.
The owner of fishnet is a waste of space on the planet too if youโve ever talked to the guy or seen what he does. I definitely would never use fishnet, nor would I recommend it to anyone.
Okay Iโll keep that in mind. I havenโt used mirror in a year, I used a fork of it more recently but it seems like Mirror is better for simpler indie games with simpler networking. I wouldnโt make a game like mortal kombat with it, I donโt think itโs well suited for that and the features arenโt up to task for it last I checked (rollback and such)
Hey questions so when loading a scene via steam multiplayer using Facepunch.steamworks how would you go about loading a scene for all the clients as currently its just the host that loads the scene but not the clients? If anyone knows how to properly do this please let me know thank you!
I have an object and a target rotation, I want the objects rotation to kinda spring to the target rotation and overshoot a little(like a spring would) but I cant seem to get it to work properly. With my current attempt it just turns into a jarring jittery motion no matter how much i dampen it or how much I change the stiffness. How Can i fix this ?
your first mistake is reading localEulerAngles.z and using it in a calculation
Corresponding overshooting easing: https://easings.net/#easeOutBack
There's a formula at the bottom of the page you can translate to C#. You can evaluate it and pass the result to Quaternion.SlerpUnclamped() to achieve the desired result.
Or, you can use a curve (AnimationCurve) set in the Inspector instead of the function
Basically rot = Quaternion.SlerpUnclamped(rot1, rot2, EasingFunction(progress01))
thanks, I don't want to use an animation curve as i want the result to be fairly realistic. But im probaply using the completley wrong approach for what i intend to do. I want the wings of a plane to bend like they do in real life, my approach works but since it doesnt store actuall momentum when you do a hard landing the wings wont bend down as im using the lift force of the wing segment to determin how much it should rotate
its not, it works perfectly fine like this
it may work under certain circumstances, I can guarantee you it will not work under ALL circumstances
have a look at this, might help if you haven't seen it https://www.youtube.com/watch?v=KPoeNZZ6H4s
It's been a while since the last video hasn't it? I've made quite a bit of progress since the last update, and since one of the things I worked on was some procedurally animated characters, I decided to make a video about the subject. In particular, this video highlights the entire process from initial motivation, to the technical design, techni...
yo, so i am pretty bad at math and i really want to make procedural animations like this:
https://www.youtube.com/watch?v=tkDg-5rc8T0
How can i do this? I would like to see maybe a tutorial or a unity page because i can understand that its a bit much to say it here on discord.
Work In Progress.
I'm using Unity's animation tools to blend my quadrupeds animations.
(Sprite Rigging - 2D IK - Blend Tree)
Next step : use and modify the script of my previous video to make this little monster controllable and react physically to its environment !
It's mostly just inverse Kinematics
And a blend tree
Not much math
(for you anyway)
thank you, but i dont think thats very realistic so ill stay with my dampened spring method
I changed my function a bit and it works perfectly as i can see in the inspector for the values but if I try to actually set the objects z rotation to the new rotation it rotates arround all axis for some reason and none of them match with what i set them to
alr tanks apologies for wrong chat
your calculation of currnetAngle (sic) seems rather odd
currnetAngle = targetAngle - (targetAngle - currnetAngle);
I dont see that line in my code but If your talking about the sin stuff thats because its calculating the height difference that I dont think increases linearly and because i want the offset at the iwng tip so it might be different depending on th espan of the wing segment
had you posted your code correctly I would have copy/pasted it. but as you didn't I just wrote what it actually does
but the actual problem was this bit where i confused eulerAngles and localEulerAngles
no, it was using localEulerAngles in the first place, setting eulerAngles is fine
but current angle is = target angle - Asin((Sin(targetAngle - currentAngle) * span - velocity) / span) so you can't actually cross out the span nor the velocity parameters
my bad, you're reusing variables and I didn't spot it
Why do you always do this ? Setting euler angle to a target in localEuler angle space is not fine can you just please not tell my that my solution didn't fix it when infact that was the only mistake in the code and it did fix it
listen, what I said was, you cannot read from an eulerAngle property and expect it to contain useful information because it will not.
There is nothing wrong with calculating angles and using them to set an eulerAngles property
But settin euler angle.z is clearly wrong when im using local angles and im trying to change the local z rotation. Also theres nothing wrong with using local euler angles in this case please stop think act
you do you. but I suggest you learn how Quaternions work before telling me you know best, bye
Hey all, im busy with something rather niche and i cant find many examples or much good documentation.
Im trying to use cuda + untity + Direct3d11 interop to register a texture in cuda so that i can access and edit it, but no dice.
I think a big problem is once i register a resource it should stay the same, but when i remap to it later, it has changed.
And i cant keep registering resources every frame, far too much over head
If anyone knows how to handle this stuff pls drop a message ๐
wow harsh, did he personally scam you or something?
I suggest you do your own research and make your own mind up
i have already made up my mind about the fishnet guy lol
just interested in hearing about the guy's experience
then you would know that what @silent matrix said is not harsh at all
i mean i wouldn't call him or anyone a "waste of space" lol
I would, many of them active on this server, lol
in fact there's one in #๐ปโcode-beginner right now
what
Hi, i have custom build routine (Editor Coroutine) that i am running in batch mode. Recently i started encountering that my builds just hang, i discovered that sometimes when i unlock assemblies it just reloads domain which of course kills my routine and clears all prepared data. How can i fix this? is there a way to just force disable domain reload? or just survive it somehow?
I know i can make scritpable object and save some data to it and then in InitializeOnLoad try start the build again but its ugly and now it happend on 3rd place so it would be super ugly...
Can anyone help?
why not do the build external to Unity?
what? how extrnal? i am using teamcity as CI/CD an i just run my build routine in batch mode, how more can you make it external
look at the Unity command line arguments
i need to configure the project before build, so i just run the method. i already have huge pipeline, i just need to fix this issue that appeared out of nowhere
I wouldn't use a SO for that, you can use SessionState instead. If you're changing scripting defines, you need to allow the domain reload or run Unity twice - one pass for configuring, one pass to do the build
SessionState sounds nice, so i guess set the session state, unlock reload, and then will i get InitializeOnLoadMethod when the domain reloads? or how would you start the continuation? Is there a way to detect that the reload happend? because it does not trigger always.
I see, thanks, will try it out
What's up. Is there a way to use System.Windows.Forms in modern Unity? Saw some usage of it a while back but I need to use it in Unity 6. Even tried to import the dll manually to the Plugins dir but not luck.
Is there a reason you want to access outside unity forms instead of just using unity UI stuff?
Its mostly to handle stuff outside of Unity's control like making a tray icon and adding interactions with it
Not really getting, what you are trying to do, but tha tmight just be me ๐
Oh, did not know the tray icon is actually included in the forms assembly
Apparently it does
It can be done via the basic Windows pinvoke library
But that's too much for me
Did you add the forms assembly to the csproj file?
I did but Unity is overwriting the file
Guess you might have to write your own script to rewrite the csproj after reloading the assemblies
Hi, I'm trying to make a neural network, but after a while, the bots still don't learn. The bots lose fitness/score by hitting walls and going further from the player (the player is in the same spot each generation), and gain score for finding the player. I'm pretty sure it has something to do with the output function, as the surviving bots give completely different outputs in different generations even though they're given the same inputs. Here is the output function, which outputs x and y from -1 to 1 based on the inputs of plr's x - bot's x and plr's y - bot's y: ```private float[] outputs(float[] inputs)
{
for (int i = 0; i < inputs.Length; i++)
{
neurons[0][i] = inputs[i]; //sets inputs to first layer neurons
}
for (int i = 1; i < layers.Length; i++) // Loop through each layer starting from the first hidden layer
{
for (int j = 0; j < neurons[i].Length; j++) // Loop through each neuron in the current layer
{
//print(neurons[i - 1][j]);
float value = 0.25f;
for (int k = 1; k < neurons[i - 1].Length; k++) // Loop through each neuron in the previous layer
{
value += neurons[i - 1][k] * weights[i - 1][k][j];
}
neurons[i][j] = (float)Math.Tanh(value); // Set value of current layer neuron between -1 and 1
}
}
return neurons[neurons.Length - 1];
}``` (Tell me if you need the full NN script)
!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.
It would've been worse but I would get banned from this server if I said anything else.
No, but he's exactly what I said. A waste of space. He treats everyone like trash, nobody likes him because he acts like his framework is god even though his code is absolutely garbage and his framework is awful. He goes onto other servers like Mirror with fake accounts, trolls, talks trash on the mirror framework, then says his framework is better. He goes on reddit forums with fake accounts and talks in third person saying how good his framework is and he deletes anyones comments who have issues with it instead of helping them. I asked for help once with the framework and he said the problem was my computer without even asking more than 1 question of the issue I was having.
I could go on and on about the guy, he's just a POS and if I could say anything worse then I would. It wouldn't surprise me if your account was one of his alt accounts and he would be finding things that I say about him to get me banned so he can try to maintain a perfect reputation that everyone knows doesn't exist.
Not saying you are an alt account, but that's exactly what he does. He makes alt accounts and does greasy things like that
I think he actually got banned from the Unity server because of the things he has done and said.
I know lol
I'm just saying it's funny because you've experienced the same thing so you know what I'm talking about
he does things like that and acts like he is super nice and his framework is the greatest
i searched for your name in his server, and i didn't see you there
he probably nuked your msgs
but thinking i am a fishnet alt is making laugh tbh
you are smart, i like you
Lol you'd be surprised
It usually doesn't take long to find out when he is using an alt account. He's easily irritable
I had a picture of the guy at one point ๐
wow, dude you really hate him, i thought i was his biggest hater
problem solved