#archived-code-advanced

1 messages · Page 18 of 1

lament salmon
#

yeah to my understanding this is the go-to resolution

iron urchin
#

So, in essence, it’s an engine limitation?

frozen badger
#

Yeah but I dunno about the 16k x 16k figure, I feel like a lot of games have more

lament salmon
#

as to storing the map, you could store it in chunks all in their local space, but with a world offset

compact ingot
#

its a limitation of digital computers

iron urchin
#

Well 16 K is arbitrary without defining a unit of measurement, and a scale. Right?

lament salmon
#

so meters

frozen badger
#

The example of minecraft which has like, 60 milllion in diameter plus a z axis of like 255

compact ingot
#

those that do, use a floating origin but that is super annoying to deal with

iron urchin
#

I mean within the virtual world. Defining what 1 m is on the screen.

frozen badger
#

I feel like if one dude in his basement can make a world that big that works it's not that hard of a limit

compact ingot
#

it doesnt really matter how big 1 unit is

frozen badger
#

Yeah it's more the number of units

lament salmon
#

its still taking the range of 1 from that float

frozen badger
#

Terraria has like, 17000 x 5000 or something?

compact ingot
#

1 unit in a game is usually what 1m would be to a human, maybe 1 foot

#

its not a hard cutoff

#

but just for giggles, make a unit sphere in unity and move it to like 16000, 0, 0

frozen badger
#

Ah, nevermind apparently it's 88920 x 64600

compact ingot
#

and you will start to see glitches in the mesh

compact ingot
lament salmon
#

if you fall thru your map, and wait for a bit, your character might start to deform

#

this was trippy when i didnt know the concept of floating point imprecision

frozen badger
#

But... I worked on a pretty big survival game in unreal, and our world was like 400k x 400k

#

we had no floating origin as it was multiplayer and your position would just be shown as like, x 120 000

frozen badger
#

Doesn't that depend on the build? Anyway here is a ball at 45k in unity

compact ingot
#

you need to move it to see it

frozen badger
#

I did

#

if I bring it up to 150k unity warns me that bad things may happen

iron urchin
#

According to Google

frozen badger
#

Ball does get a bit wonky at 75k

#

30kx, 30ky is fine though.

compact ingot
#

actually you can see it without moving this is at 16k

compact ingot
#

unity is a 64 bit app too, but all the graphics are 32 bit

iron urchin
compact ingot
#

furthemore the display quality isnt even the problem, its just that all your math gets progressively more wonky beyond 8k

#

integration errors accumulate much more quickly and comparisons will fall out of range

frozen badger
#

Well yeah, comparing floats to each other won't work very well

#

but then, shouldn't do that in the first place

compact ingot
#

duh

#

but if you compare ranges, i.e. your approximately function with a custom epsilon

#

those ranges might not work for large values

#

because values are spread further apart than your epsilon

iron urchin
#

As far as I just read, UE5 now handles double precision coordinate systems.

compact ingot
#

anyway, make a game keep everything within 8k from the origin and you're fine

compact ingot
#

iirc UE5 will also do floating origin automatically (as part of the world streaming)

frozen badger
#

In our case our physics started going wonky after numbers reached 800k

#

wouldn't floating origin mean physics wouldn't go wonky ever?

iron urchin
# compact ingot so we will get even bigger, more empty maps now 😄

Funny enough, this is exactly tied to the reason I started inquiring in this channel. I want to understand the limitations to filling that emptiness with digital psuedo-life and let the player discover it. With the advancements of a.i. in games (like ML Agents) can’t the world be alive and ever changing without the players input?

frozen badger
#

I mean it could anyway

compact ingot
frozen badger
#

don't need machine learning for it

compact ingot
#

you can get away with it to some extent but an engaging environment will always have to be handcrafted

frozen badger
#

Machine learning is like a hammer and every programmer that touches it goes around seeing nails everywhere

compact ingot
#

ML wont solve the lack of creativity problem

frozen badger
#

The original Ultima Online actually had this

compact ingot
#

you can see that with Midjourney/Dall-E, those images are not capable of the same expressiveness as a handcrafted image and to a trained artist they look outright bad

frozen badger
#

which is a 1997 MMO

iron urchin
#

What I imagine is the rules of the world are handcrafted, the world itself is procedurally generated, and the player and non-player entities in it interacts and exist together and independently of one another.

frozen badger
#

It doesn't really sound concrete

compact ingot
#

such a game will never exist

iron urchin
#

I have a much more fleshed out idea, something I’ve been working on on the side for the past 15 years. However, I feel that we’ve gotten to a point where technology is actually caught up with our imaginations for what games can be.

frozen badger
#

yeah man I had this dream of making a game where the whole world was simulated like skyrim and characters would go around eating and sleeping and talking to eachother kilometers from the player

#

I felt that way 10 years ago

iron urchin
frozen badger
#

Still though, gotta warn ya, we all have that same exact idea

compact ingot
#

all modern tech in games is focusing on compressing the simulation more and more to the point where only the visible pixels are simulated

#

this is where ML is heading to

frozen badger
#

ML dialogue in games could be fun though

compact ingot
#

ML dialogue would be meaningless

iron urchin
#

I didn’t mean specifically dependent on machine learning. That just being one of the many expansions of the tools developers have. Compared to 20 years ago.

compact ingot
#

why would you care about dialogue that is inventend on the spot with no relation to any other systems in the game

frozen badger
#

Nah I mean, google had that one programmer that went nuts and started believing their text generator had become sentient right?

#

What you never wanted to just, hang out and talk with your crewmates in mass effect

iron urchin
#

I’m gonna have to look that up.

compact ingot
#

ML can interpolate

#

thats all its good for

#

if you interpolate too much, you get ugly artefacts

frozen badger
#

Yeah, sure. It's not great. But it's a step up from npc repeating dialogue

compact ingot
frozen badger
#

Still, If it can trick that google engineer into losing his job over it

#

I'm sure you can trick the people that marry hatsune miku into enjoying it too

compact ingot
#

we're already tricked into believing all sorts of crap that came out of ML and not a human brain

#

everything you watch on YT is brainwashing driven by an AI

frozen badger
#

AI tricked me into watching WIDE PUTIN 10 HOURS meme

iron urchin
#

To go back to the skyrim example, I think questing/Npcs controlled by aspects of ML and Neural networks could help to create a very unique and meaningful experience for gamers. If Npcs behaved based on weighted needs driven systems, you can create unique worlds and ecosystems with problems that need unscripted solutions.

frozen badger
#

Why do you think machine learning will help you in this case?

#

Why not just use, say, utility AI

iron urchin
#

You can hardcode things like movement and interaction, and let a reward/punishment ML system govern the actions and evolution of the entity behavior.

frozen badger
#

Yeah but why do you think that would be engaging to interact with?

compact ingot
#

but you do not specify at all what ML contributes to that

frozen badger
#

not to mention, how do you define "good" or "bad" for the ML?

compact ingot
#

and what data would you use to train it in the first place

frozen badger
#

is it good for the AI to stand in a corner all day, wait for the exact moment it needs "food" and then go "eat"?

#

Nearly every good machine learning project has a very simple "win" or "lose" condition, and the reason certain machine learning algorithms exploded in skill recently is that people managed to clearly define "win" conditions for them

#

AI is now able to kinda draw art because someone coupled it up with AI that tries to guess which picture is a picture of something that fits the description.

iron urchin
#

That’s where the programmers ingenuity and creativity come into play in defining tue rules of the world. What makes something good or bad for a human? or good for one person and bad for another. The framework for the digital existence has to be specified, but the uniqueness of the “life” the entity lives out and how that effects the digital world, in unscripted ways, is where the intrigue grows from.

#

What if every time you played Skyrim, the rules were the same but the experience was completely unique?

frozen badger
#

And when you have made all this right, you've made all these rules for how important it is to run out of your house when its on fire vs how important it is to eat when you're hungry

#

you've made Utility AI

#

and don't need the machine learning at all

#

and Utility AI has the thing you want anyway, just look at something like dwarf fortress or rimworld

#

or heck, the sims even

iron urchin
#

There are tons of tutorials on YouTube from complete beginner to extremely advanced.

frozen badger
#

Maybe we can help if you have a precise question

iron urchin
#

To slide back to the discussion at hand, I feel that utility AI is just limited to the possible decisions that are hard coded in, while with machine learning you can get to a point where the entity is using input data to create its own possible decisions.

sly grove
frozen badger
#

It's like thinking text generator AI will come up with its own letters

#

There have been examples of AI playing games really well and coming up with strategies that humans never knew about

#

but still entirely within the options coded by the player

iron urchin
#

Right. And if the entity can learn to access code that was not inherently accessible to it, you can create unique situations.

frozen badger
#

What do you mean learn to access code

#

It's not magic, it gets segfaulted by the OS just like any other program

#

It's like saying if we give dall-e 2 another 500 billion images it's gonna learn to reach out from the computer screen and grab a brush and paint in real life

#

It just seems entirely disjointed from what machine learning is actually capable of, or even good at

iron urchin
#

let me try to give a practical example. Imagine a child that sticks a fork in a light socket. That child is going to get a zap, and it’s not going to feel good. depending on how intelligent and perceptive the child is, the child may or may not ever do that again. That we have a learned behavior through a reward and punishment system.

if I replicated that whole scenario digitally, I could use utility AI to specify that if the child puts the fork in the socket the data that it collects will tell it that that was bad and to not do that again.
however through machine learning the entity would collect data and then make its own decision from the decisions available to it.

that’s the difference to my understanding, and I think one of those lends itself a lot easier to vastly unique and varying situations.

frozen badger
#

The issue is that, through defining all these rules for what is "good" or "bad" you really just end up with utility AI and there is no value added from "machine learning" it

#

you say it'll be more dynamic if the AI figures it out for itself but really all it figures out is how to follow the rules you've set out

#

which, you could just tell it to do

iron urchin
#

Then every entity would react the same to every stimuli. If you vary the weight of the stimuli for each individual entity then outcomes won’t be repetitious

frozen badger
#

That is also true for machine learning

#

every entity would react the same to the exact same stimuli

iron urchin
#

Not if the weights aren’t the same though.

frozen badger
#

So what, each individual character has their own neural net?

#

it's not "one" machine learning it's one per person?

#

In normal AI this is solved by just, giving characters traits that cannot be shared. Or indeed by them not ever receiving the exact same stimuli

iron urchin
#

I suppose so. To go back to a cruel perversion of the child getting shocked example. What say you have two children and one is a masochist. The masochist would then continue to zap itself, possibly until death, because it drives pleasure from the pain.

frozen badger
#

Right but that is already doable

#

no machine learning required

#

dwarf fortress does stuff like this all the time

iron urchin
#

I’ve heard of that game, but I’ve never looked into it. Perhaps I will now.

frozen badger
#

a third of my soldiers are too cowardly to fight for me and run away from danger, or my best smith goes berserk because he doesn't get to work with the materials he wants

iron urchin
#

So the AI gains traits that begin to form their personality and influence their decisions and reactions?

rugged radish
#

machine learning is perfect for situations when you have a lot of data, and want to turn it into behaviors
if you have nothing, you yourself will end up being the source of data, and you will drive the network to learn the things you want it to learn
which only adds a lot of overhead and work and gives the same result as just writing code

frozen badger
#

Yeah. Like you have clearly defined outcomes and good/bad states, and data you can easily curate

#

like you could probably use machine learning to make a bot that fakes being a player in an MMO

iron urchin
#

What do you mean by fakes being a player?

frozen badger
#

Like, you already have player data for a hundred thousand players right?

#

So you make one AI that tries to separate bot players from real players, and one AI that tries to behave like a player

iron urchin
#

So basically how a chess computer works?

compact ingot
#

the state space of a MMO is way too large for an AI to learn it

iron urchin
#

I guess a Chess trainer to be more accurate

frozen badger
#

I would have agreed with you, but it doesn't have to be "good" right, it just has to behave like a player

#

it could stand in the auction house half the day

#

and that would be "like a player"

compact ingot
#

the best use case for AI so far is upscaling coarse data of any kind

#

its basically all that these fancy AIs from DLSS to Midjourney to Copilot do

frozen badger
#

I mean the best go player in the world is an AI right

#

self taught

compact ingot
#

in theory you could define A over here on the left and B over there on the right and have a NN that was trained on basically everything and it would invent a random permutation of the world constrained by A and B

frozen badger
#

created its own data

compact ingot
frozen badger
#

I mean, that is also the only thing it was taught

#

"did you win" or "did you not"

compact ingot
#

yes, but that is a classifier

frozen badger
#

it wasn't taught the win condition it was just told if it won or not

compact ingot
#

it did not come up with the idea of winning

#

which is the whole point of creativity

frozen badger
#

I mean yeah but you said the best use case for AI was upscaling data

#

I am saying there was no upscaled data here

#

it solved a problem better than humans did

compact ingot
#

it constantly interpolates data

#

thats how it works

frozen badger
#

data it itself provided

#

as opposed to AI trained on human data

compact ingot
#

it interpolates between winning and loosing and invents a game inbetween

rugged radish
#

you also need access to resources google has to make something close

compact ingot
#

don't get confused by the convolutions inside the interpolation, the rules are the A and B

rugged radish
#

it will take forever to train it on consumer hardware

#

realistically you need a good dataset, most likely marked

iron urchin
#

so what is the true bottleneck that is stifling innovation in the video game industry? Is it really just lack of creativity on behalf of developers?

#

Or perhaps that just boils down to aversion to risk…

#

Game companies, at least the major ones, will only focus on products that have made money in the past…

sly grove
iron urchin
#

Great point. It’s as if games have become little businesses, as opposed to products businesses create.

#

Micro transactions have truly become the thorn in the side of the industry. At least, in relation to consumer satisfaction.

#

seems to me that most of this money is made off of trying to give players a pseudo-unique experience. Leveraging that inate desire in people to tell their own story, in a legitimate, non-faux way, would be a gold mine.

#

I’ve definitely driven this far off the subject of coding, so I’ll leave you all be. But I appreciate you all humoring me, and sharing your knowledge.

mortal orchid
uneven ocean
mortal orchid
uneven ocean
#

Well yeah the smoothed velocity would help if they were stopping for a short time to hold the animation state for longer

#

What you could do is to ignore the idle state

#

Set it up in a way that makes it so that it maintains the last state (left / right) until it switches to the other side, or maybe if you have a face for walking up and down too

#

If they walk left and stop walking left they shouldnt switch to the front facing posiiton

#

Only if they start walking in ANOTHER direction should they change their sprite

mortal orchid
#

It is flicker between horizontal and vertical movement basically

undone coral
compact ingot
midnight venture
bronze geyser
#

Is there a CPU effecient way to track whether or not a new GameObject had become active this frame? (And to get a reference to said gameobject)

compact ingot
bronze geyser
#

I don't suppose there's any way to hook into the GameObject lifecycle

compact ingot
#

Not from the outside

undone coral
#

don't overthink it. it isn't cpu heavy

#

you're modding my bro. it do not matter

fathom rover
#

is it okay to ask about modding related things here? AkaHappy

balmy cargo
#

anyone knows how to fix this ?

#

i just have a start function with this line
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

fathom rover
lament salmon
balmy cargo
#

yeah

bronze geyser
#

That being said, I would probably reduce the call down to like every 6 frames

#

Frame perfect percision isn't required, but I largely just need to know when certain GameObjects have become active

midnight venture
#

Does the game spawn more of those game objects? If not, you should just cache game object references

#

And then GameObject.activeInHierarchy can be used to check if the object is active

digital helm
#

Is it possible to calculate childs world rotation from local rotation?

#

Well i'm sure it is, but does anyone have an idea how

upbeat path
digital helm
#

Yeah but

#

I have localRotation values

#

I wanna calculate into world rotation values

devout hare
#

That makes no sense, just get the world rotation directly

#

If for some bizarre reason you only have local rotations all the way down, you have to add them together until you get to the root object

#

or multiplying if they're quaternions

digital helm
#

Okay basically what I'm trying to do is

#

Apply babylonjs's camera rotation values into unity

#

but because it's a different coordinate system the values aren't correct ofcourse

#

any advice how to convert?

devout hare
#

so actually nothing to do with world/local rotation then

#

first figure out what coordinate system BabylonJS uses, then find out how to convert between those two systems

digital helm
#

It uses right handed y up

blissful bay
#

Hi, this is a very specific issue, but I hope there is a solution... is there a way to start a coroutine defined in class A from class B and run it in a separate thread?

compact ingot
blissful bay
#

Well, that was fast

upbeat path
upbeat path
#

becarefull though because most Unity API calls will only run on the main thread

blissful bay
#

to elaborate on the issue - I have a very demanding task that needs to be on a separate thread, but the class that has all the needed logic musnt be monobehaviour

#

and it appears to me that

sendThread = new Thread(() => SendFrame());

a wording like this simply doesnt cycle as it should

upbeat path
soft ginkgo
#

Hello, anyone here who have samples/references on how to use unity authenticate with Google play games?

#

Tried my best following the manual but still stuck for like a month now

blissful bay
pliant crest
#

one way is use ECS

#

other ways depends on what you are trying to do

#

with that singleton

brisk pasture
#

feel its too generic of a question, like without more details all i would say is remove the static stuff from it, and and stuff enforcing one instance, then simply pass it to things that depend on it instead

tidal maple
#

i have a Managed Dll and i should be able to access it, but unity says it can't find it at runtime

fickle obsidian
#

@regal olive I’m working through something similar and I find that the only option that I’ve found to work so far for me is implementing an observer pattern to handle manager-like communication between classes. You’re asking the right questions imo, as we all usually seem to agree that singletons are sometimes the right fit.

However, in the community of Unity it’s very rare that folks get into a robust/scalable implementation of other patterns as I believe most folks who can actually utilize these patterns do know how to implement them from a high level conversation, while others looking to “get there” are sort of left with a half measure.

pliant crest
#

i literally just pass the reference of the "manager" class to whatever needs it

#

when its instantiated

#

or assign it in the inspector before hand

#

if it already exists in the scene

dawn haven
#

Hi, I want to get the percentage of color in my render texture for each color (as an example to know how many % of blue there are), how can I do that?

#

(I would like to retrieve this value as a float variable)

sly grove
#

how would you classify a given pixel as a color?

#

there's like 32 million possible colors for each pixel right?

dawn haven
#

basically I need to know if there is more orange or blue in my scene and for that I use this material:

sly grove
dawn haven
#

(not really in the whole scene but only for the inked surface so I can use a tag on the materials concerned)

#

I have to do that with the render texture or the materials?

sly grove
#

Is this like a game jam people are doing? THere's been like 5 people asking about this lately

dawn haven
#

exactly

sly grove
#

you need to just do that analysis on the splatmap texture or whatever you're using for painting

sly grove
# dawn haven oh

Oh wait duh I know why, it's because Splatoon 3 just came out recently.

dawn haven
#

probably i guess

humble leaf
#

I guess Splatoon will become the new Backrooms like Dani-Grappling-Gun-Mechanic before it. 😆

dawn haven
sly grove
# dawn haven

Seems like the shader you're using doesn't have a texture called "Mask"

dawn haven
#

Does GetTexture work with Texture2D?

sage radish
#

It's not guaranteed to be a Texture2D. It could be a RenderTexture too.

#

Otherwise it would just return Texture2D

sly grove
#

I think the actual name might be different?

dawn haven
jolly token
#

See the properties of it

dawn haven
#

How can I do this? I don't understand what this mean

jolly token
#

Reference name can be different

#

Just click it ig

dawn haven
#

_MaskTexture

#

ok i think i can use this

jolly token
#

Yeah that

sly grove
undone coral
#

when the players run around and paint the ground, a piece of code does that right?

#

so you already know exactly when paint is added and removed

#

count there

#

you don't have to interact with the texture at all

#

splatfest... they probably have a little tutorial on this yeah?

dawn haven
#

I found how to do it but I just need to know how to convert a texture to a 2D texture ("as texture2D" doesn't work)

#

splatfest?

undone coral
#

i'm describing another approach

#

do you know where the code is that paints the ground?

undone coral
#

you already know how much paint was added or replaced, it's in the code that paints the ground

#

did you find it?

undone coral
dawn haven
#

I know what you want to do but that would mean I have to know when the blue player is painting on orange paint to know when to take points off the orange player

undone coral
#

it sounds like you did not author it

#

are you using an asset?

#

it is okay. you should read it

#

it is going to illuminate for you how it works

undone coral
dawn haven
#

I added the multiplayer myself so the code doesn't expect there to be two different colors on the ground, that's why I can't tell when the blue ink covers the orange ink

undone coral
#

i don't really know why you're being stubborn about this

#

you know when you draw on the texture. it is writeable and readable there.

#

you have to look at the code

undone coral
#

?

undone coral
# dawn haven

you also have a reference to the texture elsewhere

#

it's in the code. you have to read the code!!

blissful bay
undone coral
#

@blissful bay if you use the code snippet that was shared with you as is, it is going to crash your editor

blissful bay
#

And the task is demanding, so I need to have it in a separate thread

undone coral
#

what is the task?

#

you're authoring a library for someone else? or what is the idea?

blissful bay
#

Yes

undone coral
#

so what is thea pplication / game?

#

succinctly

#

this matters a lot

blissful bay
#

Reading camera output, chunking it up into packets and sending them to a remote java application

undone coral
#

okay

#

camera output? you mean a unity camera right?

blissful bay
#

I have a non-DLL version working, I have a DLL non-threaded version working, but I cannot combine then

undone coral
#

as in a Camera, not the webcam right?

blissful bay
#

Ye, sorry

undone coral
#

and the point of this is to show the unity camera feed in a web page? or what are you doing with it in the java application

blissful bay
#

Not necessarily a web page, an application

undone coral
#

instead of my guessing

#

like what is thea pplication? you've almost helped me understand

dawn haven
#

this is what paints the ground, I don't know how to tell if you are painting on a blank surface or if you are painting on a surface that has already been covered by enemy ink

undone coral
#

there isn't anything sensitive about what the application is

blissful bay
#

tbf Im not familiar with the other end of the app, I have the java script that recieves the data and converts it back to JPEGs, which are then displayed on an android app, but I havent really digged into it

undone coral
#

hmm

#

i'm asking what is the application, not the Application

#

if that makes sense

#

"i am making a basketball game that streams a camera to a remote android phone because the gameplay is XXX"

blissful bay
#

oh

undone coral
#

you've achieved a lot so far based on you've been writing in the chat for a while

#

i mean in the search results

blissful bay
#

Im making VR educational software and I want to stream what the teacher to see what the students are doing etc

undone coral
#

like i'm asking you Why you need this, not why you need this.

#

OKAY

#

THANK YOU

blissful bay
#

lmao

undone coral
#

it took 10 minutes to get to that

blissful bay
#

sorry for me being a lil dumb

undone coral
#

are you a student?

blissful bay
#

ye

undone coral
#

okay

blissful bay
#

honestly really new to all this "backend" stuff, I mostly do the gameplay logic

undone coral
#

how much time do you have

#

to work on this? is there a deadline?

blissful bay
#

not a hard one, why?

undone coral
#

you're on the start of a very long journey

blissful bay
#

even if I have the working scripts up and going?

#

I just need the one last step

undone coral
#

the problem is just way harder than you've discovered

#

i'm also familiar with how students use the word "just" and "working" lol

#

for example, punch the three words i just need into the search

blissful bay
#

understandable, lmao

undone coral
#

to see where you are in this journey

#

from the outside

#

this is a pretty good illustration

#

do you see what i mean?

blissful bay
#

I do

undone coral
#

so

blissful bay
#

so, how much difficulty does the threading add to the task?

undone coral
#

when you want to send the rendered output of a video game over the network, the image graphics transit over a lot of different boundaries that have very strict rules - the gpu, the unity render thread, the unity main thread, the api to the network stack...

#

trying to do this in real time is extremely hard. it isn't possible to do in unity on the oculus without a native android plugin yet, for example

#

for the application you're talking about, the best thing to do will be:

blissful bay
#

could you elaborate on "without a native android plugin"?

#

there is obviously something I am missing and I am well aware of it, and regarding my current main-thread version working - I am getting the input back just fine

dawn haven
#

I managed for a while to add points to the player when he paints but how do I know if he paints on his own ink (this is to prevent the player from accumulating points by re-painting on his own ink)

undone coral
#
public class SendView : MonoBehaviour
{
 string playerId;
 void Start()
 {
  StartCoroutine(Loop());
 }
 IEnumerator Loop() {
  while (Application.isRunning) {
   yield return new WaitForSeconds(1f);
   yield return new WaitForEndOfFrame();
   ScreenCapture.CaptureScreenshot("temp.png");
   var form = new WWWForm();
   var data = new MultipartFormFileSection(File.ReadAllBytes("temp.png"), "1.png")
   form.Add(data);
   var www = UnityWebRequest.Post($"http://server:8000/imagefor/{playerId}", form);
   yield return www.SendWebRequest();
  }
 }
}
#

this is probably your best bet

#

is this already similar to what you're doing?

#

@blissful bay

blissful bay
#

Waaay off

undone coral
#

the reason i'm suggesting this is

#

you can't send the graphics off the device in real time with low latency

#

not without writing something that is going to take you 6-12mo of full time work to achieve

#

even with high latency, it is going to take you a really long time. i would still say at least 3mo

#

based on what you know today

blissful bay
#

Which part are interested in, the sender itself, or the camera capture?

undone coral
#

so in this code, we're taking a screenshot every second

#

and uploading it to a remote server using a simple http post

blissful bay
#

I'm looking at at least 25 FPS

undone coral
#

that remote server can be a standards based one

blissful bay
#

Ideally 60

undone coral
#

i mean, you can get there eventually. you would first have to scrap pretty much everything you already have

blissful bay
#

The script I already have already works in production tho

undone coral
#

you can certainly try recording pieces of video, for which there are plugins, then uploading those pieces. the video feed will be 5-10s delayed

undone coral
blissful bay
#

Because

undone coral
#

lol

blissful bay
#

It is the truth

undone coral
#

i'm just teasing

#

c'mon

#

you don't comprehend yet that the multithreading isn't going to improve performance.

#

you don't really know what the problem is yet

#

i actually started writing what it was, and you asked no follow up questions about it

#

you're still convinced that if you "just" could get htis thread working

#

or whatever

blissful bay
#

Wait, let's get one thing straight, as I think we are missing the point

#

What do you think is the issue I have

undone coral
#

you don't know yet it will instantly give you errors

#

i think you have a 3d rendered game on a Quest device

#

and when you turn your image sending code "on" the game runs very slowly

#

and you've been working on trying to make this faster

#

you may have given it to someone else to use

#

and they got a headache

#

because it isn't running at 90fps

#

there might be a lot of stuttering too

#

75fps or 90fps... it might be running too slow

#

you might have an empty scene

#

and this is "working"

#

and maybe you tried the "library" in the "real" game and now you've discovered it's "too slow"

#

is this correct?

#

it might be running at 60fps but 60fps on an HMD is too slow

blissful bay
#

Alrighty so, I have 2 scripts - one without threading, one with threading, first one causes lag, second one doesn't (tested and proven) and my task is to turn the second one into a library, which I'm struggling with, so I came back to the first, simpler one, to try if it helps me uncover something I am missing
I have managed to turn the first one into a library, but it didn't help me with the second one at all, so I asked here

undone coral
#

yes, but everything i described

#

is it true?

#

is that was literally happened?

blissful bay
undone coral
#

well but the new one doesn't send picture at all now does it

#

not on the real device

#

the new script isnt' finished

#

it isn't "working" as you say

#

right?

#

and if you "just" had multithreading then it "will" work

blissful bay
#

It does, but I cannot turn it into a library

undone coral
#

i'm sorry, i am not trying to bully you or anything

#

i don't understand, is it running inside the unity game or not?

#

this new script?

#

i don't think it is right?

#

otherwise you wouldn't be here

blissful bay
#

Yes it does

undone coral
#

hmm

#

this is a weird gambit you are doing

blissful bay
#

The streaming works, but I need enclose it in a library, so it can be a marketable product on its own

undone coral
#

you're saying the streaming works...

#

what is working according to you?

#

you keep saying "working"

blissful bay
#

I am receiving JPGs at preset frame rate and dimensions

undone coral
#

a quite low frame rate i presume

#

which is fine

#

there's nothing wrong with that

blissful bay
#

Doesn't need to be 144fps for the target use

undone coral
#

i am trying to say it will never be at 60fps with this approach

#

on the quest 2, it will probably not be able to send at even 25, and also have a real game happening at the same time

#

it can be an empty scene, but not a real game

#

so if you dispose of this objective of trying to do 60fps

#

or even 25fps

#

for this application, probably 3fps will work

#

and this is besides the latency - i have no opinion, i would guess a second of latency will be fine, maybe even 5s, realyl depends what the idea is

#

you will have a much easier time

#

if you make the goal fps lower

#

i understand you might occasionally observe "60fps" in some situations, but i am telling you know, me, someone who knows a lot more about this than you, that off a quest, in an ordinary condition like someone else's wifi network and accessing a remote server, it's not going to work

blissful bay
#

Im comparing your code to mine, Im usind UDP client to send the data

undone coral
#

you think it's about the network

#

we tried to talk about this. there are boundaries with rules

#

they're complex

#

you haven't run a profiler. you don't know yet what is slow

blissful bay
#

I am absolutely not denying that

undone coral
#

i am just trying to instill some perspective of what is hard. 60fps is really hard

#

it's way beyond what you are going to be able to do

#

target 3fps

#

then, you can use an HTTP API. which is way simpler, and it is already "multithreaded"

#

that is to say, in unity, the unitywebrequest api does blocking IO on a different thread, and it presents an easy to use async API

#

this would have the added benefit of obsoleting this java backend, which was a bad idea

#

@blissful bay stay focused on what i am writing

#

i think you can go to class, and you'll read that UDP is fast and TCP is slow

#

or something

#

this just happens to be a uniquely hard problem

#

i can also tell you that this thing you are developing

#

there are other people developing it, it sort of already exists, specifically for this purpose, specifically people doing VR trainings and seeing what the trainees are doing in a browser

#

they use agora, and they accept the performance limitations, and i had the same exact conversation with them. agora is the library you are trying to replace

#

so there's another thing you can do. you're a student, you don't have to make a library to sell

#

you can work on making a really great piece of technology! just focus on that

#

you can try ot learn this stuff and just make it free and work on it with clear goals

#

@blissful bay do you see what i am saying?

blissful bay
#

I am

undone coral
#

okay

#

agora is pretty good

#

like if this sounds all so annoying, "just" use agora 🙂

#

it has samples, the samples look very similar to what i showed

#

saving the screenshot is slow. you'll see examples in their repo for how to do it correctly

#

@blissful bay exact same approach as yours

#

this all exists

#

just with a protocol that actually works

#

then you can use the agora react component

#

and agora signaling server

#

and show the feed in the browser

#

then you're done

#

you can do it in an android app too

blissful bay
#

the thing is - this part has been written by my colleagues and tbh I dont see a reason to rewrite it

undone coral
#

one perspective is that 3 developers do not do 3x the work of 1 developer. sometimes it adds up to less than 1 developer

blissful bay
#

what would be the benefit of changing a working piece of code?

undone coral
#

you're using that word again 🙂

blissful bay
#

let me reword that then - what is the benefit of changing a piece of code that does what it needs to do?

undone coral
#

because it isn't solving the problem

#

right now you're north korea trying to build a rocket ship

#

like you can launch a rocket repeatedly into the sky and is repeatedly crashing into the ground, and it goes a little higher every time

#

is it going to go into space? i don't think so

#

i'm sorry, you're right, afghanistan*

#

agora focuses on this one aspect that is 90% of the work

#

in this application

#

it's a very good value

#

@blissful bay using this will also help you focus on the domain specific problem of teaching using headsets

#

it will end this colossal distraction

#

@blissful bay share this colorful explanation with your friends, with the other students / grad students

#

tell them doctorpangloss thinks you guys are the Afghan Space Program right now

#

and i think they'll be convinced they should just use agora, and you will be in a much better place

blissful bay
#

there is one more issue - this is a commertial product, not a school project

undone coral
#

well

#

you said you were a student right?

#

are you?

#

like this is for an internship?

#

i don't know what to say, you pay for the agora fee, it is small

#

you pay for a unity license, you pay for the backend servers, you pay for agora

#

you can also try to do something impossible

blissful bay
undone coral
#

you can afghan space program

blissful bay
#

sort of

undone coral
#

lol to sort of

#

is this your company?

#

i am trying to understand

#

you're doing it again

#

you're not saying the thing

#

anyway agora is your best bet, good luck out there

blissful bay
#

alright, thanks for your time and sorry for being a dork, lol

undone coral
#

lol

#

no it's okay

#

i am trying to help for real

#

basically you can go back to them and ask for way more time

#

or moderate expectations somehow

blissful bay
#

and I am trying to apply your advice on what I need to do

undone coral
#

you're certainly going to be able to start a thread and loop send udp packets with it

#

i don't think you really need help with that

#

you will readrawtexturedata and it will be fine

#

you should probably google "vr training instructor watch"

#

and see that there are like 10,000 people in 1,000 different companies working on stuff like this

blissful bay
#

well, thanks again

#

I will try to sort it out somehow and I will see

rugged radish
#

is there a way to make a compute shader kernel handle zero length buffers ?
if I don't set the buffer that is referenced in the kernel's code I get an error that the buffer was not set (it is known in advance it won't be used by the kernel)
and it's not allowed to create zero length compute buffers

right now I have to put dummy 1-length data in those cases, which makes the c# side of things somewhat ugly

native plover
#

There will be many CustomRigidbodies, but not many GravityVolumes

icy aspen
#

I am having a small problem with the playfab RegisterPlayFabUserRequest: I want to sign up users with a username and a password, this is my code:

public void Register()
    {
        var request = new RegisterPlayFabUserRequest
        {
            Username = username,
            DisplayName = displayName,
            Password = password,
            RequireBothUsernameAndEmail = false
        };
        PlayFabClientAPI.RegisterPlayFabUser(request, OnRegisterSuccess, OnRegisterError);
    }

The displayname, username and password get defined here in the update function:

displayName = displaynameInput.GetComponent<TextMeshProUGUI>().text.ToString();
        password = passwordInput.GetComponent<TextMeshProUGUI>().text.ToString();
        username = displaynameInput.GetComponent<TextMeshProUGUI>().text.ToString();

When i run this, this error pops up (it's from error.GenerateErrorReport()

I've read some stuff online and this is what i found: https://community.playfab.com/questions/36762/registerplayfabuser-fails-with-invalid-characters.html There seems to be a problem with TextMeshPro.

Does anyone know how to fix this?

#

this was the error i was talking about

regal olive
#

anyone know why this interface isnt available in Unity.Jobs

sly grove
regal olive
sly grove
regal olive
#

there's nothing like that in package manager

sly grove
#

it's an experimental one

#

you have to add by name

regal olive
#

oh great

#

thanks @sly grove

sly grove
#

I think by "kernel" they're talking about the compute shader "program"/"function" itself which are referred to as "kernels".

dapper cave
#

in 2021.3 is Mathematics still dog slow compared to Mathf?

wooden cedar
#

No idea, 2021 hasn't had a stable build that gave me a clean pass on my team's QA

#

But we need to support a large array of devices, so getting a true stable Unity build is very rare for us

dapper cave
#

I wish more people would share their in-production experience of each Unity version... it's become a game on itself to find a config that's not shit

dapper cave
#

there used to be a bool in Application, I think it was called Application.isQuitting or similar, that'd go true if the game is exiting, thing's gone. you know what it's called now?

#

(hope not one of these god damn events)

pliant crest
#

whats wrong with events?

rugged radish
#

as PraetorBlue said, it's a compute shader kernel
I should've worded that more clearly

maiden turtle
rugged radish
stuck onyx
#

is it possible after upgrading unity from 2020.3 to 2021 the script execution has increased quite a lot ? im on I2LCPP build

#

i had a quite heavy script that i tested on editor and device and it took almost 1 second to execute... now im doing exactly the same on device and its barely 200ms

maiden turtle
#

one or two functions got inlined in some hot loop

#

+200 speed

obsidian glade
#

they don't - but a decoupled architecture that achieves its decoupling by using events will be easier to test

maiden turtle
#

interfaces same thing

#

that's one of the points of these things

jolly token
#

Is it? Test setup for events are pretty fussy because their async nature

orchid marsh
#

Targeting the individual credibility rather than the nature of async isn't beneficial.

#

I didn't see the mentioning of issues just that of asynchronous nature which could be fussy.

jolly token
#

How do you testing the event? If your code base has lots of events? With lambdas and counting events?
I guess basic unit test would look like this

int eventCount = 0;
EventPublisher pub1 = new();
pub.OnSomething += () => eventCount++;
pub.SomethingHappened();
Assert.Equal(1, eventCount);
#

When do integration test it will become more complex to set up
Because each event can expect other event to do anther thing 🤔

obsidian glade
#

the parts doing the work in making your code easy to test there are the interfaces rather than the events

#

having a simple interface for components to connect & interact, you don't necessarily need events to do that

#

the hard part of testing would come when you have a component you can't just instantiate as a prefab - perhaps some networking service or database IO, in which case you can replace the entire interface with a stub instead while the rest of your code can be tested as if it's there

jolly token
#

Even with integration tests you'd need to mock some behaviour, (e.g. Server response)
I find it is easier to mock things with interface and Tasks than bunch of event callbacks

jolly token
#

I guess it is code smell because it means your implementation is aware of test?

tired creek
#

Hi, I am writing code that removes loose vertices from a mesh. Ive come up with the following:

public static void RemoveLooseVertices(List<Vector3> vertices, List<int> triangles)
        {
            SortedSet<int> looseVertices = new();
            HashSet<int> usedVertices = new(triangles);
            List<int> subtractions = new(new int[triangles.Count]);

            for(int i = 0; i < vertices.Count; i++)
            {
                if (!usedVertices.Contains(i)) looseVertices.Add(i);
            }

            foreach(int v in looseVertices)
            {
                for(int i = 0; i < triangles.Count; i++)
                {
                    if (triangles[i] > v) subtractions[i]++;
                }
            }

            for (int i = 0; i < triangles.Count; i++)
            {
                triangles[i] -= subtractions[i];
            }

            foreach (int v in looseVertices.Reverse())
            {
                vertices.RemoveAt(v);
            }
        }

However this is O(n*n) which is not good.

#

Does anyone know how to do this in O(n) time?

flint sage
#

I doubt that is possible in o(n) unless you already have analyzed the mesh before hand

tired creek
flint sage
#

Actually, can't you just add all used verts to a hashset and then check what verts (from vertices) are missing, wouldn't that still scale linearly

#

Idk what that subtractions is all about tbh

tired creek
#

subtractions says how much do i need to subtract from a given triangle index

#

so trianges match up with correct vertices after i remove the loose vertices

jolly token
#

And for same reason you are sorting looseVertices which is actually indices?

tired creek
#

i am sorting looseVertices so i can iterate from the largest to lowest index, because otherwise I woudl invalidate looseVertices values by removing stuff from vertices

jolly token
rugged radish
#

can't you just reassemble the vertices and indices
linear time complexity

#
newVertices
newIndices

iterate over input indices
using them, take out vertices from the input vertices
copy them into newVertices
add the new index to newIndices```

at the end you have new vertex and index lists
tired creek
jolly token
hasty nimbus
#

How to get all gameobjects in the scene in C#7.3 (not 8)

dawn haven
#

hi, i use cinemachine for my TPS camera, I want to make a port of my game for android but i can't put mobile axis in my freelook component :

#

Is there a way to replace that with the touch screen?

hasty nimbus
#

"Feature 'range operator' is not available in C# 7.3. Please use language version 8.0 or greater." but i have the problem that i cant upgrade

jolly token
#

Then don't use range operator

hasty nimbus
jolly token
tired creek
#

@jolly token @rugged radish @flint sage

#
public static void RemoveLooseVertices(List<Vector3> vertices, List<int> triangles)
        {

            HashSet<int>[] tIndexesOfVertices = new HashSet<int>[vertices.Count];
            for (int i = 0; i < vertices.Count; i++)
            {
                tIndexesOfVertices[i] = new HashSet<int>();
            }

            SortedSet<int> looseVertices = new();

            for (int i = 0; i < triangles.Count; i++)
            {
                tIndexesOfVertices[triangles[i]].Add(i);
            }

            int offset = 0;
            for (int i = 0; i < tIndexesOfVertices.Count(); i++)
            {
                if (tIndexesOfVertices[i].Count == 0)
                {
                    offset++;
                    looseVertices.Add(i);
                }
                else
                {
                    foreach (int idx in tIndexesOfVertices[i])
                    {
                        triangles[idx] -= offset;
                    }
                }
            }

            foreach (int idx in looseVertices.Reverse())
            {
                vertices.RemoveAt(idx);
            }

        }
#

Changed to this and I think this is linear

#

pinging if you are maybe curious

tired creek
blazing osprey
#

I have an issue with pun2 after changing my build to uwp, is this the right channel or should I use #archived-code-general?

undone coral
blazing osprey
#

why is #archived-networking in the simulation category I collapsed that like a year ago and haven't opened it since

#

thank you

last compass
#

Hey yall I have a big project

lavish sail
last compass
#

Oh I am a producer of a project

lavish sail
#

I mean how much experience do you have with gamedev

last compass
#

Oh

#

I have been into it for about 4 years now

jolly token
#

Your profile says you're 21

lavish sail
#

so you're sure you're ready to handle a "big project"

lavish sail
last compass
#

I have been through many projects before big and small

lavish sail
#

alright then good luck

last compass
#

But i am looking for some programmers and I found this server

jolly token
sleek ocean
#

I have 4 years and I started at 13

sleek ocean
last compass
#

I am gonna be honest I am not a professional at this

sleek ocean
#

I had friends make tens of thousands of dollars

lavish sail
#

years of experience don't even mean that much because it's all up to how much you've actually learned in them

last compass
#

but I have experience to be able to head into a new direction

sleek ocean
last compass
#

I have worked with many ppl

#

but I am not myself a programmer

tired creek
last compass
#

I am a producer and director

#

and streamer/recorder

lavish sail
#

so you hire people to do all the development job?

last compass
#

I wouldn't put it like that because we all do the development job

#

everyone has their own part in it

#

like we have animators and we have artists

lavish sail
#

and what do you do exactly

last compass
#

you mean the language or what game

jolly token
sleek ocean
lavish sail
sleek ocean
#

They dev on roblox so they make a lot more money but the games are more cash grabby

last compass
#

oh I see what you mean

lavish sail
sleek ocean
#

I quit though because single player is a super niche meta

#

That isnt pushed very often

#

I also wanna make games that can run smoothly at any degree

#

Performance is a major issue

#

And I found a lot of issues in the engine

#

Overall it’s really for devs who want to make some money

lavish sail
#

Roblox is a highly commercialized platform so it's almost all about money really

sleek ocean
#

Yeah

last compass
#

basically, my job in the project is to help put it all together and help with everyone's job and basically make the project run smoothly make sure the tests all get performed and I make sure it gets published correctly

lavish sail
#

so you're just overseeing

last compass
#

if that's the words you want to use

lavish sail
#

ok then, it should work as long as you don't expect people to work for free

#

but generally it won't work with non-commercial collaboration

last compass
#

The languages involved are C#, JavaScript, and maybe some Python

#

if you are interested in trying out for the project you can DM me

orchid marsh
lavish sail
#

^

sleek ocean
#

Wait how did you

lavish sail
#

that's where you go if you want to hire

orchid marsh
sleek ocean
#

Oh that’s an image

blazing osprey
sleek ocean
#

I shall log off for the day

blazing osprey
#

ok

undone coral
tired creek
#

im writing an implementation of a mesh splitting algorithm

undone coral
#

for what purpose

#

i mean what's your goal

undone coral
tired creek
#

it kinda works

#

but I still need to fix the uvs

undone coral
#

ah

tired creek
#

and fill the holes

tired creek
undone coral
#

you might want to look at poseidon CSG

#

"CSG" is the name for this class of mesh operations

#

like boolean operations

long tangle
#

i was making a first person shooter and i was trying to make the camera stop rotating when looking completely up or completely down. I have come up with this code and i wanted to know if there is a better way to do this

tired creek
#

you can look at functions Mathf.Clamp() and Mathf.Min/Max to explore other solutions

#

a nice trick is to write
cameraX = Mathf.Clamp(cameraX + angleDifference, -90f, 90f)
instead of
cameraX += angleDifference
this way the angle will never be outside the desired range in the first place

terse bobcat
#

Hello does anyone know how to smooth the camera rotation i have liitle jitter

    {
        if (!HasAnimator) return;

        var MouseX = InputManager.Look.x;
        var MouseY = InputManager.Look.y;
        Camera.position = CameraRoot.position;


        XRotation -= MouseY * MouseSensitivity * Time.smoothDeltaTime;
        XRotation = Mathf.Clamp(XRotation, UpperLimit, BottomLimit);

        Camera.localRotation = Quaternion.Euler(XRotation, 0, 0);
        PlayerRigidBody.MoveRotation(PlayerRigidBody.rotation * Quaternion.Euler(0, MouseX * MouseSensitivity * Time.smoothDeltaTime, 0));
    }```
tired creek
terse bobcat
#

no

#

in LateUpdate

tired creek
terse bobcat
tired creek
#

not really

queen meadow
#

Trying to figure out a good flow for interactive animated meshes. Shortly named Active Ragdolls, usually.

I want to create a zombie, that I can interact with in VR. Grab his head, stab him etc; while keeping some animations like swiping towards you as he is grabbed by his head. Now, I got Active Ragdolls going.. though they aren't perfect in any matter, with addition, if I try to play a walking animation... well they love to bounce.

My currently solution which feels the wrong direction, is to do Animated Mesh -> Ragdoll -> Active Ragdoll (play get up animation) [if the character successfully get up at some angle]->Animated Mesh. Interactions with the mesh, a cylinder trigger would cause the Animated Mesh -> Active Ragdoll. Maybe even a zombie swipe causes it to go into active ragdoll.

If anyone has a clean way to reproduce something like Blade & Sorcery and/or Boneworks (less soo, too clumsie for my needs).
Thanks!

lament salmon
queen meadow
#

This is what my Active Ragdoll looks like so far. With the puppet on the left.

lament salmon
# queen meadow Ah ye, I'm also using ConfigurableJoints and have my guy standing upright... tho...

Yeah, bipedal balancing is hard to do realistically, robotics engineers struggle with it IRL too... 😁
As to blending back to animation... you would usually have two animators/skeleton inside your character. First armature would always run the animations, and the second one has rigidbodies and joints enabled, copying their respective target rotations from the 100% animated version.
Then when your character gets back up/you want to disable physics, you just blend into 100% following animations, and finally back to using only animations

queen meadow
# lament salmon Yeah, bipedal balancing is hard to do realistically, robotics engineers struggle...

Ye trying to solve a robotics question is difficult. 😅

So are you suggesting that the Active Ragdoll will always be the visible model, the animated mesh would be hidden (with the animator Always Animating turned on). Then when checking if the character is upright, if it fails that test; then you want to disable the physics towards itself, and run the animation of getting up, then turn back on the physics when the character is upright again?

lament salmon
# queen meadow Ye trying to solve a robotics question is difficult. 😅 So are you suggesting ...

I mean it all depends on how you want your character to behave. But I think you got the basic idea of having 2 skeletons:

  1. The Source skeleton, that always runs animations and yes, using Always Animating
  2. The Physical skeleton with Rigidbodies & ConfJoints, that copies target rotations to each of it's bones from Source skeleton

If you want to 'disable' physics, just show the Source renderer
Use joint slerpDrive/angularDrive strength to simulate muscle strength

#

I'm by no means solving a certain problem you have here, but throwing at you this workflow/technique that works for me

queen meadow
#

Hm okay, and does animations need to be different in any way or can I use normal animations for example, walking and running.... currently causes a lot of bunch, maybe that's related with my fixed hip?

#

Right of course, I'm just throwing questions, since I'm at a very early state of learning active ragdolls, and it seems you have more of an idea than I do. Which I appreciate your guidance on this. 🙂

lament salmon
#

A lot of this is so usecase specific that you just have to try a lot of stuff out

queen meadow
#

Hm interesting. It sounds like you don't use the animated mesh only for puppeteering, if I am not wrong, with custom animations for some physical ragdoll differences.

lament salmon
queen meadow
#

Okay that makes sense, performance would tank otherwise. 🤣

lament salmon
#

A couple of GDC videos to check out:
https://www.youtube.com/watch?v=TmAU8aPekEo
https://www.youtube.com/watch?v=7S-_vuoKgR4
Not Unity related directly, but similiar concepts and good visualization

GDC

In this 2020 GDC Summer session, Respawn Entertainment's Bartlomiej Waszak explains how Star Wars Jedi: Fallen Order uses physical simulation blended with authored animations to create high-fidelity character motion.

Join the GDC mailing list: http://www.gdconf.com/subscribe

Follow GDC on Twitter: https://twitter.com/Official_GDC

GDC talks c...

▶ Play video
GDC

In this 2017 GDC talk, Naughty Dog's Michal Mach explains how to drive physics objects with animation more predictably, with minimal distortions and almost absolute artistic control.

Register for GDC: https://ubm.io/2yWXW38

Join the GDC mailing list: http://www.gdconf.com/subscribe

Follow GDC on Twitter: https://twitter.com/Official_GDC

GDC...

▶ Play video
queen meadow
#

When you are trying to get back up, are you still in active ragdoll?

lament salmon
queen meadow
lament salmon
regal olive
queen meadow
#

I am planning to write my own Ragdoll Builder, because it Unity's version doesn't work well for active ragdolls or at least my use.

#

But first need to get the darn thing working. 🙂

regal olive
#

oh alrigh

#

thanks lol

jolly token
#

Does RegexOptions.Compiled work well in IL2CPP?

lament salmon
#

also ragdolls are a pain to debug, so one idea is to create a ScriptableObject that all ragdolls use to get their joint values

#

makes it easier to debug and test different values runtime

#

just a peek on my SO's inspector so you get the idea

#

and then multipliers and mass scales etc for each type of bodypart... you just adjust them until it works like you want

regal olive
grave vortex
#

Can I set render order by render layer rather than material type?

torn basalt
#

under the hood, where does transform.localscale get its info from to determing the xyz scale of an object?

wild bane
#

I switched unsafe code on in Unity Editor and tried to get a pointer to a Transforms Vector3 position but I get an error that I cannot access that address..
I'm either doing something wrong here or it just can't be done with such things
(I also learned C++ earlier so I'm quite new with how pointers work in C#)

private unsafe Vector3* _playerPos;

private unsafe void Start()
{
    _playerPos = &GameManager.instance.playerFollow.position;
}```
#

Even tried to just make it a var instead of Vector3* just to check if the type was incorrect, but after hovering on it it's say's it's a Vector3* so no issue with that, the problem is probably the way I try to access it or maybe I have to do something more than just turning the unsafe code on in Unity settings

gaunt spoke
#

Hello, I believe you can use pointers on structs only if the struct contains primitive value types, maybe that's not the case for Vector3 ? I also really wonder why do you need to use pointers here, can you tell us a bit more about your use case ?

wild bane
#

Actually there's no real reason for me using pointers here, I was just testing stuff and I wondered if I can just get a pointer to a Vector3 position instead of getting the Transform reference and access it's position via the Transform at all times

umbral trail
#

this is really dangerous because you're not checking the lifecycle of playerFollow so if it gets destroyed you'll crash

#

Also you can't take pointers of objects in the heap because they will move when heap compaction happens in the garbage collector

tired creek
#

Hi, can comeone tell me why consecutive calls of a function get faster?

#

Is the mesh data getting cached somewhere?

flint sage
#

Could be jit, could be faulty measuring

#

Could be cache

errant plinth
#

Could be a warm-up effect

tired creek
# flint sage Could be jit, could be faulty measuring

            var timer = new Stopwatch();
            timer.Start();
            Destruct.SplitResult splitResult = SplitMeshAlongPlane(v, t, u, new PlaneSplitter(new Vector3(1f, 1f, 0f), 0f));
            timer.Stop();
            Debug.Log("Splitting " + t.Count + " triangle mesh took " + (float)timer.ElapsedTicks / Stopwatch.Frequency * 1000 + " ms");

I do measuring this way

#

Is this alright?

flint sage
#

Not really, if you want reliable results you should really be using benchmark.net but not sure if you can integrate that into Unity really

tired creek
#

okay

#

didnt know about benchmarkdotnet

#

what can go wrong in the above method?

flint sage
#

Well you're only doing one iterate so you're prone to outliers

umbral trail
flint sage
#

If you're running this on Start for example, you'll likely be influenced by unity initializing things

#

Hence why it could be slower

#

Ah cool, didn't know about that package

umbral trail
#

Add a 5 second delay and if that changes it, there was other stuff happening at the same time slowing it down

#

3 seconds seems a bit long for JIT

flint sage
#

You're probably right but we can't know since it's not a reliable way to test 😛

tired creek
umbral trail
#

well I'd just use the profiler

lament salmon
flint sage
#

Stopwatch in itself is fairly accurate but the way they're testing isn't

hushed moth
#

Hi, I am using webrtc, rendering the image on a material (skybox/panoramic e.g. skybox.SetTexture("_MainTex", tex)) and I noticed (profiler) when I start the stream then the GPU usage is going high (82% in profiler) RenderTexture.SetActive()
How can I lower the gpu usage?

undone coral
#

it's a red herring

#

especially if you are splitting work across frames or something

regal lava
#

Note: This function is very slow. It is not recommended to use this function every frame. In most cases you can use the singleton pattern instead.

#

I don't use them, but I can see them potentially being useful on scene loading. You can probably get away with using them in smaller projects, but once you've got a lot of stuff loaded, that seems awfully inefficient at finding the objects you want.

ashen shard
#

there are much better ways of getting references

#

[SerializeField] and as mentioned singletons to name a couple

#

because you don't have to do any finding

#

xD

jolly token
#

Outside of efficiency and performance, it is still bad practice as it hides dependency and rely on global state without context

#

It does. Both methods make your logic "everything can be accessed everywhere"

#

Which may easy at scratching but horrible when maintaining

magic ridge
#

IMO singletons are fine in specific cases yeah, but too much and it can get quite bad

#

ie "SoundManager" so you can play a sound easily.

ashen shard
#

but what is the best then?

regal olive
#

m

jolly token
hollow jay
#

I'm having a few problems understanding semantics in compute shaders, so if anyone can help that would be great:

[numthreads(32,1,1)]
void CSMain (uint3 threadId : SV_DispatchThreadID, uint3 groupId : SV_GroupID)
{
    //Use x and y of id to get position of Vertex
    uint i = threadId.x + groupId.x * resolution;
    uint x = i % resolution;
    uint y = i / resolution;
    uint mapIndex = x + y * resolution;

    float percentX = (float)x / (resolution - 1.);
    float percentY = (float)y / (resolution - 1.);

    vertices[mapIndex] = float3((percentX * 2. - 1.) * scale, 0.0, (percentY * 2. - 1.) * scale);
}

It seems that when the thread is not in group 0, threadId.x becomes 0. I tried to solve this by using the group's index, but that had the same result. Can anyone point me in the right direction to the cause of the issue? Thanks!

#

Oh, and here is the relevant C# code:

int groups = Mathf.CeilToInt(resolution / 32f);

//Dispatch shader
computeShader.Dispatch(0, groups, 1, 1);
maiden turtle
#

use them in editor scripts, serialize the references in arrays

#

is generally how i do it

hollow jay
timber flame
#

What data structure do you prefer to use for open set in A* algorithm?
SortedDictionary or Dictionary itself?

SortedDictionary
Retrieval (smallest f cost): O(log(n)), Add: O(log(n)), Remove: O(log(n)), FindByKey: O(log(n))
Dictionary
Retrieval (smallest f cost): O(n), Add: O(1), Remove: O(1), FindByKey: O(1)
or use both? store nodes in both

compact ingot
# timber flame What data structure do you prefer to use for open set in A* algorithm? SortedDic...

a priority queue (heap). As a matter of principle in implementing a performance oriented algorithm, you generally should not use general purpose implementations of data structures as they are in many cases wasting performance due to their generality. So if you bother to implement A* you should also bother to write or find fully optimised data structures for it. Big O is pretty meaningless for this purpose as well, you will care a lot more about performance on small sets and how big that O(1) actually is.

timber flame
#

and, isn't the internal implementation more performant? I mean .Net libs

compact ingot
# timber flame and, isn't the internal implementation more performant? I mean .Net libs

They are very good for the generic case but not optimized for any special case, the backing datastructure may even be theoretically optimal, but that is only the first line of optimization, ideally you want to allocate your own continuous region of memory for it and use all properties of your specific algorithm variation/expected data/use case to eliminate extra work that a generic datastructure would perform

#

it is generally not possible to implement a generic tree data structure that performs well for a wide range of cases. There is just no real optimization that is independent from the size and structure of the data actually contained in it.

blissful moth
#

hey can anyone help me on how do i connect the joystick to the weapon looking point like this..any help will be great thanks

inland delta
#

Better not to use this asset at all

blissful moth
inland delta
#

This "MoreMountains top-down engine" is not modular or easily extensible

#

Pretty coupled code

blissful moth
#

yes

compact ingot
#

TDE is a prototype engine, for a real game it gets in the way constantly.

blissful moth
compact ingot
#

if it’s not obvious how to set it up from the docs and ui, best not use it

blissful moth
#

yee ill check one last time if i can scrap something i can use

lone minnow
#

Hello I'm not sure if this is correct channel to ask this
I'm trying to build player by code and my target platform is dedicated server but it's unavailable in the old Enum only in the new Enum NamedBuildTarget.Server

#

So I'm unable to call BuildPipeline.BuildPlayer

undone coral
#

have you played virtual joystick games on mobile?

undone coral
#

another perspective is, retro doesn't make sense for mobile

jolly token
#

target should be standalone you're trying to build

coarse cave
#

Hello

#

is there i difference betweeen this ?

fresh salmon
#

First one will get input on your FixedJoystick, on the horizontal axis, going right
Second one will get input when you press W on keyboard

#

So entirely different

coarse cave
#

But in code-generel, there was no one capable of halping me

coarse cave
#

Can I send the code please, its a car controler.

lone minnow
jolly token
surreal quarry
#

Is it even possible to use transform.Translate as the inDirection for Vector3.Reflect, or does it require rigidbody.velocity to work correctly? My projectiles use transform.translate for movement.
I've been trying to implement a bullet parrying system for a game, but currently it works in a way that the projectile spawns from behind of the enemies that shot the projectile, after trying to parry it back at the enemies.
It's like the projectile spawns from a different world position after the reflect function.

jolly token
surreal quarry
# surreal quarry Is it even possible to use transform.Translate as the inDirection for `Vector3.R...
private void SendProjectileBack() {
//TODO FIX THIS
// The projectiles spawn from wierd position.
reflectDir = Vector3.Reflect(_enemyProjectile.transform.position, _normal).normalized;
_enemyProjectile.transform.Translate(reflectDir);
}
private void OnCollisionEnter(Collision collision) {
  if (!collision.gameObject.CompareTag("EnemyProjectile")) return;
  _normal = collision.contacts[0].normal; // get collision normal from box collider
  _enemyProjectile = collision.gameObject;
            // DEBUG
foreach (var item in collision.contacts) {
Debug.DrawRay(item.point, item.normal * 100, Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f), 10f);
  }
SendProjectileBack();
}
rugged radish
#

probably caused by local - world space mismatch
try using world space in that Translate (I assume you move the projectile somewhere else, because that code will only move it 1 unit away)

surreal quarry
#

yeah, I'm moving it inside the projectile script itself

jolly token
surreal quarry
jolly token
dapper cave
#

is RectTransform.hasChanged no longer working? It used to only be true if the transform changed

#

oh fuck, I know what's going on, UI autolayout is chaning the rectTransform every frame even when unnecessary... wow

misty glade
#

So, in my game I have this "radar" thing showing a planet that you're approaching. I've added a little static effect to it, but I want to add a little fake handheld camera movement to it, getting it to kind of wobble around in the frame. I've tried tweening it to a random point in a unit circle in a random amount of time, but it just looks stupid - like it's bouncing around.

Any ideas?

misty glade
#

(tweening to a random spot in the box for a random time between 0.1-0.6sec with an in-out ease)

jolly token
misty glade
#

I was sorta wanting to do like a battlestar galactica camera shake .. but.. it's kind of hard to emulate. I suppose there's a reason those animators have entire studios of people doing this shit :p

#

zooms, blurs, off-centers etc

#

lemme finish tweaking this shader and then lemme know what you think (I'm making the saturation come up as you get closer to the destination)

#

but as you get closer.. the flickering gets more sparse and the saturation increases to 100% - it's almost not noticeable until you hit the destination and see the next planet (fully desaturated and full flickering)

jolly token
#

I like the concept 😄 just the smooth interpolation between position kinda looks unnatural

misty glade
#

does that look good? bad? weird?

#

Not sure what to fiddle with any longer.. have been looking at it too long to see "the whole"

#

maybe the in-out circ ease should be .. something else

jolly token
#

IMO you don't really need to interpolate this kinda thing

#

Because it should look like sudden change

misty glade
#

oh, you're just saying .. "flick" it to a new location every so often..?

#

that... might be weird?

#

(I'll try)

jolly token
#

Kinda, I'd tweak with cooldown and distance

fervent parcel
#

Hello, in custom Editor, how do I go about making the Inspector scroll bar either hide or show permanently?

#

I am getting this jittery effect where the inspector resizes just because the bar disappears when I have smaller list size

misty glade
jolly token
#

But I am no artist 😿

misty glade
#

neither am i lol

#

ah well you know what? this is good enough, i've probably burnt like 3 hours just fiddling with this

jolly token
#

Lol

gray pulsar
# misty glade <@307360612403642370> not sure it's better .. thoughts?

Another 2c: I like this better than the original drifting, but I think it would be better if it blinked completely black for a second before repositioning. And the very small movements look better than the large movements.

How long is this going to be playing for, though? I feel like it'll be distracting if it is onscreen for long periods of time. If it is short, having the planet start small and grow bigger as you get closer could be another way to give it some movement. (I guess that might work okay even if it is a longer period of time)

misty glade
#

It's on the screen 100% of the time on the "idle" screen, but it's.. pretty small overall:

#

It shouldn't be too distracting actually, since most of the gameplay isn't "on" this page all that much.. you're taking care of your missions, seeing what upgrades you can buy, managing your crew, doing battles - all of which are on separate screens

#

you do come back here in between those things but .. mostly just to make sure you don't have anything to do

gray pulsar
misty glade
#

i'm doing a planet in the game space that grows as you approach already.. so I was sort of thinking the header there would be like a "radar" or something

#

but I wanted to do the planet growing in the game space kind of like EVE online (which I used to play) - ie, you pretty much don't see it until you're at 99%

undone coral
mint sleet
#

Hello folks!
I am coding and interpreter that sits in between my backend and unity.
I wonder what would be the best practice for model mapping? Writing each model in separate classes or putting them into, for example Models.css

maiden turtle
glass glade
#

i'm using this code to change the volume settings at runtime

ColorAdjustments colorAdjustments;
FindObjectOfType<Volume>().profile.TryGet(out colorAdjustments);
colorAdjustments.saturation = new ClampedFloatParameter(saturation, -100f, 100f, true);

the values are changing in the inspector, but are not visible in the game??

strange cradle
#

I've got an interesting problem......
USB Steering Wheel with pedals and H-Shifter (Logitech G29)
Works on the Unity player, in Unity....
But if I build to an Android, only the button presses are detected....???
I can't seem to pick up on the axis movement at all....(on the phone)
Ps. Connected via USB OTG.... I'm soooooo close, I can taste it!
Button presses are working!!!
I just need to figure out what input Unity is expecting for the axis to work?

maiden turtle
maiden turtle
strange cradle
maiden turtle
#

I've tried Rewired, I know this lib supports virtually any input device. But find out whether your thing is supported simply by unity first since you already have most of the setup

strange cradle
# maiden turtle I've tried Rewired, I know this lib supports virtually any input device. But fin...

Oh I see... Yes! I think it's supported....
I base that on Unity detecting movements when looking at debug log, and moving the wheel, from the Unity Player...
And also, when clicking the "Listen" button, in the Input Actions pop up, Unity detects both button and axis movements....
Everything seems to work great on the PC....
But when deploying to the Android (Real Device) then we lose the Analigue Axis (Pedals and Wheel), but all buttons are working fine on the Real Android Device (Showing it's not a usb connection issue)

glass glade
strange cradle
# glass glade can i trigger an update by code? or how would this work 🙂

I would put the code inside a method, and call that method...
For example, you could put all your Update code in a method called MyUpdate()
And then in the Update, you can call MyUpdate(), and then also anywhere else in the code too....
But, I feel like I shouldn't tell you this, because... I dont know "why" you want to do that... and there may be a better way to do what your trying to achieve...
This is just to answer you directly "How can I manually trigger an update by code"

maiden turtle
#

there's also OnValidate, which gets called when any value changes

#

you can use that if you don't need granular update info

glass glade
#

thanks a lot for your help so far 🙂 I think I explained the problem wrong, I want to decrease the saturation base on how much health the player has left, the inspector wont matter. The problem is when I try to set the saturation like before, one can't see any changes on the camera. In contrast if I decrease the saturation on the inspector manually the saturation decrease appropriate on the camera

maiden turtle
glass glade
maiden turtle
#

maybe even SetDirty the camera

glass glade
#

thanks for your help 👍 , found the solution
use colorAdjustments.saturation.SetValue(new ClampedFloatParameter(saturation, -100f, 100f, true)); rather than colorAdjustments.saturation = new ClampedFloatParameter(saturation, -100f, 100f, true);

cerulean scaffold
#

When I know that two floating point values should have the exact same value,
is this a valid approach to verify that they are indeed exactly the same?
aFloat.ToString("N16") == bFloat.ToString("N16")

sly grove
undone coral
cerulean scaffold
# sly grove if you want to check for them to be exactly the same just do `a == b`

I have a case where .ToString("N16") shows that two numbers are exactly the same, however when comparing the floats with == the result is false.

var mismatch = hashMessages
                .Cast<HashMessage?>()
                .FirstOrDefault(_x =>
                    _x.Value.VirtualTick == _message.VirtualTick &&
                    _x.Value.Hash != _message.Hash
                );


            if (mismatch != null)
            {

Debug.LogError(
                    $"Hash mismatch found!: Virtual Tick {_message.VirtualTick} with hash {_message.Hash:N16} has encountered hash {mismatch.Value.Hash:N16} with an approximate difference of {(_message.Hash - mismatch.Value.Hash):N16}"
                );```
`Hash mismatch found!: Virtual Tick 4 with hash 553,5958000000000000 has encountered hash 553,5958000000000000 with an approximate difference of -0,0000610351600000`
sly grove
#

why is your hash function producing a float anyway?

cerulean scaffold
#

It's so I can see how big the difference is

cerulean scaffold
# sly grove they are different

Isn't this correct?: Floating point numbers only have 7 digits. All other digits are always 0.
How then can 553,5958000000000000 be different from 553,5958000000000000?

devout hare
#

That's not correct. Floats are accurate to up to 7 digits. Their decimal representation can have any number of digits (including repeating to infinity)

sly grove
#

they aren't actually represented in base 10 at all so some idea about how many digits they have in base 10 is not really meaningful

#

Try this @cerulean scaffold :

bytes[] b = BitConverter.GetBytes(hash);
int i = BitConverter.ToInt32(b, 0);
Debug.Log("data: " + Convert.ToString(i, 2));```
devout hare
#

but as said, producing a float as a hash is a bit strange anyway

sly grove
undone coral
cerulean scaffold
cerulean scaffold
sly grove
#

bad idea

#

this will never work

#

due to hardware differences you will simply not get the same results for floating point arithmetic on different machines

#

same CPU architecture isn't the issue

#

Even different CPUs with the same architecture can and will give different results.

#

If you want to do lockstep networking you need to be doing fixed-point math only

cerulean scaffold
#

I do most of my calculations with DOTS jobs but I could have missed something.

undone coral
undone coral
#

in any case the language and architecture do not make things any easy for lockstep determinism

cerulean scaffold
#

Thanks for your help @sly grove, @devout hare and @undone coral !

cerulean scaffold
timber flame
#

To find k closest points from a point, the best way is to use Octree/ Kd-tree?
There is a 3d array and I would like to find k closest points (specific id) from a point.
Also, these points are chunk based. The easiest way is to keep the target points in chunks and then for a point, find its chunk, then the adjacent chunks and finally find the closest ones
(Points are Vector3Int) grid games

#

Suppose there are a bunch of specific items in the world and I want to find the k-closest items

pine pendant
sly grove
#

That's what Photon Fusion does

pine pendant
#

Does unity have a deterministic physics engine?

sly grove
#

Havoc

#

But it doesn't work with GameObjects, only with DOTS

pine pendant
#

does unitys current netcode solution support dots?

sly grove
pine pendant
#

Thanks for the help though with havoc

#

one step closer

rugged radish
#

not even that small n, I don't remember the exact numbers from my benchmark, but it was in the thousands

timber flame
#

it is 3d

#

Can I use octree with chunks? or it is not required?

#

point in a chunk, then find the adjacent chunks and then use octree or directly use octree and find k-closest points

rugged radish
#

I only benchmarked k-d tree vs chunked, so can't say for sure

#

and in my case, I had 2d k-d tree
it scales better with dimensions

placid jacinth
#

Other channels occupied, will put this here:

Just wondering if there is an alternative to Coroutines that I can use on a class that is not derived from MonoBehaviour?

Creating a library function and therefore don't really want it to be a component, but I still need something to occur over time not immediately.
:o

wintry wind
#

LeanTween?

#

If not, they actually do something like you mention so maybe you can check their code

stray pewter
#

I'm not sure if this is "advanced" (sorry) - but is there any way to interrupt a gameObject from being disabled and do something before it gets fully disabled, eg. run an animation?

stray pewter
west scarab
stray pewter
#

@west scarab thanks anyway!

hushed fable
#

You are likely to make your code incompatible with WebGL when using Threads and Tasks, while UniTask should fallback more gracefully and avoid certain threading APIs that Tasks sort of implicitly rely on.

sinful fossil
#

Does anyone know if we can add type specific methods to a class that uses a generalized type?

class Test1<T>
{

}

class Test1<Color>
{
    public void Blur()
    {

    }
}

The example shows a class being redefined and type specified (I know that is wrong). Is there a way to do what I am trying to do?