#archived-code-general
1 messages Β· Page 452 of 1
is it possible to use multilpe layers in an object?
im sure I can find a work around but im curious
because that's.. not how layers work?
if you have an object with 2 layers, A, B, where A should collide with C, and B should not collide with C, then that object hits an object on layer C, what should happen?
thats a good point, thats exactly the problem I faced a while ago when I had an object with the layer "canPickUp" where I can pick up the object using a script, then I had another script that used the layer "Interactable" to show that the item is interactable. I want an object to be picked up and interactable, how would that work?
can classes be extended in C#
actually couldnt you make that whole thing significantly easier by just using a bool? Like "canPickUp" could just be a bool that you could check on or off then do code based on that
you would not have "canPickUp" as a layer since it doesn't define how stuff collides
"interactable" on the other hand could be used to define that its trigger should detect the player but not anything else
yes
you could have the pick up function be another component (that the pick up script you mentioned checks for) or an extension to interactable, yeah
unity tends to lean towards composition
aight cool
got into unity from learning java since I heard C# was virtually the same for the most part, its interesting to see what you can do
Hey guys, so I got some code to fire a bullet. I've got a variable which indicates whether the player can move or not (in another script) which is a condition for shooting the bullet. This is the code but somehow it doesn't work... any suggestions?
Ive been trying to figure out how to check if 2 booleans are not equal in c# but I can't figure out a good way to do itπ
This is the best way I've found
(((Convert.ToInt32(a == b) << 1) ^ 2) < 0) ^ (((Convert.ToInt32(a == b) << 1) ^ 2) > 0)
debug it. make sure the if-condition is triggering, for example. if not, then find out why
use debug.logs to see what the variables are
yess thankss i fixed it
Just curious, what fixed it?
a != b
Whatever you have there is massively overcomplicating it
It was a joke lol
there's no way to tell such a joke from a normal question people ask in here Β―_(γ)_/Β―
π
When should I use an abstract Monobehaviour class over an interface?
when you need inheritance, plus other things like private fields n all that
What is the ":" in C#
inherits? i think
depends on the context
You should use an abstract class when you define a concept/object over a functionality/capacity.
By example, you would have a Character, a Projectile or a Buff as an abstract class and a IAttackable, ITargeatable or IBuffable as an interface.
It can be, non exhaustively, inheritance, string formats or ternary operator.
show example
it depends on context
like you could do
class Dog : Animal {}
to make dog inherit from animal or you could do
string myVar = myBool ? "true" : "false";
which is the same as
string myVar;
if(myBool)
{
myVar = "true";
}
else
{
myVar == "false";
}
and more
can anyone look at my tetris game and see any ways i could optimize it?
using System;
namespace PlayerInfo {
public class Program
{
// Define an enum for different player roles
public enum PlayerRole
{
Warrior,
Gunner,
Archer,
Healer
}
public string PlayerName { get; set; }
public static void Main(string[] args)
{
PlayerName player = new PlayerName();
player.PlayerName = "Inferno";
// Assign a role to the player
PlayerRole role = PlayerRole.Warrior;
// Print role to the console
Console.WriteLine($"You have selected the role: {role}");
// Use enum in a switch statement
switch (role)
{
case PlayerRole.Warrior:
Console.WriteLine("Strong and brave! You deal high melee damage.");
break;
case PlayerRole.Gunner:
Console.WriteLine("You are have control over all the weaponary in the world!");
break;
case PlayerRole.Archer:
Console.WriteLine("Swift and accurate! You excel at ranged attacks.");
break;
case PlayerRole.Healer:
Console.WriteLine("Supportive and vital! You heal your teammates.");
break;
}
}
}
}
this is a unity server
Can someone aid me in the object instantiation, I came from Java.
I'm trying to fix out the error.
if you need help with c# outside of a unity context then perhaps ask for help in the !cs discord
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
PlayerRole role = PlayerRole.Warrior;
Is this a unity question
Well, just C#, thanks for guiding me in the right direction.
static void PlayGameF1()
{
PlayGame();
}
[MenuItem("Edit/Run _F2")]
static void PlayGameF2()
{
PlayGame();
}
[MenuItem("Edit/Run _F3")]
static void PlayGameF3()
{
PlayGame();
}
static void PlayGame()
{
if (!Application.isPlaying)
{
EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), "", false);
}
EditorApplication.ExecuteMenuItem("Edit/Play");
}```
is there a better/cleaner way of doing this?
Is that recursion?
no?
Cleaner way of doing what in particular?
not having to separate keybinds across unique functions to do the same thing
Why do you need 3 functions that do the same thing?
i want f1, f2, and f3 to all do the same thing, but i cant attach a MenuItem attribute to a single function that controls the logic for all 3 keybinds
so i was asking if there were alternatives
probably not Β―_(γ)_/Β―
hi, im running into a problem trying to access variables in one script from another.
//script A, not attached to any game object, contains many stats
using UnityEngine;
public class Stats
{
public readonly int baseHealth = 100;
public int Health;
}
//script B, attached to the player, should access the baseStats, apply modifiers, and update the stats to use them.
using UnityEngine;
public class DoStuffWithStats : MonoBehaviourGizmos
{
public Stats stats;
void Start()
{
Debug.Log(stats.baseHealth);
stats.Health = stats.baseHealth * //player object children with a certain component//
}
}
it doesnt work, saying an object reference is required and i kinda ran into a wall here
What exact error do you see and where do you see it?
I see you have a public Stats stats variable in script B but I don't see you initializing that variable anywhere.
So my expectation would be a NullReferenceException the first time you attempt to access one of its members in the Debug.Log(stats.baseHealth); line
but if this is pseudocode - you should share the exact actual full error message and the actual script code instead,.
Stats is the class name
stats is your actual variable
you would do stats.bIntegrity
you will definitely get that NRE issue here as well, unless Stats is serialized in the inspector.
yeah you're right, how would i go about fixing that
either make it serialized (by adding the [Serializable] attribute to the Stats class, or manually create an instance of it with new before you use it.
im used to just chucking everything needed into one script but the stats need to be accessed by a few different scripts so im new to connecting scripts together
yeah adding stats = new Stats(); in start fixed the nre 
so i can just do stats.Health = //whatever// in another script, and reading stats.Health from yet another script down the line would return the new value, yes?
as long as your references point to the same instance
how would i do that? i added [System.Serializable] to my stats, and have 2 scripts now with public Stats stats, but changing e.g Integrity in one of them doesnt affect the other.
of course, they are two separate instances and no way connected.
If Script A has public Stats stats and ScriptB has public Stats stats they are two different version of Stats unless you told ScriptB you want to instead use Stats from ScriptA, so you would reference ScriptA and access stats from there
public class ScriptA : MonoBehaviour
{
public Stats Stats;
}
public class ScriptB : MonoBehaviour
{
public ScriptA scriptA;
private Stats stats;
void Awake()
{
stats = scriptA.Stats; //changing stats from here would affect stats in scriptA
stats.MyInt = 99;
}
}```
oh i see.
so i make a script with an instance of Stats, and then have all other scripts that want to use the same stats, reference thatScript.stats instead of Stats.stats
from the example shown above, if you reference the same Stats object you are not instancing a new one because ScriptA already instanced it
you are just referencing the same object Stats
though if these are meant to be shared stats you could also use a ScriptableObject you can plug into a field for all items that need it
so uh my idea was
//one script to make an instance of Stats
public class StatAccess : MonoBehaviour
{
public Stats stats;
}
//script a changes a stat
public class ScriptA : MonoBehaviour
{
public StatAccess access;
private Stats stats;
void Start(){
stats = StatAccess.Stats;
stats.Integrity = 999;
}
}
//script B reads changed stat as 99?
public class ScriptB : MonoBehaviour
{
public StatAccess access;
private Stats stats;
void Start(){
stats = StatAccess.Stats;
Debug.Log(stats.Integrity);
}
}
so yeah it would kinda work in how you think of it , but for Unity specific case two functions in Start is not guaranteed which one runs first (unless execution order is changed but thats another topic) or one is not active before another
but yes both would have the same 999 value
i wouldnt change or read the stats in start, that was just for the psuedocode here to be more compact
btw this is also is specific to Reference types, if it were a Value type ie a struct instead of class then you would only creating a copy and changing the item on scriptA referencing stats from StatsAcess would no affect the one on StatsAcess
i see, thank you for your help, i think i understand the instancing of classes somewhat now
you would have to assign the new value to stats back to StatsAccess (for struct / value type)
also this is not how you access stats
stats = StatAccess.Stats;
it would be access.stats
access is the variable name you want access the instance of Stats from
StatAccess is the class tho
yes thats just the type you want to use, not the instance itself
so wouldnt the things i wanna change be StatAccess.Stats.Integrity basically
oh nvm i see
no you're confusing Declared type and instance of that type
yeah i got it xd
classes are just blueprints
unless an item is marked Static it belongs to a specific instance of that object/class
yeah was an error writing the pseudocode, i see it now
if you had public static Stats stats;
then you could access it with StatsAccess.stats.Integrity
cause it belongs to the class instelf
this is why normally static is used for a singleton pattern which you might also benefit learning tbh
Where do these stats live in relation to the script? Itd be better if you just pass the instance to the script themselves
i think i'll have a look at scriptable objects, they seem like a good choice for these shared stats
Scriptable objects would be useful for declaring what npc has what stats, but you'd still ideally want to copy the values. It doesn't really change what's happening in the code above
Actually it can be fine to just access the stats in start, but there should ideally be 1 central class which sets up the stats based on your scriptable object
Setting up the values should happen in awake
can i make "instanced" classe instances in the inspector work with derived classes?
for example public MyBaseClass myClass;
how could i selected MyDerivedClass1 or MyDerivedClass2 in the inspector ?
If you drag them in it should just work
this works with instances
im talking about creating new one, using SerializeReference, which seems not supported by default
i found a free plugin that does
your seems better that the one i have pulni
Ah... well in that case, let me leave it here π https://github.com/pulni4kiya/unity-editor-tools
(I deleted my message as it seemed spammy after you said you already found one)
98% of the time it just works. But there are weirdnesses every now and then that I'm usually trying to resolve as I encounter them.
when im nesting stuff, should use [SerializeReference, TypePicker] on the variable that holds the abstract base class ?
yes
mm... if you have a nested abstract thing it would also need the [SerializeReference, TypePicker] on that field/property of course
yup that works
i was using a serializeddict and then had a list of that base class inside
how does nested coroutine works ?
if i call StartCoroutine(FirstCoro()), and FirstCoro calls NestedCoro(), how would any yield return placed in NestedCoro behave ?
i assume it would work like it was inside FirstCoro if NestedCoro returns a IEnumerator
or am i forced to do yield return NestedCoro() in FirstCoro
Would behave as normal. If the first coroutine yields the execution of the second then that affects the first only.
and if i call StartCoroutine inside a running Coroutine function, i assume it will be independant ?
Hi just a quick question, how can I access the Transparency Sort Axis in the settings? I'm using URP and I'm trying to make a 2.5D game. I can't seem to find it in the graphics settings. I tried looking it up but unresolved
Yes it is. It's like an un awaited async function.
how to fix that
you likely have a duplicate script
how to fix
read the error message to find out
Amazing how many people make this mistake and don't read π€
I guess people follow older tutorials using old input on unity 6?
How to fix
each one of your errors is #π»βcode-beginner level at best. and you should perhaps maybe do any amount of research instead of just dropping a screenshot here like "hOw FIx" every single time you see an error
Your project has nothing named UnityStandardAssets in it
havin a brain fart rn, how can I structure this so my player gun knockback & dash will work normally? Right now theyre being affected by my rb velocity still
It worked earlier when I only had one thing to check but now since I got two only one can work
oh wait
choose one to have priority and make the other an else if
already tried that
oh wait that's not what the code says
the first one should be right
the one that's commented out
Quick question, is it possible to add white to a TextMeshPro text rather than multiply? By default, multiplying white just gives me the same color I started with. But I'd like to add a glow effect to my text so I need to add white to it (Not the border glow option that the default shader gives)
Pretty sure you can just access the color using textMeshPro.color and then putting the intensity up to add glow/more white
Ahh, interesting. I'll try that
Hmm, I don't see any changes when raising the intensity past 1
You need to describe what you want better
I have text that is like this. It's a bitmap font type. I still need to be able to multiply it for different colors, but I also want it to glow a white. Since TMP multiplies color, if you use white, it just gives the same base result. I can try to do a mockup if I'm still explaining it poorly.
does anyone know stuff about like final IK and VR perchance?
trying to make a boneworks/lab type game
problem is tho
the xr rig does fall through floor and come back which is what i want BUT
the characters parts trying to target the controllers and stuff dont fall alongside the xr rig
also maybe even the jumping
when i jump, it doesnt move with the xr rig
@steady bobcat I'm looking to do an effect like this
Spoiler tag so flashing doesn't bother people lol
You could instead make the text's normal color at the brightest it gets, and then turn the color multiplier down for the normal state
Otherwise you'll need a shader that supports HDR colors since the default one can't go above 1 intensity
That does make sense
But hmm, wouldn't that kind of fudge up the contrast?
Oh actually, I can just use a mask
my editor script was working perfectly as intended yesterday, but after reopening my project today, im told that it's not possible to do what i already did? even though it was working perfectly before a restart?
static void PlayGameF1()
{
PlayGame();
}
[MenuItem("Edit/Run _F2")]
static void PlayGameF2()
{
PlayGame();
}
[MenuItem("Edit/Run _F3")]
static void PlayGameF3()
{
PlayGame();
}
static void PlayGame()
{
if (!Application.isPlaying)
{
EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), "", false);
}
EditorApplication.ExecuteMenuItem("Edit/Play");
}```
so i changed my code to the following but i'm still getting the same warnings about f2 and f3???
i realize i read the warning wrong now, but i have no idea why this is happening still
Is this a duplicate script? Have you tried rebooting the Editor?
i checked for duplicates and this is the only one. i even tried deleting and remaking the script under a different name and i still get the same warnings. i also tried restarting but i still get the same warnings after every restart and domain reload
also, if it was a duplicate script, i would be getting an error for my PlayGameF1 method as well
You've simply changed the hotkey but the menu item names are the same
im not sure what you mean
To create a menu with hotkey G with no required key modifiers to press, use "MyMenu/Do Something _g".
A space character must precede hotkey text. For example, "MyMenu/Do_g" isn't interpreted as a hotkey, but "MyMenu/Do _g" is.
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/MenuItem.html
Try "Edit/Run1 _F4"
ah, that fixed it, but why was my script working properly yesterday despite this?
Not sure, it shouldn't have with the above lines of code as you've got two functions wanting to be the same menu item but simply with different hot keys
just went back to check to see if everything was the same when i asked a different question regarding the same script yesterday, and everything was the same... #archived-code-general message
im truly at a loss
You probably had that warning but didn't realize it. It isn't an error so it shouldn't be stopping your function from "working". Do understand though that you'd have duplicate menu items if you opt to have them use the same name. For example, there would be two "do something" etc
It's only a warning, not an error
i remember specifically writing this script yesterday, testing all of the keybinds out, and remembering that they all worked properly. i also always have all errors and warnings visible so that i can fix them when they pop up, so im sure i wouldve noticed it for the hour or so that i was making changes to my project yesterday
also, the warnings do stop my f2 and f3 keys from working as intended
only f1 was working properly when the warnings started showing up
also, can you access menu items like that for SO's? (my script is an SO so i have no way of testing that)
I'm not sure, just stating that it's simply a very reasonable warning (duplicate name etc)
Why it wasn't visible yesterday or why it's producing an undefined behavior could be due to anything. You'd need to show us what Play Game is actually doing.
It wasn't my image (a random image from the net illustrating menu items)
As for it being available on SOs, I wouldn't see why not as you ought to still be able to access the inspector of an SO from the Unity Editor (not entirely sure as the inspector view for an SO does differ a bit).
(I'm not on a PC right now)
Hey guys, I've got two scripts: one for player health and another for movement. Now the movement script should disable movement once the player is dead (which is determined in the other script) but it won't work! Any suggestions?
Log the player health in the if statement
Verifying if:
- they're referring to the same player
- health is the expected value
inb4 alive is not the static var they are checking elsewhere
Show !code for both scripts
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
π 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.
Does anyone have tips on how to use NavMesh for 2D alongside rigidbody operations? Like implementing enemy navigation and dashing into the player.
kinematic rb, switch to dynamic , do dash / disable agent , then reverse
If you mean having a kinematic rigidbody during navigation and switching to dynamic when dashing, then it still results in weird behavior, or it could be my code
weird behavior can be dozens of things
what is supposed to mean
I tweaked my code, now the enemy behaves mostly fine, but when chasing a moving player the enemy dashes and bumps into air, so they can't quite catch up to the player (this is without the kinematic rigidbody method)
maybe show more of the setup up
I tweaked some more, now the enemy behaves almost perfectly, I increased the dash force and added linear damping to the rigidbody, and the enemy can catch up now. Sorry for the trouble.
curious on the differences between return and yield return in this instance:
public IEnumerator WalkCoroutine1()
{
while (true)
{
yield return StepCoroutine(controller);
}
}
public IEnumerator WalkCoroutine2()
{
while (true)
{
return StepCoroutine(controller);
}
}
public IEnumerator StepCoroutine()
{
yield return new WaitForSeconds(stepDelay);
Step();
}
the one difference im sure of is that return will end the coroutine? and it seems like you can't have yield return as well as return?
WalkCoroutine2 effectively does nothing at all except serve as a sort of alias for StepCoroutine(controller). The while is definitely not supposed to be there
WalkCoroutine1 will repeatedly run StepCoroutine(controller) over and over again forever
A coroutine yield returning another coroutine will wait for that coroutine to finish
my guess is top returns an ienumerator iteratating over each value returned by yield return, while bottom returns whatever Ienumerator StepCoroutine has
A normal return effectively replaces this coroutine with the new one
ok ok
The while loop in the return one is pointless
yeah I know I was just trying to set up a generic example
Yeah but it's key to understanding the difference
yes
public static IEnumerator ShootFanEnum<T>(T prefab,Vector3 position,Vector2 direction,int projectiles,float angle,Transform anchor) where T : Projectile {
for (int i = 0; i < projectiles; i++)
{
float currentAngle = 0;
if(projectiles != 1) {
currentAngle = i*(angle/(projectiles-1)) - (angle/2);
}
var shootPosition = position;
if (anchor)
{
shootPosition += anchor.position;
}
yield return ObjectPooler.main.Shoot(prefab, shootPosition, Quaternion.Euler(0, 0, currentAngle) * direction);
}
}
public static IEnumerator ShootFanEnum<T>(T prefab,Vector3 position,Vector2 direction,int projectiles,float angle) where T : Projectile {
return ShootFanEnum(prefab, position, direction, projectiles, angle, null);
}
public static void ShootFan(Projectile prefab, Vector3 position, Vector2 direction, int projectiles, float angle)
{
var shootFan = ShootFanEnum(prefab, position, direction, projectiles, angle);
while (shootFan.MoveNext())
{
}
}
ok this was the reason this came up
The regular return is just delegating to another coroutine entirely
I wanted to have a function that can shoot in fan, but also can be used by a coroutine to delay one shot after another
Just make a coroutine with branches
(if statements)
You can put your yields in conditionals
I originally had the second overload just have yield return ShootFanEnum(...) but that never ran the original overloaded function
if I ran it from the bottom non-enumerator function
so I changed it to return and it worked
You have to use StartCoroutine to run a coroutine
yield return StartCoroutine?
Only if you're trying to make one coroutine pause and wait for another
lets say I want that
Then yes that will work
ok I guess my confusion lies in how yield return works
Or just yield return the other coroutine
When using an IEnumerator as a coroutine, yield return means "Wait here until the condition is met, then continue from the next line"
If that condition is WaitForSeconds, it'll wait until that amount of time has passed
if that condition is a StartCoroutine, it'll wait until that coroutine finishes
The unity engine is calling MoveNext etc on it yes, and processing whatever you yield return
Depending on what you yield return it will come back to that coroutine at a certain time
But you should not be iterating it manually
what are the functions you use to wait? Like what are you even returning? I always assumed WaitForSeconds() was itself an Ienumerator but I guess that doesn't make sense
in this instance these are not coroutines i guess, just generic ienumerator that could be used by a coroutine
It's just an object that the engine looks for and contains the number of seconds to wait
YieldInstruction it seems
Yes
is the waiting not even inside WaitForSeconds it just checks the type you return
and does predefined things
Suffice to say it just checks once per frame until the amount of time has elapsed
which is interesting
you could probably do 99% of the same thing with a coroutine
anyway thank you for your ienumerator and coroutine insight
they are a very weird thing that you learn as a beginner and just go "huh thats odd" but just kind of compartmentalize the knowledge without understanding how/why they work
That's the downside of close sourced engines/software. You only know what the developers decide to tell you. Everything else is assumptions(though they can be close to reality).
As for nesting coroutines, I'd avoid doing that precisely because we don't know how it works under the hood.
Use async if you need complex asynchronous logic.
I think understanding IEnumerator functions is like 80% of the understanding, its just a more advanced topic
most of the weirdness is from that
i remember wondering what the hell yield return was but never looked much into it
Its meant for IEnumerable collection itteration
i think for a while I thought it was a unity specific thing
but that didn't rly make sense
since it was a special keyword
just the reality of being a beginner using a very complex system most advanced users don't even understand completely
If you understand async it helps but async took too long to work nicely in unity (UniTask is still better π )
This is quite common in software development. You always use a complex system that you don't entirely understand. Like, most people don't understand graphics APIs, yet we're using engines that use these under the hoods. And people that do understand those, probably don't understand how the GPUs work under the hood(on driver level or even lower).
Programming is dealing with abstractions
yeah, its the reality of using a computer
pretty much nobody is going to understand from the ground up how ever single layer of every single program works
except for very specific instances
also nesting coroutines seems fine actually, my code wasn't actually using one in the nesting bit. I was manually iterating another IEnumerator manually inside a coroutine, and the nested IEnumerator didn't work
you can yield the execution of another just fine if started correctly otherwise yea the unity magic is not gonna work
I think because it was returning the IEnumerator to .MoveNext() instead of nesting them
im still kinda confused why yield returning an IEnumerator does not just start iterating over that? It seems like it should looking at examples
no maybe not
the returned result is used to tell when to next execute the IEnumerable so you just confuse it
you return something from another coroutine which is gonna fuck what you want it to do
there is one example that says doing yield return OtherCoroutine() works to nest them but thats probably just unity doing that
I think thats where my confusion came from
well you dont have to be confused you can read how it works: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/yield
it seems unity checks if what u returned is an IEnumerator and if so it jumps into that
thats my guess
you can do yield return StartCoroutine(Foo()) to make it actually work
anything else wont because again this is just lucky abuse of yield
I do remember trying this and it working as well
is it documented anywhere why this is "wrong" and the other way is "right"?
What i said is from the doc page and what I used to use:https://docs.unity3d.com/6000.1/Documentation/ScriptReference/MonoBehaviour.StartCoroutine.html
I only use async now and ditched coroutines
// Start function WaitAndPrint as a coroutine. And wait until it is completed.
// the same as yield return WaitAndPrint(2.0f);
yield return StartCoroutine(WaitAndPrint(2.0f));
print("Done " + Time.time);
seems like both are valid
in fact, are equivalent
Anybody ever ran into an issue where when trying to build you get errors saying that "type or namespace doesn't contain a definition for"...but it actually DOES contain it?
you'd have to show the specific example. Sometimes it's due to preprocessor directives, or sometimes it's due to the use of assemblies that don't compile for your target platform.
Or, sometimes you just have a plain old compile error
Don't know if you can help me from these screenshots.
If it helps...everytime the Build process fails, the scene that I have opens gets marked as if there are changes in it that need to be saved...even though I haven't touched it.
Read the errors it's clearly a compile error in your code. Can't help you more than that if you can't share the code.
This middle one at least is pretty clear that you have runtime code trying to use UnityEditor stuff (Handles)
the other two look like more generic compile errors. Will point again to #archived-code-general message
Thanks. I forgot to encapsulate an OnDrawGizmos method in an #if UNITY_EDITOR
Prime example of the risks you take when working late.
yes its good
Hey friends. Has anyone got crashes on Editor open? I'm not exactly sure what to do with the 'attached files' in the bug report, namely the dmp file. I sent it off anyway. I'm struggling to understand the crash log.
Im using multiple NativeArrays for the OverlapSphere command, and using Allocator.Temp to init these.
Since the size of the array is different each frame, im calling this at each new fixed frame, so im wondering if there is a more optimal way to allocate the memory needed
Also for stuff as these physics commands that are executed as a job, im currently doing:
- Fixed Update 1
- allocate arrays, fill with commands, wait for complete, read and dispose
- Fixed Update 1+?
- ...
- ...
I saw some people waiting for completion and reading the results on the next frame, is there any reason ?
Does anyone know if Unity supports Microsoft.Toolkit.HighPerformance in newer versions? I think they brought in Span etc so I assume it works, but I cant find anything specific around this, I mainly want to use Span2D
That's entirely for yourself to determine
If the feature works and it's overly complex I'd say it's generally good
If you want to know if it's the best approach, that's a different question
why can't i use IPointerClickHandler to detect click on a nonUI-gameobject
added physics2draycaster on the camera but still doesnt work
do your objects have colliders on them?
π§ yes and i just find out having rigidbody on it make it not work for some reason
make sure no canvas is in front
blocksraycast to false
its solved. but i have no idea why having rigidbody make the collider not detect mouse input
oooh i turned off simulated. thought it just turn off the physic
h im wondering why i shouldnt store json save data into playerPref but into a seperate text file
Because you create garbage in the users registry.
would it be the same as storing other preferences ?
PlayerPref API is also quite limited and awkward in more complex saving setups.
Yes. Though it's not like an absolute rule. Just avoid storing a lot of structured data in it. Something like 1-2 primitive values is fine.
i just had a senior say he been doing it all along in a interview, so trying to figure this out
is there a scenario where the file works but the playerpref doesnt
I'd imagine there's a size limit to the registry entries, so you won't be able to save strings if they are too long.
max size 1mb, indeed
But just avoid it as a good practice. If you overdo playerprefs, it's not much different from being a malware
ah no
Im going to presume services like steam cloud saves do not work with registry values so that should be a good reason to never use it
You can also do versioning and backups if you save JSON files
Highly recommend putting a version in there from your first iteration
Yes i always have a version in saves i handle, very useful later to perform automatic upgrading
does using yield return break; execute any remaining code in the coroutine?
that's a compile error
yield break; exits the method immediately
oh I wrote yield break; in the editor but mistakenly added return here
but does it execute any remaining code in the coroutine?
No, that's what I mean by exiting immediately
I see thanks
if breaking doesn't make the variable which is holding the coroutine to null, then would this work?
if(!isGrounded)
{
yield break;
reduceSpeed = null;
}
No
yield break exits immediately
We just established that.
You need to do it the other way around
other way?
if i assign it to null first wouldn't it cause an error bcuz the variable just removed the coroutine?
well ig I can try first & see
The coroutine doesn't need to be stored in a variable for it to run. The variable has nothing to do with it
I see
Wdym by "removed the coroutine"? No, all you did was assign a variable to null.
I understand
how often does the inspector redraw its content ?
when showing the content of a scriptable object, im loosing around 80fps
how are you doing it
im using two plugins, one to serialize and edit dictionnaries, another one for a subclass picker
the combo of both ruins the perf
one of those might be doing something goofy
i only have a few entries lol
yeah, a single empty entry in the dict is enough to nuke the editor perf
yeee
public SerializedDictionary<int, LevelDataEventEntry> events;
[Serializable]
public class LevelDataEventEntry
{
[SerializeReference, TypePicker]
public List<LevelGenerationEventBase> eventList;
}
What's this "TypePicker" thing?
Pulni, do you know why this would be the case ?
(Busy atm, will ping you in a bit)
well nvm, sorry for the ping, a standalone [SerializeReference, TypePicker] public List<LevelGenerationEventBase> eventList; doesnt lag
the nesting in SerializedDictionary does
(doesn't mean its not the typerpickers fault, just depends)
i have 43 entires with various settings in the list and 0 lag, a single EMPTY LevelDataEventEntry in the dict and im nuked
this does not change what i said
what would cause a lag inside TypePicker
only when nested in a dict
a list of LevelDataEventEntry doesnt lag either
lag only appears in SerializedDictionary<int, LevelDataEventEntry>
i understand why your making this conclusion
but without knowing what specifically is causing the problem you can't say for sure
eg. the typepicker might be doing something ideal that's only problematic when the code is pushed by the dict stuff
not saying thats the case but can't know until someone looks into it
well i tested https://assetstore.unity.com/packages/tools/utilities/serialized-dictionary-lite-110992 which was my second choice, and i have less lag, so whatever caused this issue doesnt happen here
ok
i have even less lag with this one https://assetstore.unity.com/packages/tools/utilities/native-serializabledictionary-classless-226789
but i have to admit that the initial plugin i was using has a better inspector
https://github.com/TylerTemp/SaintsField
this one is pretty good and should be able to serialize dictionaries too
or you can always open up the wallet and pay for Odin
Though odin dicts get abit weird with prefabs no?
no idea, never used much of the editor serialization part
does anyone know how to make a script that uploads images onto game objects? I have this tv I made by stretching 2 cubes through scales (one is a parent that is selectable, hence its green, and one is the plasma child)
I have multiple sizes (this one is 86 inches) and they all share the same materials for the plasma and the borders, any tips on how to make it work, if its even possible
this is very vague, what do you mean upload images? are you talking about something like render to texture?
how am I being vague? I don't know how else to put it, I want to make the plasma output the image like a tv usually does
well, what images?
drag a texture into the texture slot on the material or something more than that?
FHD images
I mean in runtime
material.mainTexture = myTexture?
I'm coding a screen placement simulator for a pitch im doing for my company
and I want a feature that when I upload my image (in context it'd be like a ad) when I have a TV selected (highlighted in green) it'll output the image in the plasma
Hello
where would those images/gifs go? into a cache folder that would get deleted after leaving the application
im not really aiminig for videos but it could also be an option
how would this even be implemented realistically? that's whats my issue here
i see, you'd need something like a file picker plugin, and then you could load the results into textures using Texture2D.LoadImage
Sorry for bothering you, but could you please tell me what type of device you haveβdesktop or laptopβand what model it is?
im running on desktop, no phone ports
unless you're not talking to me but yeah π
a quick google comes up with this which seems to support most platforms, i'm sure there's other options too or you could implement it with native APIs for the platforms you care about: https://assetstore.unity.com/packages/tools/gui/runtime-file-browser-113006
You can load images at runtime with unity web request (this becomes a texture 2d) and then this can be shown on a material or sprite render
Why are you asking?
This works for images locally too: https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Networking.UnityWebRequestTexture.GetTexture.html
I do have a runtime file browser coded in (sort of) but its not really applying the image anywhere, I tried asking chatgpt for something like that and it still yieled the same issue pretty much
it opens my files, lets me browse and asks for only pngs and jpgs and once I select them, it just yields my debug log that I setup in case its sucessful, but nothing really happens
can you share your code then?
Is your issue with loading the file, or applying the image? You should share relevant !code
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π 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.
Just questions
Just questions
This is a coding channel, your question is neither code or unity related
Is it relevant to coding or unity?
sure 1 second
Sorry
A tool for sharing your source code with the world!
like i said, since i didnt have much of a clue on this i kinda did rely on chatgpt for this one
When I take the mesh and want to combine it with a floor piece but it doesnβt work, whatβs the reason?
You mean the floor piece is distorted, do you understand what I mean?
how does this code even compile, what is ObjectDrag?
you said the log is getting hit, is that the last one (""image is on da screen"")?
Do you use Unity in developing your games?
my script that drags objects like my tv, and it also handles selection, when selected it changes the material and sets off a boolean
its a complete mess at this point but i can send you it if you want ig
I think I'm stupid for coming here.
I do need a better log π ,but yes it gets hit when i select an image on the file picker
πβοΈ
yes, it's a good software for that
and ""simple""
ah I just didn't realize it'd be static, early morning brain
Unity? No, ew. Why would anyone do such a thing?
all good, it also prevents it to upload the image randomly if no screen is selected
ong we ALL love scratch better
Torque3D of course
do I wanna find out what is that? π
who tf am i decieving ofc i want lmao
so it has a texture then! maybe put the result in a public field temporarily so you can inspect it for debugging? if the texture itself looks fine it's probably an issue with your renderer/material
I do share one material for all tvs, maybe it has to do with that?
I could just clone them anyway and have them essencially look the same
you're having it make a new material each time this gets called so that shouldn't really matter
I was searching in ChatGPT for a Unity game developers group, and it gave me a link that brought me here.
Hahaha
I did not remember this lmao
chatGPT rots the brain y'all π
ngl as helpful as it can be sometimes, in the end you really need to just learn c#, I know the basics and thats as far as it goes. for my school project it carried because it was simple, but now I want to persue this and I spent around 120 for a c# course
so im just going to learn it like a normal person, with chatgpt around, ppl who actually know how to code will be way more valorized
do you even need to create a new material there? accessing renderer.material should create a new one for you
i think what im doing is applying the texture onto the cloned material
and thats why it maybe doesnt show up at all
Thank you, your words motivate me a lot.
you're assigning that material back to the renderer so it should be using it
if you want to keep track of it more easily, make your code rename the new material after creating it so you can be sure it's the new one
is it possible to make any variable readonly just for the inspector?
if would still show up. the difference i was saying is you dont need to new a Material because accessing the renderer.material will do this for you
the way I handle my TVs is a bit finicky, so I dont really spawn them, I clone a existing prefab on the scene, maybe that has something to do with it? I did just check the original prefabs and they are fine (no pic tho), but I don't think it should be any different if it wasnt cloning so yeah
I've been coding for a while, but since I just learned by watching tutorials and finding out what was what along the way and then finding out what they are needed for, I have a very big lack of knowledge in a lot of areas in C# because of that I have trouble trying to code more complex stuff by myself, Idk what to do to get more knowledge in C# without having to buy a course, but I don't have any money because I'm a teen/:
i this and the material cloning are more code quality issues, there's nothing that should actually stop this working, i think you just need to do some debugging and check that the texture, material and renderer are all set up correctly to display this texture
for example, does the material used have a texture property that can be set by mainTexture
it doesnt have a texture its just a color
what are you expecting it to do then?
if you don't have a texture slot on your material it won't grow one lol
thats fair, well back then I didn't design them around having an image and thought a plasma texture would be pretty pointless
im on the same boat tbh
except that now I do have a course
thats good because most of the courses are a scam. there are links in #π»βcode-beginner with some beginner to intermediate level resources. if you're already comfy with the basics then the rest is just practice, googling your issue and seeing what related topics come up, googling the related topics when you dont know what it is
I really don't understand the point of serializing datatypes that "otherwise can't be serialized" using this method: https://docs.unity3d.com/6000.1/Documentation/ScriptReference/ISerializationCallbackReceiver.html
I mean isn't the code example not just looping through two serialized lists and then it adds it to a non serializable dictionary and that way you have the benefit of adding values to variables in the inspector? Why not just loop through the serialized lists in the OnStart() method and add it to a dictionary?
the point is to make a type so you don't have to do that independently on every script where you want a dictionary structure
hmm, i dont think i understand
if you wanted to store 10 dictionaries, would you want to write 20 list fields and 10 loops in start, or just 10 serialized dictionary fields?
ohh, now i see. Thank you!
another reason you dont just use Start (which should likely be awake) is because you would be able to modify this in inspector at any time. you wouldn't have to exit/enter playmode to change 1 value
Sorry thatβs what I meant
What is the best approach of making a zoom feature
i want to create a roguelike game, i already hav a boss and when i kill him, a canvas appears with 3 randomly chosen cards(it has 8), the cards its an ui buttons. in-game, it works all except the cards buttons, it doenst work at all, some advices? i alr put the OnClick() functions and all, i really dont know what to do...
Hello, im having an issue where:
when i click my cursor disappears (not clicking the button) and i have to click esc to bring the cursor back otherwise it just dont exist
and yes i have connected my click function
to the button
You should be able to check the bottom part of the inspector on your event system to see what object is hovered. There might be something invisible blocking the button from being clicked on
Since the button doesn't seem to be responding to hover either
Select the Event System while playing. It'll be the same place that preview is in your current inspector
It should show what object it's hovering over
The object named Event System
i dont see mine
i think i gotta make one one sec
maybe thats why
well i added one in the canvas but idk how to use it now
or does it automatically apply itself
It shouldn't be on the canvas, it just needs to exist as an object in the scene
It gets created when you first create any UI object
ye i created one
idk why there wasnt one earlier
idk
its still happening
no hover reaction either
Having an issue with some code, but in a really odd way.
capsule.enabled = true;
Debug.Log($"enabled capsule - {capsule.enabled}");
ToggleRenderers(true);
Debug.Log("enabled renderers");
ToggleHitboxes(true);
Debug.Log("enabled hitboxes");
This code is being executed, since I'm seeing the messages in the consoles, but the code inside those other methods isn't being executed in the way I want it to
And the code inside ToggleRenderers
public void ToggleRenderers(bool enabled)
{
for (int i = 0; i < allRenderers.Length; i++)
{
allRenderers[i].enabled = enabled;
}
}
i have the fastscriptreload plugin so i dont need to wait for the compile each time, its not updating public floats tho
Can i manually update float maybe?
in what way is it not executing how you want? You could add logs to ToggleRenderers to see that it's running through all the renderers. Maybe your list doesn't have all the elements you think it does, or maybe something else is disabling it
its not re-enabling the renderers
Put a log inside the loop and see if it prints. If it does, those renderers are definitely being re-enabled
allRenderers has 4 entries on each of the characters present in my game, each of them referencing one part of the character's body
I'm in the process of doing that bit, digi
That does not mean they are the renderers you expect them to be, and it does not mean they stay enabled
I've got a log in the following places
- player dies
- colliders disabled
- hitboxes disabled
- player revived
- colliders enabled
- hitboxes enabled
They're all executing in the correct place. I'm certain that they're not being modified in any other place
your logs right now are hardcoded strings, they don't actually tell you anything. i feel like you skipped over the important part of what i wrote
"Maybe your list doesn't have all the elements you think it does, or maybe something else is disabling it"
So, each iteration of the loop is giving you a log? If so, then whatever is in that list is definitely getting enabled
Did someone mention a debugger yet?
not yet, im about to do that bit
public void ToggleRenderers(bool enabled)
{
Debug.Log($"toggling renderers - {enabled}");
for (int i = 0; i < allRenderers.Length; i++)
{
allRenderers[i].enabled = enabled;
Debug.Log($"toggled hitboxes - {allRenderers[i].enabled}");
}
}
public void ToggleHitboxes(bool enabled)
{
for (int i = 0; i < playerHitboxes.Length; i++)
{
playerHitboxes[i].enabled = enabled;
Debug.Log($"toggled hitboxes - {playerHitboxes[i].enabled}");
}
}
this is what they look like right now, just about to test this
I don't mean logs but using an ide debugger
might be silly maybe, but im unfamiliar with ide debugging in unity
A debugger would certainly help
meh its hard to suggest it in every case. sometimes you want to just let the code run first and see if the logs line up with what you expect
if there are more values you want to see like the name of the object, length of list, etc then it makes sense to do
I have something spawn but its spawning every frame currently, i read u have to do time.deltaTime but it still does the same
how do i make it wait like a second or whatever
is this likely to add a lot of stuff into my workflow? I've got like, 2 days to finish this project and im stuck on the damn revives lol
no, it takes like one minute to setup. the debugger lets you see all the values and pause execution
its a good tool to learn but truthfully id be adding logs here myself. because all you really need to see is how many elements are getting toggled, maybe the names, and that they are being enabled. With the debugger you would be "stepping through" every breakpoint and imo doesn't really make sense to need here. You dont need to pause to look at the list length or object name everytime
the main thing we're trying to tell you here is that if the code is running, everything in those lists are getting enabled. Those lists might have the wrong (or no) objects for all you know.
The arrays are definitely assigned correctly as well. I can inspect them in the editor, and they point to the correct things
ok yeah, the logs are saying they're disabled when i pass false, and im directly reading the collider.enabled value
the annoying thing is, all of this was working as expected earlier/yesterday
I've made some changes to an unrelated script and now its uh... now its not
If you have anything even semi complex you should just use a debugger so you can actually observe what executes
Do spherecast jobs hit disabled colliders?
OH
no im stupid oh my god, im disabling the hitbox component, not the associated collider...
ok so that solves the hitboxes not behaving as expected
that'd be quite a concern if it did
But it doesn't solve the renderers not being re-enabled all the time
oh.
this thing has to be against me. Renderers are now being re-enabled correctly
hitboxes should be fixed, added a reference to the collider they're attached to
i wouldnt call this complex at all. im aware of what the debugger solves but I just don't like using it for every case. Sometimes i just want the code to run without pausing, and without needing to observe every value or every line that runs. Given the code above, im sure all of us were aware what executes
nothing would magically change. maybe it's related to how you get the renderers, or maybe you thought the issue was something that it wasnt
Perhaps. Either way, it seems like its working right now?
I shall re-evaluate if something is not working later on, but i want to move on from this for now
Tbh I didn't read their code closely I just think it's wise to use a debugger when helpful
my unity keeps refreshing after the first second
After the first second of what?
Opening the project?
Running your game?
prefab was ruined i guees
Not sure what that means, doesn't sound like an answer to what I asked.
I'm not sure if it would technically be considered a singleton, but is there a way to write a constructor so that it can be instantiated with parameters and everything, but any attempt to instantiate it after that first attempt results in absolutely nothing? My first thought is that it would look something like this
{
public static Actor1 instance = null;
public string name { get; private set; }
public Actor1(string inName)
{
if (instance != null)
{
name = inName;
}
else { return; }
}
}```
But I'm worried that writing it this way DOES still technically instantiate a second object but with no information. Am I correct in this assumption and how would I go about making sure the second instance straight up can't be created ever?
Is this a component? If it is, you can't use constructors on it
A constructor always creates an object, there's no way to prevent that
It's not a component
What you can do is make the constructor private, and expose a static function to create/get the single instance instead.
Yeah, I was worried about that. I just don't know what I would do otherwise
That seems to be how most of the singletons I've seen work, but I'm worried doing that way makes it so I can't pass parameters into the first instance the class attempts to create
Why wouldn't you be able to pass parameters in?
I mean it's weird/confusing that you would want to, but I'm not sure what you're worried about
How about instead of using a constructor, you use a static variable that calls a constructor if the instance doesn't exist
In fact the name Actor1 for a class is a red flag in and of itself
use a method instead of a property then
WHy is it numbered?
The numbered class name implies the existence of an Actor2 and Actor3. And the differences between those classes should almost certainly just be data in different instances of a single class, not different classes.
These are OOP crimes you are committing
Also, if it's supposed to be a singleton, why are more things creating it? This probably shouldn't be that common of an occurrence
Kind of. It's more that they all inherit from a character sheet but have certain fixed values so that, when it attempts to read values from a binary formatter, it can calculate what all the other values are supposed to be with as little information as possible
I don't want to be importing in a mountain of numbers
That's how I was taught to make a save/load system. Is there something wrong with that?
Check out the HUGE scary red box on this page: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.formatters.binary.binaryformatter?view=net-9.0
By using BinaryFormatter you are putting anyone who plays your game at risk of their computer being taken over by malware.
So what's the alternative then?
literally any other serializer
I don't know any others
protobuf, messagepack, various json serializers, etc.
bebop but not sure if that requires newer c#
guys, any idea why when i click my mouse disappears? (not letting me click ui buttons) i acn show a video too
probably intended, using some other first/third person character?
im using
a first person
ye
i disable the player in the start
which has player cam and all the scripts
so how can that interfere
im using this in in FixedUpdate in a script on my main camera but the camera seems to lag behind a bit sometimes? is that an issue with my code or how ive got my scene setup?
transform.position = cameraPos.position;
transform.rotation = cameraPos.rotation;
ill attatc a video showing what i mean
fixed update is not executed every frame so it will cause that
oh ok
for some reason i thought fixed update ran after update
like lateupdate
oops
okay ill try it in upate
yo any idea why this is happening????
it just wont let me
click
at all
my mouse disappears
can i move the rest of this codde to upddate too then??
void FixedUpdate()
{
Transform cameraPos = camPositions[camPosIndicator];
if (camPosIndicator == 0)
{
smoothTime = Mathf.Lerp(baseSmoothTime, 1f, Mathf.Clamp01((carScript.speed / 100) - 1));
transform.position = cameraPos.position * (1 - smoothTime) + transform.position * smoothTime;
transform.LookAt(lookTarget);
}
else
{
transform.position = cameraPos.position;
transform.rotation = cameraPos.rotation;
}
}
first part is for a smooth car following camera
the smooth follow becomes very jittery in Update()
so ill juust keep that in fixed
hey so @steady bobcat i tried disabling and enabling the fps contrtoller script but that also didnt rlly do anything
Most things use Cursor.visible and also locked:
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Cursor-visible.html
LateUpdate runs after Update
though generally camera positions are updated in LateUpdate already, so... yeah there isn't anything that runs after that unless you use script execution order
yeah its fine i dont really need it to run later. i just misunderstood my own code lol
yeah generally camera tracking stuff would be in lateupdate, so it runs after the thing you're tracking has moved
yup everythingg works as intended now, thanks for the help guys
so what is Lateupdate actually used for aside from camera tracking? i havent needed to use it yet for anything
anything that needs the updated state of stuff in the scene, i guess?
stuff related to camera stuff like background parallax
oh okay
@vestal arch please can u try to help me with this?
the cursor.visible part on what u said doesnt make sense, bc when i click its like my cursor is centered, when i click esc it comes out the center no matter how much i move it around
locked cursor state does this, hides it and locks it to the center
something is still changing this state
don't ping random people for help
Okay, I have a fairly large problem and I have no idea how to fix it.
Situation: I have a runtime-loaded mesh that defines a "room". It's just the walls, no top or bottom caps. It's a mesh collider that just makes up the faces on the outside of it. I need to determine when the player is inside the room for a post-processing volume. As such, the room has a Trigger Collider, which necessitates a convex mesh collider.
Problem: The convex collider cuts across corners (as it's designed to do) and is therefore detecting the player as in the room when they're not actually inside it. I need to detect when the player is inside this closed, concave polygon.
Attempted solution: I got an addon that can decompose a mesh into convex shapes, the plan was to make a bunch of child objects of those decomposed meshes with trigger colliders, so this object's rigidbody could still detect them. But the mesh isn't actually filled in, it's just walls. So the decomposed polygons are just sections of wall, and don't contain the space inside the room.
How can I (procedurally! I can't just eyeball this I'm loading it in at runtime) detect when something is inside this polygon and not also detecting the corners
my initial thought is to detect if some pos is within a triangle (if you have one for the inner area)
https://stackoverflow.com/questions/2049582/how-to-determine-if-a-point-is-in-a-2d-triangle
But that's just kicking the can down one more road, if I could break down the internal space into triangles, I could just build a mesh out of those and be done with it
Any method of triangulation I could find produces a convex polygon
I think you need to actually get the convex decomposition to be the space inside the room, not just the walls
I e. Start with a "filled in" mesh
Not sure where the mesh comes from in the first place
I don't have a filled in mesh, and if I could triangulate the caps from the edge meshes I'd be golden on that front
You can probably programmatically fill in those holes
Blender can do that, why not you
It's generated from an Autocad drawing, which is just lines
So I just have the lines, but taller
If you can get the vertices in perimeter order, you can programmatically triangulate the ceiling and floor
If that makes sense
I'm not sure how. Everything I've tried to look up for how came up with triangulation algorithms that either failed to cover it all or made the mesh convex
(plugins exist for that too)
It's two phases basically, triangulate to get the ceiling and floor for the concave mesh
Then decompose into convex pieces
I don't know how to get the concave caps though. Delaunay Triangulation is giving me polygons that look like this:
If I could find a way to generate these, then that would be my problem solved but I don't know how
Everything online for filling in a polygon just says "Use delaunay triangulation" and that just doesn't work with this shape
If you have a plugin or even just an algorithm name I could make progress but I'm just stuck on this one
If it doesn't require faces you should be able to filter and get the verts for the top or bottom only right?
I have them all. But how do I fill them in
I guess there's the brute force method of make a triangle between every single vertex and every other pair of vertices, but I am gonna have a whole lot of these and I'd prefer my graphics cards not on fire
And I'm pretty sure VHACD would just give up at that point
Hmm this lib appears to have a few methods of filling holes: https://github.com/gradientspace/geometry3Sharp
I guess I'll give it a shot and see if this one can manage
I had a similiar situation and I used the ear clipping algorithm to split the shape into triangles and made a collider out of each one
Can optionally combine the tris into convex shapes if possible
I have a problem that I dont know how to handle. I have a project that has a camera movement, a player movements and some other scripts. In Game Editor once I pressed play, the sensivity was the same with the one that I have in the build app. But after some changes in another script, nothing about the camera settings or player movement, nor camera movement, the sensivity on the game editor became very very slow, but in the build it was the same. Luckily, I had a backup and once I loaded the new scene and the new assets, everything became good again. So its not from the scripts, neither the scene. It's not my first time I encountered this type of problem and a resolve to it would be very helpful. Thanks in advance!
Are you using Git? Firt thing I would check is exactly which files were changed
None of them changed. On a project the sensivity is very very low and on another project with the same scene and scripts the sensivity is normal.
It was normal and after some coding, It was like that. I thought I did something with the Code, but after putting The Code into a backup, everything was normal. Its not my first time in a project and i dont know why
if something changed after you did some code, and then revert to normal after you removed the code, then its the code
I can't think of something else
how should i play once an animation on a object that overrides (as long as it runs) the active animator ?
making a new animator state for each "one shot" animations isnt the correct way
Only then I realised. Once I finish the code. But its not from the code because on another project with the same scripts and scene, everything is back to normal
why am i have such hard time making a sphere roll and steer like a unicycle ?
My setup is an empty game object the steering which rotate on Y, inside that a sphere that rotate on X
but the sphere keep changing orientation weirdly.
i tried locking axis wont work, any clues ?
You'll have to show the code and describe the issue in more detail than that it changes "weirdly," maybe show a video
Can't you just raycast from 1 side and counts the number of hit ?
Even => Outside.
Odd => Inside.
You can use https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Collider.Raycast.html to raycast on a single collider as well. (But it only gives you a single point. You might want to use the Physics.RaycastAll)
Also, it seems like you can directly get the triangle of the mesh collide with https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Collider.GetGeometry.html (Never used it), you could always do your own raycast on them.
Who here felt like an intermediate level dev until they realized there was a data structure that lets you avoid unsafe and unnecessary code?
...and then you felt like a beginner or an expert level?
Good question. Since it's the first time I should replay the tutorial
What data structure is that?
arrays/lists so you don't have to do item1 item2 item3 item4
i thought they meant unsafe like the keyword and had no idea what data structure could relate to this problem lol
Any possible fix with these?
Don't crosspost
Guys, why does the particle system sometimes play and sometimes doesn't? It seems to be based on a die roll
should I use .Emit instead of .Play? Is that more consistent
people online have been saying this has been the case with the particle system for at least a decade lol
If you want to Emit, yes. If you want to play the particle system no.
You should not use Play -> Stop as a way of emitting a single particle.
It's a non looping system, it just emits particles when I want it to, then emit again etc.
So in this case I should use emit?
If you want to control the emission, yes.
If not, then no.
What do you mean by control?
Decide whenever it emits
Usually, you do not care about that.
It plays, end of the story.
In some case, you want to emit precisely a number of particle
Let's say for the sake of the argument, the effect is an explosion.
When stuff happens, I play the explosion once. Once that stuff happens again, I play the explosion again.
What is right in that case? From what you're saying, it should be play
You should use Play
If the system is not emitting, you might have an issue with it.
Maybe it is not working as you expect.
but I don't want to stop it before playing again. Could that be causing an issue?
It seems like literally a random number generator on whether it works or not
You should be able to play it multiple time.
maybe it's to do with the fact that I childed another particle system on the parent particle system.
But if that were something to consider, then it should either always play or never play. Sometimes only the parent plays, sometimes only child, sometimes both and sometimes none
It should stop itself if it is not looping.
I do not know, but the expected workflow is to call Play(). It works correctly in every case I did it.
Which is quite a lot given that I do video game professionally.
So all the children should play automatically, right?
ok thanks
I have a suspicion on why it might not work, will solve tomorrow probably
if (transform.position.x >= -15.3 | transform.position.x <= -15.2)
This doesnt work. If i make it just the position.x >= -15.3 then it functions but adding the or statement makes it bug
~~you probably want || | ~~
wait can u explain again
|| if first one is true doesnt check for both like | does
in this context it's still a logical OR operator, not a bitwise OR. but unlike the conditional logical OR || it always evaluates both sides. that shouldn't change the logic, just the amount of work it does
i'd bet there's some other context we aren't getting here that would indicate why it isn't working the way they expect
(you generally should use || to link separate conditionals in this context for consistency, but it won't change the behavior)
so || is if i want it to work if any of those 2 function?
i did that aswell, i just send this version of it eventho its the wrong one* sorry
you should show the full context because adding that second condition won't magically make it not work if the first condition is true
I'm getting mixed answers when I try to Google this. Unity's byte.Parse... Can it take a whole string, or is it just a single character? The docs seem like it can take a whole string, but C# talk says it can't because each character in a string is a byte, so it would need to be turned into a byte[] not just a byte.
As you can see in the docs, it takes a string
it's just like int.Parse
but it parses to byte instead of int
byte and int are the same thing, except that byte only has 8 bits, where int has 32.
(also byte is unsigned, so it's kinda more like uint)
Okay. So I was using it incorrectly, but I think my followup question belongs in -advanced
each character is 2 bytes a char is a 16bit value
I have a transform at A (global pos)
And point at B (global pos)
How can I calculate local vector AB for transform A?
I need to account for rotation of A
No need to account for scale as it's guaranteed to be uniform 1
or B.position - A.position, if you want to know the math
hey so i keep having this problem. I try to load saved data. when saving it should check if entry exists and if highscore points are higher. if so, then it should overwrite the old one, if not, it should do nothing. i tried a lot of things but i cant make it right. I even experimented with sortedlist, ilist and hashsets, but keep running into other problems with them.
can you say where the problem is?
c#
/// <summary>
/// creates new single entry OnLevelDestroyed
/// </summary>
public void CreateHighscoreEntry(string _name, float score, int id)
{
var Entry = new HighscoreEntry{Score = score, Name = _name, ID = id};
HighscoreEntryToCurrentList(CurrentHighscore ?? new CurrentHighscores(), Entry);
}
public CurrentHighscores CurrentHighscore;
/// <summary>
/// adds new or overwrites old entries
/// </summary>
private void HighscoreEntryToCurrentList(CurrentHighscores scores, HighscoreEntry newEntry)
{
/////if list is empty
//if (scores.Entries.IsNullOrEmpty())
//{
// scores.Entries.Add(newEntry);
// return;
//}
///if entry exists and points are higher
foreach (var existingEntry in scores.Entries.ToList())
{
if(existingEntry.Name.Equals(newEntry.Name) &&
existingEntry.Score <= newEntry.Score)
{
scores.Entries.Remove(existingEntry);
}
return;
}
scores.Entries.Add(newEntry);
/////if list is not empty, but entry does not exist
//if (scores.Entries.ToList().All(loadedEntry => loadedEntry.Name == newEntry.Name)) return;
//scores.Entries.Add(newEntry);
}
[Serializable]
public class CurrentHighscores
{
public List<HighscoreEntry> Entries;
//public SortedSet<HighscoreEntry> Entries;
}
[Serializable]
public class HighscoreEntry
{
public int ID;
public string Name;
public float Score;
}```
foreach (var existingEntry in scores.Entries.ToList())
{
if(existingEntry.Name.Equals(newEntry.Name) &&
existingEntry.Score <= newEntry.Score)
{
scores.Entries.Remove(existingEntry);
}
return;
}
scores.Entries.Add(newEntry);
This seems sound and should work just fine, but why do .ToList() on a list? (its wasteful)
You can do it faster by itterating backwards with a for loop and doing RemoveAt() instead.
Oh hangon, you RETURN when you find a match... did you mean break?
that would explain it π
wouldn't you want a leaderboard to be sorted?
there is no leaderboard. no sort needed
@subtle path fix the logic error i pointed out and see if it acts as you desire now π
yes i am currently testing. gimme a minute
oh needs to be serializable
you should probably have the Add also beside the Remove
you're just adding unconditionally here
i also need to cover adding new entries
also perhaps some built-in methods could make this easier
ah, gotcha.
then you'd need to be able to check whether or not you should add if the existing entry is higher
about this - you could use Find and then check on that result
I would recommend a reverse for loop doing the same check so it can be removed quicker via index.
whats the right way to make character wear stuff that change appearance
is it just hat and armor as prefabs and throw it on the bone spot ?
speed is really no issue here. but i urgently have to make this save system work properly π
use a debugger to check whats happening
if you had earlier you would have found that return a lot sooner
i am on this for month now π
var existingEntry = scores.Entries.Find((entry) => entry.Name == newEntry.Name);
if (existingEntry == null) {
// new player - add `newEntry`
} else {
// existing player - check for score, if new score is higher then remove `existingEntry` and add `newEntry`
}
HighscoreEntryToCurrentList(CurrentHighscore ?? new CurrentHighscores(), Entry);
This looks sus btw, new CurrentHighscores() is not assigned to anything...
or if you change HighscoreEntry to a struct (which you possibly should) you would check if ID is 0 i suppose, something like that
(then you'd have to make sure actual ids aren't 0)
ill try your suggestions. will take a bit
Take a byte
take a buffer
for (int i = scores.Entries.Count - 1; i >= 0; i--)
{
var existingEntry = score.Entries[i];
if (existingEntry.Name == newEntry.Name && existingEntry.Score <= newEntry.Score)
{
scores.Entries.RemoveAt(i);
break;
}
}
What I would do
if you loop yourself you'll need an extra variable to see if the matching name was found
well you could pull i into the outer scope and check if it's -1 i guess
we can just set a bool or yes move out i to the outer scope. This way we don't need to loop twice which is just more costly with a list of pointers.
you already do loop twice though lol
tis not the same
it is though..?
good to see you are as confused as i am
oh well i guess my Find/Remove method would iterate slightly more but if you're worried about that you can just swap it out with FindIndex and RemoveAt for sometimes more, sometimes less iteration
or you can use List.RemoveAll and not care about any of this
wouldn't really work with the intended logic
yea... that would destroy all entries
FindLastIndex/for -- + RemoveAt: distance to the end of the list, twice
FindIndex/for ++ + RemoveAt: full size of list
Find + Remove: distance to the start of the list + full size of list
FindLast + Remove: distance to the end of the list + full size of list
Yea my point is to itterate and compare once, then remove a faster way (via index). few ways to do that yes
ah sorry π
it really wouldn't make too much of a difference in the grand scheme of things though lol
premature optimization go brrrr
just get something that makes sense and is readable, imo
we game devs must optimise everything!!!!! /s
i dont need to optimize.
i need it to work
i am literally saving at one set point. and its a tiny bit of data
well we told you how to make it work and for it to be fast!
speed is not important
yeah we're basically discussing theoreticals
you don't have to worry about/apply the extreme micro-optimization
I dont know where you use this or how often so i wanted to provide a solution that I deem to be good
we've given multiple suggestions on what you could do
and i am currently testing
not sure what you're complaining about
less complain more fix-y
Guys when i change a simple thing in unity 2d it legit takes 10 seconds before i can run it again
when its not even big, i have 4 scripts and 5 items
Why does it take so long
"a simple thing" - you mean code, yes?
It has to recompile, it doesn't care how "simple" the change is
yea but why does it take so long
depends on a ton of factors
i have a good pc setup and a friend of mine has a worse setup and 3d game with more and its faster when he changes a simple script with 10 lines like me
For various reasons. It's not just code compilation. Check the logs for more details.
where are logs?
but also if it's a "simple thing" - is it just a number value or something? if so, use the inspector lol
unity 2d and 3d aren't like different things btw, just a different project preset
!logs
disk speed and processor power is a big factor, also worth checking if you can set an exclusion on the project folder in your antivirus so it's not scanning files as you work
no, its like Destroy(GameObject); to myrigidbody or whatever
2d or 3d is not relevant, it makes no difference to a recompile
what part would i exclude? i just did the whole unity folder rn
that shoud be fine, unity creates and modifies a lot of files in Temp and LIbrary as it works so those are the important ones i imagine
like it reloads domains, and compiles
oh you said unity folder, you don't want to exclude the unity install path itself haha
is it supposed to do both those
well, in the other order, but yes
Yeah unity just kind of does that
Well it might not even matter that it's a better setup
Some hardware doesn't mesh with unity as well as others
There's like a million things this could be
Good day people, i am in need of some help
low disc space?
bigger project (more classes) - this includes plugins and packages?
too much running?
unit project stored in a cloud storage folder (dropbox, etc)?
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
So basically, i've been using Spine (animation software) for months now, and updated yesterday.
For some reason, ALL of the IK constraints don't work anymore
this is a code channel, is this a code question?
i have amd 5 7500f 6 core and my gpu is idle with edge, discord unity and more running at 30celcius (i feel like it should be good enough considering the gpu costs 300$)
so .. what code are you using with it?
Again, it doesn't really matter if the hardware is good, you could have a supercomputer and it can still take time to compile
wouldn't this be more of #πβart-asset-workflow's thing
500gb ssd with 150gb storage still, unity is legit the basic install with nothing else really, and my pc is running at like 5% usage and its not on the cloud
could i turn of the domain loading or whatever, i saw somebody say it but idk if it will be bad or sm
hmm, true
you can turn the automatic domain reloading off
sorry
just so it won't automatically recompile
but it'll still need to recompile and domain reload before you hit play
then how will i recompile when i wanna test it
manually, via ctrl/cmd+r
you can turn off a) automatic reloads when you make a change, and b) the domain reload that occurs every time you hit play
if you're on mac
Before you do that, what do you think this will accomplish?
it will take less time to start using unity after changing 1 simple word in a script thats 10 lines long
cus now i legit have to wait 10 seconds before i can even use unity
the point they we're trying to make is its not 1 simple word being changed
its the entire thing being redone
you'll still have to recompile. it just won't be done automatically when changes are detected.
so i just have to work with the pain of 5 second wait everytime i want to see if a change in a script fixes something
if that's how long it takes to recompile, yeah
if it makes you feel better 5 seconds is pretty fast compared to how people used to have to do things π
man i can only dream of a 5 second domain reload per change
i think the rider plugin often triggers it in the background when you hit s ave though, so it's ready by the time i tab back in
rider plugin? i alreayd tryed a plugin named fastscriptreload and it works but wouldnt load functions when i edited it
does ctrl+r reload functions aswell?
they're referring to the ide integration package
what do you mean by "reload functions"?
it's the entire recompilation
these things
this is just.. any member of type float?
i know what a function is
im asking what do you mean by reload functions
those aren't functions
it wouldnt update and i had to relaunch the unity program
those are fields
that's probably a thing with the "fast script reload"
yeah this question just.. doesn't really make sense? it's literally just the normal recompilation, just triggered manually
i mean it kinda does if u used the plugin
It would make it so u didnt haev the recompiling thing but still updated it
see, a plugin is a separate thing. this isn't
ctrl+r isn't a magic button
it's just the default shortcut to trigger a recompilation
hot reload plugins often have limitations when it comes to changing the structure of a class (adding/removing members)
or well, more accurately, refresh assets
still cannot get it to run and cover all cases..... 
{
var Entry = new HighscoreEntry{Score = score, Name = _name, ID = id};
HighscoreEntryToCurrentList(CurrentHighscore ?? new CurrentHighscores(), Entry);
}
public CurrentHighscores CurrentHighscore;
/// <summary>
/// adds new or overwrites old entries
/// </summary>
private void HighscoreEntryToCurrentList(CurrentHighscores scores, HighscoreEntry newEntry)
{
//if no entry exists => add first entry
if (scores.Entries.Count == 0)
{
scores.Entries.Add(newEntry);
Debug.LogWarning("NEW ENTRY: " + newEntry.Name + "/ " + newEntry.Score);
return;
}
//iterating backwards and
for (int i = scores.Entries.Count - 1; i >= 0; i--)
{
var existingEntry = scores.Entries[i];
if (existingEntry.Name == newEntry.Name)
{
//if entry exists and score is higher than new => do nothing
if (existingEntry.Score >= newEntry.Score){return;}
else //if entry exists and score is lower than new => remove
{
scores.Entries.RemoveAt(i);
Debug.LogWarning("Removed: " + scores.Entries[i].Name + "/ " + scores.Entries[i].Score);
//overwriting entry
scores.Entries.Add(newEntry);
Debug.LogWarning("Added: " + newEntry.Name + "/ " + newEntry.Score);
break;
}
}
}
//if entry does not exist => add new
if (scores.Entries.ToList().All(loadedEntry => loadedEntry.Name == newEntry.Name)) return;
scores.Entries.Add(newEntry);
Debug.LogWarning("Added: " + newEntry.Name + "/ " + newEntry.Score);
}```
im running in circles
i keep getting double entries
All checks if all entries in the list have the same name. You need Any instead
or just return in the loop when an existing entry is found, no need to check it twice
ok that fixed the double entries. but now it deletes old entries when points are higher, but doesnt save the new one lol
i might see why....
that was the final thing... i fixed it.... its working now.
thank you very much guys
The whole thing is quite overcomplicated. You could just do
int index = scores.Entries.FindIndex(loadedEntry => loadedEntry.Name == newEntry.Name);
if(index == -1) {
scores.Entries.Add(newEntry);
}
else if(scores.Entries[index].Score < newEntry.Score) {
scores.Entries[index] = newEntry;
}
thanks ill note your solution... but there aint a chance in hell ill ever touch it, if not nessecary lol
well that's pretty much what i suggested LOL
we still on this score thing dang
How do I create a dashbar where you can reduce the image fill amount using lerp where the bar is split into 3 equal parts?
I can do it with bar by giving specific values in the lerp but the bar eventually fills up by time. I need something that checks the current fill amount so that I can store it in a variable to use it in the lerp.
you would generally have all the logic and variables in your script and then just set the value onto the image fill
all the values would be managed there, you wouldn't have to read back the current fill amount
I need help with adding boimes to my procedural world generation
anyone having issues with package manager timing out ?
dont crosspost, and this isn't a code question
Soo, I have a perspective camera
How I calculate the "bounds rect" of the camera in for example
Z: 5
I.e. do it 4 times to get the 4 screen corners
how do y'all manage health for your games? I have one script for all entities and just sort it out through tags, if its a player its a different function from if its a enemy
I dont know where to begin optimizing my code, and since I had some jank code going on health, I figure I'd start from there
A lot of people use an interface in some form or way
example of interface usage
public interface IHurtable
{
public int GetHealth();
public void RecieveHealthModification(int difference);
}
public class MyHealthThing : MonoBehaviour, IHurtable
{
int health;
public int GetHealth()
{
return (health);
}
public void RecieveHealthModification(int difference)
{
health += difference;
}
}
public class MyDamagingThing : MonoBehaviour
{
int damageToDeal;
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent(out IHurtable hurtable))
hurtable.RecieveHealthModification(damageToDeal);
}
}
what is an interface in c#? im not really good at coding but i want to keep my project going
are you talking about an UI?
nah, interface is the name of a specific c# feature
this is how I have it, with some comments to explain some of the reasoning behind doing that method
it's basically a contract/promise, where in the interface you can say what will be included, but the thing implementing the interface has to actually fulfill that contract/promise and implement the functions in that interface
so it's like a requesting system of sorts?
kind of, there's two reasons why you'd want an interface for something like this
-
You can try to get the interface from a monobehaviour the same way you'd check for tags. instead of checking for "player" or "enemy" you can directly check (and get) the
IHurtableinterface if it has one -
the point of the interface is the thing damaging it's victim doesn't need to care how that victim recieves its damage. in this case you just call
hurtable.RecieveHealthModification. buttt the thing that implemented the interface doesn't have to recieve that damage the same way as something else might, eg.
public class MyHealthThing : MonoBehaviour, IHurtable
{
int health;
public int GetHealth()
{
return (health);
}
public void RecieveHealthModification(int difference)
{
health += difference;
}
}
public class MyOtherHealthThing : MonoBehaviour, IHurtable
{
int health;
int shield;
public int GetHealth()
{
return (health);
}
public void RecieveHealthModification(int difference)
{
if (shield > difference)
shield += difference;
else
health += difference;
}
}
"IHurtable interface if it has one" well yeah but that makes it equally as annoying to implement death animations instead of using tags, because its much straight forward
basicially your health system right now handles the way it recieves damage based on what its connected two inside that single class
imagine if you could just handle that per usecase in each of the usecases directly, rather than trying to figure out what it is
What makes you believe that
im just trying to understand
I don't understand, so instead of the script having to read every single thing its connected to, it'll just be called by the thing that needs it in the moment?
The idea is that you shouldn't have 1 script that explicitly handles the health logic for both players and enemies, because as im sure you know most of your script is doing a bunch of checking to be like "if this is the player do that" "and if this is the enemy do that".
So from there the solution would be to split that 1 script into 2 scripts of some sort, one that handles player health and one that handles enemy health
But when you want to actually give those scripts the damage or tell them to die your gonna have to check if it's the player health system or the enemy health system etc. which is what we wanted to avoid in the first place
that's why we can use an interface thats implemented on both scripts (eg. PlayerHealthSystem and EnemyHealthSystem) where the interface basicially says (hey, you can send this thing damage, i have no idea what that actually means but it does support recieving damage)
should I also make a main animation script? where all the booleans are stored, why? because it'll be easier to work with other people
so for health for enemies and players I need 3 scripts
1 - player health system
2 - enemy health system
3 - the said interface (called by the other 2 scripts)
my question now is what do I put in the interface?
a method to deal damage, and perhaps a health property, presumably
anything that implements that interface can be damaged
see batby's example of IHurtable above
where would I make invincibility frames? on the interface aswell?
not saying this is better, just offering an alternative:
combining things in most programming languages boils down to either inheritance or composition
batby's example is inheritance, but you could also do composition
i have an Entity component that handles core stuff about any entity (both players and enemies) that manages health and getting hit (as well as the related UI), set up as a prefab
then it exposes a UnityAction for getting hit, so other components can subscribe and be notified when they get hit, so it can stun or whatever accordingly
an interface would specify what can be none, not how to do it exactly. if there's shared functionality, perhaps use a base class instead?
i seem more interested in the interface method because it'll make it easier to work with multiple people, I like to think of it that other entity health scripts are branches and the tree being the interface itself
im cleaning up the project because im the lead coder but my other two buddies are also joinning in, and so I need something easy to work in
how do you remove multiple packages that are dependent to each other (remove button is grayed out) ?
Hi guys i need some help about some code and im not quite sure in which channel i should post this question. Even chatgpt+ couldnt help and 4+ hours of debugging
depends on the level of the question.. there are three code channels - decide what level it's at and ask in the appropriate one. Probably this chan or #π»βcode-beginner
Alr thank you
it shouldn't be possible for 2 packages to depend on each other. can you show what you're looking at?
chatgpt is usually bad at game dev so doesnt mean much here
Those don't depend on each other
chatgpt is usually bad at game dev so doesnt mean much here
but its probably better than me at gamedev
well maybe another default one, but i cannot remove it
What dependencies does that one have?
whats showed on previous screenshots
for example the Entities package is used by CC and Unity Physics, im obviously not removing those
CC isn't an obvious keep
If you don't want to remove those then you can't remove this package either
CC and Physics stop working if you don't have all their dependencies installed
things change and get updated
unless i never paid attention when using the CC packages
im used to unity 2022 maybe thats why
im curious why CC NEEDS entities to work
Probably for compatibility with ECS
well thats dumb IMO, such features should be in a third package "CC & Entities"
You won't notice a difference if it's there or not
only when you look at the PM
anyways, i think we agree that on a deisgn POV it shouldnt be done like so
but yeah, doesnt do much harm
other than more compilation times
Is there a way to exclude code from tests only? So for example in a normal class:
#if TEST_CASE
// some code
#endif
I've been eyeing Player settings' Scripting Define Symbols, but I haven't found a way to make it work yet (have the symbol off when playing in Editor, but on while running Edit mode Tests)
initial nitpick, does it have to be instantly? because that sounds like something you can fit into more than one frame
Have you tried just doing it? Did it actually result in a framerate dip?
Nvm, found out how. I can use PlayerSettings.SetScriptingDefineSymbols to set the self defined symbol, and check for that self defined symbol in my code.
cant be tbh
it's heavily intergrated into the cc package
