#archived-code-advanced

1 messages ยท Page 140 of 1

hallow cove
#

No need for a good anticheat

#

It's a 1 - 6 player coop game

#

Story mode

#

So

#

Yeah

undone coral
#

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);
}
hallow cove
#

I see

#

Thanks!

undone coral
#

do you see what i mean? if it's a unit test, it wouldn't be in the context of a game

hallow cove
#

Ahhh, I see

#

So I still have to manually test then

undone thorn
#

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

undone coral
undone coral
#

scene setup can be a little toxic

undone coral
undone thorn
#

wind up with a game object with dozens of the only instance of a particular script on it
could you elaborate on this?

undone coral
#

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

undone thorn
#

I think I see what you mean

undone coral
#

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

undone thorn
#

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

raw path
undone thorn
#

Well, I would say dividing 7 รท 0 for obvious reasons, but bubbles can only contain positive integers, so.. 7 - 7, then

misty glade
#

@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

undone thorn
#

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

regal olive
#

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.

bleak gorge
#

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? ๐Ÿ™‚

humble onyx
misty glade
regal olive
#

Unfortunately. I am desperately trying to get a very specific job.

misty glade
#

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

cobalt crater
#

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?

undone ferry
#

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

tropic lake
#

text mesh pro ugui is responsible for the text only

#

the button component handles highlighting / being selected

undone ferry
#

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

undone ferry
#

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

tropic lake
undone ferry
#

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

tropic lake
#

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

undone ferry
#

yea i saw that within the button transition stuff

#

might give it a whack

violet bramble
#

How do you get name of next scene without loading it??

cobalt crater
austere jewel
cobalt crater
#

So I guess that confirms that it is an ECS concept then? That's more what I was looking for guidance on

austere jewel
#

The class is in the entities package, so yes

cobalt crater
#

Got it, I wasn't aware of that. Been struggling to find docs. Ah well, bummer.

untold pilot
#

You don't need to worry about breaking Mirror, because Mirror is breaking their API every release.MLAPI is probably a safer option.

shadow seal
#

Uh, no

untold pilot
#

You do not like MLAPI? Or now called, netcode for gameobjects I believe?

shadow seal
#

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

flint sage
#

Don't trust unity to write a networking solution

#

They've failed what? 4 times now

untold pilot
#

In all fairness their current solution is being developed openly.

modest lintel
#

they realized they need help ๐Ÿคฃ

untold pilot
#

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.

shadow seal
#

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?

untold pilot
#

No. I am just stating that I asked a few questions to help me determine which to use and was banned.

modest lintel
#

I doubt that

shadow seal
#

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

untold pilot
#

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.

shadow seal
#

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

frozen imp
untold pilot
#

I did not, and you can post your nonsense elsewhere, this isn't the place.

frozen imp
#

Also know people who had great experience with Mirror and making second project on it, which went viral now.

untold pilot
#

I've made projects in worse things than Mirror, it does not really mean anything.

shadow seal
#

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

untold pilot
#

I'm advising people to not use it because it's in a bad place.

frozen imp
#

!mute 590573457863999493 1h I don't have time to wait here for another tirade to moderate.

thorn flintBOT
#

dynoSuccess firerockstudios#3936 was muted

untold moth
#

Now he's gonna think that we're Mirror agents.๐Ÿ‘€

kindred tusk
#

I kind of wanted to know what's wrong with Mirror

regal olive
#

Guy suggests ending the conversation multiple times, others do not end it, guy gets muted. ๐Ÿ‘

frozen imp
#

Spreading gossip is not a conversation tolerable here. Any kind of off-topic in-fact.

regal olive
#

wasnt aware saying something is in a bad place was gossip, more an opinion. But sure.

frozen imp
#

@regal olive I suggest you read their messages again then before jumping in defending and continuing off-topic discussion yourself.

regal olive
#

sure thing.

left stag
#

hey, is there a way of adding a variable to an inaccessible class?
like extension methods, but with a variable?

flint sage
#

No

left stag
#

I guess I found another solution

#

how can I check at what index a certain value is in an array

frozen imp
#

You mean inaccessible as in another assembly?

left stag
#

I mean like the GameObject class

frozen imp
#

To look into array you need to iterate it

left stag
#

I probably need to add a constraint

#

the question is what constraint..

frozen imp
left stag
#

it heled me, thank you!

#

how can I add comments to methods like this:

thin mesa
#

/// <summary>
/// description goes here
/// </summary>

left stag
#

oh.. it was that simple

#

thanks!

misty glade
#

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?

#

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

modest lintel
#

Sorry, do you want to build locally? Or via something similar to github actions?

misty glade
#

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:

modest lintel
#

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

sage radish
#

But usually you automate builds so that you don't have to run them on the same machine as you develop on

misty glade
#
  • 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

bleak gorge
#

Anybody knows how to implement steamworks with a build, only works inside editor, after build steamworks dont work

modest lintel
#

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

misty glade
#

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)

stone slate
#

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?
regal olive
#

@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?

static marsh
#

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.

static marsh
static marsh
dawn zinc
sly grove
misty glade
kindred tusk
#

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

misty glade
#

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

kindred tusk
#

Not if you have a separate project or a separate machine...

#

Why would I suggest it if it did nothing?

#

Lol

misty glade
#

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

kindred tusk
#

Oh yeah

misty glade
#

(the server isn't unity-based, just a standalone C# app)

kindred tusk
#

So you can just call CLI from unity

misty glade
#

yeah.. I'm assuming there's something in BuildPipeline for that

kindred tusk
#

Nah

#

It's just C#

misty glade
#

UnityEditor.Build ?

#

oh

#

right, derp

kindred tusk
#

If you want to build something with msbuild?

misty glade
#

why would unity reproduce something already done in C# ๐Ÿ™‚

kindred tusk
#

The DLL

#

Building unity is in pipeline

#

But a unity project is not a DLL

misty glade
#

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)

kindred tusk
#

Wait... I'm confused

misty glade
#

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

kindred tusk
#

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

misty glade
#
  1. Build DLL
  2. Copy DLL -> Unity, Server dirs
  3. Copy JSON -> Unity, Server dirs
  4. Build server (c#)
  5. Build unity client(s)
    6+ deploy
kindred tusk
#

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

misty glade
#

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?

kindred tusk
#

Oh... You wouldn't

#

I thought you just told me it wasn't

kindred tusk
misty glade
#

I have a separate project that is [a DLL]

#

sorry, that was unclear

kindred tusk
#

Unity project?

#

No

misty glade
#

no, native DLL

kindred tusk
#

DLL is not a project

misty glade
#

Project 1. Unity clients
Project 2. Shared DLL + JSON files
Project 3. Server

kindred tusk
#

You mean. csproj right?

misty glade
#

yeah, VS project

#

"solution", more accurately, I suppose

kindred tusk
#

Okay well build it

#

Lol

#

Using msbuild

#

You can do that from unity

misty glade
kindred tusk
#

I gtg

misty glade
#

It just hadn't occurred to me to make the unity project "the master" and build the other stuff from there first

#

cheers mate

#

๐Ÿ‘‹

distant kernel
#

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?

gentle topaz
#

instead of adding components, you could always make a prefab that you instantiate to represent the chunk, then just pool the prefab

distant kernel
#

It randomises the selection based on perlin

#

Would that still work fine

gentle topaz
#

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

distant kernel
#

ill look into it and come back if im stuck lol

distant kernel
#

quick question guys

#

how do u get away from having many if statements

kindred tusk
distant kernel
#

(finally someone said it)

#

i've seen some ridonkulous questions in here

#

far from advanced lol

kindred tusk
#

Having many if statements is not necessarily bad, and how you'd refactor it changes case-by-case.

distant kernel
#

i was wondering on waht the advanced engineer method would be

kindred tusk
#

What is the code?

distant kernel
#

therefore it could be classified as advanced for all intents and purposes

#

i have several classes that just have chunks of if statements

kindred tusk
#

I think anything that comes down to "how to write code" is not advanced

distant kernel
#

but when i look at other more advanced code i dont see so many

kindred tusk
#

But just show the code anyway

distant kernel
#

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

kindred tusk
#

okay, and when you share the code I'll have a look

distant kernel
#

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

flint sage
#

Tbh, I'd use events here

distant kernel
#

ahhhh

flint sage
#

E.g. an event when the speed changes and an event when the user starts/stops walking

distant kernel
#

yea defo, i did figure that would be the next implementation

flint sage
#

You can also simplify some of these if statemetns

distant kernel
#

hows the performance of firing events compared to this

#

also can u give me a simple example of simplifying one of those

#

appreciate it

flint sage
#

Yes was just getting to it ๐Ÿ˜›

untold moth
#

I'd use a state machine.๐Ÿค”
Or link that code to animator states.

distant kernel
#

hey again dlich

#

can i access the animator states from my audio manager class im guessing yes ill have a look

flint sage
#
IsWalking = movementScript.Speed > 0;

if(!IsWalking)
  audioSource.Stop();
else if (movementScript.Speed < .51f)
   {// Walking
}
else
{// Running
}
distant kernel
#

oh isee thank u navi

flint sage
#

Which is probably fine for most cases

distant kernel
#

yea thats what i assumed

#

but defo worth looking into

kindred tusk
#

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

distant kernel
#

damn fair play

flint sage
#

(also it's technically already a state machine)

distant kernel
#

benefits of using a struct?

flint sage
kindred tusk
kindred tusk
#

Due to fewer cache misses

distant kernel
#

yea totally get ya

flint sage
distant kernel
#

thank u for indulging my questions guys

#

much appre

kindred tusk
untold moth
flint sage
#

For sure, each of these solutions is pretty decent but they have different benefits

distant kernel
#

aye, i just wanted to feel some less run of the mill implementations if u get me

kindred tusk
#

I would probably stick to the if approach and just put the magic numbers into [SerializeField]

#

pitch and speeds

distant kernel
#

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

kindred tusk
#

Well that's one. Replacing checks with an array search.

distant kernel
#

sorry i cudnt provide a decent example tho

kindred tusk
#

Which comes in via config

#

But yeah, don't be afraid of if statements

distant kernel
#

i love them

untold moth
distant kernel
#

i just didnt wanna be stuck on the ground

#

x)

kindred tusk
#

@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

distant kernel
#

is performance ok for that

#

or not noticeable

kindred tusk
#

not noticable

untold moth
#

I say, don't worry about performance. Get it working first. Then it's just a matter of refactoring.

kindred tusk
#

It just gives you what you want, and that's what matters

untold moth
#

Unless it's some kind of systematic bad practice that your whole system relies on.๐Ÿ˜…

tropic lake
#

pre emptive optimisation is the root of all evil or something

distant kernel
#

ahahaha agreed

#

ok thanks guys i will probably be back

#

useful as usual

#

seeyasoon

kindred tusk
distant kernel
#

(jokes)

kindred tusk
#

I thought you were serious

#

:-P

distant kernel
#

(glad i clarified then)

tropic lake
flint sage
#

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

kindred tusk
#

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

distant kernel
#

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

regal olive
#

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 
  ...
kindred tusk
#

@regal olive Sounds like Java is not properly installed?

#

do you indeed have java there?

regal olive
#

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.

kindred tusk
#

The Java installer should do this

#

You'll need to restart unity to get the updated environment variables though

#

After you change it

regal olive
#

Alright, I'll try setting JAVA_HOME manually and come back.

kindred tusk
#

They are only set at the start of a process

regal olive
#

Do I need to reboot my PC?

regal olive
#

Rebooting my PC.

kindred tusk
#

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

regal olive
#

I rebooted my PC for safety

#

starting unity

kindred tusk
#

You can test that it's set by running cmd.exe and entering echo %JAVA_HOME%

regal olive
#

Same error appears, no change.

regal olive
#

As I said, I've tried setting JAVA_HOME to even the path to the JDK given by Unity, but that didn't work.

kindred tusk
regal olive
kindred tusk
#

is that correct?

#

That's the same one that's showing in the error

regal olive
#

Yes, I set it myself just 2 minutes ago

kindred tusk
#

oh... so the path is correct?

regal olive
#

Yes.

kindred tusk
#

What's in the folder?

regal olive
#

It doesn't matter wwhat JAVA_HOME is, that error always shows this path.

regal olive
kindred tusk
#

But that's what you set it to anyway?

#

well it's meant to point to your JDK

regal olive
#

aaand it's a JRE.

#

Let me return with some brain ๐Ÿ˜‚

kindred tusk
#

Did you put that EXE there?

#

Or is it the actual java install path?

regal olive
#

I didn't use any installers for this though.

#

I put the exe there, yes

#

But I need JDK not JRE

kindred tusk
#

lol

#

WEll yeah...

#

That was silly of you

modest lintel
#

java is just ๐Ÿคฆโ€โ™‚๏ธ

regal olive
#

...which is why I said I'll return with some brain

kindred tusk
#

the exe likely expects to have files

#

You're meant to change JAVA_HOME to point to your install directory

regal olive
#

Even if that's the case, it should have worked perfectly for the Unity installation location, but it didn't earlier.

kindred tusk
#

But you also said that it showed the same path?

#

So it was looking in the wrong place then too

regal olive
#

Still not working

kindred tusk
#

show the error?

#

this is the same path

#

And echo the path?

#

in cmd

#

(new cmd session)

#

or powershell whatever

regal olive
#

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)

regal olive
#

If I can that is.

kindred tusk
#

what?

#

You just need to set JAVA_HOME!!!!

#

hahah

regal olive
#

I did, didn't I?

#

๐Ÿ˜ข

kindred tusk
#

I don't know, when you showed me before it wasn't changed

kindred tusk
#

This is the same wrong path again

regal olive
#

Should I change it to Unity's directory for demo?

kindred tusk
#

I mean, I have seen no evidence that it's been changed

regal olive
#

Remember, I set that JAVA_HOME path myself

#

by manually changing the env variables

kindred tusk
#

Have you installed JDK?

regal olive
#

Yes

kindred tusk
#

where is it installed?

regal olive
#

is it valid?

#

should I make it look at bin?

kindred tusk
#

No, it should point to the install folder

regal olive
#

Could you explain it for my benefit? I didn't get you.

kindred tusk
#

Hm, I'm looking at my install

regal olive
#

Ah, okay

kindred tusk
#

But I do know about env vars

#

This is what my install looks like

regal olive
#

Are those JREs?

kindred tusk
#

I also have this

regal olive
#

Makes sense

kindred tusk
#

I don't have JDK installed

regal olive
#

I've followed that.

kindred tusk
#

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

regal olive
#

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?

regal olive
kindred tusk
#

yo

kindred tusk
regal olive
#

sec

#

changed to Unity's path, still showing error box

kindred tusk
#

Even after restarting Unity?

#

and hub

regal olive
#

Yes

regal olive
#

@kindred tusk any suggestions?

kindred tusk
#

No idea. It should read the new variable once you restart unity and hub

regal olive
#

Which it doesn't unfortunately

untold moth
#

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

regal olive
regal olive
untold moth
#

2019.4.29f

regal olive
#

Is it safe to downgrade my project, though...

untold moth
#

What version are you using?

regal olive
#

2020.3.20f1

#

I'm trying a downgrade just to be sure

#

Downgrades aren't pretty...

runic tendon
#

What do you guys use for AI? Custom state machines, some behaviour tree framework or Bolt?

regal olive
#

You can use Bolt for AI?

#

Nice.

untold moth
#

Depends on the complexity of the ai that I need

runic tendon
regal olive
#

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.

untold moth
#

There are assets implementing behaviour trees

#

No default implementation.

regal olive
#

Yep, that's indeed the case.

kindred tusk
#

Yeah, the BT tools for unity look great

#

I'm going to be checking one out soon

fallen halo
#

is there any way to stop player's y velocity when touching wall without messing with gravityScale

kindred tusk
#

But gravityScale seems like a better solution

#

wait...

#

Just disable gravity on the rigidbody

fallen halo
#

got it, thanks

hushed fable
regal olive
#

Well, a chance towards good stuff. Is it GOAP or BT?

hushed fable
#

I believe it's neither, but something beyond. It's called AI Planner

untold moth
#

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...๐Ÿ˜ข

regal olive
#

Exciting!

hushed fable
#

Yea I would say closer to GOAP than BT

#

There are bunch of talks about it back from the Unity hype days

primal ivy
#

Results in this error :

#

With this empty function call

kindred tusk
#

You're including a different namespace

primal ivy
#

They reference UnityEngine.NVIDIA

#

UnityEngine.NVIDIAModule is also not valid

#

While UnityEngine.NVIDIA is found

kindred tusk
#

Bizarre.

primal ivy
#

Yes exactly, I thought so too !

#

I have of course attempted all the usual, create an empty project, restart Unity etc.

kindred tusk
#

Maybe they forgot to compile it in your build? Haha

#

If you have another version of unity installed you could try it out

primal ivy
#

I don't know ! I am using 2021.2.0b 15.3666

kindred tusk
#

Oh a beta?

primal ivy
#

Yes, its only available in 2021.2 and up

#

Check the documentation

kindred tusk
#

Right.

primal ivy
#

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

kindred tusk
#

No I'm not sure what it could be. If you have rider you can look inside the DLL I believe

primal ivy
#

I can try

#

Ill also try installing 2022

kindred tusk
#

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

primal ivy
#

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

primal ivy
#

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.

hallow moon
#

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

merry notch
#

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?

urban warren
# hallow moon Heyo, I am not sure if this is a question that can be answered in a brief discor...

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.

urban warren
merry notch
#

so Object.Instantiate works fine?

carmine ermine
merry notch
#

cracking

urban warren
#

Not just gameobjects

merry notch
#

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

urban warren
#

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.

merry notch
#

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

carmine ermine
# hallow moon Heyo, I am not sure if this is a question that can be answered in a brief discor...

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

merry notch
#

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

carmine ermine
#

ye

merry notch
#

but also it IS still normal C#. Nothing different there. Just a big library API attached to a game engine

carmine ermine
#

^

#

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

hallow moon
#

Thanks for the responses fellas

compact ingot
# hallow moon 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.

hallow moon
#

Hmmmm i see, that's pretty informative thanks

static marsh
weary river
#

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?

weary river
kindred tusk
ember geyser
#

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?

ebon obsidian
#

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

ebon obsidian
smoky glade
#

Whether legacy animation's curve and AnimationCurve is the same perf wise, i'm not sure

young raft
#

Guys I need help For some reason my player doesnt move when jumping please help

#

character locomotion script:

#

basic locomotion state script:

untold moth
young raft
#

im new to the discord lol

#

i dont know if it is advancced or not...

untold moth
young raft
#

oh okay thanks!

#

if I do would you mind taking a look?

untold moth
#

I'll have a look if I have time.

young raft
#

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

young raft
#

yes

young raft
#

it should work because the directional movement is independent of what movement state the player is in.... but for some reason its not

kindred tusk
#

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

untold moth
kindred tusk
#

architecture

#

Platform is not a setting that would be committed

young raft
kindred tusk
#

Since it's just an editor state

#

Perhaps architecutre is alsonot?

#

I guess it's not

young raft
flint sage
#

What are you changing it from (and to)?

kindred tusk
#

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

#

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?

untold moth
flint sage
#

That's indeed not versioned, but the one in PlayerSettings is

flint sage
#

In BuildSettings or PlayerSettings?

kindred tusk
#

Oh, build settings.

#

I can change in player settings? Nice.

flint sage
kindred tusk
#

I can't seee that option

#

@flint sage where are you seeing that one?

#

I can't see it in the player settings

young raft
young raft
# untold moth 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.

#

โ“

untold moth
flint sage
kindred tusk
#

Doesn't seem to have the option

flint sage
#

Weird, I guess then it's only a build setting

kindred tusk
#

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

untold moth
young raft
untold moth
ember geyser
young raft
young raft
untold moth
#

You don't need the capsule collider. CC is a capsule collider in itself.

untold moth
#

I'm not sure if that's the source of the issue, but remove it.

ember geyser
# smoky glade What is this for? I'm not sure about the curve in legacy animation, but Animatio...

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.

young raft
untold moth
smoky glade
#

Maybe if u explain what u're trying to do, the context is more clear

ember geyser
#

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

smoky glade
#

And disclaimer, i've never used stackalloc

ember geyser
#

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.

smoky glade
#

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..

ember geyser
#

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.

ember geyser
ember geyser
untold moth
ember geyser
untold moth
ember geyser
#

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

untold moth
#

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.

ember geyser
#

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.

untold moth
#

I've close to 0 knowledge on audio processing, so I'm afraid I can't help you there...๐Ÿคทโ€โ™‚๏ธ

ember geyser
ember geyser
#

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

smoky glade
#

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

runic tendon
#

Would storing animator.stringtohash() cause any problems? Like in a ScriptableObject.
It'd be run inside SO's OnEnable.

compact ingot
vivid nimbus
#

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

untold moth
#

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.

zealous abyss
#

Hey guys Im looking for tutorials for a simple
3D archer AI, so that my AI archers hit a target

runic tendon
primal ivy
kindred tusk
ember geyser
#

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.

compact ingot
ember geyser
#

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.

compact ingot
#

you could also animate the 4 ADSR floats

#

and previs the curve via AnimationCurve without evaluating it all the time

ember geyser
#

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.

hardy inlet
#

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):

kindred tusk
#

Like if you're doing a MoveTowards instead of MoveTowardsAngle

hardy inlet
#

Gotta ask the coder

kindred tusk
#

If you're not a coder you're in the wrong channel.

hardy inlet
#

But I ask this for my coder

lavish sail
#

Having to go through a middleman makes things a lot more complicated

hardy inlet
#

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.

hardy inlet
#

Thanks. But I am a poor guy at the moment XD. I just suggested a revenue share.

compact ingot
#

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.

hardy inlet
compact ingot
#

sorry, don't know much about ragdolls other than that they are supposed to animate themselves ?!? But really, don't ask me about ragdolls ๐Ÿ˜‰

hardy inlet
#

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.

ember geyser
#

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.

hardy inlet
#

Thanks! Will try that out!

zealous abyss
#

Hey guy how can I get the global rotation between two vec3?
currently it seem Im only getting local results

shadow wraith
#

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?

regal olive
#

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?

solid laurel
#

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.

untold moth
untold moth
vocal dagger
#

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 ^^

compact ingot
vocal dagger
#

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 ?

shadow wraith
compact ingot
crimson ivy
#

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!

regal olive
crimson ivy
#

@regal olive sure

regal olive
#

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?

tropic lake
regal olive
#

i try and its not working

tropic lake
#

so what have you tried and how is it not working

remote pumice
#

If your problem isn't solved by that answer, you might need to show us the rocket and spawner scripts

regal olive
#

i try instantiate and assing player to each rocket but i have only one

tropic lake
#

can you show your code?

regal olive
#

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

tropic lake
remote pumice
tropic lake
#

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

regal olive
#

yes i try changin but its the same

remote pumice
#

How are u destroying the rockets and how do u do their movement?

regal olive
#

one moment

#

im new so i dont now how to properly send code so sory for that

remote pumice
#

wrap your code in three backticks before and after (`)

regal olive
#

[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

remote pumice
#

If that's a prefab, how do u set target?

regal olive
#

my player are also prefab

#

that how i set

remote pumice
#

You referenced the player prefab in the rocket prefab as a target?

regal olive
#

yes

remote pumice
#

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

urban warren
regal olive
#

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

regal olive
#

ok

thin mesa
#

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)

toxic ore
#

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 ?

dense aspen
#

8mb.....

#

are they 4k or something?

#

@toxic ore I am certain that unity lets you change the resolution of the textures in-engine

void crystal
#

Is anyone familiar with UniTask?

#

I have a question

void crystal
#

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;
    }
}
void crystal
#

I'll try adding that Yield

#

This is confusing ๐Ÿ˜

compact ingot
#

its something silly like having to wrap something in a different/explicit delegate because the type inference doesn't work.

void crystal
#

But I'll try different things

compact ingot
#

not very helpful that repo is

void crystal
#

Yeah, couldn't find a single UniTask being called example

#

Or you mean the framework itself?

compact ingot
#

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?!

void crystal
#

Right

#

Eh I'll figure it out

compact ingot
#

i find Rider hints help to find the actual issue rather quickly in such cases

void crystal
#

Rider's hints?

compact ingot
#

static code analysis in JetBrains Rider... tells me which types are incompatible while typing

compact breach
#

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?

untold moth
#

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.๐Ÿค”

sly grove
compact breach
#

aye - from reading hardware seems to vary between 31 and.... n

sly grove
#

Yeah exactly

#

So I think that's not a per shader limit but an overall limit for your game

compact breach
#

Very good point! Guess I'll refactor my code to work with structs ๐Ÿ˜…

compact breach
#

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

modest lintel
untold moth
#

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.

flint sage
#

I would agree with you, yes

#

It's the whole reason we try to minimize drawcalls

modest lintel
#

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

fresh agate
#

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?

untold moth
fresh agate
#

to do the coloring

#

like this

untold moth
#

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.

fresh agate
#

in the compute

flint sage
untold moth
#

And you can always try it out and profile

fresh agate
#

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

untold moth
#

I'm pretty sure "dispose" releases the memory in the gpu

#

That's the whole point of dispose

fresh agate
untold moth
#

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.

fresh agate
#

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

flint sage
#

It depends

untold moth
flint sage
#

What do you do in the loop

fresh agate
#

and change the values

flint sage
#

Probably cheap

#

But your answer is so generalized that it's impossible to say

fresh agate
untold moth
#

Just do it on the cpu first and profile

flint sage
#

ComputeShaders are probably more complicated

untold moth
#

if you're not satisfied you can think of a different solution

fresh agate
untold moth
#

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.

untold moth
fresh agate
#

i did

untold moth
#

Well, you can, but it's not great

#

performance wise

fresh agate
#

its amazingly expensive

#

ngl works fine unless you use 3,000 positions

untold moth
#

are you doing 3000 cycles in the shader??

#

are you using thread groups and stuff?

fresh agate
untold moth
#

Okay

flint sage
#

You probably did somethign stupid

#

Because I've done a similar thing and that was fine until like 10 million objects

fresh agate
#

the shader does (n^2)-n calculations each frame

flint sage
#

jfc

fresh agate
#

so i guess its normal for it to be cost

fresh agate
untold moth
#

does it iterate all of the points for each of the point?

#

Why is there a need to do it?

flint sage
#

You can't just leave important info like that out...

fresh agate
#

each point

#

iterates through all other points

toxic ore
#

Like they are downloaded from a server and instantiated

untold moth
fresh agate
#

good thing i will change to the Barnes hut algorithm, which loops in the cpu

untold moth
#

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.

dense aspen
#

is this.... it?

#

(no it's not oops)

fresh agate
#

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

fast briar
#

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.

robust swift
#

Hey, what is the equivalent of Unreal RHI for Unity? is the SRP/URP... basically abstraction layers to communicate between different platforms?

glass glade
#

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?

hexed oracle
#

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...

fast briar
#

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.

tropic lake
#

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

fast briar
# tropic lake i'm not sure what your case is, but when i read/write csv files, i use a library...

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...

โ–ถ Play video
#

My case simply extracting data on specifics fields on this script and show it on the CSV.

tropic lake
#

ah ok

#

so what data is being extracted

fast briar
#

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

tropic lake
#

what type is shapeLabel

#

that's what's going for the Letter column right

fast briar
#

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.

tropic lake
#

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

fast briar
tropic lake
#

i'm having a hard time trying to understand the issue

stable spear
fast briar
#

I would admit its difficult to convey what's my issue through text.

tropic lake
#

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

fast briar
#

Btw thanks for the reply, I've been stuck with this exercise for quite a while.

tropic lake
#

i don't really get the point of the exercise but good luck

fast briar
#

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.

fast briar
tropic lake
#

i see

tropic lake
fast briar
#

In order for the string to work?

tropic lake
#

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

fast briar
#

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?

tropic lake
#

you'll need an array or list for something like a for loop

fast briar
tropic lake
#

although having a look at some of the answers they use reflection

#

which is slow

fast briar
tropic lake
#

slow in terms of performance yeah

fast briar
#

A concern, but if it's get the job done.
Im currently calling between 3, possibly 4 classes for the fields I require.

fast briar
#

Alright @tropic lake , I was able to figure out the possible fields I require.
My next step I believe is creating the ForLoop Method.

tropic lake
#

are the fields always constant? if they are you can get each one by variable name

fast briar
#

Checking the code, I dont think they are.

#

Guess I have to leave it as is.

tropic lake
#

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

fast briar
#

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));
}```
fast briar
#

@tropic lake Im baffled in regards to the foreach loop. I dont understand why it's considered invalid.

tropic lake
#

i'm not sure either

#

reflection isn't something i've done

fast briar
#

I can try to do it the hard way without the Reflection.

tropic lake
#

add each property to a list and iterate through that?

fast briar
#

Probably.

fast briar
tropic lake
fast briar
#

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?

tropic lake
sinful lily
#

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

tropic lake
#

is it each one's value as a string

fast briar
#

The test field for shapesManagerReference is already in place, I just need to get the selectedShapeID and CalculatedCollectedStars().

tropic lake
#

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

fast briar
tropic lake
#

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

fast briar
#

I see. So far trying it out the first time, I guess im implementing it wrong.

#

Im not suppose to add in fields.

tropic lake
fast briar
#

I know for certain my declaration is wrong.

#

Oh wait the first picture is wrong.

#

My bad.

tropic lake
#

GetCurrentShape needs a return type

tropic lake
# fast briar

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

fast briar
tropic lake
fast briar
#

Still getting an error, saying name 'Test' cannot be found.

tropic lake
#

have you defined a class called Test?

fast briar
tropic lake
#

also in an interface you can't define a return or value, you just say that it has a get and or set

tropic lake
fast briar
#

Hmm, its more rigid than I expected.

tropic lake
#

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

fast briar
tropic lake
#

yes multiple children can inherit from the same base class

#

but a class can not inherit from multiple bases (at least not in c#)

fast briar
#

Since I only need the base class for the ForLoop, that's what i'll do.