#archived-code-advanced
1 messages ยท Page 140 of 1
yeah you can unit test saving
void TestSavesPlayerData() {
var playerData = Test.CreatePlayerData();
SaveManager.Save(new GameState() {
playerData = playerData
});
var reloaded = SaveManager.Load();
Assert.AreEqual(playerData, reloaded.playerData);
}
do you see what i mean? if it's a unit test, it wouldn't be in the context of a game
That's good to know
Yeah, that's kind of what I meant by composition. I read this blog post where a team at Unity like sped up timeScale and actually used that to unit test a few different gameplay scenarios, but that just seems like it would still take an enormous amount of time if you had to run a simulation for every test. And a lot of unnecessary code might need to be written just to run the test, which could also break
If I have a MonoBehaviour that has parts that work with each other, I try to separate them into subclasses. And then, since the subclasses are not MonoBehviours and don't need to be instantiated, often they don't need Unity Objects at all and I can just test them like a normal class. For actual behaviours, I like the idea of having modular, independent prefabs that can just "work" upon instantiation, grabbing all the data they need and what not. That way, I don't have to worry about scene setup if I want to write behaviour-specific tests. Unfortunately, I'm doing a sort-of "arcade" style numbers game, so my system doesn't really work like that. I may re-write some things so it can later, but it feels more work than it's worth now
there isn't really a point to test gameplay this way
grabbing all the data they need and what not.
unless your game rules are mostly unity physics, you wind up with a game object with dozens of the only instance of a particular script on it
scene setup can be a little toxic
if you're google, and you have a rule that says "all code must be tested" and then you have to make a unity demo
wind up with a game object with dozens of the only instance of a particular script on it
could you elaborate on this?
really depends on the game
like if the setup of the level and your character running around it is most of the rules
then yeah you'll have objects you put in the scene with scripts attached to them and they do the right thing
but who is still making games like that?
we have enough platformers
I think I see what you mean
most games with new ideas don't interact with the scene or physics or raycasting or anything like that at all
the scripts attached to your scene prefabs are Views, the ones you have many copies of
everything else is the only-instance-of-this-script-attached-to-a-game-manager-prefab
for example in Mini Metros, i doubt the stuff happening in the unity scene is like, there's a Road script and it specifies a chunk of road behavior
there's a script called RoadManager that deals with all the road rules, and the object in the scene has a RoadView script that RoadManager puppets
RoadView doesn't do anything and doesn't have any rules, it just renders
Boiling to the basics, my game consists of bubbles that hold numbers. The player can drag them with their finger to combine them into other bubbles. Right now, I can't just instantiate a bubble prefab because bubbles are instantiated by a bubble "set" they belong to and there are some dependencies regarding the set in the bubble class that go along with that.
It would be nice to have bubbles work independently and not have that set dependency. I could just spawn two, combine them (with the test method moving object position or just by calling the combine method stuff internally) and check whether the combined bubble has the right value. But that would take a bit of reworking. For now, it's easier to separate my functionality into modular non-MB objects and test those.
For example, these bubbles will combine depending on the current operator (+, -, divide, etc...). There are some things not allowed, like combinations that result in negative values. It might take a bit of setup to truly, holistically test combinations of bubble GameObjects in the scene in an integrated-like way (would need to have bubbles spawn on their own and simulate finger movement, etc.,), but one thing I can do for now, is abstract and modularize the internal logic to private nested classes (or just separate non-MB public ones). So if I try to combine some numbers and get a number back that violates a rule I have set or a combination fails that should not have failed, I can test that without MB, and will likely get the similar benefit to a holistic integrated-style test, even though I did not test the whole process
Sorry if that was too long to read
can you name an example of a combination that is not allowed?
Well, I would say dividing 7 รท 0 for obvious reasons, but bubbles can only contain positive integers, so.. 7 - 7, then
@undone thorn Sorry, I may be missing part of the conversation here, but wouldn't your game just have a BubbleMathUnit class (which isn't a MB at all)? You would compose a MB that's like a .... rendering of a BMU and subscribe to various events on it (like OnValueChanged or OnAddAttempted), but then also ask it for IsValid operations with another BMU and/or operation as a parameter
That way, you could test your MB as one "thing" and your BMU as another thing (with tests that don't even need unity). Your Unity MB would pretty much only handle display logic and input collection, and would contain as little "logic" as possible - it would always ask the underlying BMU for the logic
Yep, that's pretty much what I do. I guess I'm just poor at wording things
Though I maybe should mention that the naming and methods are different because the base type is actually generic
Im looking for someone for one on one help with rapidly learning Zenject (or understanding specific things).
So someone with good experience on Zenject/Di is needed.
I need to learn two whole APIs in under 2 days and am already experiencing some frustrations.
This is very very very very urgent.
there are things which are normally super simple to implement which have become frustrating.
I have some problems with Building in unity,
I have Steamworks plugin for the Steam Overlay, It works fine in scene gamemode, unity gets player name,
But when i build game and tries, game doesent get steam name,
Anybody knows? ๐
any errors in the log of the build game?
DI is one topic, and an entire API or framework is another entirely. I'm not sure it's all that reasonable to learn both in 2 days - hopefully you can find some resolution that's not related to just trying harder. Learning takes time, and implement a new technology takes (twice as much) more time than you expected. And I expect that learning a DI framework to be especially sticky.
Unfortunately. I am desperately trying to get a very specific job.
Yeah.. I mean... DI is a pretty big thing / paradigm change evolving from separation of responsibility/concern.. I uhm.. know you want the job and all that, but if familiarity and experience with DI is a requirement and you don't have it.. it's kind of hard to cram that knowledge in .. I hope that doesn't deflate you, but.. I mean.. learn what you can and see how it goes, but I think it's important to level-set with yourself here
Dumb question: Do Unity SubScenes require DOTS/ECS? Or could I use that concept to chunk up a large world map that is GameObject based?
textMeshPro buttons use a class called TMPro.TextMeshProUGUI that handles button color changes (for example, highlighting the button when it is the current selection). It normally uses the mouse, but is there a way that I can control whether or not it is selected via code?
can't seem to find the right method or parameter
text mesh pro ugui is responsible for the text only
the button component handles highlighting / being selected
ah i see i have the wrong component
UnityEngine.UI.Button is what i was looking for
thanks!
i wanted to use buttons as a lazy way to animate color changes, but i see now they're a whole worm can unto themselves
yeah there are pointer events that will allow you to do the same highlighting events as buttons
https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerEnterHandler.html
I'm actually building a pause UI for VR, so the mouse is not an option
starting to think I should not use a canvas for it and build them from 3D elements instead
if it's VR then there's going to be some sort of line/ray casting to find buttons
so you can do the same thing, attach a simple raycasting script to the hands to check for a layer for just buttons, and if it does hit something then you can call an event on that button
actually I was considering using joystick selection
moving around a highlighter
reason being the pause menu that is not a part of the game is already damaging to VR presence and immersion
and aiming controllers at buttons is a bit of a hassle
so having a joy-stickable UI would allow for faster and more comfortable/non-intrusive pause UI experiences
ah ok
unity's UI has a selection map so that can work
i've seen it a few times whenever i click on it by accident
How do you get name of next scene without loading it??
https://answers.unity.com/questions/1262342/how-to-get-scene-name-at-certain-buildindex.html I would use the answer provided by ibx00 on this post
So doing some more reading, maybe I'm misunderstanding the point of SubScenes? I was assuming it was related to Additive Scene Loading, but if I'm understanding what I'm reading (big if) it seems to be more related to creating entity hierarchies in ECS based games? Is that a correct reading of the API's intent?
You should ask questions about ECS in #archived-dots
So I guess that confirms that it is an ECS concept then? That's more what I was looking for guidance on
The class is in the entities package, so yes
Got it, I wasn't aware of that. Been struggling to find docs. Ah well, bummer.
You don't need to worry about breaking Mirror, because Mirror is breaking their API every release.MLAPI is probably a safer option.
Uh, no
You do not like MLAPI? Or now called, netcode for gameobjects I believe?
Calling it the safer option is ludicrous, I do like MLAPI (Netcode for GameObjects) but it is a preview package with only one release so far
Compared to a tried, tested and well used solution like Mirror
In all fairness their current solution is being developed openly.
they realized they need help ๐คฃ
I would advise using anything but Mirror. It's just a hot mess. Seems like it always has been and always will be.
They are also extremely unprofessional, a huge turn-off. Had a conversation with Mirror folks comparing their solution to FishNet and was met with a ban.
Oh you want to talk about the FishNet controversey?
Imagine if ASDA walked into Tescos, and completely shat on Tescos. Do you think ASDA would be allowed back?
No. I am just stating that I asked a few questions to help me determine which to use and was banned.
I doubt that
Because that is what happened, the dev of FishNet went into the Mirror Discord and constantly shat on Mirror
So what did he expect?
I was surprised at how long they let him do it
Welsh, I am speaking on my experience not theirs.
All I know is I asked for a comparison in the most polite way possible and was later banned.
Regardless, not an appropriate conversation for this channel. I just wouldn't use Mirror if you are planning to start networking.
Don't give me that crap, your message history in the Mirror Discord clearly shows you arguing with them over it all
It's a good solution, and you shouldn't dismiss it
Or the server. Which I imagine was the reason for a ban there.
I did not, and you can post your nonsense elsewhere, this isn't the place.
Also know people who had great experience with Mirror and making second project on it, which went viral now.
I've made projects in worse things than Mirror, it does not really mean anything.
Mirror is a fine solution, with good docs and many online resources. So don't go telling everyone never to use it because you got a telling off for being petty with them
I'm advising people to not use it because it's in a bad place.
You can stop with off-topic now.
!mute 590573457863999493 1h I don't have time to wait here for another tirade to moderate.
firerockstudios#3936 was muted
Now he's gonna think that we're Mirror agents.๐
I kind of wanted to know what's wrong with Mirror
Guy suggests ending the conversation multiple times, others do not end it, guy gets muted. ๐
Spreading gossip is not a conversation tolerable here. Any kind of off-topic in-fact.
wasnt aware saying something is in a bad place was gossip, more an opinion. But sure.
@regal olive I suggest you read their messages again then before jumping in defending and continuing off-topic discussion yourself.
sure thing.
hey, is there a way of adding a variable to an inaccessible class?
like extension methods, but with a variable?
No
I guess I found another solution
how can I check at what index a certain value is in an array
You mean inaccessible as in another assembly?
I mean like the GameObject class
To look into array you need to iterate it
/// <summary>
/// description goes here
/// </summary>
I am working on automating my entire build pipeline, but I ran into this snag (using Unity.exe to execute command line building): from https://docs.unity3d.com/Manual/CommandLineArguments.html
You cannot open a project in batch mode while the Editor has the same project open; only a single instance of Unity can run at a time.
Does anyone have a workaround for this, or a way I could compile my unity builds without unity.exe?
https://elijahlopezz.medium.com/automating-unity-building-9899836aaa01 (this was the approach I was going to take)
I just don't see quitting out of the editor to run the full build script as a thing, and there are other parts of my build script that don't require unity that I need to do.. my preference is not to handle the CI through Unity, but rather in a generalized tool like gradle
Sorry, do you want to build locally? Or via something similar to github actions?
Ha! I'm just reading the github actions sales page right now.
I'm looking for a solution that could ideally handle both - but right now my "production build" pipeline looks roughly like this - any/all of this that could be automated would be great:
In the github actions workflow, what basically happens is you listen to a commit on a specific branch, and when it happens you trigger a build
If you have a duplicate of the project folder, you can have that open at the same time.
But usually you automate builds so that you don't have to run them on the same machine as you develop on
- Set some production settings in code (server ip address) - this can eventually be moved to a .config file, it's just convenient for me now in code.
- Compile a shared DLL.
- Copy the DLL and JSON files to unity and server directories. (in a post-build script on the DLL project).
- Compile a PC build.
- Compile a server build.
- Zip the PC build and upload to a shared google drive folder.
- Zip the Server build and upload to gdrive.
- RDP to the server, kill the process, delete the executable and logs, and upload the new version>
- Start the server.
- Smoke test it by connecting to the server.
Long term I'd like to move all of this ^ to the cloud.. github actions is maybe appealing, because everything (currently) that's needed exists in the github repos.
We're also planning on cloudflare based content delivery so... whatever technology I choose should be able to support that integration as well
Anybody knows how to implement steamworks with a build, only works inside editor, after build steamworks dont work
1-5* definitely possible with Github actions. I dunno what kind of access GDrive gives you to upload stuff without proper authorization, but still doable (I imagine). Not sure why you'd want GDrive anyway ๐ No idea about the last 3
GDrive is our document repo for now.. can't see doing something like confluence ๐คฎ makes it convenient to host/deploy builds alongside documentation, spreadsheets, notes, etc
(FWIW I'm not tied to gdrive as a file distribution mechanism for our team but.. it's convenient now)
I have a problem that I'm struggling to track down. I have two main game objects one Lobby and a Game which contain many children and grandchildren.
When I move the player from the lobby to the game I call
MainGame.SetActive(true);```
The problem is about 5-10% of the time when running these commands [or the inverse] my game just infinitely hangs. I tried using the unity debugger but the only thing its pointing me to is some background thread waiters that aren't using any cpu.
Anyone have any thoughts on how to track down why this is happening?
@stone slate Do you have any scripts in one of those gameObject that might alter the workflow of your game? Do you have any cameras attached to those objects?
Does someone know how would I find the nearest vertices within a radius on a mesh? similar to a brush?
The solution I am using is to put as much of the build process into Unity as possible, and run that code from the editor when a button is pressed. I then have a separate system that can create the builds automatically, by calling those editor scripts through Unity.exe, but this is only intended for CI servers to use. Developers are intended to use the in-editor buttons.
For testing purposes, I do run the automated system locally, but I have to make sure to close the project first, otherwise I get the error you mentioned.
But for normal development, it seems like Unity wants you to use in-editor tools for this sort of thing.
Are you running the build through Steam? Steamworks integration requires the App ID, which in a standalone build is provided by the Steam client.
Edit: It looks like you could also copy the steam_appid.txt file from your project into the root of your build directory, and that should allow the game to run.
You didnโt directly ask about this, but in case itโs helpful: One recommendation I have, from my experience trying to get these systems to work, is that deployment (most of steps 6-10) should be handled separately from building and archiving. This makes the automation process easier to debug and work on.
have you tried just, switching around the two lines
Probably something in an OnEnable or OnDisable of a script on one of those objects
This is great insight, thanks. I think I agree - ideal is quick turnaround for local development and/or testing, and then a separate, dedicated .. something .. VM or otherwise that handles building/deploying as a separate task. I hope that my build process doesn't get to the point where I need to debug it though. ๐
If you just want to do this locally create a new project folder that's symlinked from your other
Just link assets and project settings
That way it will stay in lockstep with your project (as opposed to cloning the repo into a second folder)
But the ideal is too have a CI server
I mean I'd still need to close/reopen unity, right? or.. actually maybe it's easier to build my server from within unity (rather than a script to build unity from outside of unity)
ie - my unity build script will just build the DLL, server, copy files around, then build the unity clients
No
Not if you have a separate project or a separate machine...
Why would I suggest it if it did nothing?
Lol
ya i mean.. the issue is that I have to figure out a way to build the server in one script.. so it's gonna have to be a unity script.. which I hadn't considered
Oh yeah
(the server isn't unity-based, just a standalone C# app)
So you can just call CLI from unity
yeah.. I'm assuming there's something in BuildPipeline for that
If you want to build something with msbuild?
why would unity reproduce something already done in C# ๐
I have a separate project that is
(it's the shared lib stuff between unity and my server - i consume it as a /Plugin in unity)
Wait... I'm confused
I also (currently, not permanently) put the shared data files in the shared project - but those don't get compiled into the DLL, just copied around as needed
I thought you wanted to build a DLL
Why don't you use UPM for this?
Sounds really complicated
If it's in unity already
- Build DLL
- Copy DLL -> Unity, Server dirs
- Copy JSON -> Unity, Server dirs
- Build server (c#)
- Build unity client(s)
6+ deploy
Man just use UPM to have a shared dependency between them
Put the shared stuff in Server/Packages/my-shared
Then put a dependency to that folder in the client
I don't know much about unity packages, but... the server is unity-less, so.. (not sarcastic, honest question) why would I want the shared stuff in a unitypackage?
??
no, native DLL
DLL is not a project
Project 1. Unity clients
Project 2. Shared DLL + JSON files
Project 3. Server
You mean. csproj right?
https://elijahlopezz.medium.com/automating-unity-building-9899836aaa01 So I'll do something like that but build the CSProjects using command line .. msbuild
I gtg
It just hadn't occurred to me to make the unity project "the master" and build the other stuff from there first
cheers mate
๐
I'm generating a tile class and a chunk class that do not inherit from monobehaviour. I'm generating many chunks around the player as he moves so it's in the 1000s. I checked the profiler and it's showing many calls to the addcomponenent function. In the classes there are mesh filters and renderers being added so it can be drawn. Is there any way to pool components?
instead of adding components, you could always make a prefab that you instantiate to represent the chunk, then just pool the prefab
I do not know what that means
what selection?
Nothing would be different about your logic except that you instantiate / enable an intermediate gameobject that already has the required components on it, instead of manually adding the components
ill look into it and come back if im stuck lol
This is not an #archived-code-advanced question
(finally someone said it)
i've seen some ridonkulous questions in here
far from advanced lol
Having many if statements is not necessarily bad, and how you'd refactor it changes case-by-case.
i was wondering on waht the advanced engineer method would be
What is the code?
therefore it could be classified as advanced for all intents and purposes
i have several classes that just have chunks of if statements
I think anything that comes down to "how to write code" is not advanced
but when i look at other more advanced code i dont see so many
But just show the code anyway
its not about how to write code
its about how to engineer it into something beyond simple if else checks
which would be beginner or general
okay, and when you share the code I'll have a look
ok thanks
{
// Reset Speed check to 0 after movement has occured
if (movementScript.Speed == 0)
{
IsWalking = false;
}
// If running, play grass step sound at higher pitch
if (movementScript.Speed != 0 && movementScript.Speed > 0.5f)
{
IsWalking = true;
audioSource.pitch = 0.66f;
}
// If walking, play grass step sound at lower pitch
if (movementScript.Speed != 0 && movementScript.Speed < 0.51f)
{
IsWalking = true;
audioSource.pitch = 0.58f;
}
// If walking but audio isn't currently playing
if (IsWalking && !audioSource.isPlaying)
{
audioSource.clip = footsteps[Random.Range(0, footsteps.Count)];
audioSource.Play();
}
// If not walking stop all audio
if (!IsWalking)
audioSource.Stop();
}```
its just an example
but my movement class is something similar
and i have a character customise class again using lots of ifs
im just wondering if there is an advanced set of things i can research or look into that takes me above the simple if else logic all day
i understand its not an advanced level question its more of a 'how do people who are advanced handle the same thing'
thank u in advance
movement class is basically the same deal with if triggers for 10+ buttons
and the sounds that go with them are also many ifs
everything is just ifs
Tbh, I'd use events here
ahhhh
E.g. an event when the speed changes and an event when the user starts/stops walking
yea defo, i did figure that would be the next implementation
You can also simplify some of these if statemetns
hows the performance of firing events compared to this
also can u give me a simple example of simplifying one of those
appreciate it
Yes was just getting to it ๐
I'd use a state machine.๐ค
Or link that code to animator states.
hey again dlich
can i access the animator states from my audio manager class im guessing yes ill have a look
IsWalking = movementScript.Speed > 0;
if(!IsWalking)
audioSource.Stop();
else if (movementScript.Speed < .51f)
{// Walking
}
else
{// Running
}
oh isee thank u navi
That works, but then everything is very closely coupled
Which is probably fine for most cases
For these ones:
[Serializable]
struct WalkingPitch {
public float maxSpeed = 0;
public float pitch = 1f;
}
[SerializeField] WalkingPitch[] _walkingPitches = null;
void WalkingPitch() {
var speed = walkingScript.Speed;
IsWalking = speed > 0;
if (IsWalking) {
var index = Array.FindIndex(_walkingPitches, e => speed < e.maxSpeed);
if (index == -1) index = _walkingPitches.Length - 1;
audioSource.pitch = _walkingPitches[index].pitch;
if (!audioSource.isPlaying) audioSource.Play();
} else {
audioSource.Stop();
}
}
That's how I'd do it anyway
damn fair play
(also it's technically already a state machine)
benefits of using a struct?
This is what I'd do if it is used for more different entities/more different pitches
Main motivation is just to expose it in the inspector
Won't make a huge difference here, it's just how I store config because it's slightly more efficient to read in a loop.
Due to fewer cache misses
yea totally get ya
You can just have a walking/running pitch as field as well
You could indeed.
True that, although there are ways to have it less coupled.
For sure, each of these solutions is pretty decent but they have different benefits
aye, i just wanted to feel some less run of the mill implementations if u get me
I would probably stick to the if approach and just put the magic numbers into [SerializeField]
pitch and speeds
yea i means its not a good example for getting away from if statemetns per se
i literally just wondered what was gonna be more 'advanced' ahaha
Well that's one. Replacing checks with an array search.
sorry i cudnt provide a decent example tho
i love them
Yes you can, although, it's not great because of coupling your audio to animator, as Navi mentioned.
I think a combo of states and events is good. And I don't mean a solid state machine implementation. If you have a clear separation between states, entry and exit points, I already consider it a state machine. Even if it's just a bool/enum check in Update.
@distant kernel for this one in particular you could have an animation event on the footstep
And play a single walk or run foostep audio on each event
not noticable
I say, don't worry about performance. Get it working first. Then it's just a matter of refactoring.
It just gives you what you want, and that's what matters
Unless it's some kind of systematic bad practice that your whole system relies on.๐
pre emptive optimisation is the root of all evil or something
ahahaha agreed
ok thanks guys i will probably be back
useful as usual
seeyasoon
"premature" is the quote
thats no way to talk about my father
(jokes)
(glad i clarified then)
ah ok
fwiw, you should take the premature optimization argument with a grain of salt. There's plenty of cases where you can over engineer for performance you don't actually need but there are lots of smaller things that you'll learn about, that are more performant and you'll start to tend to use those more
A better quote is: Don't compromise readability for performance unless absolutely necessary
I like Scott Meyers' extension: Don't prematurely optimise, but don't prematurely pessimise either.
Which I guess means use the most efficient solution that's maintainable.
But all this stuff really comes down to your understanding of Unity/C# and habits.
I guess an example from how I work: always use an array unless you know you need a resizable collection.
Being strict about YAGNI helps as well
no one likes code that reads like ancient egyptian
as in, if u can read it now thats well and fine but if u gave it 4000 years and tried to read the same code that even u wrote urself, it will probably be a struggle (lol)
bytecode is fun tho
Having trouble integrating Facebook SDK 11.0.0 in Unity 2020.3.20: getting the error in the picture.
The logs look like this:
Job failed with exception: GooglePlayServices.JavaUtilities+ToolNotFoundException: jar not found, C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.EXE references incomplete Java distribution.
at GooglePlayServices.PlayServicesResolver.ExtractZip (System.String zipFile, System.Collections.Generic.IEnumerable`1[T] extractFilenames, System.String outputDirectory, System.Boolean update) [0x00130] in /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:2437
...
@regal olive Sounds like Java is not properly installed?
do you indeed have java there?
Everything is installed well, and I even tried setting JAVA_HOME to the JDK installed with Unity, with no effect.
Restarted and everything of course.
This SDK's PlayServices part doesn't seem to play with the Unity-supplied JDK.
Oh that path it's coming up with doesn't have Java of course. Should there be a Java there for the sake of it?
@kindred tusk?
Tried getting a Java exe there, to no avail.
Where is Java installed?
No, you need to set JAVA_HOME to your install location
The Java installer should do this
You'll need to restart unity to get the updated environment variables though
After you change it
Alright, I'll try setting JAVA_HOME manually and come back.
They are only set at the start of a process
Do I need to reboot my PC?
Still getting the problem without rebooting my PC, after restarting Unity.
Rebooting my PC.
I don't really know where the env vars come from when you boot unity. It's possible that you need to restart untiy hub
You can test that it's set by running cmd.exe and entering echo %JAVA_HOME%
Same error appears, no change.
do this
As I said, I've tried setting JAVA_HOME to even the path to the JDK given by Unity, but that didn't work.
do this
Yes, I set it myself just 2 minutes ago
oh... so the path is correct?
Yes.
What's in the folder?
It doesn't matter wwhat JAVA_HOME is, that error always shows this path.
Ah, that might be important
I didn't use any installers for this though.
I put the exe there, yes
But I need JDK not JRE
java is just ๐คฆโโ๏ธ
...which is why I said I'll return with some brain
the exe likely expects to have files
You're meant to change JAVA_HOME to point to your install directory
Even if that's the case, it should have worked perfectly for the Unity installation location, but it didn't earlier.
But you also said that it showed the same path?
So it was looking in the wrong place then too
Still not working
show the error?
this is the same path
And echo the path?
in cmd
(new cmd session)
or powershell whatever
Do I need to be exact about where java.exe should be, because it's in java-se-.../bin right now
Job failed with exception: GooglePlayServices.JavaUtilities+ToolNotFoundException: jar not found, C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.EXE references incomplete Java distribution.
at GooglePlayServices.PlayServicesResolver.ExtractZip (System.String zipFile, System.Collections.Generic.IEnumerable`1[T] extractFilenames, System.String outputDirectory, System.Boolean update) [0x00130] in /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/PlayServicesResolver.cs:2437
at Google.GradleWrapper.Extract (Google.Logger logger) [0x00000] in /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/GradleWrapper.cs:100
at GooglePlayServices.GradleResolver.GradleResolution (System.String destinationDirectory, System.String androidSdkPath, System.Boolean logErrorOnMissingArtifacts, System.Boolean closeWindowOnCompletion, System.Action`1[T] resolutionComplete) [0x0009f] in /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/GradleResolver.cs:267
at GooglePlayServices.GradleResolver.DoResolutionUnsafe (System.String destinationDirectory, System.Boolean closeWindowOnCompletion, System.Action resolutionComplete) [0x000bc] in /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/GradleResolver.cs:820
at GooglePlayServices.GradleResolver+<DoResolution>c__AnonStorey13.<>m__1D () [0x00000] in /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/GradleResolver.cs:710
at Google.RunOnMainThread.ExecuteNext () [0x0003d] in /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:377
UnityEngine.Debug:LogError (object)
Google.RunOnMainThread:ExecuteNext () (at /Users/smiles/dev/src/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:379)
...
GooglePlayServices isn't working and I think it might cost me my job ๐
(Heads up, I removed images with the error box since it contained copyright material in them, providing this instead)
I'm afraid that might simply be the case, yikes. I'll have to find out how to change that in the code.
If I can that is.
I don't know, when you showed me before it wasn't changed
Should I change it to Unity's directory for demo?
I mean, I have seen no evidence that it's been changed
Have you installed JDK?
Yes
where is it installed?
Refer here
in JAVA_HOME, check the dir structure
is it valid?
should I make it look at bin?
No, it should point to the install folder
Could you explain it for my benefit? I didn't get you.
Hm, I'm looking at my install
Ah, okay
I don't know much about this, it's more of a #๐ฑโmobile question
But I do know about env vars
This is what my install looks like
Are those JREs?
I also have this
Makes sense
I've followed that.
This suggests that JAVA_HOME would be set to C:\Program Files\Java\jdk1.8.0_65
Could you entertain me by echoing the JAVA_HOME then?
And showing me that it's updated
Welp it doesn't matter I think
anyhow atm I have shoehorned the JDK in the Common Files directory like so: (this is JAVA_HOME)
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java-se-8u41-ri\bin
@kindred tusk you there?
Tried the Atlassian reference by shortening the path name, didn't work.
yo
@regal olive yeah I'm waiting for this
Yes
this keeps showing up
@kindred tusk any suggestions?
No idea. It should read the new variable once you restart unity and hub
Which it doesn't unfortunately
facebook sdk 11 works fine with the unity provided JDK in my project
Also, unity is very picky about JDK. I was trying to provide custom installation path myself at some point and never managed to get it working.
So you should go back to unity's JDK and look into the facebook sdk issue - it must be unrelated to jdk
I see, can't be sure exactly.
which Unity version?
2019.4.29f
Is it safe to downgrade my project, though...
What version are you using?
What do you guys use for AI? Custom state machines, some behaviour tree framework or Bolt?
Depends on the complexity of the ai that I need
I guess if you make a FSM with it you can see what state it's in easily.
Don't mind me plugging UE4 here but the primary reason I love AI is its visual Behaviour Tree editor. Having something like that in Unity will do wonders.
Yep, that's indeed the case.
is there any way to stop player's y velocity when touching wall without messing with gravityScale
void FixedUpdate() {
if (isTouchingWall) {
var v = rigidbody.velocity;
v.y = 0;
rigidbody.velocity = v;
}
}
But gravityScale seems like a better solution
wait...
Just disable gravity on the rigidbody
got it, thanks
Unity has started the work on their own AI solution, but I believe that has been postponed until new navigation stuff comes out.
Well, a chance towards good stuff. Is it GOAP or BT?
I believe it's neither, but something beyond. It's called AI Planner
It is close to GOAP in terms of being a Planner too if I got it right. Was a long time since I looked at it last. Shame it didn't get updated since then...๐ข
Exciting!
Yea I would say closer to GOAP than BT
There are bunch of talks about it back from the Unity hype days
Okay, so I was looking into the DLSS functions exposed by UnityEngine.NVIDIA - however even after declaring a using with this module no functions are exposed - I can't call NVIDIA.Plugins.LoadPlugin or create a graphics device.
Using Unity 2021.2, documentation about this module is here :
https://docs.unity3d.com/2021.2/Documentation/ScriptReference/UnityEngine.NVIDIAModule.html
Results in this error :
With this empty function call
The docs you shared describe UnityEngine.NVIDIAModule
You're including a different namespace
https://docs.unity3d.com/2021.2/Documentation/ScriptReference/NVIDIA.GraphicsDevice.CreateGraphicsDevice.html Take a look at the other page in the nvidia category as well
They reference UnityEngine.NVIDIA
UnityEngine.NVIDIAModule is also not valid
While UnityEngine.NVIDIA is found
Bizarre.
Yes exactly, I thought so too !
I have of course attempted all the usual, create an empty project, restart Unity etc.
Maybe they forgot to compile it in your build? Haha
If you have another version of unity installed you could try it out
I don't know ! I am using 2021.2.0b 15.3666
Oh a beta?
This is the only version of 2021.2 I have access to. This is quite recent functionality
Yes, its only available in 2021.2 and up
Check the documentation
Right.
So any idea what is going on here ? This is also the only available 2021.2 build.
I could only attempt to go to 2022
But I more than highly doubt that would improve things
No I'm not sure what it could be. If you have rider you can look inside the DLL I believe
I wonder if you can get the class via reflection?
Not that that sounds desirable
I dunno, really can't help you. I'd probably ask on the forums
Same, but I don't think it would get much attention
Since this is a rather obscure class and seems more like an interface for Unity themselves to implement DLSS into HDRP
Update : The EXACT SAME PROBLEM persists.
WAIT
Its a module in the package manager that wasn't enabled.
Could have said that in the documentation...
Seems that out of all the built-in packages this is the only one not enabled.
Heyo, I am not sure if this is a question that can be answered in a brief discord message (giving me an online source would be fine too if so,) but I am a programmer that has quite a bit of experience working with C# using .NET and other frameworks for various types of software that is looking to study the Unity engine, and I have heard numerous times in the past that there are some notable differences between how standard C# is written for normal applications vs how C# scripts are written in Unity for game development. I was wondering if anybody could tell me (or link me a source) of some of the most important differences and best practices that i should know about
I want to have scriptable objects where you can change the settings but also have it so that I can instantiate these into the game and have it act like a normal object just copy all the values from the scriptable object when I create it
is this possible?
I honestly don't find that many differences (though I have heard what you have too), however I also started by learning Unity so take that as you will.
It is hard to say specifics without knowing what you already know (for example do you already know about GameObjects and components?).
If you are experienced with C# already then I don't imagine that it will be hard for you to figure it out.
You can use Instantiate with scriptable objects to create copies of them at runtime ๐
so Object.Instantiate works fine?
yes
cracking
Sure does, it works with most everything that inherits from UnityEngine.Object
Not just gameobjects
alright
I was a little worried since it was a scriptable object it would curse me later on
one time I made a potion effect scriptable object and the timer started ticking down in the editor ๐
that was mostly me not making a copy
Maybe a component would be better suited if you want to created instances of it at runtime though. You lose most of the benefits of it being a ScriptableObject.
I lose all of the benefits of it being a scriptable object
im making a text adventure engine for a client who doesn't really code so I want it to be easy for them to create everything
there probably is a source for that if you dig for it, i remember reading about that topic.
a few differences are from the top of my head are:
theres a lot of different ways to get references to other objects in unity that isn't normal in c#
not sure if im right 100% but the compiler lets you for example leave empty arrays because it belives that you will populate them by referencing them in the inspector, or by injecting them later, etc
theres "magic" event functions for each object that really change the workflow for unity, like start, update, OnEnable, OnDisable etc
theres a lot of things that dont really match up between normal SOLID C# workflows and unity. for example hard to use interfaces and non serializable classes in the inspector, needing to be mindful using MonoBehaviour derived scripts(components on a gameobject have to inherit MonoBehaviour ) and normal C# scripts in the same project and knowing whens it better to use which
theres probably more
someone will probably bash me for saying something wrong here
my best advice is when you look up how to do something always add "unity" to the end cuz theres alot of much easier ways to do it than just with standard C#
even stuff you know how to do
ye
but also it IS still normal C#. Nothing different there. Just a big library API attached to a game engine
^
basically the api is super integrated in the engine, its not like a slap on pre-existing project api. so everything will be a tiny bit different
Thanks for the responses fellas
I find the differences are mostly in that code for games (soft-realtime apps) is much more performance/smoothness oriented and, for example, tries to avoid memory allocations unless necessary, where in regular c# you'd almost never worry about it. Also multi-threading works differently in subtle and not so subtle ways that might trip you up. Some patterns from enterprise software dev are problematic or outright wrong (depends on who you ask and your context) and since unity as an engine is very data oriented and compositional from the start you may end up fighting with the engine if you want to use interfaces and inheritance exactly like you are used to. So in general: don't make any assumptions that what you know from "regular" software development and in particular web-dev is "correct" in game dev or w/ unity... someone will probably point out to you that some of what you do is wrong... although they may also be wrong... so cross-check their and your own arguments carefully, i guess. Nevertheless, most of the differences only come into play if you have tight performance/platform constraints, multi-person teams and 6+ month projects or actually want to distribute something commercially to end-users.
Hmmmm i see, that's pretty informative thanks
One thing Iโve heard from C# devs moving to Unity is that async and await have unexpected issues. If youโre used to using that feature, it might be a good idea to research what those issues are (unfortunately I donโt have any articles on hand).
I'm building out a custom editor, and have run into an issue with EditorGUI.MaskField -- mostly in that it has trouble with the 'Water' layer, apparently? Has anyone ran into this?
You might want to ask in #โ๏ธโeditor-extensions
Danke.
Oh lol. What a pain. So what were you importing? Same namespace from a different assembly?
Is it possible to stackalloc a space of stack for an AnimationLegacy Curve, so as to be able to rapidly spit out an evaluation of the curve for its entire length at a resolution of (for example) 1000 samples of its timeline?
when using GUILayoutOptions is there any way to introspect the values of a collection of these passed into you without resorting to publicizing Unity? I want to find out say a GUILayout.Width has been passed in and pull out its value
Try in #โ๏ธโeditor-extensions
thank you
What is this for?
I'm not sure about the curve in legacy animation, but AnimationCurve itself is really fast. I read somewhere that it's (potentially?) faster than Mathf.Lerp
Whether legacy animation's curve and AnimationCurve is the same perf wise, i'm not sure
Guys I need help For some reason my player doesnt move when jumping please help
character locomotion script:
basic locomotion state script:
Are you sure it should be in #archived-code-advanced?
Also check #854851968446365696 for how to share code.
At least check #854851968446365696 and share your code properly.
I'll have a look if I have time.
Guys I need help For some reason my player doesnt move when jumping please help
Character Locomotion script : https://pastebin.pl/view/3a31ff9c
Basic Locomotion State script : https://pastebin.pl/view/837694a8
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
Did you write it yourself?
yes
Yes I did
it should work because the directional movement is independent of what movement state the player is in.... but for some reason its not
Can anyone advise how to change target architecture in a way that modifies the project?
I've changed it in the build settings dropdown but I don't see any staged changes
Okay. Add a debug in your UpdateLocomotion debugging the value you pass into the controller.Move.
Architecture or platform?
Already did. The Values i recieve are not 0s and are actual input values
Since it's just an editor state
Perhaps architecutre is alsonot?
I guess it's not
I can send screenshot if necessary
What are you changing it from (and to)?
Well that's a good question. I have no idea what it's using by default. I guess whatever I've set locally which is Intel 64 + Apple Silicon
but I'm trying to change it to Intel 64
The API just accepts an integer https://docs.unity3d.com/ScriptReference/PlayerSettings.SetArchitecture.html
Am I to assume that the integers correspond to the dropdown indices?
Sets an integer value associated with the architecture of a BuildTargetPlatformGroup. 0 - None, 1 - ARM64, 2 - Universal.
wtf is None?
Can you just debug the MovementVelocity * Time.deltaTime instead?
That's indeed not versioned, but the one in PlayerSettings is
Well I'm not seeing any file changes when I change it, even after build + save project
In BuildSettings or PlayerSettings?
I can't seee that option
@flint sage where are you seeing that one?
I can't see it in the player settings
I Debuged the jump movement values * deltatime compared to normal movement values * deltatime and they seem the same
What values do you get?
stuff like 0.005867. However an interesting thing I noted is when I dont set the isJumping boolean to true(and dont play the jump animation) it works perfectly fine.
โ
Okay.
Can you record a video with what happens when you jump and the console debugs visible?
This one is from ios, it's under Other Settings
I'm building for macOS
Doesn't seem to have the option
Weird, I guess then it's only a build setting
Oh no, apparently it's not even a setting you can call at all!
wtf is going on here
GetArchitecture only accepts BuiltTargetGroup which lumps windows, mac and linux together.
And has a single "architecture" integer
okay, found a solution.
#if UNITY_EDITOR && UNITY_STANDALONE_OSX
UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64;
#endif
jesus
What components do you have on your character?
CharacterController
Only CC?
Yes, you're absolutely right, AnimationCurve, and evaluating it in particular, are incredibly fast. Not just in terms of their evaluation of the curve, but also in terms of a much more direct connection to the Transform, permitting much master/lighter movement of many things.
Also CapsuleCollider and CharacterLocomotion
Excluding default unity stuff like transform, etc
You don't need the capsule collider. CC is a capsule collider in itself.
oh LOL
I'm not sure if that's the source of the issue, but remove it.
Thanks didnt know that
Part of the reason for this speed is that it somewhat caches the keyframes nearest the last look in (evaluation) and some because of a much more direct connection to Transforms (and a few other properties of Unity). However, I need it to be even faster, for doing a bunch of evaluations in a small time, to create a resized Lookup Table as fast as possible. Hence trying to use stackalloc, to get the most streamlined possible use of the evaluate function, in conjunction with a register friendly allocation of the curve and the destination array for the LUT.
It wasnt the source :C ima take a break for the night
I'm not sure then. That controller looks too convoluted if you ask me. Hard to debug.
Hmm i probably never done what u're trying to do (if i understand it correctly), but for storing a lot of values in my experience i stored it in a texture (this is for Vfx purpose). Mostly position/dir data
Maybe if u explain what u're trying to do, the context is more clear
Create a the LUT (texture or array) as fast as possible, based on a curve and a number of samples of that curve (usually about 1000 to 20000 samples, as a DSP envelope for filtering sound
And disclaimer, i've never used stackalloc
Argh, ok. Stackalloc is like Temp nativeArrays, but even faster.
And you can Fix, in position, an object and the calling site for its function, such that it's very close to the top of the stack, as you iterate over and array, which is popping on and off the stack the the results into another stackalloced array. This is about the fastest way to create anything.
Yeah never used it, sorry
Altho for filtering sound i process it realtime with resolution (1024?) and pretty happy with that
Maybe someone else can take over then..
But I'm having trouble figuring out how to do this with an Object (which is what an AnimationCurve is), rather than what I normally use, which are structs.
Seems like you can't use it for reference types:
https://stackoverflow.com/questions/35598078/why-stackalloc-cannot-be-used-with-reference-types
Cheers! That would certainly explain the problems I'm having "fixing" it to the stack. DOH!
Do you think it'd be worth trying to make a struct wrapper that holds the AnimationCurve, so it can be passed by value, and thereby popped onto the stack?
I don't think that it's gonna be different from just referencing the required curve. In fact it might be even slower.
DOH DOH DOH. That's part of my fear, too. I'll probably have to write my own way of making curves rather than use the bloody beautiful and convenient animationCurve
What's the problem with unity curves though?
I need more speed. Making a LUT, for speed, and the speed of making the LUT is a bit too slow.
I know I can do rough envelope shapes with 1 - x * x * x * x etc, but that's nowhere near as controllable in terms of curve shapes as animation curves.
for x = 1 to 0 by step -1/10000 ; y = 1 - x * x * x perhaps a more sensible way to show example
Why do you need so many samples? Does your curve really have so much detail? If not you could sample at smaller frequency and lerp between 2 values if you need an in-between value.
the LUT needs to have every value to avoid needing to do any calculations. It's a "whole of range" LUT, for speed purposes.
Audio Signal processing, needs to 1024 * channels, and there's much processing going on to the signal, this is just one of them, an envelope to shape volume, being drawn to the LUT, from a curve, that's editable.
I've close to 0 knowledge on audio processing, so I'm afraid I can't help you there...๐คทโโ๏ธ
Donno if you've seen this pose, but they discuss sampling an animation curve from jobs. Maybe that could be useful to you.
https://forum.unity.com/threads/need-way-to-evaluate-animationcurve-in-the-job.532149/
Cheers. It's just like any other processing of anything, except you have to do LOTS of them, each frame, whereas normal animation just needs to project/place one position in a frame, you've gotta do 1024 of them in each frame of audio.
yes, got some info from there. Their goals are a little different.
That's where i learnt about the inherent speed of AnimationCurve being not just in its access rights to Unity Transforms, but also in its caching of the keyframe
What kinda audio processing do u need? I used 20k/1024 and its fine for all my needs, including pitch detection
Now if its multi channel that ure looking for, its also on my roadmap for my audio project.. that would explain the need for speed
Would storing animator.stringtohash() cause any problems? Like in a ScriptableObject.
It'd be run inside SO's OnEnable.
In what way/context? It returns the CRC32 checksum of the string,which can be calculated deterministically from the string input and has negligible chance of collision.
Is it normal that my first scene is activated while the built-in splashscreen is still on?
I don't remind this behavior ever :S
Yes, the splashscreen shows after the first scene is loaded. Afaik it was always like that.
Or maybe at the same time with the loading. So if it's quick enough, it'll be loaded before the splash screen is closed.
Hey guys Im looking for tutorials for a simple
3D archer AI, so that my AI archers hit a target
I'm using scriptables to represent animator strings along with some other data. I figured it might be worth storing the hash itself too.
Since it's determinisitic, it wouldn't change as long as the string itself doesn't change. So I guess there shouldn't be a problem;
I was importing the assembly, but the module wasnโt loaded so the assembly was just empty
Interesting. I don't know enough about how these things work.
This particular interest in curves is for ADSR envelopes to operate on raw signals of sound
AttackDecaySustainRelease is an "envelope" that crafts/shapes an underlying property of an audio signal over the time it's played. Most commonly this is volume and filtering values, but can also be any other aspect of an audio signal, and be a low frequency oscillator in and of itself, when looping. Known as an LFO.
wouldn't it be better (for optimization) if you make a super efficient ADSR evaluator, instead of using unity's more generic bezier evaluator?
I'm quite sure it would be, but first need to design the curves, which is best done with access to the curve editor.
And, if I can get the evaluation of the curves fast enough, there might be situations where I don't render down to an ADSR evaluator, and instead stay at the curve level, so I can animate the curves in real time, for "wave shaping" of the ADSR envelopes.
you could also animate the 4 ADSR floats
and previs the curve via AnimationCurve without evaluating it all the time
Yes, of course you're right, but in order to know what to animate, and what the curves should be like, I need to use a curve editor. You can't take photos without a camera.
I'm not evaluating the curves all the time, I'm building LUT's of them. that's what this request is all about. I "render" the curves to LUTs so I can do other things with the processing power that's saved by using the LUTs
Audio has a very distinct set of limitations, which require that everything be done as fast as possible, if you want to do more with it, and LUTs are about as fast as it can get, especially if they can be cached onto the top of the stacks feeding the registers.
The current issue is that I'd like to render those LUT's about twice of 3x faster, which should be possible if I can get the curves up onto the stack somehow.
Hello. Is there some good way to animate a 2d ragdoll? We have animated object and then somehow the parameters are copied from it on the ragdoll.
But the problem appears when there is rotation over 180 degree happens.
The part of the body seems like make a rotation to jump with 360 degree when rotation goes over +-180 degree.
Here in the video it is good visible on hairs of ragdolls. On the win screen look at hairs(hands also have the same problem, but not as noticeable):
I wonder if the problem lies in here: "somehow the parameters are copied from it on the ragdoll"
Like if you're doing a MoveTowards instead of MoveTowardsAngle
Gotta ask the coder
If you're not a coder you're in the wrong channel.
But I ask this for my coder
Why doesn't your coder ask?
Having to go through a middleman makes things a lot more complicated
I don't know. Coders are weird people. Giving me headache. But if I want something like that to be done it's most of time I go ask people. Coders are usually like - oh well, that's not possible to make, lets just not make it.
time to fire that guy
Thanks. But I am a poor guy at the moment XD. I just suggested a revenue share.
this isn't the right channel for business advice, but revenue share is not something most coders will be interested in unless the revenue is somewhat guaranteed and would exceed a regular rate at reasonable risk.
Exactly!
Anyway, do you know some legit way to animate a 2d ragdoll? So the rotations not make the weird behavior? Also it seems it's the fixedJoint which doesn't like the over 180+- rotation. Hinge joint seems fine with that.
sorry, don't know much about ragdolls other than that they are supposed to animate themselves ?!? But really, don't ask me about ragdolls ๐
maybe #๐โanimation ?
Yes. That's basically what happens in the game. I animate only the "body" object. And the body parts are free to hang around. And it does look cool as you can tell from the video I attached.
There is enormous truth here! Tell him to attach the hair ragdoll in the local space of the character. This should fix it.
It might also make the hair ragdoll unaware of movement, and really FIX it in place. This will require adding input to the ragdoll to make it flick around appropriate to the model's movements. Coder probably thinks it looks good enough and doesn't care.
Thanks! Will try that out!
Hey guy how can I get the global rotation between two vec3?
currently it seem Im only getting local results
ill try ask it here because its depends on code. Im profiling app and see this nightmare but im confused about profiler.CallStack is this because profiler do or my code is guilty?
I started creating a game whit rockets my player can move and that is ok and my rocket is following my player and it get destroyed when touch player but when i put rocket in script for spawning rockets its spawn but whet it get destroyed they stoped spawning and it missing a game object, and when i put it in prefab they spawn but are just spinning around. How do i fix that?
Does it makes sense to use Sprite Atlases for 4k project for PC in order to reduce the total size of the build? Some assets take 200 MB, but have lots of empty spaces because they are just a bit bigger than the previous Po2.
Yeah, it's probably profiler overhead. It can go crazy sometimes, especially with deep profiling. Does it happen without deep profiling as well?
Try this too: https://docs.unity3d.com/Manual/IL2CPP.html
If build size is a concern, then you should be compressing your assets.
I want to share a code base between my c# console server and my c# unity client.
How would i do that ? Any tipps ?
Any help welcome, basically my first time with something like this ^^
a shared .dll maybe.... in many projects a server is just the same unity project running in headless mode, that way you get maximum reuse and consistency without the need to change interfaces/protocols on two ends.
Thanks !
Another question... im trying to add litenetlib to unity.
I downloaded the source, unziped it and placed it under /Plugins
However the namespace is not recognized
I restarted unity and rider... and its still not here...
Any ideas why ?
It happens without deep Profile. Only Call Stacks Enabled
add it to any asmdef that needs to see it, make make sure it doesnโt show version errors (those go away when you clear the console)โฆ disable version checksโฆ make sure unity recompiles the project and isnโt blocked by other/unrelated errors. Make sure you are using the correct script backend and build target
Hello everyone! Can you anyone tell me if there are any good communities/groups of independent unity developers working on their own projects to chat with, exchange tips or assets or just hangout and brainstorm together? I know that I am on the official unity discord, so here are probably the people I am looking for but I think it would be better if I would join a smaller more personal group rather than a mass server like this. I am a really proficient programmer and have a lot of experience outside of game development and would love to connect and network with like minded people. (unity developers). So if anyone has a group or is part of, write me!
if you are so good can you help me with something
@regal olive sure
just a sec
I started creating a game whit rockets my player can move and that is ok and my rocket is following my player and it get destroyed when touch player but when i put rocket in script for spawning rockets its spawn but whet it get destroyed they stoped spawning and it missing a game object, and when i put it in prefab they spawn but are just spinning around. How do i fix that?
i gave you the answer here #๐ผ๏ธโ2d-tools message
i try and its not working
so what have you tried and how is it not working
If your problem isn't solved by that answer, you might need to show us the rocket and spawner scripts
i try instantiate and assing player to each rocket but i have only one
can you show your code?
just a sec
public class HoimingSpawn : MonoBehaviour
{
public GameObject hoiming;
void Start()
{
InvokeRepeating("SpawnObj", 2, 1);
}
Vector2 GetSpawnPoint()
{
float x = Random.Range(-10f, 10f);
float y = Random.Range(-5f, 5f);
return new Vector2(x, y);
}
void SpawnObj()
{
Instantiate(hoiming, GetSpawnPoint(), Quaternion.identity);
}
}
this is spawner
#854851968446365696 for how to send code properly
Ok, doesn't look like the source of your problem, can u show the rocket as well?
Is hoiming a prefab or scene object? You should eventually rename that anyways xd
it doesn't look like you're passing anything to the rocket when it's instantiated
i think it's the same script you showed earlier
yes i try changin but its the same
perbab
prefab
How are u destroying the rockets and how do u do their movement?
wrap your code in three backticks before and after (`)
[RequireComponent(typeof(Rigidbody2D))]
public class follow : MonoBehaviour
{
Rigidbody2D rb;
public Transform target;
public float speed = 5f;
public float rotateSpeed = 200f;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
Vector2 direction = (Vector2)target.position - rb.position;
direction.Normalize();
float rotateAmount = Vector3.Cross(direction, transform.up).z;
rb.angularVelocity = -rotateAmount * rotateSpeed;
rb.velocity = transform.up * speed;
}
void OnTriggerEnter2D()
{
Destroy(gameObject);
}
}
that rocket movement
If that's a prefab, how do u set target?
You referenced the player prefab in the rocket prefab as a target?
yes
That might not work as expected, your instances of the rocket should rather have a reference to your instance of the player, not the prefabs
At least in your situation
But that's not your issue I think
#archived-code-general may be a better place for this problem than #archived-code-advanced.
Or maybe #๐ปโcode-beginner.
my issue whit that is they are spawning but not following the player just spinning around the middle until they colab and then get destroyed
#โ๏ธโphysics or #๐ปโcode-beginner this is definitely not a #archived-code-advanced problem though.
you've already been given the answer to your problem.
#๐ผ๏ธโ2d-tools message
ok
also maybe read #854851968446365696 so you can understand how to properly share code (no idea how the bot didn't catch it and delete your unformatted code)
What's my best options for compressing textures so they are usable in Unity ? I have like a good amount of models that I want to instatniate on an Android Device and the .png textures of them are like 8mb each, which adds up so fast. Compressing the objs with draco for example was not a problem but what about textures ?
8mb.....
are they 4k or something?
@toxic ore I am certain that unity lets you change the resolution of the textures in-engine
I mean I'm not sure if this is the right place to ask. Here's the error I'm getting.
public async UniTaskVoid OnSearchEnter()
{
JikanGenericResultAndCoverArts genericResultAndCoverArts = await jikanClient.GetGenericResult(searchBar.text);
SetupContent(genericResultAndCoverArts);
}
public async UniTask<JikanGenericResultAndCoverArts> GetGenericResult(string searchKey)
{
UnityWebRequest uwr1 = UnityWebRequest.Get(genericURL + searchKey);
await uwr1.SendWebRequest().ToUniTask(progress: this);
if (uwr1.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(uwr1.error);
return null;
}
else
{
JikanGenericResultAndCoverArts jikanGenericResultAndCoverArts = new JikanGenericResultAndCoverArts();
string jsonResponse = uwr1.downloadHandler.text;
jikanGenericResultAndCoverArts.genericResult = JsonConvert.DeserializeObject<JikanGenericResult>(jsonResponse);
for (int i = 0; i < jikanGenericResultAndCoverArts.genericResult.results.Count; i++)
{
UnityWebRequest uwr2 = UnityWebRequestTexture.GetTexture(jikanGenericResultAndCoverArts.genericResult.results[i].image_url);
await uwr2.SendWebRequest().ToUniTask(progress: this);
if (uwr2.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(uwr2.error);
}
else
{
Texture2D texture = DownloadHandlerTexture.GetContent(uwr2);
jikanGenericResultAndCoverArts.coverArts.Add(texture);
}
}
return jikanGenericResultAndCoverArts;
}
}
its something silly like having to wrap something in a different/explicit delegate because the type inference doesn't work.
Tried looking though https://github.com/Cysharp/UniTask
But I'll try different things
not very helpful that repo is
Yeah, couldn't find a single UniTask being called example
Or you mean the framework itself?
no, the documentation of the repo is very basic
i.e. its fine if you understand exactly what the library tries to do... but otherwise its a bunch of what?!
i find Rider hints help to find the actual issue rather quickly in such cases
Rider's hints?
static code analysis in JetBrains Rider... tells me which types are incompatible while typing
Does anybody know the performance difference between sending an array of
struct
{
float
float
}```
To a computer buffer vs sending 2 float arrays to 2 separate buffers? (RWStructuredBuffer)
also - not that I'm likely to hit it but is there a limit to the number of RWStructuredBuffers you can have in a compute shader?
I think a struct array is probably gonna be faster, since it will avoid some overhead.๐ค
And I don't think that you have a limit on structured buffers. You might get limited by the memory though.๐ค
there is a limit to the number of buffers on certain platforms
aye - from reading hardware seems to vary between 31 and.... n
Yeah exactly
So I think that's not a per shader limit but an overall limit for your game
Very good point! Guess I'll refactor my code to work with structs ๐
Posting this here as a continuation as it's so niche I don't think it suits the shaders tab:
Is it possible to extract a buffer of members from a buffer of structs?
A RWStructuredBuffer is just a pointer with a stride? Can I pass an offset too? I'm not particularly familiar with how to manipulate a RWStructuredBuffer in hlsl
Curious, what kind of overhead would an array of structs of two floats solve as opposed to two arrays of floats? Shouldn't it be actually the same or maybe better for the two float arrays?
Wouldn't there be an overhead for moving the array into the gpu? If it's one, it would allocate space for it once and acquire pointer and stuff once. If it's 2 arrays it'll have to allocate space twice separately for each array and also upload the same amount of data.๐ค
I'm by no means an expert, just assuming.
Oh, you meant better from the array standpoint, makes sense. Assumed from your initial statement that you were mentioning structs being faster than floats :P
just have this problem
im using like 3 arrays of positions
because i use a shader, and a compute one
maybe i should make a struct with 2 positions?
do you have separate compute buffers for compute and regular shader?
one compute shaders moves the spheres, then the shader uses that spheres positions and then a vertex position
to do the coloring
like this
So assuming my assumption is correct, putting it all in 1 array would be better. Although how much better is a different question. It might be a negligible difference.
in the compute
Depends on the amount of data, probably...
#archived-shaders might know more
And you can always try it out and profile
oh the memory allocation its very big
its at the top
probably i should do something with the colors
but do you have any ideas of how i could clear or dispose a buffer in the normal code
without it affecting the buffer in gpu
I'm pretty sure "dispose" releases the memory in the gpu
That's the whole point of dispose
is there a way to dispose in the cpu?
You don't need to. It's the job of the garbage collector. I think there's only the ComputBuffer object that holds the pointer to the gpu memory or something like that. Basically, there's nothing to dispose of.
maybe i shouldn't worry about it
theres a high change i wont use compute buffers
btw
how cost is to iterate through 10000 or less variables?
is to know if i could do a for loop that moves it in the cpu
rather than the gpu
could be problematic tho
It depends
probably quite costly. Could do it in jobs too.
What do you do in the loop
iterate through the array of positions
and change the values
too much complication
Just do it on the cpu first and profile
ComputeShaders are probably more complicated
if you're not satisfied you can think of a different solution
well its because im doing gravity, and making a new algorithm in the cpu to not do a for loop in the gpu
Doing it async in a coroutine could probably be the easiest solution, although it might not result in a smooth movement, if that's what you're aiming for.
You don't do a for loop on the gpu
your right
its amazingly expensive
ngl works fine unless you use 3,000 positions
yes
Okay
You probably did somethign stupid
Because I've done a similar thing and that was fine until like 10 million objects
the shader does (n^2)-n calculations each frame
jfc
so i guess its normal for it to be cost
alone without looping its good
does it iterate all of the points for each of the point?
Why is there a need to do it?
You can't just leave important info like that out...
hmm
each point
iterates through all other points
Yeah they are 4k. All the importing of said assets happens on runtime
Like they are downloaded from a server and instantiated
That doesn't sound like something that should be done on the gpu imho
well i didn't know that gpu were that bad with loops
good thing i will change to the Barnes hut algorithm, which loops in the cpu
It's not that they're inherently bad with loops. You're just missing the whole point of the gpu: it's basically hundreds/thousands(maybe more) small processors that each executes the shader once.
So, while there're extremely fast to perform a simple calculation on a huge array of data, they're not as fast as the cpu.
I think I've heard of "texture streaming"
is this.... it?
(no it's not oops)
i think i just will keep the movement and make them be attracted by some other stuff
a bit confusing to explain
rather than looping through each other n^2
do n(log n)
its probably better to do the movement on the gpu
so there wont be a massive for loop in an update
Good Day, Im currently in need of assistance in an exercise im doing.
For context, I've been tasked into getting the data of this game into an excel file CSV. For for further context, the game in question is an English Tracing Game that was bought in the app store for the purposes of this exercise.
Here is the code where im specifically worked on. Majority of the functions are explained through the summary.
https://hastepaste.com/view/2a8Jvw
I have established the filename as shown on void start. I have also coded in the means in order to show the CSV file through void update. And I have made the data titles I require for the data, which are the Current List, which means which shapeManager is being used at the time of data writing, the Letter which means which Letter of the alphabet, from my understanding it starts at 1 to onwards, and Stars Collected are the numbers of stars accumulated throughout the game.
The problems Im facing are as follows. As you can see below the established WriteLine im currently making a loop function in order to get the rest of the alphabets, but the code is initially structured in such a way that a clear variable for the forloop function is not present, atleast in my understanding. I tried ShapesManager.Test to see if it works but it's not valid. I tried to create a function for the forloop as seen with the public class Test and TestList, the shapesManagerReferences was initially from the outside. However another problem arises in that there's other scripts outside of this code that is also calling on some of the functions here like the aformentioned shapesManagerReferences, in that when I put it inside the public class they no longer recognize it.
Another thing is that im not suppose to show the accumulated star count but actually the star count for every corresponding letter, which are at max three for each letter.
Im even thinking that this may not be the script Im suppose to work on, so If that is the case, I can show the rest of the other scripts and which are used for which.
Hey, what is the equivalent of Unreal RHI for Unity? is the SRP/URP... basically abstraction layers to communicate between different platforms?
Does anyone have an idea how to efficiently re-generate the navmesh on a voxel terrain (marching cubes) that is changing during the running time?
You'll need to use the navmesh preview package:
https://docs.unity3d.com/Packages/com.unity.ai.navigation@1.0/manual/index.html
is there a way in 2d to take a component, screenshot it, and use that screenshot as a sprite for performance caching?
been searching all over...
Just to showcase, this the code that I did for the WriteCSV for the contents of the CSV, along with the code on how to activate said CSV.
The above Writeline are the headers while the below WriteLine are the contents.
What im currently doing right now is isolate the 3 fields in a public class in order to use said public class for a forloop for the 2nd WriteLine.
i'm not sure what your case is, but when i read/write csv files, i use a library or package, doesn't matter too much as they all work, but this is the most recent one i used
https://joshclose.github.io/CsvHelper/
i used this outside of unity, but it's a nuget package and i don't know why it wouldn't work in unity, so you can give it a shot
it's helpful because in csv there are a lot of edge cases with commas and speech marks etc etc so this just helps to remove the tedious string manipulation
I was simply following this video in exporting Data to CSV.
https://www.youtube.com/watch?v=sU_Y2g1Nidk
Exporting data in Unity to open in Excel as a spreadsheet - writing using CSV format, Super Easy!
Follow me on twitter https://twitter.com/JamesDestined
Follow me on instagram https://www.instagram.com/artbydestined/
Buy my pieces on redbubble http://DestinedArt.redbubble.com
Any comments or questions welcome. Enjoy the video!
Song: TheFatRat...
My case simply extracting data on specifics fields on this script and show it on the CSV.
Ill showcase the CSV file being shown right now, give me a bit.
This is the CSV file currently.
The Current List is which part is currently being checked, on this case, its the UShapesManager, which are the Capital Letters on the top left.
The Letter is suppose to showcase the Letters, which are, from my understanding of the code, is an equivalant to 1 = A, 2, = B, etc.
Stars collected are suppose to showcase the points collected for each letter
Correct, I was checking to see if that is the one, I removed it and changed it to shapes which is the result of the screenshot right now.
Time is suppose to be how long has the game been finished, however im concentrating on these 3 fields first before going to that.
so if you're trying to get a list into one string, you'll need to iterate through the list and add each item to one string
I assuming adding them all into one class? Like this one?
i'm having a hard time trying to understand the issue
What is the object you want to take a screenshot of?
I would admit its difficult to convey what's my issue through text.
you say you've gotten this from the app store, so you haven't written the game, so you need to go through the code and find where the Letter information is stored
then just put that into whatever array or custom class that you'd like and write it as a string
Gotcha, Ill get back to you if I find any other issues.
Btw thanks for the reply, I've been stuck with this exercise for quite a while.
i don't really get the point of the exercise but good luck
This is odd. When changing the shape into GetCurrentShape(), which does as the name says, it removes the field of which current Manager it is of Current List but it shows the current star total in Stars Collected.
I dont follow this, but Ill continue to press on and try something else.
My boss wants to get the data for documentation purposes. Wanting to get it with a push of a button.
i see
if you can contact the programmers who wrote the code they could help point to where everything's at
I could try.
Is it required to put all of the fields into a singular custom class?
In order for the string to work?
no not necessarily
you just need a reference to all the data to format it to a string
making a custom class just helps organise that
I see, my next concern is making a ForLoop method for this string, in order to hopefully show the rest of the data. I believe putting all the stuff in this singular custom class makes it a valid field for the ForLoop, correct?
you'll need an array or list for something like a for loop
And that's my problem I think, with how rigid this code was made I think it may be difficult to create a list or array out of my required fields without atleast breaking either the current code or whatever script outside of it.
here's something
https://stackoverflow.com/questions/8151888/c-sharp-iterate-through-class-properties
although having a look at some of the answers they use reflection
which is slow
Slow for program running?
slow in terms of performance yeah
A concern, but if it's get the job done.
Im currently calling between 3, possibly 4 classes for the fields I require.
Alright @tropic lake , I was able to figure out the possible fields I require.
My next step I believe is creating the ForLoop Method.
are the fields always constant? if they are you can get each one by variable name
yeah so you can use reflection to iterate through the properties, but i've never done that before so i've got no clue
only really pitched in cus i've used csv a number of times
Ill declare the ForLoop for now as a base, Ill get back to it.
Following the example in the link youve sent, im not entirely sure what Im doing wrong here.
foreach is an invalid token, in states that it expects an ',', and properties is expecting an ';'.
I found this one, can I use the Reflection method as the ForLoop?
As seen by the example here
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo property in properties)
{
Console.WriteLine("Name: " + property.Name + ", Value: " + property.GetValue(obj, null));
}```
@tropic lake Im baffled in regards to the foreach loop. I dont understand why it's considered invalid.
I can try to do it the hard way without the Reflection.
add each property to a list and iterate through that?
Probably.
So since these are different Fields in different classes, Ill have to declare them into a property?
you'd want to have a base class or interface that they all inherit, to define functionality like their name, their value as a string etc
Guess since they're different classes, I have no choice but to extract the individual fields into this new class, and rebuild the code from there?
what is is that you need from each class
Whatโs a good way to see when an object has a new child or lost a child while in editor? I have a list of the children and currently Iโm using List<Transform> => get children
is it each one's value as a string
These ones.
The test field for shapesManagerReference is already in place, I just need to get the selectedShapeID and CalculatedCollectedStars().
you can have each class implement an interface such as IDataExtractable that has these properties
then make a list of those classes and since they all implement that interface you can iterate through them and use those properties
So every class I need, an IDataExtractable interface?
have each class you need implement that interface yes
and since it's an interface what those properties are defined as doesn't matter (when you iterate through them)
all that matters is that they exist
I see. So far trying it out the first time, I guess im implementing it wrong.
Im not suppose to add in fields.
Ive declared the interface on all of the classes I need but Im finding difficulty in declaring the actual Interface method. Take for example the property for my ShapeList.
I know for certain my declaration is wrong.
Oh wait the first picture is wrong.
My bad.
having a class Test isn't valid, if you want a property of type Test then do
Test testObject{};
GetCurrentShape needs a return type
this'll happen if the class hasn't implemented all the properties or methods, i know on rider you can autofill that not sure about vs / vs code
The Test testObject{}; didnt work.
sorry i forgot you need get; and set; in the brackets
have you defined a class called Test?
Yeah.
also in an interface you can't define a return or value, you just say that it has a get and or set
seems like it's a nested class, so isn't accessible to the interface
Hmm, its more rigid than I expected.
i suggested an interface because it seemed like you already had classes that might have their inheritance set up
if you want default methods, then you can have a base class instead
I can have multiple children for the base class?
yes multiple children can inherit from the same base class
but a class can not inherit from multiple bases (at least not in c#)
Since I only need the base class for the ForLoop, that's what i'll do.
