#archived-code-advanced
1 messages · Page 18 of 1
So, in essence, it’s an engine limitation?
Yeah but I dunno about the 16k x 16k figure, I feel like a lot of games have more
as to storing the map, you could store it in chunks all in their local space, but with a world offset
its a limitation of digital computers
Well 16 K is arbitrary without defining a unit of measurement, and a scale. Right?
well, they dont
human scale
so meters
The example of minecraft which has like, 60 milllion in diameter plus a z axis of like 255
those that do, use a floating origin but that is super annoying to deal with
I mean within the virtual world. Defining what 1 m is on the screen.
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
it doesnt really matter how big 1 unit is
Yeah it's more the number of units
its still taking the range of 1 from that float
Terraria has like, 17000 x 5000 or something?
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
Ah, nevermind apparently it's 88920 x 64600
and you will start to see glitches in the mesh
certainly using floating origin
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
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
is unreal 64 bit?
Doesn't that depend on the build? Anyway here is a ball at 45k in unity
you need to move it to see it
According to Google
actually you can see it without moving this is at 16k
doesnt mean the coordinate system uses 64 bit
unity is a 64 bit app too, but all the graphics are 32 bit
Oh, I see.
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
Well yeah, comparing floats to each other won't work very well
but then, shouldn't do that in the first place
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
As far as I just read, UE5 now handles double precision coordinate systems.
anyway, make a game keep everything within 8k from the origin and you're fine
so we will get even bigger, more empty maps now 😄
iirc UE5 will also do floating origin automatically (as part of the world streaming)
In our case our physics started going wonky after numbers reached 800k
wouldn't floating origin mean physics wouldn't go wonky ever?
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?
I mean it could anyway
AI and procgen will only ever produce self similar environments
don't need machine learning for it
you can get away with it to some extent but an engaging environment will always have to be handcrafted
Machine learning is like a hammer and every programmer that touches it goes around seeing nails everywhere
ML wont solve the lack of creativity problem
The original Ultima Online actually had this
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
which is a 1997 MMO
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.
It doesn't really sound concrete
you are imagining the perfect game that has been on the "want to make" list of every gamedev since 1985
such a game will never exist
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.
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
no
Short and sweet lol
Still though, gotta warn ya, we all have that same exact idea
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
ML dialogue in games could be fun though
ML dialogue would be meaningless
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.
why would you care about dialogue that is inventend on the spot with no relation to any other systems in the game
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
I’m gonna have to look that up.
ML can interpolate
thats all its good for
if you interpolate too much, you get ugly artefacts
Yeah, sure. It's not great. But it's a step up from npc repeating dialogue
superficial improvement really
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
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
AI tricked me into watching WIDE PUTIN 10 HOURS meme
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.
Why do you think machine learning will help you in this case?
Why not just use, say, utility AI
You can hardcode things like movement and interaction, and let a reward/punishment ML system govern the actions and evolution of the entity behavior.
Yeah but why do you think that would be engaging to interact with?
but you do not specify at all what ML contributes to that
not to mention, how do you define "good" or "bad" for the ML?
and what data would you use to train it in the first place
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.
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?
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
There are tons of tutorials on YouTube from complete beginner to extremely advanced.
Maybe we can help if you have a precise question
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.
That is a common misconception
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
Right. And if the entity can learn to access code that was not inherently accessible to it, you can create unique situations.
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
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.
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
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
That is also true for machine learning
every entity would react the same to the exact same stimuli
Not if the weights aren’t the same though.
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
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.
Right but that is already doable
no machine learning required
dwarf fortress does stuff like this all the time
I’ve heard of that game, but I’ve never looked into it. Perhaps I will now.
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
So the AI gains traits that begin to form their personality and influence their decisions and reactions?
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
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
What do you mean by fakes being a player?
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
So basically how a chess computer works?
the state space of a MMO is way too large for an AI to learn it
I guess a Chess trainer to be more accurate
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"
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
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
created its own data
self taught by knowing the win condition of the game, not really self taught
yes, but that is a classifier
it wasn't taught the win condition it was just told if it won or not
it did not come up with the idea of winning
which is the whole point of creativity
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
it interpolates between winning and loosing and invents a game inbetween
you also need access to resources google has to make something close
don't get confused by the convolutions inside the interpolation, the rules are the A and B
it will take forever to train it on consumer hardware
realistically you need a good dataset, most likely marked
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…
I'm a capitalist, but the bottleneck is capitalism. It rewards terrible games with profitable monetization strategies (skinner boxes), disincentivizes risk taking.
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.
When Many enemies come to attack the player and when they collide with each other they go into this kind of drizziness state. I am using Aaron's A* package.
Here is the code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I haven't looked at your code, but my first guess is that as soon as they don't move they face toward the camera. They alternate between not moving and being able to go a pixel toward you, so they snap back and forth between these two states.
Yes, actually the animations are flickering. Initially, I passed the directions to the animations of the enemy but they were flickering all the time then I used the smoothed velocity to tackle this problem and it worked but when they came at the same time and collided it started to flicker again.
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
There is no idle state there are just horizontal and vertical blend animations.
It is flicker between horizontal and vertical movement basically
i forget, is it possible to translate the physics world bounds and resolve this issue?
no, you'd have to move the stuff in the scene so player and stuff are closer to the origin
I don’t think creativity of the old days has really gone anywhere. Indie and ”AA-indie” are at least as willing to try something different as AAA of 90s was and the budgets are comparable (not to mention you often can do more with similar value adjusted budget)
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)
You could make a component that on enable fires a static event with the reference. Put that on all objects you want to track.
Doesn't quite work here. I'm doing this for a modding project, so I would largely need be able to do this purely through runtime logic.
I don't suppose there's any way to hook into the GameObject lifecycle
Not from the outside
you can check every frame and compare to the previous one
don't overthink it. it isn't cpu heavy
you're modding my bro. it do not matter
is it okay to ask about modding related things here? 
anyone knows how to fix this ?
i just have a start function with this line
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
because my unity is crashing trying to add a MonoBehavior to a GameObject at runtime on Linux 😭
did you do what the error suggests?
yeah
I mean I imagine doing a FindAll for gameobjects 60 times a second is a bit much
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
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
Is it possible to calculate childs world rotation from local rotation?
Well i'm sure it is, but does anyone have an idea how
no need to calculate it a GameObject contains both
Yeah but
I have localRotation values
I wanna calculate into world rotation values
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
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?
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
here's an example for Blender -> Unity: https://forum.unity.com/threads/converting-positions-and-rotations-from-blender-within-an-internal-tool.1092433/#post-7046887
It uses right handed y up
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?
no, if you want to use threads, use Tasks or Jobs
Well, that was fast
The Coroutine will always run on the main thread but I suppose it would be possible to start a new thread from within the coroutine to do the actual processing
that would be great
becarefull though because most Unity API calls will only run on the main thread
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
Something like this should work
IEnumerator StartThread()
{
ThreadStart newTh = new ThreadStart(myMethod);
Thread th = new Thread(newTh);
th.Priority = System.Threading.ThreadPriority.AboveNormal;
th.Start();
yield return new WaitUntil(() => !th.IsAlive);
}
void myMethod()
{
}
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
Thanks, will try to make it work
one way is use ECS
other ways depends on what you are trying to do
with that singleton
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
i have a Managed Dll and i should be able to access it, but unity says it can't find it at runtime
@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.
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
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)
wdym by "each color"?
how would you classify a given pixel as a color?
there's like 32 million possible colors for each pixel right?
basically I need to know if there is more orange or blue in my scene and for that I use this material:
you'll need to classify each pixel as being "orange" or "blue", probably by converting the RGB to HSV and bucketing the hue
(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?
wait you're talking about scoring for a splatoon like game right?
Is this like a game jam people are doing? THere's been like 5 people asking about this lately
exactly
you need to just do that analysis on the splatmap texture or whatever you're using for painting
oh
nope
Oh wait duh I know why, it's because Splatoon 3 just came out recently.
probably i guess
I guess Splatoon will become the new Backrooms like Dani-Grappling-Gun-Mechanic before it. 😆
Seems like the shader you're using doesn't have a texture called "Mask"
It's not guaranteed to be a Texture2D. It could be a RenderTexture too.
Otherwise it would just return Texture2D
See the properties of it
How can I do this? I don't understand what this mean
Yeah that
yep that'll be the one you use in code
you're at the start of a long journey
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?
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?
what is your objective?
hmm
i'm describing another approach
do you know where the code is that paints the ground?
this is an xyproblem
you already know how much paint was added or replaced, it's in the code that paints the ground
did you find it?
what's your objective? what is the code trying to do?
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
have you looked at the code?
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
you can use the exact approach of counting the pixels, pixel by pixel
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
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
that's why I can't tell when the blue ink covers the orange ink
?
you also have a reference to the texture elsewhere
it's in the code. you have to read the code!!
I need a loop that sends some data, enclosed in a internal class, so that I can "hide" it inside a library. Since the class is internal, it cannot inherit from monobehaviour, thus no update and no StartCoroutine
@blissful bay if you use the code snippet that was shared with you as is, it is going to crash your editor
And the task is demanding, so I need to have it in a separate thread
what does the code do?
what is the task?
you're authoring a library for someone else? or what is the idea?
Yes
Reading camera output, chunking it up into packets and sending them to a remote java application
I have a non-DLL version working, I have a DLL non-threaded version working, but I cannot combine then
as in a Camera, not the webcam right?
Ye, sorry
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
Not necessarily a web page, an application
instead of my guessing
like what is thea pplication? you've almost helped me understand
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
i make a unity streaming technology, i probably know more about this than anyone. i'm asking a really basic question
there isn't anything sensitive about what the application is
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
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"
oh
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
Im making VR educational software and I want to stream what the teacher to see what the students are doing etc
lmao
it took 10 minutes to get to that
sorry for me being a lil dumb
are you a student?
ye
okay
honestly really new to all this "backend" stuff, I mostly do the gameplay logic
not a hard one, why?
you're on the start of a very long journey
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
understandable, lmao
to see where you are in this journey
from the outside
this is a pretty good illustration
do you see what i mean?
I do
so
so, how much difficulty does the threading add to the task?
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:
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
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)
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
Waaay off
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
Which part are interested in, the sender itself, or the camera capture?
so in this code, we're taking a screenshot every second
and uploading it to a remote server using a simple http post
I'm looking at at least 25 FPS
that remote server can be a standards based one
Ideally 60
this is beyond your abilities
i mean, you can get there eventually. you would first have to scrap pretty much everything you already have
The script I already have already works in production tho
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
why are you saying stuff like this
Because
lol
It is the truth
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
Wait, let's get one thing straight, as I think we are missing the point
What do you think is the issue I have
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
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
This is true with the old script, not the new one
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
It does, but I cannot turn it into a library
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
Yes it does
The streaming works, but I need enclose it in a library, so it can be a marketable product on its own
you're saying the streaming works...
what is working according to you?
you keep saying "working"
I am receiving JPGs at preset frame rate and dimensions
Doesn't need to be 144fps for the target use
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
Im comparing your code to mine, Im usind UDP client to send the data
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
I am absolutely not denying that
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?
I am
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
the thing is - this part has been written by my colleagues and tbh I dont see a reason to rewrite it
i am really not trying to bully you into doing anything that doesn't make sense
one perspective is that 3 developers do not do 3x the work of 1 developer. sometimes it adds up to less than 1 developer
what would be the benefit of changing a working piece of code?
you're using that word again 🙂
let me reword that then - what is the benefit of changing a piece of code that does what it needs to do?
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
there is one more issue - this is a commertial product, not a school project
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
yes
you can afghan space program
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
alright, thanks for your time and sorry for being a dork, lol
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
and I am trying to apply your advice on what I need to do
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
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
There will be many CustomRigidbodies, but not many GravityVolumes
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?
An open forum for users of PlayFab to get answers to questions and to provide feedback on features and add-ons they'd like to see.
this was the error i was talking about
anyone know why this interface isnt available in Unity.Jobs
Do you have the package installed?
Burst package?
Jobs package
there's nothing like that in package manager
I think by "kernel" they're talking about the compute shader "program"/"function" itself which are referred to as "kernels".
in 2021.3 is Mathematics still dog slow compared to Mathf?
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
oh boy, thanks for the heads up 😅
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
What are you testing?
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)
whats wrong with events?
as PraetorBlue said, it's a compute shader kernel
I should've worded that more clearly
I'd guess you need to make shader variants then, use ifdef and defines to make the buffer optional
gave it a quick read, looks like it would work, but also sounds painful, considering how small the issue is
thanks 👍
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
it's either internal optimizations or better code generation, totally possible
one or two functions got inlined in some hot loop
+200 speed
I see....
thanks
they don't - but a decoupled architecture that achieves its decoupling by using events will be easier to test
Is it? Test setup for events are pretty fussy because their async nature
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.
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 🤔
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
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
I guess it is code smell because it means your implementation is aware of test?
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?
I doubt that is possible in o(n) unless you already have analyzed the mesh before hand
what data do you think i would need to generate for the mesh
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
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
And for same reason you are sorting looseVertices which is actually indices?
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
Hmm you could keep your deleted vertices as empty spots, keep your indices unchanged, and when you need to add vertices fill from empty spots.
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
I need to remove them because otherwise Unity will consider them when creating MeshCollider convex hull
Or you could set all of them as one of your valid vertices
How to get all gameobjects in the scene in C#7.3 (not 8)
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?
Why would C# version matter? https://docs.unity3d.com/ScriptReference/SceneManagement.Scene.GetRootGameObjects.html
"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
Then don't use range operator
But how can i get all gameobjects in the scene without using a range operator?
Why do you need range operator, I just gave you a link
@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
Either way this takes 5ms in debug mode when previous took 18ms
I have an issue with pun2 after changing my build to uwp, is this the right channel or should I use #archived-code-general?
#archived-networking ? or photon has own discord server
why?
are you saying there is a performance regression in 2021?
huh
why is #archived-networking in the simulation category I collapsed that like a year ago and haven't opened it since
thank you
Hey yall I have a big project
and your skill level is?
Oh I am a producer of a project
I mean how much experience do you have with gamedev
Your profile says you're 21
so you're sure you're ready to handle a "big project"
having 4 years of experience at 21 is normal
I have been through many projects before big and small
alright then good luck
But i am looking for some programmers and I found this server
I wouldn't count it as professional experience but yeah
I have 4 years and I started at 13
Don’t downplay because of age
I am gonna be honest I am not a professional at this
I had friends make tens of thousands of dollars
years of experience don't even mean that much because it's all up to how much you've actually learned in them
but I have experience to be able to head into a new direction
Yeah it’s just his reason is when he started and not the one between
why what
so you hire people to do all the development job?
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
and what do you do exactly
you mean the language or what game
That's like minimum wage, sure
Can someone really say what to do in a big project if they didn't experienced professional environment
I mean like at 16 that’s a lot for a month
what work do you do in the project? do you do 3d modelling? programming? sound? game design? animation?
They dev on roblox so they make a lot more money but the games are more cash grabby
oh I see what you mean
oh yeah, that's roblox nowadays
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
Roblox is a highly commercialized platform so it's almost all about money really
Yeah
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
so you're just overseeing
if that's the words you want to use
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
The languages involved are C#, JavaScript, and maybe some Python
if you are interested in trying out for the project you can DM me
^
Wait how did you
that's where you go if you want to hire
Oh that’s an image
I had 4 at 13
As a writer it is highly offensive to be caught off guard in such a way
I shall log off for the day
ok
I am writing code that removes loose vertices from a mesh.
why this part? what is your objective?
im writing an implementation of a mesh splitting algorithm
there should be libraries that do this
ah
and fill the holes
to learn something
you might want to look at poseidon CSG
"CSG" is the name for this class of mesh operations
like boolean operations
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
this is alright
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
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));
}```
do you call this in FixedUpdate?
also this should probably go in #💻┃code-beginner
okay, but do you have a solution?
not really
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!
For my active ragdolls I setup them with ConfigurableJoints, and these extensions make settings their target rotation easy:
https://gist.github.com/mstevenson/7b85893e8caf5ca034e6
Nevertheless you will be doing a lot of tweaking
Ah ye, I'm also using ConfigurableJoints and have my guy standing upright... though I'm totally cheating by constraining the hip rotations. Though I guess my questions leads to how do you get the character to get up again after falling down?
This is what my Active Ragdoll looks like so far. With the puppet on the left.
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
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?
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:
- The
Sourceskeleton, that always runs animations and yes, usingAlways Animating - The
Physicalskeleton with Rigidbodies & ConfJoints, that copies target rotations to each of it's bones fromSourceskeleton
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
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. 🙂
In my own project I use a separate AnimatorController when the character is in 'Active ragdoll' mode, just for custom sets on animations when physics are enabled, so yeah thats a possibility
A lot of this is so usecase specific that you just have to try a lot of stuff out
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.
My characters are fully animation driven by default, but when they get injured/die, the active ragdoll activates, and the source skeleton plays appropriate hit animations
Okay that makes sense, performance would tank otherwise. 🤣
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
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...
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...
When you are trying to get back up, are you still in active ragdoll?
I got some work to do on that part still, but it's a blend from physics back to normal 100% animated
Alrighty, yeah this sounds like my mindset was in the right place. Thanks, I really appreciate this!
( I have lunch, gotta go eat 🍔 )
happy to help, it's a pretty niche thing that no one seems to discuss much 😁 bon appetit!
Woah that’s some accurate looking collider sizes, did you use unity’s default Ragdoll builder?
I used the Ragdoll builder then throw away their character joints. I did have to tweak up the sizes just a little bit.
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. 🙂
Does RegexOptions.Compiled work well in IL2CPP?
Thought to share where I was with a vid. 😄
might want to start by trying larger damping values, to avoid the shakiness. Idk how active this channel is but theres always #⚛️┃physics
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
oh my god they are alive
Can I set render order by render layer rather than material type?
under the hood, where does transform.localscale get its info from to determing the xyz scale of an object?
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
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 ?
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
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
Hi, can comeone tell me why consecutive calls of a function get faster?
Is the mesh data getting cached somewhere?
Could be a warm-up effect
Ah, I see, thanks
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?
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
Well you're only doing one iterate so you're prone to outliers
unity has built-in performance testing: https://docs.unity3d.com/Packages/com.unity.test-framework.performance@1.0/manual/index.html
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
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
You're probably right but we can't know since it's not a reliable way to test 😛
i run this in update on button press
well I'd just use the profiler
Im curious, how is Stopwatch inaccurate?
Stopwatch in itself is fairly accurate but the way they're testing isn't
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?
i think because the first one is called when there is something in the editor slowing things down
it's a red herring
especially if you are splitting work across frames or something
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.
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
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
are you using burst? If so it's possible it hasn't compiled until the second time. You can force this to not happen via Jobs/Burst/Synchronous Compilation
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.
but what is the best then?
m
Dependency injection is most generic solution widely used to resolve this kinda issue
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);
use them in editor scripts, serialize the references in arrays
is generally how i do it
Update: I fixed the problem. I was supposed to be dispatching (resolution * resolution) / 32 groups, not just resolution / 32
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
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.
Yes, thanks. Heap is more efficient than Red-Black tree for this purpose (open set in A*)
but to know if a node is in the open set or not O(1), a hash set is required, right?
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.
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
Better not to use this asset at all
you mean this?
This "MoreMountains top-down engine" is not modular or easily extensible
Pretty coupled code
yes
TDE is a prototype engine, for a real game it gets in the way constantly.
the mobile controls are very buggy just wanted to know how they did this ..cant get through that code
if it’s not obvious how to set it up from the docs and ui, best not use it
yee ill check one last time if i can scrap something i can use
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
is this exact demo scene not visible?
have you played virtual joystick games on mobile?
retro genres are coupled
another perspective is, retro doesn't make sense for mobile
You can build dedicated server by setting subtarget to StandaloneBuildSubtarget.Server
target should be standalone you're trying to build
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
Next time in #💻┃code-beginner or #archived-code-general, not an advanced question
I am sorry sir
But in code-generel, there was no one capable of halping me
I have a script. When I use the KeyCode.W the code works just fine. But when I use the FixedJoystick, the functions are being called too, but nothing is happening
Can I send the code please, its a car controler.
I'm really trying to aim into dedicated server as It would help me better
That's how you build dedicated server, are you saying you have problem applying it?
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.
You should share the code, Reflect is just mathematic calculation
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();
}
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)
yeah, I'm moving it inside the projectile script itself
You are putting position as argument of Reflect, it should be direction
what would the best way to the get the projectile direction? Since I want to use other projectile types for the parry system too
Using the same value you are using to move the projectile
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
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?
here's the shader "flickering" i'm using.. might be a little hectic, I'll probably turn that down a smidge
Sigh.. this looks janky as heck. Any ideas?
(tweening to a random spot in the box for a random time between 0.1-0.6sec with an in-out ease)
Shader looks nice. If you wanna make it look like it's having connection issue, I don't think tweening would be good for that (too smooth). maybe just teleports with smaller range?
this one looked good
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)
a little long, sorry
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)
I like the concept 😄 just the smooth interpolation between position kinda looks unnatural
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
IMO you don't really need to interpolate this kinda thing
Because it should look like sudden change
oh, you're just saying .. "flick" it to a new location every so often..?
that... might be weird?
(I'll try)
Kinda, I'd tweak with cooldown and distance
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
@jolly token not sure it's better .. thoughts?
Hmmmmm yeah I think the sample one looks nice because it matches with timing that it jitters & only moves little bit horizontally
But I am no artist 😿
neither am i lol
ah well you know what? this is good enough, i've probably burnt like 3 hours just fiddling with this
cuz now i'm making easter egg cows flying in space
Lol
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)
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
mmm, in that case I think the planet growing as you get closer instead of jumping around might be kinda cool
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%
use
var noise = amplitude * (Mathf.PerlinNoise(frequency * (Time.time + offset), 0f) - 0.5f)
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
an interpreter of what? what sort of model?
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??
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?
it's either not reread each frame, some calculation involving it having been cached, while setting that value via the inspector does not trigger any sort of update event. or you're looking at a wrong object in the inspector
afaik unity's new input system's input device support is still worse than some 3rd party solutions, check if the device is supported at all
I've been reading the same....
I have no experience with the old system (or any input system to be honest, im usually just point and click style)
But at this stage, I'd be happy to do it in 'any' way that works...
I just need the values coming from the pedals and wheels 😢
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
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)
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"
not by setting thing in the editor directly. you have to either read from the inspectoror every frame, possibly checking if the values have changed, or wrap the input boxes by using a custom editor, triggering an event after setting the value manually
there's also OnValidate, which gets called when any value changes
you can use that if you don't need granular update info
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
you're setting it on a wrong object probably
hmm I only have one volume active in the scene. The value for the saturation on this object is changing in the inspector but wont affect the camera
it uses a custom editor. it might not be linked directly to the field. you may need to SetDirty, or something like that
maybe even SetDirty the camera
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);
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")
if you want to check for them to be exactly the same just do a == b
if you want to animate volumes robustly, you should create a volume with the saturation at the max color value you want, and then modify its weight
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`
they are different
why is your hash function producing a float anyway?
It's so I can see how big the difference is
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?
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)
"floating point numbers only have 7 digits" no not correct
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));```
If you want to compare two floating point values to see if they're practically the same disregarding rounding errors, there's https://docs.unity3d.com/ScriptReference/Mathf.Approximately.html
but as said, producing a float as a hash is a bit strange anyway
most hash functions are "chaotic" in that a slightly different input should give drastically different outputs. "Difference" in hash outputs is generally not meaningful. Unless you are using a different definition of "hash" than everyone else.
are you trying to synchronize a float seconds in a multiplayer game?
Not seconds, I'm just trying to check if all clients connected to the host did some calculations with the exact same result each tick.
(It's for determnistick lockstep networking)
Yea I know that a float is strange as a hash.
I just need to ensure that some calculations result in the same floating point numbers (on two different machines with the same CPU architecture).
And it looks like there is a difference for some reason.
No
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
Yea, or if I use DOTS jobs for all my calculations it should also be deterministic
https://forum.unity.com/threads/dots-determinism-not-yet-or-is-it-restricted-some-tests.846991/
Floating point in burst is deterministic on the same architecture.
I do most of my calculations with DOTS jobs but I could have missed something.
It's for determnistick lockstep networking
what's your objective?
Floating point in burst is deterministic on the same architecture.
i think we discussed this last time. they didn't test it well enough to know
in any case the language and architecture do not make things any easy for lockstep determinism
deterministic physics
Thanks for your help @sly grove, @devout hare and @undone coral !
Btw, here is the actual difference between the two floats:
1000100000010100110011000100001
1000100000010100110011000100010
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
How would I replace the unity functions like physics.raycast() with a fixed-point version?
you'd have to use a custom fixed-point or deterministic physics engine
That's what Photon Fusion does
Does unity have a deterministic physics engine?
does unitys current netcode solution support dots?
Good question to ask in #archived-networking and/or #archived-dots
depends on the number of points, and space dimensions
I needed the same thing, and after a certain threshold k-d tree was greatly outperforming full scan
for small n, chunk scans will be faster
not even that small n, I don't remember the exact numbers from my benchmark, but it was in the thousands
yes, thanks
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
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
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
LeanTween?
If not, they actually do something like you mention so maybe you can check their code
Task
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?
to expand on cathei's answer - you can use C#'s Task or UniTask to do async/await style coding - which is very similar to coroutines - UniTask has some Unity specific improvements
I don't think there is a Unity native way, I think ideally you would call an async function / coroutine that plays your animation, then disables the game object.
yeah - interacting with another API that causes the gameobject to be disabled, was hoping I could hack my way around it.. oh well
@west scarab thanks anyway!
Threads? native to C# i believe
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.
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?