#archived-code-general
1 messages · Page 328 of 1
yeah but then id have to make a different script for each loading zone tile
not really
or i could just make the variable public yeah
i guess that works
and write in the variable for each tile
public class SceneLoadingTrigger : MonoBehavior
{
public string targetScene;
public void OnTriggerEnter2D(...)
{
SceneManager.LoadScene(targetScene);
}
}
thats essentially the same thing as making this thing
but yeah, write the variable for each
except instead of using a string directly im putting the string in a SO
i guess ill do that instead lol
ill save this for when im better at programming
putting the string into a SO doesnt really do anything for you at this point
that kind of data structure is really useful for more complex systems based on it tho
for example, a door system
where you open a door and teleport to another scene at an specific point
having a SO with your scene definitions, then have another SO with your door definitions, and in there define all of your transitions with door IDs into target door IDs
for that kind of systems, then yeah you must hold the data somewhere
and even then, you can still do this by just storing the info in the scene itself
it just doesnt scale well, while the SO approach is just cleaner and scales really well
thank you
next up is figuring out how to make it so the camera wont follow the player if i get too close to a wall
for most of your camera needs, use cinemachine
i tried using cinemachine on a bunch of stuff in 3D earlier but god it was rough
i couldnt figure out how to make it so the camera just updated instantly instead of having it move on a slight delay when i moved the mouse
and god i had a couple of lights in one spot and it made the camera move 10x faster for some reason
something with framerate
you have everything there, look up some tutorials if you have doubts, but I assure you Cinemachine is your best bet to have a decent camera system
is cinemachine good in 2D?
for now i think im just gonna make tiles with "Wall" tags and put them up and then write some sort of raycast that checks if the player is within 8 tiles of one
cause thats the length
oh and 5 up and down
hey guys i got a question
im a bit new to unity and im not sure if this is the right place to ask
im trying to load another scene
what does this mean?
open Build Settings and click add open scenes when youre in Scene 1
im in scene one, clicked add open scenes
it isn't doing anything
Scene 1 would mean you need TWO scenes added in the build menu
Scenes are 0 indexed, just like lists and arrays
oh that makes sense
all i see is this
Scene 1 simply means the second scene in the build menu, not a specific scene
i clicked the second scene
Yeah, so you cannot load another scene by index
oop i got it to work
i didn't double click it
i somehow single clicked it
thanks for the help :)
ooh i have another query
so everytime I restart unity
it always opens script in vs code
instead of visual studio
and whenever i select visual studio
it opens it in visual studio until i restart
then it's back to vs code
Then you have vc code selected in external tools.
Hey, can you finish what you are saying before hitting enter btw. What you're doing is called "message spam"
!ide follow the vs guide here
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
oh im sorry i'll do that from now on
what else do I change? The only thing that I can change (regarding script editor) is the menu up on the top right. It always goes back to vs code
Regenerate project files maybe? Be sure you are hitting ctrl+s too I guess?
It shouldn't be going back. So I am unsure
does anyone know the solution to this voxel rendering issue
Next time you have a lot of info to share, start a thread. It would be easier for people to follow without scrolling back and forth.
I guess that would be a good idea.
created
enum state { a, traveling, b }
IEnumerator GoToDestinationRoutine()
{
for(float f = 0f; f <= 1f; f += Time.deltaTime)
{
transform.position = GetPointOnBezierCurve(start, p1, p2, destination, f);
yield return new WaitForEndOfFrame();
}
}
I have this boilerplate routine that lerps from a to b. When it's at b it should allow the player to go back to a, simple stuff. Now ofc my coroutine could feature a block that checks for the current state and then sets start and destination accordingly. This check would have to be done at the end to, to update the new current state. Are there better ways to this without 3 if-statements? Would you pass everything as four arguments, or a struct? I know it's a bit over engineering but I want to write better code and not just throw if-statements at everything. 😄
Thanks!
I would pass in a and b and a bool to say, go back and let the routine start itself again with a and b switched and set bool to false
surely it is only your for statement you need to make dynamic.
Also you should set position to destination (or start) after the for has completed to make sure that the curve is completely done
Thanks 🙂
https://paste.ofcode.org/gigqPHFHzr9cRQfRgi3ghc
can anyone help me with what's wrong here?
I made a grapple hook which pulls the player towards the hook direction. When I press a key, the function gets called, the hook gets hooked on raycast.point.
Everything seems to work except when the function is called it stops pulling before the Vector3.Distance(transform.position, HookShotPos) is less than reachedHookPosDis.
you probably want to change
Vector3.Distance(transform.position, HookShotPos) > reachedHookPosDis
to
Vector3.Distance(transform.position, HookShotPos) - reachedHookPosDis > -0.01f
or another suitable offset
same result
plus
I've tried shooting the hook in long distances so I don't think this would be the issue
you are checking for > so <= will not fire the if
yeah ik but
It does pull me a little
so that means the distance was high when function was called.
something just stops it without getting close to the hook
then you need to debug your values to find out why
the distance is higher than -0.01f
but still stops for some reason
Anyone use an asset or other C# .net library to manage session-based or general http communication in place of Unity's?
WebRequests are pretty limited without a lot on top
What is your issue?
Well I have to login to a session server, check my session does not end, check all returns for any failures and repeat if required. All these things are auto managed by other APIs with optional changes.
Then you need something like a websocket or similar to send and receive data. Have a look at Nakama for example.
you can use the HttpClient class from System.Net
That is a good point, I wonder if any issue at all using that vs Unity's?
none at all, I use it extensively for my network solutions
Ah great, thanks for letting me know
Im trying to save the count of coins in my game, https://paste.ofcode.org/38uvNTBgrNzhBgHTFpViCdm
https://paste.ofcode.org/Ln8LgcEwEHqKuDaZFnKK9P
The issue I am having here is that the count isnt saving, so in game when i collect the number is changing, however the new value isnt saving on quit and instead im getting the intital value.
OnApplicationQuit is not called in the Editor
so if i build the project and played it from there it would work?
should do. But not if you build for Android
Ah this will not work for any webgl stuff though, only desktop
because i am seeing the debug.log from the save in the datapersistencemanager
yes it does
oh ok, was reading stackoverflow comments - but not always a good thing!
so just need to target .net framework?
indeed
It is called in the editor
i just added a debug.log for it
exiting playmode calls it
interesting, was not always the case. I tend to rely on OnApplicationFocus as it's more cross platform
right, any other ideas?
there are the Application.quitting and wantstoQuit events
the thing is, I know that SaveGame() is being called, because that debug.log is coming up
I can only go on the code you have shared which does not include your FileDataHandler class
let me send that now
the GameData class please
sure thing
the contents of the json file please
ok, so moneyTotal == 0
but your log says 10
and from my debug.log in the SAVthat was earlier when i changed it temporarily in the JSON to see if that worked
so the loading side of things is perfect atm
Sorry, I'm confused. You posted a log with the value of 10. So the json should contain 10. True or not?
true, i then modified the json to say 0 and saved that,
wtf would you do that in the middle of a help session?
because i wasnt thinking
sorry, but I give up, you drip feed information and then change the data
So, you load your asset. you change the coins to 10 and then save your asset and the json (after reopening) is still 0?
thank you for trying, im sorry, i wasnt thinking. i didnt think it would make a difference
Or was it just you changing it and there is no error anyymore? 😄
I manually changed the JSON, the issue is that for some reason, the JSON isnt being updated when i quit the game, IE: if the value of coins in the JSON is 10. and i collect 2 , it dosent come up with 12 and instead stays at 10
the whole reading the JSON part works perfectly though
can you point me to the scripts again, where you update the values and actually save them?
you can see the full scripts here for the dataPersistenceManager and the CollectiblesManager
this is the fileDataHandler
this si the game data class
Do you ever update this.numGemsCollected = data.moneyTotal; ? Besides loading it from file?
This is the only spot I can identify, where you update the gemscollected. So why would it change on saving then?
here when the gem is collected it updates the numGemsCollected
and the save happens on quit
on application quit
And this debug is showing the correct or wrong moneyTotal?
Debug.Log("Saved money total =" + gameData.moneyTotal);
the wrong one
Jesus, your code is all over the place
Why are you passing your gamedata through three different scripts?
you could just make it public static for now and access it directly from all scripts
im not sure, the idea was to have any script that needs data saving to go through the interface and then have the manager gather and store references to the scripts that use the interface and then have the file data handler to save it to the file
But right now your script takes all dataPersistenceObj and saves the same local gameData. I understand, what you are trying to achieve here. but its just not working right now. If you want your interface using classes to store their data, they need their own private variable, not a global one passing to them. And when saving, they should return their own gamedata to the savemethod. This right now is a great start for spaghetti code 😉 Maybe get some paper and write down what you actually wanna do and come up with your objects, inhertiances before trying to code them right away
what is weird to me rn, is what i have is working perfectly for the 2 dictionaries but not for this
Yes, pretty much.
for now i ended up going with a much simpler method since my game isnt gonna be too complicated
As long as it works, I gave you the more complete method. Eventually, you might be more interested in it when your game is getting more complex.
if it's wrong here it's got nothing to do with your saving or json, your code isn't incrementing the gems correctly in the class itself at runtime. It sounds like you could have multiple versions of CollectiblesManager - debug your dataPersistenceObjects list and event calls
ok will do
Is there a working way to save changes made to a prefab through script ?
ie after
var vfx = this.GetComponent<VisualEffect>();
vfx.SetVector4("Color", color);
I want to save this change
You want to modify the prefab during gameplay?
No, it's all editor scripting outside of play mode
you cannot update a Prefab in a build
Probably one of the save methods
Tried all of them, not a single one works
Maybe you're doing something abnormal. May want to describe what you've tried and what's not working in specific
Very very simple
Have a prefab, modify that prefab thourgh script
If I restart the editor, the changes are gone
I would like to save these changes, nothing more, nothing less
this is the console result for when loading and saving
even PrefabUtility.SavePrefabAsset(this.gameObject) does not save !!!
You haven't described what you're trying to actually do, that's possibly failing. What object are you trying to save?
A prefab asset with one script and one VFX
Editing the VFX works perfectly
The issue is that when I restart the editor, the change on the VFX is lost
After running the editor script
And after restarting the editor
I'm assuming this isn't during runtime. Where do you call the statement? Does it execute?
100% editor scripting bug, yes
the blue bar on the left suggests you're changing an instance of a prefab here, not the prefab itself
I guess so ? I posted the code just above
That's the idea, if I manage to save the change, the blue bar will disappear
is there a reason you're not using the provided method to save the changes?
the UI one.
Even when I call it, the changes are lost when reloading the editor
i dont know if that is the problem after i debugged
Saving a scene will keep the changes on the instance
hopefully the null stands out to you as a bit strange - you'll need to follow your nose a bit here and figure this out, I was just trying to narrow down where to look a bit for you
it did seem weird
but i dont know why it would affect only the money total
I mentioned two things to debug and it looks like you've only checked one of them
ah the event calls, i forgot let me do that
Using Unity 6000 and getting error of:
error CS0518: Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported
In line of:
public float test { get; init; }
Is it still necessary to do this solution?
Oh how great!
i don't think unity 6 includes any big compiler or c# library changes yet, so it's the same as 2022
afaik this is one of the most recent bits of info about the next big upgrade but it's a way off still https://blog.unity.com/engine-platform/porting-unity-to-coreclr
Melee meleeComponent = toolsList[i].toolGameObject.GetComponent<Melee>();
In this specific instance, toolsList[i].toolGameObject refers to the following gameObject, playerBat, which has a melee component:
However, Melee meleeComponent has a value of null. Why is this?
How have you verified that it's null?
I'm assuming you're getting some sort of error (nre)?
and how do you know that toolsList[i].toolGameObject actually refers to that object?
I vertified it through this:
if (meleeComponent != null)
{
//throw new Exception { "The meleeComponent is null" };
throw new Exception($"The meleeComponent is null at index {i}");
}
oh wait my bad
Hey is there a better space to ask questions specifically about Splines?
pretty sure thats a dictionary stored in Spline
which is inisde SplineContainer
Oh that's why I couldn't find it. You've got to access the spline first. Makes sense now that a spline container would contain multiple splines 🤦♂️
indeed
Wonderful. Thank you!
🫡
nice layout
while we're on that topic, I noticed that updating knots every frame causes extreme performance degradation in the editor
there's some weird editor-only caching it does that takes forever
i need to go make a project to demonstrate that
who decided to call them knots
EXTREME justified
The problem now is 2022.3.31f1 isn't out yet, and that PR to Dreamteck Splines hasn't been merged yet.
Sadge
I hate technology
the patches have been coming out weekly, and i don't actually know the exact day that .30 came out since it isn't on the download archive for some reason, but if it came out a week after .29 like it should have, and if 31 comes out a week after that, it should be releasing today
I think patches are normally on a 2 week cadence
may be faster for 6 Preview as it's still pretty new
God, they have been busy introducing new bugs, bless 'em
I guess they finally got their CI/CD workflow functioning, now if they would only test stuff
looks like weekly patches started in april, so it is possible that it is a temporary thing and we still have another week until the next patch, but .30 was released exactly a week ago today so maybe they'll stick with the weekly patches for at least a bit longer and we'll get the next patch today
Wait is Unity 6 out or in Pre-release?
Preview, so pre LTS
Just for me 😛
unity 6 is "preview" which is identical to a tech stream release, so it's out of beta, it's just not LTS yet
Right.
I'm glad they ditched the yearly notation and went back to version numbers.
Unity 6 sounds quite a bit better than Unity 2023.3 LTS
they also ditched the LTS notation which I am less happy about
I am using Application.wantsToQuit and returning false to delay quitting my application. This works fine, but when I later call Application.Quit(), for some reason, the application does not quit!
I debugged the build, and OnApplicationQuit is called on various scripts, but the application keeps running afterwards.. What could cause this?
read the docs
it does nothing in the editor
read the message! I am debugging the build!
you need to return true from the event to let it quit no?
yes, I returned false and call Application.Quit() manually later
it works fine if I call it in the same frame, but not if I call it later; at least, that's one way to look at it. There's something that causes the app not to exit.
yeah your event handler....
I am unregistering from it, so it's not there the second time around
you need to have one that returns true
It's not super complex; but I can try keeping the callback and return true explicitly
just to make it extra clear: after _QuitGame() is invoked, it does call OnApplicationQuit() on all the scripts that have it
it just keeps the app alive afterwards (and calls update on scripts etcetc)
!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.
my bad
This is the first script for my DataVariables https://hastebin.com/share/kuduhulace.csharp
This is the other snippet of a script for my Gameobjects that are trying to read data off of these variables https://hastebin.com/share/maxicotoku.csharp
So the first DataVariables has an action and I invoke it in line 130
even the debug.log on line 129 is being executed but 130 invoke isn't
and if I dont use the ? symbol it says the action is null
now in my second script, I'm subscribing to the Action<bool> action in a function thats called by the Start() on Monobehaviour
ok, so the action is not being set
even the Line 21 debug log on my second script right after adding my function as a listener seems to be called without errors
is the debig printed?
the UpdateValue() function which eventually invokes the Action is called on a different thread but even then shouldn't only the invoking be affected? not the subscribing part?
yup
Events with no subscribers will be null. You're not calling override void ApplySettings() in void Start(). If there is also a void Start() but in the base class, it won't be called by Unity
then this
settings.palletLiftingBool.boolValueChanged += OnChangePalleteLifterValue;
is not being executed against the instance you think it is
oh
wait a second
I initially instantiate my GameObject with the second script and right after Instantiate(), I call apply settings() and then I deactivate it. and when I want to use this gameobject, I make duplicates of it, activate it and then use it
This is some serious spaghetti code. Are you sure it's all necessary?
I'm trying to get data off a json string using just the variable label, but I dont know the type
I'm sure theres a better way to do it, speaking of which, could you please guide me towards this better way 😅
I think I figured out the problem
like these
public Action<bool> boolValueChanged;
public Action<float> floatValueChanged;
public Action<TimeSpan> timeValueChanged;
public Action<string> stringValueChanged;
could be replaced with
public Action<object> valueChanged;
and then cast it in the subscribed function?
yep
your subscribed method could take an object parameter and cast it itself to what it wants
Your datavariable class does not need to know what type of variable it is
is that safe?
sure, that is why we test
like would we lose the info somewhere along the way or smthng?
alright I'll get back to ya
then I guess we could do the same with each of the boolValue, stringValue etc etc
the enum alone is enough?
exactly
you dont even need the enum. GetType() is sufficient
I have a class containing a property:
public class Foo
{
public Coroutine PopUp { get; set; }
}
If I make a reference to it, it works fine:
foo.PopUp = StartCoroutine(PopUp());
But if I use this same methodology when the property is within another object, I get a null exception error:
public class Foo
{
public StoppableCoroutines StoppableCoroutines { get; set; }
}
public class StoppableCoroutines
{
public Coroutine PopDown { get; set; }
public Coroutine PopUp { get; set; }
public Coroutine WaitDuration { get; set; }
public List<Coroutine> CoroutineList { get; set; } = new List<Coroutine>();
}
foo.numPadSlot.StoppableCoroutines.PopUp = StartCoroutine(PopUp());
**NULL EXCEPTION**
Why does it work fine if the Coroutine property is directly in Foo, but not if the Coroutine property is within StoppableCourintes, which is in Foo?
Just type check it with pattern matching
switch (obj)
{
case bool b:
break;
case string s:
break;
// etc.
}
or
if (obj is DateTime dt) { /* ... */ }
wait woah that exists? danggg
something in that chain has not been assigned. likely the StoppableCoroutines object
I didn't have to assign the Courtine class when it was directly in Foo before. Do I have to assign StoppableCoroutines ahead of time?
hmm, someone skimped on their C# lessons
ah okay I'll implement this
you do not create an instance of StoppableCoroutines'
okay first off, it was just a guess at which object is null. you need to actually determine which is null and where it is supposed to be assigned. keeping in mind that reference types are null until they are assigned
if you never actually create an instance of StoppableCoroutines though, that is 100% the issue
The Coroutine is null when I reach foo.PopUp = StartCoroutine(PopUp());, but it still assigns it successfully. I don't understand why I don't need to assign the Coroutine at the start but I do need to assign StoppableCoroutines.
because you are not trying to access a property on the coroutine in that first bit. you are literally assigning something other than null to it.
you cannot access a property on a null object without getting a NullReferenceException
Spot the difference
public StoppableCoroutines StoppableCoroutines { get; set; }
public List<Coroutine> CoroutineList { get; set; } = new List<Coroutine>();
Alright, I got it.
Thanks guys, I appreciate all the information. I like having the solution but also understanding why it's behaving a certain way.
Also, and I know this is the style police talking, so forgive me. Please dont use the same name for class names and variable names
Hmmm.. is that where people start putting an underscore in front of the name to prevent it from being identical? I'm not sure what would be best here because it helps me when it's the same name and there aren't going to be multiples of the same class being used elsewhere.
stoppableCoroutines ?
That conflicts with another best practice, keeping properties pascal case.
trouble is it becomes ambiguous when you are referring to the class or an instance of the class
f..k that
Yes PascalCase for properties is the convention most C# code uses. Your issue is just that you shouldn't have a property with the same name as the class itself.
The _camelCase convention is a different thing, that's for private fields.
Yeah this, _ is for private fields you don’t wanna expose directly and use with get/set methods
_ ugly af
tbh MS C# coding conventions dont make a lot of sense. But, hey, if people don't want to think for themselves and use them, fine
What do you not like about the convention? The only part that I don't have an opinion on is the s_ for thread static, otherwise I agree with the convention.
I dont like any of it. I'm guessing you do know that the convention was developed before the advent of IDE's and so almost all of what they describe is, today, moot
Don't like how "_" prefix looks as well, but it is very practical at getting quick autocomplete for local fields. Makes them instantly accessible just by typing _.
That's definitely not the case, IDE helps but IDE is not always available when you are reading code, eg when you are doing a code review on GitHub.
yeah this. Literally only reason sometimes I do enjoy it for quick lookup on IDE
Am I the only person that actually remembers how they named their variables?
but after a while _ everywhere looks off-putting
Ido remember them, I just work with some coders who enjoy the shite out of _ and it only has 1 benefit.
People usually do it just for "not conflict with method parameters" (which is nonsense, just use the this. keyword)
The thing about the convention is not about "why should it be localVariable, _privateField, and PublicProperty but not _localVariable/PrivateField/publicProperty?" which one uses what casing is not important, what's important is that private fields and public properties need to be different because they have very different impacts when you mutate them.
When you mutate a local variable, you only need to care about the effect it has within the scope of the variable; when you mutate a private field, you only need to care about the effect it has within the class; but when you mutate a public property, that's a public API surface and you must consider how it might impact every single piece of code in this entire code base (or if you are a library author, every single consumer of your library which you definitely don't have access to).
Without naming conventions differentiating them, when you are reading code you have no choice but to commit to memory "yep this variable is local, this is private, this is public, etc."
which is what you should, as a competent programmer, be doing anyway
IIRC you are also very against var, if the position you hold is that "IDE helps you to know everything there is to know about a variable and you should always commit to memory everything about a variable when reading code" then you shouldn't be against var.
I am very much against var. it's just pure laziness and I abhor laziness
wtf thats weird..
what if you have a very long name for an object and you have to use foreach
I dont care, copy/paste exists
by that logic copy and paste is laziness
var in no way makes code more readable and code needs to be read
So if you change the thing you are iterating, you now have to change 10 other places downstream, and your commit will look like +10/-10 even though you've only made one change.
And that +10/-10 is going to cause so much problems when you have merge conflicts with your team members.
But you know what, you are right convention is mostly just a style preference, so there's no absolute right and wrong. I personally think in a team environment these conventions absolutely help a ton.
convention just help to get better consistency from people when collab
Yes, conventions are an absolute requirement in a team environment. But I can tell you having worked on 100's of projects over the years the only projects which used the same conventions were the ones where I was team lead and I imposed the convention on the team
what that convention IS is, basically, irrelevant
Whether a convention was enforced or not has nothing to do about how effective a convention is at solving problems.
I don't think this conversation is going anywhere so I guess I'll exit now.
conventions neither cause nor solve problems
I don't know how you can reach that conclusion when var objectively and measurably reduces the amount of merge conflicts.
the fact you can say that is, in itself, frightening
I disagree with this, sometimes you are dealing with absurd classes that you only need for accessing a single thing from, var clears that clutter
Ah yeah I really need to stop myself from engaging further after saying I'm exiting. I should've know this conversation goes nowhere when the premise is "people who follow Microsoft's C# conventions don't think for themselves."
Specially when you are using scoped namespaces
pretty sure they are trolling us when they say that stuff lol
Hello! I am trying to make a crater appear when punching. This is just blocks that appear above the groundlayer in the form of a crater and doesn't need to be fancy.
What I thought of is creating a raycast when punching that instantiates on that point some cubes (in a circle), but not sure if that's how it will work. Any advice?
Random.insideUnitSphere then use that point to raycast it on the surface
oh wait not random you have the point already?
Yes, where the punch finishes
oh so however you do the "punch" like ray or whatever, use that point on collider?
currently i have not yet implemented ray on it. just the animation
well you can use maybe an Animation event to fire a Ray or other Cast shape to set a hit area
thats how I usually do it
also quick question. I want to create a new script for the cratereffect and not with the animations, but is it possible to have the logic of the animationcontroller in that cratereffect script? I can assume it will start glitching very hard if i am gonna implement the input.mousedown blabla in the cratereffect script aswell
you mean crater effect is in script on different object? not sure what you are asking
oh for example when the punch is full reach it fires a function (raycast)?
Is the crater gonna be used for gameplay interactions?
Otherwise use a vfx/particle system
or at a specific point . doesn't have to be the end
Animation event is a way to fire off some code when reaching a specific animation keyframe
same object, but different script
Not really, just more a "fancy" vfx
Is that also possible with particle system? Since I want to have for example cubes out of the ground
yeah should be fine
Yeah vfx graphs are very powerful, there are a lot of tutorials about vfxs that create crater like effects with very little code
But yeah if you wanna know exactly whereyour punch landed, ray cast would be a good way to go
It really depends on what you are doing honestly
For now I wanted to play around with seeing what I could do, but hitting a punch indeed was the next step for a dummy for example
Thank you both for your help, I will look into raycast and VFX
Someone knows why when i edit a custom physics shape on a tile sometimes it updates
and sometimes it doesnt? Im getting crazy
@heavy egret You already have a warning for cross-posting. And this is a code channel.
Does it make a difference on performance whether you run one loop that runs two actions per iteration, or two loops that run one action per iteration?
So like this:
for(int i = 0; i < 10; i++)
{
whitePiece[i].Update();
blackPiece[i].Update();
}```
vs this:
```cs
for(int i = 0; i < 10; i++)
{
whitePiece[i].Update();
}
for(int i = 0; i < 10; i++)
{
blackPiece[i].Update();
}```
does anyone know a way to use world UI and Unity's even system with a locked cursor? All the solutions I found are either outdated or may cause other problems
The first is more performant
Ok, do you know if the difference would scale with the size of the loop?
first one is probably faster but it is such a small difference even if you have thousands of objects running this
Well... yeah.
Ok, thank you!
Do those double value sliders in the inspector have an attribute or is it only through custom editors / property drawers?
I remembered reading something about checking the distances of two objects being more performant if you don't squareroot their position values / something similar. Is this true?
It saves a square root operation
not doing something is always more performant than doing something
but computers are fast 🤷♂️
Not about position values, this is purely about the magnitude of the vector. Yes it is slightly faster to check the sqrMagnitude especially if you dont need the actual distance. Like if you're just comparing if something is 5 units away, you could really just compare if the sqrMagnitude is >=25.
depend, sometimes you may need the distance
What do you mean? It's quite literally built in with sqrMagnitude
Ahh, okay, I see
Yeah I noticed two functions and thought one was just a more performant version of the other
Because it is not the actual distance
Ah, lagged. That was already mentioned
Is Rigidybody.velocity = (some Vector 3) functionally the same as Rigidybody.AddForce(some Vector 3, ForceMode.VelocityChange)?
no, velocity change is v+=f, but you are assigning velocity directly
https://www.reddit.com/media?url=https%3A%2F%2Fpreview.redd.it%2F6y8myu3ruxo71.png%3Fwidth%3D1080%26crop%3Dsmart%26auto%3Dwebp%26s%3D7aa3db9af9a51d692d2f79e5bce2474a07699418
Oh dang. That is absolutely right, my apologies travis. Ignore me
This is such a good graphic
I'm trying to change my player's movement system from Rigidbody.Move to use Rigidbody.AddForce() to make it feel more natural + To respect collisions better with just a tad bit of momentum, but I'm struggling to make it feel reasonably responsive while retaining a little bit of momentum. I think ForceMode.Acceleration might be a good choice
A big consideration with that is also how you capture input. If you are using Input.GetAxis, note that it has smoothing, and you may want to use GetAxisRaw. There would still be some momentum from the force, but it would be less "floaty"
I'm on the new input system and I use a composite 2D vector with the Digital Normalize mode
I'm not sure if this is the best choice
Here is my current movement code: https://pastebin.com/eExtZvaa
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Currently, it's okay but whenever I jump while running, the continued applied force subtracts from my linear y-axis velocity and makes my jumps feel muted. Adding _rb.velocity.y on line 36 where the _rb.AddForce vector is defined doesn't work; that just whiplashes and makes the jump float upwards abnormally fast
edit: edits
Hello, I was wondering if anyone here has encountered the same problem that I am currently faced with. My problem is that my character's horizontal velocity is supposed to be capped at a certain speed, but it is being capped at higher speeds for some unknown reason. It is quite strange because it works when my character is on the ground but not the air. I have a video here to demonstrate.
You'll notice that the RigidBody shows that the character's horizontal velocity on the ground is the same as when it is in the air, despite that clearly not being the case
Here's a snippet of my code for how I capped the speed
Where do you cap it horizontally? And where is your SetVelocityX code? please refer to !code how to post code correctly
!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.
hey yall, how do i rotate a parent so that its child has the same rotation as another transform's rotation?
transform.rotation = activatingObject.transform.rotation * (transform.rotation * Quaternion.Inverse(attachTransform.rotation));```
the solution that works for position calcualtions unfortunately doesn't seem to carry over to rotational math. Not quite sure how to do this as quaternions are a little complex for me
this code is run every frame as i don't currently parent the object here.
also, since my throw function throws this transform when it's let go, it must be vibrating slightly from the transform.position so if anyone could explain why it's doing that it would be greatly appreciated as well
maybe you can utilize this? https://docs.unity3d.com/ScriptReference/Transform.TransformDirection.html
Ah I guess it can work with inverse too as you did. So you need to add the child rotation, which is attachtransform? But I think you need to inverse the transform.rotation and multiply by the child to get the correct localposition?
unfortunately ive tried numerous different combinations of things that seem like theyd work on paper for only inconsistent results
You culd just rotate the transform by the child localRotation values after setting the rotation to the activatingObject.
You could get a rotation difference with something like Quaternion.Inverse(targetWorldRotation) * childWorldRotation and then multiply the parent's rotation with that
Something along those lines. Seems like your current code is close, but I dont know which transform is which
My code is unconfirmed but maybe you can check this https://forum.unity.com/threads/get-the-difference-between-two-quaternions-and-add-it-to-another-quaternion.513187/
luisfinke's answer is probably correct
any reason why T isnt found?
you are missing
using System.Collections.Generic;
AddElseRemove<T>
https://paste.ofcode.org/wBPG3gZrfm4cK7R6Dh3qW5
can anyone show me how can I take the same input to set bool to false while also being able to make it true again?
bool = !bool;
When implementing a state machine for a player, which approach is best? I'm considering using either an enum or an abstract/interface class for the base state. Additionally, I want to know if there are any ways to make the states manage input in a smart way.
i like using a base class since i prefer to put various data and methods in each state, but a simple enum might be better for performance depending on how you use it, it depends on your design and how complex it'll get
either way assuming you have some event or virtual method called when transitioning in/out of a state, it's usually fine just to register/unregister listeners on input actions there
Is it possible to tell a mono game to rejit some code? Modding a game and there’s a constant boolean property that is without a doubt being inlined
Just need to change what it returns
like a const, or just a property that doesn't change after initialization?
Property that doesn’t change after initialization
‘Public static bool useOvercloud => false;’
Technically const
Basically const actually
JIT doesn't go that far to check if a property is a constant expression.
It will always call the property getter.
Interesting, didn’t know that. I’ll play around with the getter then when I get home. Thanks
No, sorry. I was testing in debug mode. It does in fact inline it in Release mode.
how are you modding it? just thinking if you're using something like harmony you might get better answers asking around that community, this isn't really focused on modding usually
Okay, thats what I was expecting initially
With harmony, but this is one of the few things I was able to find that says it’s impossible on an inlined property https://github.com/pardeike/Harmony/issues/70
Which is why I was wondering if I could tell unity or mono to drop some jitted code and rejit it
ohh right yeah, as i think MentallyStable is saying it's not just JIT that's the problem, it's already inlined before compilation in the IL
It's not inlined yet in the IL. It's the JIT compiler doing it.
It’s not inlined in the IL, its expanded to a property when I view the code
Yeah what stable said
hmm yeah i didn't read the whole thread on github lol
sorry about that, this is my first time sending code to other people. here are links to 3 of my classes, please do tell me if you need more context and I'll send more scripts https://gdl.space/niyeqoyohi.cs, https://gdl.space/kigoxizevi.cs, https://gdl.space/udolejurep.cpp
i guess you can look at the mono API docs and see if there's anything suitable there
which seem to be timing out right now lol
Do you know the code you want to rejit? The code that is using this property. Or do you want to rejit everything that uses this property?
You can use a transpiler patch and replace calls to the getter with your own method. You just have to know which methods to patch, but you would have to know that with rejit method too, unless you intend to rejit the whole application.
Hi, I'm reposting this because I think I sent my previous message at too late of a time. My problem is that I am trying to limit the horizontal velocity of my character, but my character keeps exceeding this limit. This is only the case when my character is in the air, not when on the ground. I have a video to demonstrate
You can see that the RigidBody component shows that the character has the same speed when running as when they are jumping, which is clearly not the case
Here are three of my scripts, if anyone would like more context, I have more scripts. https://gdl.space/niyeqoyohi.cs, https://gdl.space/kigoxizevi.cs, https://gdl.space/udolejurep.cpp
I beleive that the problem lies in my PlayerInAirState script, but I don't have any idea why it's not working
Are you sure it's actually traveling faster, and doesn't just look faster because the model is smaller/thinner?
Well the problem with clamping velocity in FixedUpdate and using AddForce is that AddForce doesn't get applied until the physics update itself, which is after FixedUpdate. So your clamp will only do so much
one workaround for this is, insteasd of using AddForce, do a "poor man's AddForce" like this:
Replace:
player.RB.AddForce(Vector2.right * playerData.horizontalForce * xInput, ForceMode2D.Force);```
With:
```cs
player.RB.velocity += Vector2.right * playerData.horizontalForce * xInput * Time.fixedDeltaTime / player.RB.mass;```
The difference is that your velocity change will be immediately visible and your clamp code can then work properly.
AddForce is ultimately just scaling your input based on the force mode
Force and Impulse divide by mass. Force and Acceleration multiply by fixedDeltaTime.
(and VelocityChange doesn't do anything!)
Does anyone work with backend devs who return http results in the https://jsonapi.org/ way of wrapping it in an object with "message" and "status"? { "data": { "actualdata": "some data"}, "message": "Success", "status": 200 }
Hey guys, help me out here please.
I feel like im doing something wrong with my references.
ive got this property that im serializing and adding values to some variables (attack, defense, etc) in the inspector.
On the construtor i take this variables and pass their values into a dictionary.
[field: SerializeField] public UnitStats unitStats { get; private set; } = new UnitStats();
public class UnitStats
public Dictionary<UnitAttributes, Attribute> stats { get; private set; } = new Dictionary<UnitAttributes, Attribute>();
public UnitStats()
{
stats.Add(UnitAttributes.ATTACK, new Attribute(attack));
stats.Add(UnitAttributes.ATK_SPEED, new Attribute(attackSpeed));
stats.Add(UnitAttributes.ATK_RANGE, new Attribute(attackRange));
stats.Add(UnitAttributes.CRIT_CHANCE, new Attribute(critChance));
stats.Add(UnitAttributes.ACCURACY, new Attribute(accuracy));
stats.Add(UnitAttributes.HP, new Attribute(maxHealth));
stats.Add(UnitAttributes.MANA, new Attribute(maxMana));
stats.Add(UnitAttributes.ARMOR, new Attribute(defense));
stats.Add(UnitAttributes.MAGIC_DEF, new Attribute(magicDefense));
stats.Add(UnitAttributes.EVASION, new Attribute(evasion));
stats.Add(UnitAttributes.MOVE_SPEED, new Attribute(movementSpeed));
}
In my inspector and by debugging, everything is fine. But when i try to get a reference to some dictionary value for some reason everything is set to 0
well fill the screen why don't you!
Yeah that's not really a good way to do API, it's practically reinventing HTTP status code.
Are you consuming such an API or are you making one?
I know right, I don't get it. I am consuming another person's API
Welp unfortunate then, just have to deal with the hands you are dealt.
yeah but I have some power to change!
I tried this, and now the player is being capped at lower speeds, but it's being capped at lower speeds than I specified
I capped it at 40, and it stops at like 38.461
Drag will also come into play
In what way?
I have angular drag set to 0, but not linear drag
to be honest, I don't really know the difference between the two
Even if the drag were not set to 0, wouldn't that just slow down the acceleration instead of capping the velocity?
libnerar is for movement, angular is for rotation
It will do both
it reduces the velocity every physics update
since the physics update happens after FixedUpdate, your velocity that is capped to 40 will be further reduced in the physics update
ok that makes a lot of sense, thank you
I set linear drag to 0 when I reach max velocity and it caps at just the right speed now, my problem now is that the jumps are very high
although I think i can just cap the vertical velocity as well
either way thank you all very much for your help
Sorry just got out of a meeting
There’s 6-8 methods referencing that property. I’ve never done transpiling before so I’ll have to look more into that when I get back home. I could rejit the entire application as well if that’s easier since my mod only works on the menu screen before anything intensive or hot happens
Are there any big games done in Unity that had their source code published? Super bonus points if the unity project file is available as well.
I have lots of experience with small projects but I'm very curious to see how a big project is organized, how is the code structured etc. etc.
None come to mind, but you'd be surprised how janky the code can be in even a popular game that did well. Like Celeste's player class is a god class that is intercoupled with almost every system in the game. At some point doing things right/clean has to be skipped to get the game out the door, and the sooner that switch happens the more hacky the code base ends up by the end
yeah I've seen Celeste's Player.cs file and unfortunately that's the only example I can name. I wish I could see a different, big project from the inside
I also don't have any games in my mind, but I guess you may have a look at the unity-game tag on GitHub
Next time an AAA studio gets hacked and their project source gets dumped online, you can always take a peek. They're usually projects that are far from completion, or abandoned ones, that get stolen and exposed that way, but sifting through those monolithic folder structures might give you insights
But those aren't Unity
thanks, although public repos with this tag are usually for libraries or tutorial games
I know, but you may still be able to find something useful
Would be best to see a released project but an unfinished one would be helpful too. That's a good idea, maybe I'll hack an AAA studio or two to get the source code
yeah, thanks! I'm sifting through them
Also seeing how others code can be eye-opening. I find people's code all the time that makes me feel stupid. Even if it is just for an add-on
I make myself feel better by reminding myself that me from years ago would feel stupid trying to read my current code
indeed, but I just have no access to other people's code in gamedev. And stuff on youtube is very often very bad in quality, or oversimplified
Any particular kind of system or genre?
not really, pretty much any big project would be enlightening. I'm making a puzzle adventure game right now but those are usually on the simpler side (also why I chose it)
Good call, too many have big bold games they want to make, but are still learning at the same time, so frustration and impatience get in the way of enjoying the learning process
Some games you used to buy from steam could easily be decompiled as no il2cpp used but now it may be harder
I hate to enlighten you but, you are mistaken. I can tell you that diving into any large project of which you have not been a member of the development team is a nightmare
oh I know, I have plenty of experience in the IT industry and C#, just much less in Unity/gamedev
Best bet is look through GitHub unity code and unity's own examples. But some top games have terrible code
then you only have one thing to learn. Make it fast. FPS is everything,
Also a puzzle adventure game probably won't have complex systems underneath it, so you shouldn't be too concerned about 'the right way' to do things for a game like that. Unlike an RPG, where a poor foundation to how systems communicate and interact will bite you in the ass in no time
The only right way will be in not making something that's horribly unperformant, or that goes against how Unity works
Indeed, data design is all, whether that be in an app or game context
The best and quickest way to learn game dev, imo, is by volume. Produce as many small games as you can. Do them poorly but quickly. Try to improve a little the next one, but not to the point of hindering your progress. Continue iteratively until you know the WRONG way to do it well, and why it IS the wrong way. At that point you will know what to avoid, making it easy to know what solutions to look for to do it the right way.
Looking at other peoples code really doesn't help. Might even lead you to thinking the wrong way to do something is the best
Best would be to see good, clean codebase of course but even if the code is terrible, I would still be curious to see it.
I'm already past that point. There are many things that you don't get to do in a small project. Now I'm curious about those things exactly, those things that are only relevant in real projects
and I have no way of getting access to them
there are no tutorials on them, not on the sufficient level anyway
Like what specifically?
This blog helped me a bit while I was stumped on some systems for my RPG. It's not terribly applicable to your game, but if you ever need to have a more interactive and event driven game it will be handy to refer to
https://theliquidfire.com/projects/
Is there any way to use WaitForSeconds in the Editor?
I worry about unknown unknowns, things that I don't know that I need. But also stuff like optimization, memory management, asset loading, many things that I'm aware or not even aware exist. It's not that I have a specific question (I know I can always ask someone for help), it's that I lack an access to many things that come with experience. Looking at a big project would help me reverse engineer things.
that's an interesting resource, thanks! I'll take a look
Maybe not coroutines, but async/UniTask should work in the editor
Then you are not past that point. Every small project you do includes all of that. When you see (for example) that you are allocating 600mb in your player loop and dig down into why, you will find specific solutions.
Each project will teach you a specific new thing.
You will never learn that just by looking at other projects
Get a few dozen full games under your belt, then keep going
Sorry, but no it wont because you will never know the reason why, you will only see the how
Also consider doing console apps
It is a whole other facet that will help you understand some things about programming that you may not get from pure game dev
Well for a puzzle game most of those concerns aren't really a pitfall. So worrying about them will just lead you to optimize without a need for it, or slow down your progress
Yeah I might be worrying too much about it for the game I'm making, that might be true
I see, I'll try that out then. Thank you
coz so far I didnt have any technical issues with it
I don't want to sound rude but it feels like you are trying to find a shortcut around experience. It does not exist
And when you do find a problem, you'll have more information on your needs in order to pick the right solution for your project. Rather than guessing before it becomes a problem, if it ever does.
I'm certainly not, looking through an example project would be yet another way to learn, like a case study, to gather said experience
but that is not how you gather experience. Experience is in the doing not in the looking
in any discipline you need to see examples of what people smarter than you are doing
but, as I said, you need to know why, not just how
that would be best, yes. But I'm going to be happy with what I can get.
I was using coroutines for my RPG event/logic, but it wasn't until I had the whole system working that I found yield start Coroutine... delays the execution by a frame. And I had lots of nested calls with coroutines waiting for more coroutines, cascading down the line to handle all event listeners for any given action, and the frames were adding up. No frame rate loss, just unacceptable delays in between actions being carried out that would be annoying to the player.
At that point I knew that switching to async/UniTask was the proper solution, and a couple days of refactoring was done and its all good now. There wasn't much info out there on that behaviour of coroutines, because few people use them in a nested/chain approach. So I had to learn that myself.
@zinc merlin You can look at examples and learn from them implementing them is an important step yes, Don't worry about SteveSmith he is always like that. Chill bro why you always on the offensive chill he is trying to learn clearly.
Yeah agree super annoying to play games that use Coroutines wrong personally I never mess with them ever I will just have a function attached to some empty game object that runs timers for stuff. Same as storing lists that need to be accessed by one or more scripts, nested references where needed or just for your own sanity.
Genral game stuff like player skills, play timer etc.
Just one object that holds stuff for you easily referenced can help
They're alright in simple forms, a basic tool to bust out from time to time, but clearly async/UniTask is the right approach if you need something more involved
Agree
async/UniTask does need a bit more care because of how it can continue to run after the editor's play session is over, or after objects are destroyed during play
I'd like to have some temporary configs only in the editor, which do not persist across sessions and ideally completely in memory, and use those configs in editor play mode to alter behavior as a quick way to test things. What's the best way to store and pass these configs?
Perhaps use https://docs.unity3d.com/2020.1/Documentation/ScriptReference/ScriptableSingleton_1.html
without the FilepathAttribute?
Hmm, seems like it's in the editor assembly so the runtime code can't get access to it to grab its state.
Well you said it was "only in the editor" I thought
Yeah the runtime code in play mode still needs access to it to change the behavior, I can wrap it in #if UNITY_EDITOR to remove from production. I'll play around with it.
Works well enough, thanks.
thanks! this worked
hey ! Idk if you wanted to know but i progress in my project ^^ thanks you for your help 🙂
nice
doggo murder simulator 😮
Hey, that's cool. I appreciate you willing to share your progress with me.
I can already see the progress, and notice that you've implemented the logic we've been talking about (hopefully, they're done with ScriptableObjects).
You still have a long way to go, like adding more options, implementing cash, adding more sprites for UI and making the dog not suffer by reducing its health after it's already dead. Wish you good luck with that!
Feel free to share your progress and ask any further questions.
Also make sure those spells are assigned to the specific keys like 1, 2 etc.
Yeah of course, i'm just happy to finally succes to implemented the logic ^^ But yeah, now i will work on multiple spell, health's dog dont go under 0, add "stanza" for pay the spell (Mana/health...) ^^
Also make sure to not stretch the Layout Group of the Damages the way they fit it fully. Good luck!
I would like to arrange the layout group for have it like a list and dont stretch for exemple :
Actualli :
Damage +10
Damage +10
I would like :
Damage +10
Damage+10
The Layout Group's Child Force Expand for Height should be disabled
Also the Child Alignment should be set to Upper
Yeah it's a lot of work I spent months building my system nota coder per say but coded quite a bit in my life since young web pages and such. Go to a composite scho0l in Canada you can take all sorts of courses.
I have a Damage manager that oversees all damage in the game it runs fast as well, got it from Brackeys lol
built on it but yeah basic system
Oh yeah perfect thanks !
Its a empty Gameobject that handles all incoming collisions then apply status effect which each projectile or raycast incoming it apply that game object which two script handle each type of project hitscan or projectile.
this scripts are public static for the damage manager script so every thing can access at start you setup up your static class variables.
I hope it's also a Singleton
!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.
I see, not needed if it's a static class
I give up on that how why is it wanting to paste it as text file
im trying to post it via discord built in system
Why not simply have these methods in the Enemy script?
Because we have to download your code in order to fully see it
because multiple enemies and why have 100 of objects running it when one can run it
if it's just a method call it's just a call
the buff idea is fine (I've done it too)
So you would rather have 1 script run 100 methods than 100 scripts run the same method once each?
Yeah why not it works singletons are sick
It is usually not the best idea. You can simply make the Enemy have the methods, which are applied directly to it
i use them for everything always get fast reponsive everything
i just want to point out that if you are trying to share your code and it is ending up as a text file then it is too long and you should be using a link to a bin site like the bot says
Of course, if you have some kind of method, which should be called for Enemy, Player, GameManager etc., it should be implemented somewhere else
when it comes to GUI stuff an handling large volumes of data easily with unity auto serialization that drives me crazy more then it helps
yeah no I want it null please and thank you is often in my head
It really shouldn't
I would use unitask probably for a buff system if you do want the independency, otherwise a single update method for checking would probably better than the hundreds of coroutines you may be putting out each source of buff
or rather, you can also just self-check in each gameobject's update loop too
lot of choices for those systems
This absolutely qualifies as "Large code blocks" and you should follow the bot's instructions
Yeah, exactly I essentially have one coding loop and it works for everything essentially, lol I got one trick up my sleeve and I use on every object in unity allows for easy save states of anything as well to be serialized in my own system.
When all you have is a hammer
Calling the methods from the static class, which all have the 1st parameter of type Enemy, which is not even marked as this, is usually worse than putting the same method into the Enemy script, which not only reduces the number of parameters used by 1, but also covers the need to have an additional static script for every MonoBehavior in your game.
In the case, when the method should be used by the different types of the same entity, consider simply deriving them from each other and still implementing the method once in the parent class.
The enemy is not static the list of them is
and the the functions associated searching looking how far away they are and such
What do you mean?
hey not like I'm not willing to learn i learned Xml and SQl from people at Firaxis working with them on a super mod.
The Enemy class is not static? It's derived from MonoBehavior though
no it is public the data for the enemies is though you need to track every enemy in the game and player that needs to static that list.
Having a separate class like GameManager track them is usually a good variant
Yeah exactly what I just said
Also, why would you make that list static?
And that script should simply call the Enemy's method needed
It's runs faster having a master list of stuff and you need a master list to make thing easier and faster! then each object builds a list of what they need keeps memory usage down if you only storing like 10 lists of 100 items maybe more I don't use a dictionary but still why not singleton it and use that as a list. Like every youtuber i have ever seen codes for unity the same way except for Scriptable object fanboys well they only exist in unity it is not transferable skill. Being able to build your own system is you can go to any engine then scriptable objects will also make more sense in how they work.
this sounds like an entity-component-system design
For some reason, this is... very consufing to me
I mean the concept of SOs is that you're not having to explicitly define paths (or instance IDs) every second
except that it hasn't really gotten all the way there
actually, no, this isn't ECS; this is just manually reinventing the concept of instance methods
It's because they have no idea what they're talking about
Also, what does "master list" mean?
I have tried to implement a reuseable state system I want to hear some opinions on it if I made some mistakes or a better approach to it.
StateManager: https://pastebin.com/uDNLJhZV
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
As you saw, i have a vertical layout group for my "bricks" to create my spell but i would like to add negative cost for damage type of bricks and positive cost for compensation type of bricks.
I tried some thing but i never succes to have something symmetrical and align
How can i do it ?
Exemple :
Damage 2 -15
Mana 2 +15
Total : -15 +15 = 0 Balance !
I tried grid layout group but it's was really bad
how can i make my movement smoother? rn it feels really laggy and stuttery with input lag, this is my controller script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed;
private bool isMoving;
public Vector2 input;
private void Update()
{
if (!isMoving)
{
input.x = Input.GetAxisRaw("Horizontal");
input.y = Input.GetAxisRaw("Vertical");
if (input != Vector2.zero)
{
var targetPos = transform.position;
targetPos.x += input.x;
targetPos.y += input.y;
StartCoroutine(Move(targetPos));
}
}
}
IEnumerator Move(Vector3 targetPos)
{
isMoving = true;
while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
{
transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
yield return null;
}
transform.position = targetPos;
isMoving = false;
}
}
are you certain the issue is that the movement is laggy and not perhaps that your camera is updating at the wrong time making it appear laggy?
wait i realised what the issue is
the character is moving 2 tiles when i click the movement key
or whatever the speed is
but i want to character to ONLY move when the key is pressed
is there any way to do that?
that sounds like a totally different issue
and also how do i make the camera update better cuz you did bring that up
But also it looks like based on this it should only move one:
targetPos.x += input.x;
targetPos.y += input.y;
StartCoroutine(Move(targetPos));```
presuming input always is limited to 1
that's just how fast it will move to the target position
im quite new to unity
I know
transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);```
This will never move you anywhere other than `targetPos`
what change would i have to make to my code in order for the character to only move when the key is held
you would have to show how you're moving the camera currently
where is the setting for that
The code you're using makes it seem like you want grid based movement
e.g .like pokemon
that doesn't correspond to "only moving when held"
nothing to do wiht this
i think its because of the tutorial im following
you either:
- wrote code to do it
- are using cinemachine or another component like PositionConstraint
- or simply childed the camera to the player
I don't know which one
you have to tell us
ok then let's back all the way up
And again can you tell us what the problem is?
rn its really weird
This isn't particularly helpful
showing a video or giving a better explanation would be helpful
hmm its really weird
As well as explaining how you want the code to work
the issues seems to be fixed when the speed is 10
even less helpful
no more input lag and the movement overall feels much better when the move speed is 10
The code you're using seems to be emulating for example the movement in pokemon
where the player moves around on a grid
and can't exist in spaces between grid spaces
if you explain how you want your movement to work, then it would be possible to help you
is there any way to make the player be able to exist between grid spaces without drastically modifying the code?
No
you would rewrite it from scratch
because this is meant for grid movement
follow a different tutorial
also this is only like 20 lines of code, there's nothing about rewriting that which is "drastic"
basic movement script:
public float speed = 1;
void Update() {
Vector2 input = new(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
transform.position += input * Time.deltaTime * speed;
}```
ok ty for the help
i found a different tutorial that makes a platformer game which i will follow
that's so different lol
maybe you should decide on what kind of game you want to make before picking a tutorial
also do you think i should use rider or visual studio
Rider if possible
Rider is the best
then maybe don't follow a platformer tutorial
You'll never find a tutorial that fits exactly what you want. Actually you'll probably find something that "works" for the time being, then later when you want to expand on it you'll realize it's not feasible. Most tutorials give the shittiest code. First you should consider how you want it to play out
The best fix to this is just make your grid smaller and smaller
rather, larger
more indices ;)
if you make enough you'll have some good precisional movement without having to deal with floats! haha
Is there a way to have drag only apply horizontally and not vertically?
Why does Rider (or VS) not show up in external tools? I want to generate project files using the JetBrains Rider Editor package, but it doesn't seem to work if I just add the executable of the IDE, as it just doesn't show the option to regenerate project files.
Unity 2022.3.17f1
Is perlin noise still the best option for base procedural generation
I want to generate a perlin noise for the base of my terrain or the general landscape
Then I’ll add in some of my own prefabs with some other functions
Ok, go ahead.
I saw a neat video on this subject recently
The first half would be relevant
I don't think that Mathf can give you the gradients -- but you can definitely get them from the Mathematics package
huh, maybe you can only get gradients from 3D simplex noise?
I guess you could just ignore the Z component.
ah, I guess you'd use noise.srdnoise
You give it a 2D position, and it returns a float3
The X component is the actual value, and Y and Z are the partial derivatives in the X and Y directions
The video talks about how to use them -- basically, the derivatives give you the steepness
You can use that to control the generation. Slopes are smoother than flat areas.
(so yeah, watch the video. it explains the idea very well :p )
and it has a cute dog
hi, i'm trying to get the inspector to show different UI based on different values but i cant get it working, i want the fields to disappear /appear based on action type
[CustomPropertyDrawer(typeof(ActionInfo))]
public class ActionInfoDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Debug.Log("Drawing ActionInfo");
SerializedProperty actionTypeProperty = property.FindPropertyRelative("actionType");
// Draw the actionType dropdown
EditorGUI.PropertyField(position, actionTypeProperty);
position.y += EditorGUIUtility.singleLineHeight;
// Customize the GUI based on the action type
switch (actionTypeProperty.enumValueIndex)
{
case (int)ActionInfo.ActionType.UnitTarget:
// Show options for UnitTarget
EditorGUI.PropertyField(position, property.FindPropertyRelative("actionDescription"), GUIContent.none);
position.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(position, property.FindPropertyRelative("baseRange"), GUIContent.none);
break;
case (int)ActionInfo.ActionType.GridTarget:
// Show options for GridTarget
EditorGUI.PropertyField(position, property.FindPropertyRelative("actionDescription"), GUIContent.none);
position.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(position, property.FindPropertyRelative("aoeRange"), GUIContent.none);
break;
// Add more cases as needed
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
// Return the height needed for the number of properties you are displaying
return EditorGUIUtility.singleLineHeight * 3;
}
}
[CreateAssetMenu]
public class ActionInfo : ScriptableObject
{
public string actionDescription = "Action Description";
public int baseRange = 0;
public int baseDmgAmount = 0;
public enum ActionType
{
UnitTarget,
GridTarget
}
public ActionType actionType;
public int aoeRange = 0;
}
Trying to wrap my head around some delegate/func related stuff but I'm struggling to fully comprehend what internet is telling me
I have a class like
public class CoolCustomClass : MonoBehaviour
public void DoTheThing()
and in another class I have a list of CoolCustomClass and I would like to register them to a event in bulk (maybe using a linq extension?)
eg. i know how to do this
public class EventManager
event Action myCoolEvent;
List<CoolCustomClass> coolClasses;
public void AssignEvents()
foreach (CustomCoolClass coolClass in coolClasses)
myCoolEvent += coolClass.DoTheThing;
but i wanna do it in a way where i can pass in the list of functions generically via AssignEvents params instead of being explicit
I feel like this involves Func but i couldn't figure it out
i wanna do it in a way where i can pass in the list of functions generically via AssignEvents params instead of being explicit
Can you elaborate on this? This is vague to me
If you want your event to accept parameters you need to use a different delegate type other than Action
either define your own delegate type, or use the generic forms of Action
eg. i wanna do something cursed like
AssignEvents(coolClasses.Select(o => o.DoTheThing))
or similar
I don't really get what that would be doing
Oh wait you mean
You want to only subscribe some subset of the functions to the event?
I wanna assign the group of functions in the eventmanager generically so i can be explicit when i use it in other places
right now no params or return values
If I understand you correctly...
public void AssignEvents(Func<CustomCoolClass, bool> predicate) {
foreach (CustomCoolClass c in coolClasses.Where(predicate)) {
myCoolEvent += c.DoTheThing;
}
}```
if you have the reference to some instances, you can just directly call their methods....
use IEnumerable as argument type
btw all the instances of that class will ofc have DoTheTing method.
And this can be used e.g.:
AssignEvents((ccc) => ccc.IsRed);``` For example to only take red ones.
(obviously a made up property)
Or:
AssignEvents((ccc) => ccc.HitPoints > 5);```
I know I can offset position at same time to get this net effect but is there any way to set up a tiled sprite to grow from an edge rather than from its center?
Set its pivot to the edge, then scale it
cool that works. I wasnt expecting that to be on the sprite itself. If I wanted this behavior to be instance specific rather than common to the entire sprite is there a way to set that up or should I just duplicate the sprite and change duplicated sprite's pivot?
Sorry didn't mean like a conditional type thing, made an extended example
public class EventManager
{
public static EventManager instance;
public System.Action myEvent;
public void AssignEvents()
{
}
public void InvokeEvent()
{
myEvent?.Invoke();
}
}
public class LevelManager
{
public List<GoodClass> goodClasses;
public List<EvilClass> evilClasses;
public void Awake()
{
EventManager.instance.AssignEvents(goodClasses.Select(o => o.DoGoodThing()));
EventManager.instance.AssignEvents(evilClasses.Select(o => o.DoEvilThing()));
EventManager.instance.InvokeEvent();
}
}
public class GoodClass
{
public void DoGoodThing() { }
}
public class EvilClass
{
public void DoEvilThing() { }
}
Ok then you want this:
public void AssignEvents(Func<CustomCoolClass, Action> funcGetter) {
foreach (CustomCoolClass c in coolClasses) {
myCoolEvent += funcGetter(c);
}
}```
And used like:
```cs
AssignEvents(ccc => ccc.DoGoodThing); // assign good functions
AssignEvents(ccc => ccc.DoEvilThing); // assign evilfunctions```
all the instances of EvilClass will have DoEvilThing method...
this won't work with two different classes though unless they share a base class or something
if you want GoodClass that always does GoodThing and EvilClass that always does EvilThing maybe you just want an interface like cs interface IThingDoer { void DoThing(); }
And have them both implement this^
I want to be able to pass in a list of Func, As AssignEvents() wont have access to coolClasses
then you need to pass the list in too
public void AssignEvents<T>(List<T> theThings, Func<T, Action> getFunc) {
foreach (T thing in theThings) {
Action a = getFunc(thing);
myCoolEvent += a;
}
}```
E.g.^
Used like:
EventManager.instance.AssignEvents(goodClasses, (GoodClass gc) => gc.DoGoodThing);```
Or maybe just the simpler version:
public void AssignEvents(IEnumerable<Action> actions) {
foreach (Action a in actions) myCoolEvent += a;
}```
Used like:
```cs
EventManager.instance.AssignEvents(goodClasses.Select(gc => gc.DoGoodThing));```
ahhh ok
thank you very much I appreciate it a lot
I'm always hesitant to ask for explicit examples but in this case a working example is helping things click in my head 🙏
getting hit with this error, Am I missing something obvious here?
public void AssignEvents(IEnumerable<Action> collection)
{
}
goodClasses.Select<GoodClass, Action>(...etc)```
try this
What method do we think is best for realistic terrain procedural generation? I tried perlin noise but are there other ways just as good? Im happy to share my thoughts on what I think I need to do to create a realistic terrain and then bounce ideas around to come up with a better way
if you want realism, maybe just use heightmaps of real places.
There are many techniques. Terrain itself is often generated with layered perlin noise with several octaves. Then there are erosion simulations and what not.
Perlin noise is the base of everything though. There are things that complement it or build on it, but don't replace it.
Are you familiar with the game Rust? If so you notice how the terrain itself is not very extreme, its their prefabs like the rocks to climb on the side of the hills or the cliffs that overhang a small section really change the environment. Would it make sense to create a map using perlin noise and then procedurally place some of my terrain prefabs if the location fits?
I like this image as an example. A lot of the land is flat but when the terrain height increases so fast a rock prefab is placed against it
I dont get whether you're having troubles with adding the negative cost or aligning them. If you simply want to align them vertically, use Vertical Layout Group, which doesn't support multiple columns
are you sure its really a prefab and not just some terrain texture?
yea I know for sure they're prefabs because theres a map editor program that uses prefabs like the rocks and cliffs
i see, that does sound like more of a pain to do in the way you described with "place prefabs if the location fits". I havent looked into how that game works, but id imagine its way easier to place prefabs then build a terrain around it.
it might be but this is how its done in their game and I would think this is better but idk. In this image you can see the perlin noise map generated and then someone places a rock prefab into the ground, this would be procedurally put in the terrain but yea
normally after these prefabs have been placed you would press a button and the textures around the prefab would smooth so its a clean transition
ah i can see that being viable too. Something like make a simple terrain, place prefabs, remake parts of it to fit
Im completely new to procedural generation so I really have no clue how to do this but I think this would be how I attempt to do it
Who else hates it when they change the initial value of a public variable, run code, code still not work, stress for 30 minutes and than realise they didn't reset the value in Unity?
who uses the default value from code anyway? once it's visible in the editor that values always takes over . . .
This code returns the following output:
Space start
Something start
Space end
<- 3 seconds
Something end
Why does calling the method Something give me the following warning if that's how it's supposed to work? The Something method's Delay shouldn't stop the Update method from executing.
Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the await operator to the result of the call.
When applying the await operator, this gives the following result, which stops the Update method from executing before the Something method is finished
Space start
Something start
<- 3 seconds
Something end
Space end
So my question is how to avoid the warning without pragma
Is there a reason why you use async Task instead of Coroutines?
Yes, Coroutines don't work in the editor
Using discard fixes it
_ = Something();
Because you should await every task you create. If you're starting an async method in Unity and forgetting it it should be async void
Discarding it is not the right solution
But, as I have mentioned above, awaiting it stops the Update method from executing
I never said to await it
Because you should await every task you create
And I didn't suggest you do that
Right, you have mentioned that discarding it is not the right solution. Could you, please, tell me why?
Any exception thrown in a Task creating async function will be eaten if the Task is not awaited
Awaiting the method simply stops Update from executing though
Even if the exceptions aren't eaten
Yes, so do what I and my resource suggested for fire and forget async methods in Unity
Does it matter whether to use Awaitable instead of Task?
I'm honestly not sure what's most appropriate for methods in the Editor. Awaitable is good for runtime
Does anyone use A* Pathfinding Project?
How to get the collider to work on 2 Ais?
That is generally not a pathfinder’s job, unless you want dynamic obstacle. If so then you need to update your grid and recalculate the path periodically.
And Unity already has NavMesh that covers pathfinding and little bit of collision/obstacles options. Is there a reason you are using astar specifically?
It works much better, Nav Mesh is really bad compared to it
I would love to show you it if you got time (sharing screen), since my game is a top-down view
Nav mesh calculation for the pathfiding is kinda weird, and it jiggles alot
For NavMesh you’d need to adjust how it is generated and how your agent is set up. But if astar matches your need then it works.
I’m on mobile rn so don’t really have time for screen sharing, astar is pretty fast (depending on grid size, tho) so you could update your high-priority agent first and bake grid accounting that agent
Or you can just use physics approach
Mmmm everything so far is actually working correctly, all I need to do is a way to add a collider for the units the player is controlling, since they keep stacking on top of eachother, I dont think normal collider would work, or would it?
Maybe a Rigidbody?
Regular physics components would work as long as your movement regards the physics. Rigidbody is always required for anything that moves dynamically.
Good, Rigidbody registers your object to physics engine. Any collider without it should be considered static
Hmmmmm, now another issue im having is if i have 100 units, they would actually climb on eachother xD
Aaaaahhhh
Lmao
I just made the Collider taller, so that fixed it ^^
That’s more characters than I thought
Normally you would never get to this point, but I was just testing ^^
like here, I'd like it to be aligned vertically like costs and credits (-10 & +10)
Hey, I have problem with cameras in URP, I have a tilemap on layer "Ground"
I have a main camera which renders everything
and another camera which should only render that Ground layer
and for some reason the output texture is black?
What does the ground camera preview look like?
Is the last screenshot rendered by the ground camera?
preview shows the same thing that the main camera
Hmm. Does anything change if you enter play mode and pause the game?
nope
Hmm... What if you assign the render texture to the main camera?
Should 10 & -10 be aligned in 2 columns?
Yeah, 1 column for "+10" and 1 column for "-10"
I would suggest having a single Vertical Layout Group with the element, separated by 3 sections
Vertical Layout Group
- Option
- Option name | aligned to left
- Cost | aligned to right
- Credit | aligned to right
- Option
...
Option name | cost | credits |
Cold 1 : Damage | 10 | -10 |
Mana 1 : Consume mana | 10 | +10 |
Note that every Option's item should be an empty GameObject with the TMP_Text inside of it
Vertical Layout Group
- Option
- Option name
- TMP_Text
- Cost
- TMP_Text
- Credit
- TMP_Text
- Option
...
Like this ? but it's not next to each other
Or maybe i need to add an VLG to each gameobject ?
hi people can you help me please? I am ın a exam rıght now but my audıoSource got some problem ı cant hear the sound
ı dont know why Anyone have any ıdea for ıt?
ı watch some basıc tutorıal about thıs component but ı dont know what ıs wrong about ıt
Min distance is 500, max distance is 1000. Is this what you intended?
because that dıdnt work wıthout ıt and ı just trıed to change
Is it outputting to the main camera's sound?
No errors? Can you verify it's trying to play the sound?
lıstener ın camera audıosource ın player
ı dont know what ıs that output varıable means
yea yea
ın code that %100 should to work thıs code
because ı put jumpSound ın jump fonk
Character jumps but there ıs no voıce
Enable these two boxes
If you hear sound, then the issue is that you are not triggering the sound.
ı dıd
If you hear no sound, then the issue is that the audio player is not right
You did what?
Okay
and download some audıoclıp from ınternet
You... have done it wrong enough.
- Each
GameObjectinside of theOptionmay be assigned with theHorizontal Layout Group, but it's not necessary - These "sections"' heights should fit the whole
Optionand the widths and positions should be set the desired way - Note that the size of the sections of each
Optionshould be the same if you want them to be "in a column"
So I need you to click these two boxes:
And then press play
And then put something in here:
Without an audio clip, nothing will ever play.
This is just for troubleshooting. If you check these boxes and hear no noise, it's because there is no noise.
Your AudioSource doesn't seem to have a clip on it
my game have time.timescale in start fonk fırst
and a buton change ıt to 1
ı mean when game starts there ıs time.timescale = 0
start fonk and thıs audıosource can work ın zero timescale?
Yes, AudioSource doesn't depend on Time.timeScale
Hope this helps
ı undurstand
tryıng ty
"Fonk"?
Do you mean "phonk"?
lıke start update fıxed update or void fonk() {}
Oh i need to have the panel with vertical layout group and each "option" or "credit" i add, have 3 section with a vertical layout group ?
Do you mean Function?
yea
Each has a Horizontal Layout Group. Not sections. The Option itself has it.
It's called a "method" or a "function"
ı cant add audıo ın thıs project...
So, i have the panel with vertical layout group, in this panel i have 3 option "Name","Cost" and "credit". Each have horizontal layout group
But when i do this, i can't place "name","cost" and "credit" next to each other
How can I open this file in Unity? I transfer it to Unity and want to spawn it on the map, but it doesn’t allow it, what should I do?
you cannot that is a built unity game
Is there anything that can be done so that I can transfer it to Unity?
we do not discuss modding or decompiling on this server
bad
Eloquently said, Ast. Can someone give this guy mod privileges?
Oh no i understand sorry !
No, your Option/Credit should may have a Horizontal Layout Group. The Vertical Layout Group should be assigned to its container, the object, which contains all the options
Yeah, right, make sure you make them slightly wider. Also, it's quite troublesome to align them with the Horizontal Layout Group, so I would rather remove it from the Option object
But it's up to you
Yeah my "option" is empty , what you mean by "slightly wider" ?
Consider making credit and name slightly wider
Oh okay why ?
This is not essential, but they look slightly too close to each other
I see thanks !
This is going to cause you troubles when increasing the cost
and so -100 is not going to fit properly
You have Mute Audio checked in the game view
How would I, IN WORDS, make this happen?
set an inverse relationship between two floats within some parameters? I've made my spotlight angle be controlled via the mouse wheel, i.e. scroll up ads to the variable of angle upwards and vice versa, but I would like to make it increase in range the narrower the angle and vice versa
I made a primitive version with float switches but they go up in increments and it's kinda bad
I'm sure there is some kind of mathemathical way to do this but I'm dumb
You could have a 0...1 range float that you adjust with the scroll wheel, then use that float to Lerp between min to max angle and also max to min range
A remap function
ok so I currently have this
for (int i = 0; i < Segments.Count; i++)
{
if(i==0){
if(Vector2.Distance(Segments[i].transform.position, transform.position)>SegLen){
Segments[i].transform.position += Time.deltaTime * -(Segments[i].transform.position-transform.position);
Segments[i].transform.right = Vector3.Lerp(Segments[i].transform.right, -(Segments[i].transform.position-transform.position),0.5f);
}
}
else{
if(Vector2.Distance(Segments[i].transform.position, Segments[i-1].transform.position)>SegLen){
Segments[i].transform.position += Time.deltaTime * -(Segments[i].transform.position- Segments[i-1].transform.position);
Segments[i].transform.right = Vector3.Lerp(Segments[i].transform.right, -(Segments[i].transform.position-Segments[i-1].transform.position),0.5f);
}
}
}
created by this code
but i wish the segments didn't go along the diagonals, and instead more closely followed the path, like the centipedes in rain world
Hi, I'm trying to figure out how to reduce the size of my apk, so i found the following link (https://docs.unity3d.com/Manual/ReducingFilesize.html) but it says that i should have a breakdown of my build size in the console but it seems its isnt the cass... is it because its deprecated ? or is it somewhere else ???
Also, i found something about BuildOptions.DetailedBuildReport thing, but i dont understand why its in code and how to make it work
Not the console, the editor log:
This information is available in the Editor Log just after you have performed the build. Go to the Console window (menu: Window > General > Console
), click the small drop-down panel in the top right, and select Open Editor Log.
This could definitely be written more clearly, I'm having hard time trying to understand your code but I guess what you are doing is move each segment towards the segment before. Is that right? If so, the segments will cut the corners and towards the end the effect will accumulate even more. For better results you may consider constructing a spline or polyline which all the segments follow instead of each other. There's definitely some much easier solution out there done by just modifying your idea slightly but I'm not aware how that would work. Actually I'm wondering whether something like this could work: so instead of moving towards the next point, you would move towards the direction from the last point towards the next point (see the sketch below). I figured this might not be exactly the working formula but the idea could be worth playing around. For example you could maybe also try to lerp a direction between the direction to the next point and the direction discussed earlier with different lerp factors to see where's the sweet spot that works the best. It is more than likely someone has figured out the mathematically correct way to achieve that but this is just my thoughts on the issue, I bet there's quite some resources available online on the same issue as well.
So how can I upload this model so that it works?
You don't.
well i am probably blind, in the editor in top left their is no open editor log and their is no other thing
and as you have already been told, this server does not permit discussion of reverse-engineering or decompiling Unity games.
You cropped it out
See the top right (B)
a build is in progress, i'll come back to you when i will be able to interact with unity again ^^
Not bad (my opinion) ahah ^^ Thanks you for your help !
I'm in the Unity 6 preview, and I'm trying to use TextMeshPro, but for some reason I can add TextMeshPro components to my scene just fine but the package isn't listed in the package manager, there is no .asmdef that I can add to my project and I have no way of referencing it from my code, has something major changed in Unity 6 that I'm missing? 🤔
found it thanks
show your package manager window
which part of it? TextMeshPro isn't installed if you're curious, and trying to force install it via the manifest just causes compile errors and this warning
oh hey, you're right! I didn't know that
that's neat
but yes, good question...i don't see where to look now either
oh, no, there it is: I can still use the TMPro namespace just fine
are the errors regarding using TMP only appearing in your IDE or do they appear in the unity console as well?
(my IDE wasn't set up properly)
found the issue, the UGUI package isn't being imported properly (or at all)
well that's wonky
it exists in my cache just fine, but for some reason it isn't being imported, so that's interesting
make sure you have no compile errors. i've noticed that unity will fail to correctly import a package if it cannot compile
Just for that I would just start using UAE
no compile errors, nothing on my end that would suggest it shouldn't be working
including the fact I can put text mesh pro components into my scene just fine and the work as expected
weird. you could force a complete reimport by closing unity and nuking the Library folder
yeah I was just thinking that, I hate to do it but it is what it is
yep, all back to normal, no idea how or why that happened
I like to do that from time to time in case there's any...miscellaneous corruption in there
it also reveals how long cold builds are 😭
i need to get some shader variants under control
lucky for you unity just posted some nice info about getting them under control lol
#📢┃announcements message
will have a look!
you know, there's one thing I don't get
assuming that both sides of a branch use the same resources, why not just dynamically branch on a uniform?
e.g.
float foo = -1;
if (do_foo) {
// a ton of expensive math to set foo to something
} else {
foo = 0;
}
that's not going to diverge, and it's not like one side is using a big texture that the other isn't
Branching is expensive in shader
it's expensive when you start diverging, isn't it?
If do_foo is a feature flag of sort then multi compile would remove that branch