#archived-code-advanced
1 messages · Page 52 of 1
but i decided to settle on Netcode for fame objects
but it doesn't make sense without all the other pieces coming together, especially polish
yeah I agree, most our games are going to be simple physics based one button games
think racing games and simple top down shooters
in this framework, you stream all the players from a single unity process. they all have different cameras, screen resolutions, inputs, or whatever. but you engineer a local multiplayer game, and the simplicity of that, including plain physics and something you can easily test in editor, and then you get poof, a multiplayer game
a production example of multiplayer - https://appmana.com/watch/oreo
from a project that uses this
i'm not saying this makes sense for you, but this is to provide some background on the advice i can give
interesting, you made this?
yes, a colleague and i. mediamonks, the studio that made that little clicker oreo game, was 1 guy and made a bug free instant matchmaking multiplayer game in 5 weeks
I was originally between writing my own UDP game server, and protocol with ProtoBuf
An AppMana Streaming Experience
here's one with a car. it's not multiplayer, but you'll get the idea
this is only possible because there's no networking. i mean it is networked, it is you receiving a video, and you send back inputs, and so two people can be in physically remote locations and it Works. but from the point of view of what you author, it's a single unity process, with two players in it, and it uses bog standard unity features to make it all work. so setup is 1 script
if you want more players, you literally duplicate them.
interesting, whats the latency on something like that
(assuming the server is close to the clients)
i guess you should try to drive the car there and see if it matters
but no, i wouldn't make an fps on this platform. the latency is XXms, and after a million people have visited these experiences, it still didn't seem to matter, as based on an original test on 1,000 players. you will probably experience 40ms in the US.
yeah, at least on mobile the latency is way too high for our needs
the million people came from FB and instagram - these are used to make branded minigames that roll inside social media
think about this carefully
i think people in the know, who have actually tested this stuff, like the unity parsec folks i met just yesterday at GDC, all agree that this is an overrated concern
Well if you can bundle local latency prediction with this that would be amazing
but you mentioned its just a video stream essentially
what i'm trying to say is for a real audience, there was no statistically different level of engagement between 40ms and 180ms
kinda how those game streaming softwares work right
which is about the range of experiences
it is a valid concern, it is just one that has been investigated and turns out not to matter as much as it seems
yes, but those tend to take a long time to load
the games we are trying to build are going to be inherently competitive
games that are easy to learn but have a high skill cieling
well, it's going to take you 1-2years to have something built in unity that compares to say, what CIE games has.
i am not saying this is right for you
yeah probably
i am giving you my background knowledge, that i have thought about this a lot
that is a more realistic estimate*
Appreciate the insight
usually when people hear that they tune out everything else i have to say
indeed lol
you are not going to have a working realtime multiplayer game that is robust like a CIE games racing game is
in a year
that's just reality
our racing game is super simple
i can ping people on this chat too, whom i say these sorts of predictions to, in case you doubt my assessment
everything sounds simple in principle.
one of the worst places to be is to do this sort of psychological warfare
you've hit the things on the bingo card
to psych yourself into doing this sure
and yes, a lot of games still get made if it takes 2 years instead of 1y
that's fine
that is the journey ahead
Makes sense, but we do what we gotta do, even if it takes 10+ hours a day 😵💫
there's a reason there are few realtime multiplayer competitive games generally. and the ones you play are made with multi-million dollar budgets. and here's the thing, if robust doesn't matter, make a simpler game
that's what i'm trying to get at
since you said there are two objectives
pick one.
some of the other games we plan dont need to be realtime
a crypto game does not need to be competitive, or even good
i am really familiar with the shape and size of goals that are achievable in short time frames
we are trying to establish a skill based real money gaming platform
it's pretty much my supreme superpower
so you can tell me a concept, and i can nail for you how long it will take you to make
id love to speak about this in Dm’s maybe at a later time
righ tnow i'm hearing "thing that has to work in browser" and "be multiplayer" which is already 3 months minimum
lol
I can do a short pitch or something, if you’re interested
but not rn, as I’m currently not home / texting from my phone on the train lol
yes feel free to message there. that's fine lol
yeah I sent u a friend req
Ill dm u within an hour or two
but appreciate all the insight
my parting message: when staring at 1y, and the focus is sort of on something that isn't going to be really responsive / knowable, like the success of a crypto skill based gaming platform... it's better to just spend that year doing something original and failing, but spending every day trying something new
as opposed to say, delivering something small and very robust and polished, but which has no new ideas and is not fun and has no audience, or its audience is there for a different reason
if you're going to do psychological warfare on yourself, do it for something hard in the sense of requiring both your intelligence and serendipity, instead of just say, serendipity alone (whether or not a cryptocurrency platform sticks), or taking a bunch of adderall.
Hi, is it possible to create a dizzy/drunk camera effect through manipulating the projection matrix?
^ i did try to create one but the only result i could get is by stretching m00,m01,m10,m11 which doesn't really look good lol, i was wondering if i did something wrong or there is a way to apply some kind of effect to the camera like dizziness
you could add a post effect like chromatic aberration, excessive motion blur, lens distortion and bloom among other things
distorting the camera matrix will probably just cause nausea in your audience, a low intensity screen shake (rotation + position) is tolerable
well the effect i was going for is nausea, the closest thing to being dizzy, but i felt like there was a better way, and directly editing the projection matrix might cause problems for me? i don't really know much about it, i just play around with some values to get what i want.
as for post effects, i can't do them as i'm trying to target lower to middle end devices so i'm trying to limit them as much as possible.
Though i do use Camera.ResetProjectionMatrix(); i still think there's a catch here, i'm not sure if it can work well with what i'm targetting but yeah
your job as a content creator is to evoke emotion not to make people physically uncomfortable, people will just turn off your content if it makes them nauseous, so you should do what everyone does (e.g. movies), create a 3rd person visual or narrative representation of nausea instead of making your audience go through it first hand
no i think you misunderstood something here, i'm not displaying the "nauseous" effect all the time, let's say it's from a negitive character effect, i hope that makes sense
you should never display anything that makes anyone uncomfortable (nauseous)
anyway, you can take it or leave it
and besides that, i was just wondering if i could apply some kind of effects to the camera without using post processing, through coding or another way
yes, you can
why not the standard post processing horizontal screen-shaking thing?
For dizzy/drunk you can do that for the whole cam & add blur to it, and for nausea you can do the same, but with blur only on bot+top, and animated vignette
(animations in effects are usually associated with an urge in UX lang. The heavier the animation the bigger the urge)
seems like that's not the desired solution
coding is the way to go for post-processing effects.. Shader coding in specific 😛
you can use the post-processing stack or whatever it's called on top of your screen-shaking shader (which can be applied to your whole screen)
i know this is the wrong place to ask this question, but can you use the shader graph instead of shader coding to change the camera output?
shaders don't change camera outputs, they just do operations based on input 😛 So at best they can output a texture
you can use a fullscreen pass in URP 14 (no idea about HDRP) or make a simple custom "blit" render pass and target that with a shader graph, yes
but the possibilities with those are very limited
if, however, you input the camera's output texture to the shader, have it operate on it, then read that texture and render it on screen, you pretty much have post-processing
i'll look into it thank you very much
typical post processing is this : https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnRenderImage.html
// get camera texture
Graphics.Blit(cameraTexture, newCameraTexture, material); // Blit to it using your shader/material
// assign the new texture to the camera
and the material can use whatever shader u want -- even one that was made via Shader Graph
i'm interested in coding navigation graphs or nav meshes / volumes. not saying i'm going to do it, just want to see how it works in script. but all i can find is explanations of how it works in engine.
Try googling with pathfinding navmesh algorithm
Hi everyone !
So this question might be basic knowledge haha I have no idea how to go about this.
So, context : I am finishing to develop a game for clients, that have bought Naninovel, an asset store engine to make visual novels. They want to make a mobile visual novel game, you can choose the story to play in the app part of the game then the Naninovel engine runs the visual novel scripts.
So, in order to save some things, like unlockable items unlocked, one artwork being given to the player, etc, I have made custom commands for the visual novel engine, which can be used in scripts. In those commands, I make Rest API calls to save the game, the items owned, etc.
The problem is that making those API calls during the visual novel script execution just freezes the whole program (even my editor is frozen - when enabling the profiler window, everything freezes and the profiler records like 2-3 frames of big CPU usage, which take ~10 000ms to complete.
I tried many things, first I tried to make a class that would receive events when each command is executed. Then the events execute the functions and make api calls. So that it shouldn't block the rest of the code to happen, since the event is fired and not awaited for (right ? I use Invoke, so maybe that actually awaits for the event to be finished ?)
Then I tried to call the functions in coroutines. This doesn't work either.
Then I tried to call the functions inside a delegate in a task, like so : Task.Run(delegate { MyFunction(); }); which doesn't seem to not block the rest of the code...
So main question : how to start a function without waiting for its execution ? Make async functions and not await them for example ?
First off you should look in your profiler what is actually taking this much time to execute.
I guess its not the API Call itself with webrequest and what not, but to get all the data you send to that call is just a big heap on classes and what not. So you should look into that first without even sending the data anywhere, just see what the data handling does
you can't use httpclient to make rest calls in unity
you should use unitywebrequest
10 000ms
this makes it sound like your requests are timing out too
so it sounds like it's a lot of bugs
Ok so I'm not using either UnityWebRequest either http client, I am using a SDK generated with swagger's codegen. So yeah the requests aren't made in a unity friendly way maybe..
The 10 000ms time to execute is the "Scripts" on the CPU usage on the profiler (it's my first time using the profiler so I'm not sure how to see what takes this long). I attached a screenshot, but I see that there is script work at the start of my player loop and right at the end, maybe it's just the freezing of the editor & profiler that makes the frame take 10 000ms to be finished ? not sure at all
okay
are you aware that openapi generator has a unity web request based generator as of 3 weeks ago?
we already know what your problem is
second question - have you been relying on chatgpt to help you program at all?
I did not know 😮 that would be really convenient lol
no not at all.. but maybe I should lol to help me optimize the code
I am no expert in C# programming though, I have more experience in web dev
okay well
you have to use unitywebrequest
there's nothing to do to get around this
you can use the master openapi generator branch, build it, and run it
or you can just post against the URLs because it doesn't really matter
it won't fill in 100% of the blanks for you to use the generator but it iwll not have this issue
Okay thanks. At least it will ensure a better performance. This particular request that I made when I took this profiler screenshot holds quite a lot of data, so it might also play a role in the freezing of the program I guess
you will need to build the generator, which means understanding how to install java 8, and how to disable doclint errors in maven; then you will need to actually invoke it; then you will have to add the newtonsoft json package; then you will have to use unitask to actually invoke the async methods without bugs
no
it's freezing because you are making blocking requests on the same thread that is used to run the game*
the complexity of fixing what you already have will exceed the time spent doing it right
the RenderPipeline class has a few callback methods you can listen to, but it's difficult finding information as to what the different calls actually are. What exactly is happening under the hood at BeginCameraRendering, BeginContextRendering and BeginFrameRendering?
the only one I can roughly estimate is that RenderPipeline.BeginCameraRendering probably renders the view frustum, with the stencil buffer/depth buffer related stuff? but I don't really know
request that I made when I took this profiler screenshot holds quite a lot of data
this is concerning
are you saying youare posting image data?
define quite a lot of data
your best bet is to look at the unity graphics repo and read the URP and HDRP sources
it's also in your project folders if you are using Rider
It's json only, but the save json, so it is quite a long json approximatly 6 000 000 chars
why is it 6MB large
it sounds like you have at least three problems at the same time
it sounds like this hasn't ever been working 👀
it's the data from the Naninovel engine, so I can't really change it. I wanted to keep the saves in the API so if the user changes mobile phone, they would keep their saves
Yeah maybe not lol
- based on the profiler screenshot, which literally has all the useful data cut off, if that 10s bar is indeed an API call, you are observing a timeout or an internal server error or similar.
- you aren't using unitywebrequest
- you have a flawed approach to saving, serialization or similar
6MB is fine. even posting 6MB is fine. on a phone it could easily time out though, it could take a while to upload 6MB (10s+)
does it use Ink?
nanininonovaovvel?
anyway this is code advanced
i don't know how much progress you've made so far
Sorry about the screenshot of the profiler without useful data, I don't know what I should look at 😭
Ink ?
hmm
all of this is tractable
dont' stress
web development and unity development have a lot in common. unitywebrequest is xmlhttprequest / fetch. you'll observe that it's impossible to use fetch to make a blocking request in yavascript, because a browser's user code (ie the page) and a unity scene work the same way
but 10s is very long.
it means there are other issues
like surely you've observed calling this api without such a long time right?
and it wouldn't take 10s to upload 6MB
it wouldn't even take 10s to serialize and upload 6MB
it sounds like there is something in the naninovel save process that might be glitched. but it's hard to tell if that's accounted for in the 10s. you have to learn how to use the profiler to see that
also, when you declare this an external function, it's automatically nuanced
because the visual novel scripting engine doesn't have "async" as a notion, so you have to write your external function definition correctly
it doesn't have async, promises, etc.
Yeah, usually the api calls don't take this long.
So yeah from there, I think I should generate the SDK to call the api with UnityWebRequest,
also learn how use the profiler lol
Yeah there should be problems elsewhere too. I think that I will try to optimize the code to maybe fetch all I need from the api before starting the novel engine.
basically you should have something of the form
// most of these narrative engines have you load some assets
// or restore from a save file or whatever and give you a story instance
// then the UI calls `Continue` or similar on this instance
// a lot of things need access to this instance.
var story = new Story(m_NaniNovelAsset);
story.LoadFromSave(...);
...
// when you call async methods in general, including the browser
// you might have to gracefully deal with them getting cancelled
// by all sorts of circumstances
// if you allow users to switch scenes, you probably do not want to
// cancel when the object that happens to have this code gets destroyed
// you will need to cancel when application quitting is requested
// you may have to deal with the app being backgrounded, and will...
var cts = this.CancellationTokenOnDestroy();
// ...have to explicitly deal with resuming if the post file is large
// iOS and android both have APIs for these sorts of background file
// transfers and you can find a unity api for it. usually either the
// backend api is authored to support the background transfer APIs
// (which are just ordinary http conventions) but OpenAPI will not be
// aware of them. if the backend is not, then usually the way the backend
// works is the device posts to a service that does support background
// transfer APIs, like amazon S3, and then an event is fired on AWS and a call
// from s3 to your backend is made. you can't just wait for it to upload, then call
// because the whole point of background transfer is it's allowed by
// ios and android to do background file transfers - it's not going to let you
// schedule another call to run afterwards, your application has already
// quit by then.
story.BindExternalFunction("save", _ => {
// Forget() is a way to ignore the result of calling
// an async method.
// this will not block. the game will still be running when save is called
// and by game i mean the story engine. so people can still do stuff
// while saving is going on.
Save(story, cancellationToken: cts.Token).Forget();
});
...
async UniTask Save(Story story, CancellationToken cancellationToken=default) {
// so since people can still do stuff while this is being run
// we need a snapshot of the story at the time it is called.
// copy the story, which ought to be fast
// we have to copy the story on the main thread (or serialize it)
// because it isn't thread-safe. that means we DO want to block execution,
// and the pause will last as long as it takes to copy a C# object using
// whatever naninovel gives you
// if it doesn't have a way to copy the story, you will have to serialize
// directly to json on the main thread, which is very slow, and this will
// preclude using OpenAPI, since it expects objects (it expects to do the
// serialization for you)
var copy = story.Copy();
// unitask provides easy ways to switch from main thread to background thread
// to prevent work like seiralization from blocking your code
await UniTask.SwitchToThreadPool();
var api = new DefaultApi();
// this internally calls JsonConvert, which could be really slow
// but we've moved to the thread pool explicitly for this purpose
try {
var saveResult = await api.SaveApiPostAsync(copy, cancellationToken);
Assertions.AreEqual(saveResult. ..., ...);
} catch (Exception ex) {
await UniTask.SwitchToMainThread();
Debug.LogError(ex);
// handle the saving errors
}
}
a lot of the missing implementation is error handling, but it ought to be truly this succinct once you do everything right
and i have a feeling it is not
it's so much stuff
to learn
so don't stress
you should use UniTask
you have to deal with cancellation... what if the user closes the app before saving is finished?
if it's going to be a 10MB+ file, you are in a hard place on mobile
the approach will change
Ok thank you so much ! I will try all of that right now ! (It surely isn't that simple right now)
Yeah it's a lot to learn lol and the game is supposed to be published quite soon. I am the only dev so it is indeed stressful lol
Thanks for your time, what you told me helps me a lot 🙏
anyway i hope you didn't ask for a pathetically small amount of money to do this task
because it's a lot
you'll get it done
lol
I've been programming for years at this point and yall are still so far beyond me it's like you're speaking latin. Crazy.
But yeah really you are a saint @undone coral , now I know where to start lol 🙏 🙏 🙏
I guess multiplayer is handled with web requests just like a regular web server?
I've not done any server stuff yet so
if it helps, you will sound like you're speaking latin to people less experienced than yourself - and programming is vast enough that you will often be extremely proficient in one area & a complete beginner in another 😅
there's a ton of nuance in th esnippet i shared
i'm going to add a few more comments
I guess this is why everyone feels like a beginner forever
every few months or so I feel like I make significant gains in understanding, but it always feels like other programmers talk about stuff I still can't fathom
yeah same but at the same time there is so much to learn
thank you so much 🙏
okay that's updated
that's ok though. if you don't let it discourage you and accept that someone else will always be able to teach you something, you'll be fine 🙂
@lone fog i think if you want save games to work you have to carefully read those comments
i mean honestly it's going to take you 2 weeks of solid focused work to just make saving the game work correctly
this hasn't been working, so you haven't been testing on device
so you haven't discovered all the challenges there yet
if i were you, i'd ask your people for more time
and it's going to be catastrophic
because people will be playing the game, then they'll get a text message, and they'll reply to it
and the upload is going to get cancelled because the app gets backgrounded
and these are going to be end users on android phones, which have all sorts of weird behavior
because it's visual novels
so even the snippet isn't complete
if it's 6MB you will probably need background transfer for end users in asia
if that's the audience
another way to do it is you background transfer the save files directly to s3, and the client polls s3 when it is launched for the firs ttime
to see if there are newer saves
if you don't have any advanced functionality related to the save files themselves, you don't need to interact with a separate backend
but if you use S3, you will have to learn STS (federated tokens ie authorization for client devices)
so like, complexity is unavoidable
google won't let you upload an APK to google play that has an AWS access token in it
in fact they'll let you upload it, and as soon as like 10 people download it, then you are booted out
you were basically asked to do a $250k task for whatever, $5.
i can't imagine how you are even dealing with auth...
knowing as little as i do about the state of the porting right now, your biggest priority is to have a game that actually works first
Actually we discovered the bug while testing a build ! And I have built the game without any save or custom command in the novel scripts, which works really fine, so the problem comes from there for sure.
But yeah it's good advice ! I will talk with them on Monday since we have a meeting. In the meanwhile I will generate the SDK ith unityweb request, but yeah for now the app is in french only so we don't have to worry about asia for now.
But yeah you are right, complexity is there all the way, and I already knew that the save system was one big piece of work, but combined with the novel engine and all of that it really is a lot.
About pricing, I ask them for 150€/8h, and I know that they already don't have enough money to pay for all of the hours I already put in.. so yeah it's not the best position I'm in right now
https://siliconangle.com/2022/09/01/three-quarters-mobile-applications-found-contain-valid-aws-access-tokens/ <-- 98% were iOS because google blocks it
holy shit, this is shocking
But yeah the priority is to have the game working and I think that the saves are the only thing left for the game to work in itself, all the rest is "around" the game - in app purchases, etc
yeah really shocking
Feels like #archived-pricing-updates-talk in some form 😄
That just makes me think about how to keep variables like api keys safe ? I would have put them in an environment variable but I don't know how this works for unity games
put them on your server
not on your client
mmmh but how is the client identified to be sure that it's authorized to access a certain variable ?
it really depends on what UX you want
clash royale creates you an account that is authenticated by your app+device identity. if you want to "log in" to that account from somewhere else, supercell* enables* a phone number based authentication to the same account, and from a different device, login via a texted phone number code instead
the "account" works the same as a username and password account. from a technology point of view, authentication (username + password, a unique device id, or a secret code texted to your phone number) is separate from authorization (the permission to do something based upon facts about you, like your user id)
so in the specific case of s3, there are tons of ways to do this
btw, I just finished updating the code to adapt to unitywebrequest with the generated sdk and it now "only" takes 3000ms to do the request which is already 3x less
one of the simplest ones is
- the user is authenticated.
- now, the user would like to use an s3 api directly from his device, for important reasons.
2.1 the user requests that the server issue a piece of data that can be used to authorize limited s3 access. this piece of data is usually called a token, but a token is just a piece of text for authentication and usually a specific purpose (specific authorization to do specific things)
2.2. the server looks at the user id making the request. then, it goes to amazon and asks for a "token" (STS is the simplest of such an approach) which grants the holder of the token the ability to write to an s3 bucket path containing the user's id. so to summarize, a token might look like
(let's say the user's ID looks likeXYZ)
{
proof this token is real. created by amazon.
an id used by amazon to look up the permissions granted
to the holder of this token. this looks like...
-> an amazon IAM policy document that looks like...
-> grant the bearer of the STS token
the ability to write at most 100MB to s3 keys of the form
s3://naninovel-production/users/XYZ/*
}
2.3 the server returns this token to the user
3. the user calls s3 apis directly with the token.
@lone fog does this make sense?
if your users already create user accounts via something oidc compatible like Cognito, PlayFab, Google, etc.
you can instead express to amazon
call an amazon API ONCE with the following request:
give users who have really logged into google
that have permissions from me
(logged into google for the purposes of accessing my game)
an amazon IAM role ->
-> this role says that whatever the userId is according to google
has the ability to write at most 100MB to s3 keys of the form
s3://naninovel-proudction/users/{userId}/*
there is some arcane stuff involved, but it does Just Work
then you can use a token you get from google against an AWS api (almost)
you exchange a token from logging in with google to get a token from Amazon, then use that token. it's the same diff
they're like a chain of permissions all strung together
yes actually it makes sense ! Like this is something that I do to access for example the Twitch Api or the Riot Api - but yeah I didn't think that it was working the same way for users of an app.
Like for example, Twitch api, like we do have to request an a token & bearer to make api requests. I guess that their website uses their api, for like when a streamer goes live, it's written to the api. So like the request that's made to update the streamer status "automatically" requests a token & bearer to the server in order to identify that this request was made by someone logged in ?
not sure if i make sense
it does
it may just be surprising that token does not differentiate between a token used to authenticate an ordinary user versus a token used to authenticate an application for development purposes
a token is just a magic string
ok I understand very well, i had no idea it worked this way lol
they don't authenticate/authorize a specific kind of person/thing alone
so your AWS credentials are tokens for an application to prove it's really the application to AWS
that is how they are actually used
you could in theory create an AWS IAM user corresponding to each individual real user of your game
and then grant permissions to those IAM users. but then you have to reinvent a lot of username/password management and stuff like that
that's why all this other stuff exists
you might also not want to even have usernames and passwords. clash royale doesn't
that's also why your deviceID + a random string is NOT a token
it's a credential, like a password, used to prove to someone who you are (authentication)
a lot of this stuff gets really academic
it's tough because for mobile games, you really do some weird stuff
and you don't want to write all this code for accounts, it's very bug prone
it has a lot of gotchas
yeah haha so yeah thank you, I will implement something like jwt token auth on the api (I am actually creating the api too using api platform so it will be easy to do I think). Might look at that as soon as possible though
But yeah that's really insightful, thanks ! 🙏
yes, eventually your client will pass a token (that happens to be a JWT) to your API, and your API (which happens to be built on standards) will be able to look up a hte user's ID from the JWT token
however, something has to give you a JWT in the first place
and that's a UX question
@lone fog like do you want people to use a username and password?
it's very cumbersome for a video game
no it will only be guest account or google play/apple login
so something has to issue a JWT for a "guest account"
those can't be made from thin air
and google play and apple login give you tokens, but only apple's is a JWT (only apple is OIDC compliant) out of the box. yoiu have to choose carefully which login flow you use to get OIDC compatibility from google
so pretty much no matter what, you use a vendor or some other tool to present a single facade for login
and hardly any of those support guest accounts as you're imagining - a device-specific credential, like a random number generated by the app on first launch and then stored to private app storage
so i am really, really emphasizing just how complex this is
and how you need way more time to achieve all of this
it's not like on the web where you have firebase and it does everything for you already
and as long as you don't go out of their ecosystem, you are fine
there is even firebase for unity, and maybe that's what you ought to be using
then there is the tricky reality that 100% of people who use apple devices also have google accounts
ok thanks again, you really are of great help ! It's giving me a lot to think about lol
well
yeah true
Next wave doesnt spawn after all enemies are dead, any ideas?
i guess another perspective is that this stuff doesn't necessarily have to work
in the real world for contracting, people deliver things that don't work all the time
and nobody notices or cares
because there's no audience
i'm not advocating for that
but it's just to say that, usually, what happens in a darwinian way is, you ignore all these nuances and as long as it says there's a login with apple button, if your boss happens to have an android phone, they're not going to tap on it
like it doesn't have to be secure
no one is going to write into someone else's save
so you don't really need all this complexity
unfortunately if you ask for a google or apple account you get a lot of the complexity for no yield
you have to use AWS credentials on your server because googl eown't let you publish an APK that contains them
not because anyone cares about security
if your people cared about this stuff they would pay 10x more
and it's true, it won't matter
i mean "don't care" and happening to be right about not caring is okay
yeah currently I have a system that "works" but is not secure - the only thing that makes the thing not secure is the api key in the code (which is a random generated sting - not an aws credential, so should be safe for google at least lol), from which you can make any request, including delete requests. But I don't think that the game will have a big audience from the start - it's the first game from my bosses & they don't have that much of a following on socials so I don't think that it will be problematic for now - however we never know.. anyways now that I know more about all of this, I have a lot to talk about with my bosses lol
that's what user authentication is for
It's why you generally log in to online games.
So I'm trying to access a csv file through Unity. I've migrated the csv file (edited via msExcel) to my persistantdatapath directory and tried opening it through there. However, I run into a Sharing Violation error with it. Any tips?
maybe for now, try hardcoding the path to somewhere in your Documents folder
have you been able to open files at all?
it's unusual to use the word "migrated"
Yeah I can still open the file just fine, and by migrate I mean copy/paste
And I'll try a specific directory for now and see how well that goes
Found the issue. Silly me I still had the file open elsewhere
Make sure you're using using statements anywhere you access files to ensure file handles are always closed properly
Will do 
HPA*
I have some questions about hierarchical path planning in 3d voxel based worlds.
First, how does the algorithm determine to place a node in edges? for each common segment one node in center or two nodes in the beginning and at the end of that segment?
For example, in short segments it adds just one node but for longer segments, two nodes are added.
Second, are these nodes connected to each other pairwise? I mean if they are 10 nodes, for each pair, we should add an edge?
In the picture below, there are three nodes and three edges in the top right cluster.
Third, how are weights of these edges calculated inside a cluster? using a path finding algorithm like A* for each edge?
Source Target
Node1 --> Node2
Node1 --> Node3
Node2 --> Node3
and finally, there is no additional node in a cluster? for example a node in center of each cluster
refactored my main system and now im so paranoid that i broke something, that im doing unit and system tests for everything
it's oaky now, I just had to re-import.
I do not not have specific knowledge about HPA*, but simple Google Search should be more than enough to get you started.
https://www.google.com/search?q=site%3Agamedev.stackexchange.com+HPAstar&sxsrf=APwXEddsxF_xlfu0mGAeQEuG5ekK2YJd0A%3A1679707999112&ei=X08eZLiqBtWq5NoP0JSC8AQ&ved=0ahUKEwj41fP09_X9AhVVFVkFHVCKAE4Q4dUDCA8&uact=5&oq=site%3Agamedev.stackexchange.com+HPAstar&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzoKCAAQRxDWBBCwAzoICAAQiQUQogQ6BQgAEKIESgQIQRgAUIcEWIJXYK5YaAFwAHgAgAF9iAGiEZIBBDI5LjKYAQCgAQHIAQbAAQE&sclient=gws-wiz-serp
https://www.google.com/search?q=HPAstar&sxsrf=APwXEdehyGinyk6UHitx00dYLgaDAPcv_w%3A1679707986058&ei=Uk8eZNOFA92f5NoP8JK2sA8&ved=0ahUKEwjT9tbu9_X9AhXdD1kFHXCJDfYQ4dUDCA8&uact=5&oq=HPAstar&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIICAAQHhAPEAo6CggAEEcQ1gQQsAM6DQguEIoFELEDEIMBEEM6CggAEIoFELEDEEM6BwgAEIoFEEM6CwguEIAEEMcBEK8BOgUIABCABDoLCAAQgAQQsQMQgwE6CAgAEIoFEJECOg0IABCABBCxAxCDARAKOgcIABCABBAKOgoIABCABBCxAxAKOg0ILhCABBCxAxCDARAKOgoILhCABBCxAxAKOhQILhCKBRCxAxCDARDHARCvARDUAjoNCC4QgAQQxwEQrwEQCjoTCC4QgAQQsQMQgwEQxwEQrwEQCjoQCAAQgAQQsQMQgwEQyQMQCjoICAAQigUQkgM6CAgAEIkFEKIEOgUIABCiBEoECEEYAFDyBVjnGGDCGmgCcAF4AIABkwGIAZoFkgEDMi40mAEAoAEByAEIwAEB&sclient=gws-wiz-serp
https://webdocs.cs.ualberta.ca/~mmueller/ps/hpastar.pdf
https://github.com/Maceris/HPAStar
https://web.archive.org/web/20190411040123/http://aigamedev.com/open/article/clearance-based-pathfinding/
https://webdocs.cs.ualberta.ca/~nathanst/hog/index.html
@dusty wigeon uh thats a lot of links
is there any way to force a unity game to use the globally installed Mono instead of the local one?
Obviously, I have read most of these links. They are vague without detail
For example, I see some edges do not exist between nodes in the graph while there are paths between them
i believe the algorithm is running all pair shortest path for the nodes in the same "segment" and these nodes have to connect to other segments on graph.
and maintaining a graph of the node pairs that connect two different segments
then for all nodes belong to the segment source located at, run a* until reaching the segment target at
but i am not sure how to divide a super large graph into small segment and connect them
maybe you need a array of adjacent list like this
i want to create complex ai that can handle 3d verticality. for example a unit with a jetpack that can fly/jump around platforms. i have a movement script which i'm trying to apply to unity's navmesh (i'm not using agents). it can walk on slopes and stairs, but i dont know how to do verticality or jumping. navmesh link analogue would not work because it's too simple or at least there would have to be different links for different units. i'm considering making a script for my own navmesh generation and then some kind of a* modification. what should i do?
so if i want to check every node that next to my current node, in all ways possible in a 3 dimensional array , including the checks if moving in the specific direction breaks the matrix since it goes more than the max or min of it's dimension, makes an aprox of 27 node checks, and a node check having 1-2 checks
how do i make it auto for the check instead of importing them manually
without backtracking
since it's finding all the possible ways you can move from your current node in a graph
by moving only 1 node
I'm creating custom assets to export/save multilayer chunks of Tilemap areas. In the custom asset I'm archiving ordinary Unity tiles in a small class with the tile reference and a list of the positions. This all works perfectly. Prior to putting this on the asset store I'm trying to do some small optimizations. As one might expect, for some areas on a Tilemap the same tile may be repeated hundreds of times at consecutive positions. To reduce the size of this custom asset, I was considering using a simple Run-length encoding scheme (ie, here's a position, the next N positions have the same X coordinate) to make the asset files smaller. To get to the question: would this be a waste of time since Unity compresses when you make a build and .asset files, being text in this case, would be compressed anyway. Can anyone clarify?
Depending on which HPA* you are following
Next, we identify entrances between each pair of adjacent clusters. An entrance is defined as an obstacle-free area of maximal size that exists along the border between two clusters (Figure 12a). Each entrance has associated with it a transition point which reflects the fact that an agent can traverse from one cluster to the other. To this end we select from each entrance a pair of adjacent tiles, one from each cluster, which maximise clearance
The topological abstraction covers the maze with a set of disjunct rectangular
areas called clusters. The bold lines in Figure 1 (b) show the abstract clusters
used for topological abstraction. In this example, the 40 × 40 grid is grouped into
16 clusters of size 10 × 10. Note that no domain knowledge is used to do this
abstraction (other than, perhaps, tuning the size of the clusters).
For each border line between two adjacent clusters, we identify a (possibly
empty) set of entrances connecting them. An entrance is a maximal obstacle-free
segment along the common border of two adjacent clusters c1 and c2, formally
defined as below. Consider the two adjacent lines of tiles l1 and l2, one in each
cluster, that determine the border edge between c1 and c2. For a tile t ∈ l1 ∪ l2,
we define symm(t) as being the symmetrical tile of t with respect to the border
between c1 and c2. Note that t and symm(t) are adjacent and never belong to the
same cluster. An entrance e is a set of tiles that respects the following conditions:
• The border limitation condition: e ⊂ l1 ∪ l2. This condition states that
an entrance is defined along and cannot exceed the border between two
adjacent clusters.
• The symmetry condition: ∀t ∈ l1 ∪ l2 : t ∈ e ⇔ symm(t) ∈ e.
• The obstacle free condition: an entrance contains no obstacle tiles.
• The maximality condition: an entrance is extended in both directions as
long as the previous conditions remain true.
Personally, my experience with Flying AI is that one of the following solution (In order of what I would use):
- You do not use any PathFinding (Go towards the target, same if there is wall)
- You use Navmesh Connection Link
- You use short-sighted movement. (If there is wall in front and a wall on top but no wall at the bottom then go down. - etc.)
- You use a normal agent with a high height
- You find an Asset that does the 3D pathfinding
- You make your own 3D pathfinding
Personally, I have use the solution (3.) in real production to add jumping and it works just fine. It is true, that sometimes the AI act a bit erratic and fail to reach the target, but in general, the behaviour is more than correct. To make it works, you need to adjust the sensibility of the height of each step such as each platform is linked. You use the height of the jump as the sensibility parameters. (It won't cross hole, but will be able to jump on top of "walls") That being said, it might not be applicable for your usage and you might be better by using other method.
I highly encourage to not make your own 3D pathfinding algorithm, even more if you are not an experimented programmer. It is an expensive task and you have a lot to do so you would be better off with trying to come up with a solution that works partially and focus on what actually matters: everything else.
Not sure what is the actual stated problem here. Are you working with a constraint satisfactions problem ? If so, it is an extensive domain with a lot of given solution. (Hill-climbing, Genetic Algorithm, Backtracking) Backtracking being one of the most easy to understand and work with from my experience.
If this is a pathfinding issue, you might need to elaborate more.
I do not understand what you mean by check instead of importing them manually
I'll be considering that you are talking about runtime size because otherwise, you should not worry about it.
I'm not 100% sure what you want nor how tilemap works, but you should first monitor the actual size that you are talking. Personally, I feel like there is no way your save of positions is more than a dozen of KO. That would be 10'000 positions. This is not even near of something that would matter in most platform.
If the size is astronomical for some reason (10MO - 10'000'000), be sure that Unity is doing some sort of compression whenever you ship your asset (The resource folder acts as an AssetBundle which are always compressed). If you really have an issue with memory, consider supporting the usage of AssetBundle/Addressable.
Searching on the internet, you can find multiple piece of information scatter.
Note:
Internally, the Resources folder basically is an AssetBundle, it's just one that is generated automatically for you during the build process - but in a very inflexible way (no incremental build, no control over compression, no variant support, no ability to split into multiple bundles, files are required to be in a particular place in your project, etc). https://forum.unity.com/threads/end-of-the-resources-folder.363800/#:~:text=Internally%2C the Resources,your project%2C etc
https://docs.unity3d.com/Manual/AssetBundles-Cache.html
https://blog.unity.com/technology/asset-bundles-vs-resources-a-memory-showdown
https://learn.unity.com/tutorial/assets-resources-and-assetbundles#
https://docs.unity3d.com/Manual/ReducingFilesize.html
the sentence you didn't get meant to add by hand into a list all the possible solution , this meaning ,,importing by hand"
and ye it's for pathfinding
in a 3D space
but the other parts work perfectly, i just need to check all the nodes that are near the current node i know it's parth of the path
horizontally, vertically and diagonally
and also up and down
So you just want 3 nested for.
for x
for y
for z
ye
for x-1, x+1 and x
i could try it but it's slow
to get me all possible solutions
and also backtracking is slow too
i saw you recommened more algos, which of those is the quickest?
Hey guys, so i have poroblem when build my game in webgl. It wont call my API requsts, but in unity editor mode it works perfectly.
Any ideas on what could be? Can it be something in Player Settings when try to build game?
Thanks for the reply. For sure I'm talking about runtime. I'm not using the Resources folder, but I have to assume that they compress all asset files -but I can't find that explicitly stated anywhere in their own docs (doesn't mean that it isn't there somewhere, I couldn't find an explicit reference. Lots of blog articles and such about compressing big assets like images (which is obviously pretty important).
None of them is the quickest, each have their own quirks. What do you mean by slow ? Because if the problem is only to find all the possible neighbourhood of a given node, this is as fast as you can do. I believe your issue is located in an other part of your algorithm. Normally, when you do pathfinding, one of the most import metrics is the number of expanded nodes.
google pathfinding algorithms, depending on what you want its probably BFS, dijsktra or A*. but be aware that they all have a performacne worse than O(n), and since your graph is 3 dimension, its O(n^3).
so best performance upgrade is to reduce your node amount, like simferoce said
Hey folks if someone is able to help me to solve an issue i'd really grateful.
i've mapped a ProBuilder plane verticles into a 2d array manually.
But it seems the verticle indexes always changes due to how Unity importer changes. I can solve that.
However i was thinking if there was any smart way of mapping a plane's verticle indexes to a 2d array, would any1 know ?
Just to a nuance here, what I meant by number of expanded nodes is not to reduce the actual nodes, but to reduce the visited node. This can be done by using correct heuristic for the given problem or by solving for nearest optimal path instead of the optimal path. An other option could be to pre-compute all the available path which then result in a O(1) pathfinding algorithm. (Floyd–Warshall) This is only applicable in a static environment with a limited amount of nodes.
It is.
I am getting these two errors when running the game which does not say much:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GameObjectInspector.OnDisable () (at <d92715ccd3ac42dbaeb8a2239166e2e8>:0)
And
ArgumentNullException: Value cannot be null.
Parameter name: componentOrGameObject
UnityEditor.GameObjectInspector.OnEnable () (at <d92715ccd3ac42dbaeb8a2239166e2e8>:0)
That is all it says, when I click on the error in the console it just shows a (Game Object Inspector) empty in the inspector.
Any help would be much appreciated. Thanks
It seems to me that it is an error inside Unity code. It could be happening from corrupted GameObject
The closest reported bug would be:
https://issuetracker.unity3d.com/issues/argumentnullexception-gets-thrown-when-changing-the-base-class-to-monobehaviour-of-a-script-that-is-attached-to-a-state
Most likely you change the script type from one to an other. (ScriptableObject, MonoBehaviour, Plain C# Object, StateMachineBehaviour, etc.)
@dusty wigeon thanks! i appreciate the help!
Hi, I'm looking for some advice. I'd love to know if anyone has a theory behind how to achieve a camera scoring system similar to Pokemon Snap.
The main issue I'm running into is how to identify the animals being taken in the pictures and how to score them appropriately. Mainly because, if for example, I use raycasting then if an animal is behind a patch of grass which typically won't have a collider, then the camera will still score highly as it wont hit the grass.
My main working theory is that I use a shader and a 2nd camera whereby in the 2nd camera I render all animal gameobjects with a unique colour that corresponds to their species, and then I do some weird math that I havent figured out yet to work out how many of the animals there are, how centered they are etc. One of the issues I'm running into with that is I can't seem to find a solid way to render their normal materials to one camera, and render this new colour to the 2nd camera. Even using a custom render pass it doesn't seem to be working.
Any advice/theories/anything at all to potentially optimise this or provide alternate theories would be amazing 🙂
- Use layers and duplicate renderers (https://docs.unity3d.com/ScriptReference/Camera-cullingMask.html)
- Use custom command buffer (https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.html)
Thank you for the reply! Yeah, so my animals are all on an Animals layer and that bit seems fine in the 2nd camera preview. I was hoping there was a super simple way of doing it that I'd overlooked but I suspect not 😄
You said: One of the issues I'm running into with that is I can't seem to find a solid way to render their normal materials to one camera, and render this new colour to the 2nd camera.
I'm not sure if you understood what I meant or if you changed what you understand.
Just to be sure, in option (1.) you would be using RenderTexture
In (2.) also.
Ah okay! I didnt think of that! So I'd create a RenderTexture based on the "photo" then cycle through all objects on the Animal Layer captured and amend it with the correct colors?
Is that what you meant?
You would:
- Use a second set of Renderer on a different layer (Scoring Layer) with unlit materials that would be render by a second camera with a RenderTexture.
OR - Use command buffers to ReRender all animals with a new material on a new RenderTexture.
From which you will be able to sample the texture and see how much of the animals is visible.
In both case, you might want to look into Stencil Buffer. (https://docs.unity3d.com/Manual/SL-Stencil.html)
Thank you! Just come off of a 13 hour shift and its been playing on my mind all day - I know now where to direct myself! 😁 Really appreciate your time!
When I convert a component to JSON form, the reference to another asset / file is usually in this format {"fileID":46,"guid":"0000000000000000f000000000000000","type":0}
For-example. This ^ can be reference to a .png in a texture
I want to get the fileID guid and type using the asset's path in Unity, how can I do it ?
You want to look into https://blog.unity.com/engine-platform/understanding-unitys-serialization-language-yaml
Probably, most of your question can be answer with a good understanding of the way things are serialise.
Thanks will do. Seems like a long article, is there is a quicker way to get to the answer ?
Sure, but you won't understand what you do
I'd like to run a script via -executeMethod <ClassName.MethodName> or -executeMethod <NamespaceName.ClassName.MethodName> in my command line argument to build a server.
I therefore created a static method to Build my server via UnityEditor API.
However it failed with this message:
Assets/CustomBuilder.cs(20,41): error CS0103: The name 'BuildTarget' does not exist in the current context
This is my method:
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
public class CustomBuilder
{
public static string defaultPath = @"Distribution" + Path.DirectorySeparatorChar + "MacOS" + Path.DirectorySeparatorChar +
"Server" + Path.DirectorySeparatorChar + "bangerang_server";
public static void BuildServer()
{
Debug.Log("Building Bangerang Server...");
try
{
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.scenes = new[] { "DemoMap" };
buildPlayerOptions.locationPathName = defaultPath;
buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64);
EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
buildPlayerOptions.options = BuildOptions.CompressWithLz4HC;
BuildPipeline.BuildPlayer(buildPlayerOptions);
}
catch (Exception e)
{
Debug.Log(e.StackTrace);
}
finally
{
Debug.Log("Build Complete");
}
}
}
When checking UnityEditor.BuildTarget I can see in the comment on top:
// Assembly: UnityEditor.CoreModule
I therefore created a assembly definition but could not add UnityEditor.CoreModule since I can't locate it to add it.
Can I see it ? 🙂
Really depends on what you want, I did not really let's you finish.
I have an asset's path as an input and I need the {"fileID":46,"guid":"0000000000000000f000000000000000","type":0} part as an output.
Why ?
I have an interface / website. I will make a file browser so user can select a file and the website does the remaining job of editing the JSON, then sending to the unity.
But when the user selects an asset, we will only have the path of that asset.
Oh... You do not need to edit directly the values. You can just edit like any asset.
Are you familiar with Custom Inspector ?
And Editor Tool in general
I'm not familiar with that. My main goal is to make a website which is basically a duplicate of Unity Editor. We will be able to do everything in the website which will update unity in real time. So website and the Unity Editor are connect via socket connection.
The file browser will get all the asset files, The user will select the asset file they want to set as for-example 'm_shader' and the website will edit the JSON on the web end setting the new fileid guid and type, on the Unity end the json will be received and will update the component.
seems like I can get guid from file's .meta file
You should start by understanding the base of Unity. Because, at the moment, you are missing a crucial part. If you want to edit a value, you can simply do MyField = MyValue by using AssetDabase.
- Load the asset
- Edit the values
- Save the asset
https://docs.unity3d.com/ScriptReference/AssetDatabase.LoadAssetAtPath.html
https://docs.unity3d.com/ScriptReference/AssetDatabase.SaveAssets.html
The serialization process will do the rest. You do not need to directly manipulate the information.
Otherwise, I found this function that could be useful to you if you insist on doing that.
https://docs.unity3d.com/ScriptReference/AssetDatabase.TryGetGUIDAndLocalFileIdentifier.html
I can do that but it's tedious on the web end there are 100s of fields and components. Using JSON I can use a recursive function to display the fields, when changes are detected, the JSON is sent to Unity and it updates the function using that JSON without me needing to use separate code for updating each property of each component.
Is your BuildScript in an Editor Folder ?
Just Assets/Editor ?
Is LocalFileIdentifier the fileid ?
I read about that. Is this some kind of convention to have the script in a folder called Editor? Cause currently I don't have that folder
You can use reflection if needed. Like they do in the inspector. I'm 100% sure that at the moment you are doing an error by trying to manipulate directly the fields.
You do you. This is my advice. Do not edit the field directly and use the appropriate AssetDabase function to manipulate the asset.
At the moment, I am fairly sure you cannot even build same if you do not use your script. The issue is that your script is trying to build itself, but because UnityEditor is not define in a build, it fails. To fix the issue, you need to remove the BuildScript from the script that are being build. You do that by using Assembly Definition. In the case of editor script, Unity treats every script inside a Folder name Editor as in the editor assembly and won't build it for a runtime build.
Editor scripts add functionality to Unity during development, but aren’t available in builds at runtime. Scripts in an Editor folder run as Editor scripts, not runtime scripts.
Ok it worked as far as I can see. No errors anymore and all debug.log statements are being hit. Thank you @dusty wigeon
Used method 1. Works like a charm 🙂 Thank you again!
you can use com.unity.perception to make an image like this without authoring any code and performantly
it's not clear what your goal is though gameplay wise
you can certainly use method 1, if you want to duplicate your entire scene, essentially, for a second camera
that doesn't really make sense to me
com.unity.perception already does this correctly and robustly
if your goal is to eventually count pixels, this is going to be hard to do yourself
if you goal is to know whether or not a certain minimum amount of animal is visible on screen, it will be harder to do yourself
com.unity.perception can also tell you how many pixels of a particular animal (if that's your label, in its vocabulary) are visible
you can render the images on demand too, instead of continuously, which is probably what you want
Hey, thanks for the response!
Gameplay goal is think - Pokemon Snap. Take a photo, photo is scored eventually based on various rules etc. How I do that, I'm fully open to suggestions. The main one I've had from various people is coloring the animals with unique colors then read from the output screenshot.
To be honest, rendering twice doesnt make sense to me either but I couldnt think of any other way. I've not heard of com.unity.perception
and it will just work with your existing renderers
it's not that rendering twice does or does not make sense
it's that if you have a separate render hierarchy
it is extremely cumbersome
i don't know how pokemon snap works
The main one I've had from various people is coloring the animals with unique colors then read from the output screenshot.
this is kind of what com.unity.perception does, but correctly
guess you'll look at the package
you're going to throw your arms up though because it'll have a lot of jargon
so it's tough. you are trying to do something that is deceptively hard
the shortcut you are taking has a lot of bugs
you haven't gotten to them yet
Oh haha!
So the basic gameplay loop is: Take a photo of a Pokemon, it saves that photo, then you present that photo to the professor who scores it based on various rules like how centered the Pokemon is, how much it takes up of the screen etc.
I'll take a look at the package
and in order to do it you'll have to reinvent a lot of com.unity.perception
but you're going to look at the package and not know what the fuck it is talking about so it's stressful
don't be discouraged 🙂
You are really selling this to me here... 😉
Hi guys, I'm looking for help about app startup time optimization.
The project targets on Mobile and Nintendo (NX). There is no problem on Mobile (takes about 20 sec to startup), but in NX (its hardware is very low level compared with current mobile devices), it'll take probably more than 1 min to startup.
For now, before I really investigate the detail, I would like to gain some background knowledges to help me get start, such as, what factors can increase startup time in unity? how they affect the time?
I tried google it but didn't find proper resources. Does anyone have any idea? Is there any helpful links?🤨
To be honest, I am not sure that in your case you can use com.unity.perception. It is use for the generation of synthetic data for the purpose of supervised training of AI. In spite of that, you may be able to find useful tool inside the package. @undone coral could point towards some of them as I do not know much about the package myself, but most of the workflow and tool will be made with the idea of generating lots and lots of data for the purpose of labelling them.
If you really are interested in not having to duplicate the scene, I suggest you look instead into CommandBuffer. CommandBuffer basically enable the drawing of the camera without passing by the MeshRenderer. By doing them, you would be able redraw every meshes with the given material of your choice without the need of duplicating the meshes/your scene. My own approach will be to create an "Engine" that enables the redrawing of any MeshRenderer by the usage of components such as ScorableRenderer which would take a specified colour that could be use to identify the actual object in the resulting output.
That being said, I would not be surprise if the actual rules of the game is a lot simpler. As little experience as I have, I am always surprise by how simple rules can makes things work. What would be important is to actual define what is your target audience and what are they expecting. I'm suspecting that you may be over engineering your product.
Side Note:
The rating in Pokemon Snap is define by: the proximity of the Pokemon to the center of the screen, the size of the Pokemon on the screen and the "pose" of the Pokemon. None of those rules require what you currently do and can be done by simply transforming the MeshRenderer bounds into ScreenSpace coordinate.
Perception package is describe as: The Perception package provides a toolkit for generating large-scale synthetic datasets for computer vision training and validation.
I am almost certain that the actual issue is the intensive usage of the resource folder instead of AssetBundle/Addressable. I'm currently developing on NX (Switch) for a project of considerable size and I have no issue with startup time while using AssetBundle.
Thx for reply, but actually can't be resource folder, we are using addressable.
I think I need provide more info about our project in original question
PS: more background info about our project:
It's a AAA game mobile version, the project size is large, specific data (build size, memory occupied when startup...) I don't remember for now.
Resource management: Addressable.
Input: New Input System.
Gameplay: DOTS.
...
So it's very possible that the reason is too many DLL or plugins need to be loaded when start the game (memory related problem).
If the resource folder is not the issue, I would still look into to be sure that there is no unexpected asset loaded by emptying as much as possible the folder and double checking the actual size of it.
- If you are not using a light scene as your startup scene you may want to do so and startup the asynchronous loading of the first scene of your project.
- If you are using "always" included shader you might want to get rid of them
- Remove unused libraries and package as they could be included in the build without being actually use.
Did you profile the memory usage of the first scene ? Is everything there actually needed ?
Could it happens that you have reference that point to heavy asset in the first scene ?
For your insight, we have 450MO of DLL being loaded at the start of the game and we have no issue with startup time.
Not yet, I just got the plan to check this issue
There is a package that analyse and audit your game if you want to try. Could maybe point you to some issue. https://github.com/Unity-Technologies/ProjectAuditor
It is more than just startup time though
sry what's MO of 450MO (I'm not a native English speaker, some of term not understand)
It that MB?
O means octet while B means byte. An Octet is always 8 bits while a Byte is define as the smallest number of bits that can be access by the system which is generally 8 bits.
What issue can we expect to find from this package ?
Warn you about LINQ, the use of Instantiate in a update loop, string concatenation and so on. It comes with other tools that tell you what is taking some much time to build or what is taking so much space. You can have a quick view in the doc https://github.com/Unity-Technologies/ProjectAuditor/blob/master/Documentation~/index.md
Emmm, most possible factor can be the third.
In our project, startup scene is pretty simple.
Shader I didn't check, it's one direction I can check, but I guess it can be major problem if it's a problem in our project.
Lib, most likely it is the reason, that's what I need to check. Since the project targets on both mobile and NX, I'm not sure there are Libs only used for mobile also loaded in NX.
Unfortunately, the documentation is not clear on the capacity of the tool. By going in sub-section I am able to see multiple screen-shot that gives me a good oversee of what issue it can track. It would have been nice to have a table that resumes the tracked issue so we can read on what is considered an issue before doing it/without importing the project.
I agree. Unfortunately I don't have more insight on why it is that way.
I don't see a need.
Gone are the days of hardware counting up to 128 "voices" or w/e as it's not a hardware problem anymore.
Yes, it is. Not because of the audio like @violet valve was pointing out, but because of the instantiation of the audio source. Like VFX, SFX happens a lot during a traditional game and a lot of them have short live. (Firing Sound, Step Sound, etc.) Not pooling them add an extreme amount of stress to the game and will most likely one of the first source of FPS drop you will experience.
Beware of "simple" startup scene. It only requires a reference to a text and you then needs to load whole Atlas of font which should be heavy given the high budget production you are working for.
Mem is cheap. I'd pool as much as you can if you're just reinstantiating everything anyway.
If you ever played path of exile, that game has a horrible history of the audio tanking your fps which I find pretty funny
Depends on which device. But yeah, it should not cost a lot to pool audio source.
I am not sure I am following.
Pooling means to reuse the current object. So instead of destroying it whenever you finish, you deactivate it. You then reuse it down the line without reinstantiating an other one.
Your system, at least the part where you set the values, would be valuable.
The cost come from the allocation of the memory, not the change of the settings.
Yes, I'm 95% sure it's exactly how we did in bootstrapper scene. The point is, the startup slow problem only happens on NX but not on mobiles. So for mobile, I believe we did most optimization things that we can.
Oh I forget to mention that, we mainly focused on mobile, and recently we just planed to start up NX. That's why we just found this problem.
A pool style audio system could also be helpful in multiplayer, as it makes for a nice central place to trigger audio for everyone.
Otherwise you usually individually sync random audio sources on a case by case basis. It could fit a use case
Oh, I wasn't thinking about pooling short-lived audiosources, so I misunderstood the nature of the question.
It's definitely something I'd benchmark to validate, especially on mobile. But I'd encouraging making sure it's benefitial to the project.
Can you imagine how many bytes you need to alloc for audio??? At 48k bytes per second, I'm crying in memory optimization here!
Audio system are hardly synced in multiplayer unless it's preloaded and fired when ready.
You'd use remote procedural call to invoke event listeners such as "OnGameOver" or "Player { name = "Steve" } Killed". Then you'd invoke when you can invoke.
Instead of syncing sound behind a wall that was caused by other player, why not just spawn an "AI" that mimic the multiplayer movement in the game? Why replicate the object that affects the scene, than the one that started all?
What good does it serve to have a pool of audio? Holding Audio in memory is expensive and heavy on resources.
What 10 multiplayer titles have this feature?
I'm asking for the source or cites of the 10 games you mention has audio synced across the multiplayer mode.
Now that the user blocks in place, I can see that this went back and forth more than is reasonable. If you want projects, you can look at our website - enough are listed there.
Using Unity2020.3lts
Pun2
I have a class with 5 lists
Lists are ints
When using editor to make a client, open a room, and start game, everything is working as intended
My lists get populated with all data when new clients join.
When using a build to host the room and game, and connecting a client through the editor.
Clients joining do not populate lists.
Is this something of a similar nature to async operations?
Where editor does not do some work at runtime?
I have not tested with two devices as builds yet
Going to do that today when I find time.
when you see a difference in behavior between a build and the editor, 99% of the time it's one of the following:
- Script execution order issues (Your code assumes Start on script A runs before Start on script B for example. In reality this order is not guaranteed and can change between platforms)
- Framerate dependent code (Your code behaves differently at different framerates)
I suspect the former in your case. You should start doing some debugging, especially around your list-populating-code. Question your assumptions
Interesting point,
I do debug rather a lot to keep things neat yes.
This isn't something I thought of,
Scripts having different start times based on platform...
Thanks.
It is indeed on a start function.
Calls an enumerator forcing a 2.5 sec delay to allow multiplayer code to initiate fully before populating a list.
I'll increase the time, check that, then I'll try adding some logs to see what happens when exactly.
Have you ever experienced a list getting populated with triple entries?
In my case there is only one time code executes to add to it, but I'm getting three entries
Two blank zeroed entries one correct
The order is odd top
0 correct 0
On top of the original
If more client join they also add three more to the list
3 clients = 9 entries
It's not a massive problem as I'm only ever using the max value of a list as data but I forsee some issues if I end up with say
65 people joining in and put over an hour without ever fully ending the room.
Perhaps.. I can't exactly test that alone I suppose.
Well.. actually I could it would take an hour haha
Anyway
To the question at hand
Overpopulated lists coming from one single call to populate per client?
It's not even a issue really this bit I just have an ocd with my work
Have you ever experienced a list getting populated with triple entries?
Sounds likely you are failing to unsubscribe your event listener.
That DOES happen
For a single frame
I get one warning about event listener when clients join
Wow your super knowledgable
It's to do with my corputines allowing multplayer code to fully run before destroying parts for other clients
I managed to get it down to a single frame basically, wow so it happens that fast
You've been super helpful this morning
I can probably get that sorted yes
If people here are into mesh generation/slicing, I have a question about cutting triangles in the forums: https://forum.unity.com/threads/slicing-triangles-of-a-mesh.1417122/
What you are looking for ? What you want to do ? Boolean operation ? Culling ?
Any recommendations on methods to calculate the boundary lines for a set of axis aligned rectangles on an integer grid? I looked at sweep line algorithms but I'm confused on how to extract the boundary line. I'll eventually also need all grid positions that are "filled" by the boundary lines. Not sure if I should just flood fill or if something else is smarter...
Wdym by boundary lines
Give me a sec, I'll draw an example
I need the area in purple, and the area in pink. Only the purple area needs to be fast
(And by area I don't mean the surface area, but the grid positions)
Isn't that just a HashSet of all the grid squares inside each Bounds?
The pink area?
Yes
I mean hell you can literally convert your AABBs to BoundsInts and run https://docs.unity3d.com/ScriptReference/BoundsInt-allPositionsWithin.html on each one
And just throw them all in a HashSet
The pink area is probably less of a concern since I just need it to fill tiles on a tilemap. I supposed I could just call TileMap.SetTiles(Bounds) for each rectangle.
The purple area I need to build an outline collision mesh. The easy method would be to just iterate and check if neighbouring tiles are set, but I'm wondering if there's a faster way
Does the mesh need to have that hole in the center
Yes 😬
I'll probably just use a single collider for each grid coordinate, so I only really need the coordinates
It is for a gameplay mechanic where you pull away a mesh and then it breaks in 2. The system has to work on every mesh with many different variations, so I need to slice the mesh. Most of it works, except the triangle slicing. How I do it does not matter much
There is 2 situation:
- The triangle is separate by a line passing by one of the corner.
- The triangle is separate by a line passing by no corner.
In situation 1, the result is 2 triangles.
In situation 2, the result is 1 triangle and 1 quadrilateral. Subdivide the quadrilateral in triangle by creating a new line from one corner to an other of the quadrilateral.
Exactly how the user SunBeamCoffee answered from your Forum post.
In situation 2 you can also make it 3 tris, right?
Don't see why you would need to make 4 out of it
The reason why you should use 4 triangles is because you want to reduce the amount of stretching and tearing that arise from having thin rectangle/triangle that results from a slice. It is to keep everything stable and not have extreme which could cause issue of floating precision.
To get to 4 triangles, instead of dividing from one corner to an other, you draw two line to the middle of the opposite cut from each intersection point of your cut.
Ah fair enough
Those issue are more frequent when you do a lot of recursive subdivision. It should be much of an issue for your use case.
That being said, you might want to look into more performant approach for mesh division if this is frequent operation, because it can be quite expensive to operate.
One of the most important issue would be the manipulation of the memory that needs to be synchronise with the CPU and GPU.
But then still, I understand it in theory, but just cannot wrap my head around how to code it. All things I try result in messed up triangles
And it's not a frequent calculation, it happens once every few minutes
I'm sorry, but you will need to figure out yourself. You might be laking in the comprehension of the data structure of a mesh. The order of each vertex as an implication. Actually, this is probably the hardest part.
For now I just need something which works good enough, it's alright if it breaks sometimes. That can be fixed/optimised later
Yeah, I think that's where I mess up right now. Some tris do work, some dont, some overlap quite confusingly
You should try to follow the following tutorial. Anything computer graphics related is pretty much well describe in this collection of tutorials.
https://catlikecoding.com/unity/tutorials/procedural-meshes/creating-a-mesh/
I actually have followed that in the past
I understand the theory of mesh generation, and mesh slicing, but cannot get the cutting a triangle in 3 (or 4) parts working properly.
Already looked at some open source projects and tutorials. I might rewrite everything again, but I feel like I'm just missing some simple steps to get it to show up properly
Try small, maybe create a new project instead of working on the current project you have. Use simple meshes with limited amount of vertices. Only do the division of the mesh and remove everything else. Create a scene where you keep track of all the previous step that you succeed to make.
Try a single triangle.
Try two triangle.
Try a cube.
Try a sphere.
...
This is standard procedure in programming. It will happen for a lot of the work/bug you gonna work on.
Nobody is gonna solve your issue for you.
anyone else having debugger trouble lately? this identifier IS defined- why is it telling me it's not? Am I just overlooking something stupid?
It might happens whenever you modify a file without correctly saving before launching the debug tool.
I also seen issue like this whenever it fails to correctly evaluate the values. In your case, it does not seem like it is that.
A good restart is usually the answer.
@worthy lodgethis resource may prove useful for that.. plane/triangle intersection in particular, i'd think. https://www.realtimerendering.com/intersections.html
hmm I restarted both unity and VS.. I go for a full reboot - good idea.
no help- will try deleteing libraray folder and letting it rebuild
I have a text input field, that the player can write in. How would I allow them to resize the field you can write in during runtime? Here's an example of what I want to achieve.
create 4 draggable objects. Add script to them that will note the change in position when dragged, and adjust the RectTransform of you TextInput by that delta. @fair plank
@dusty wigeon any other ideas? full system reboot and even deleting library folder didn't help.
No, it may cause issue. The resource path is not the same as the system folder path.
Is the only value you cannot inspect ? Do you have a recursive reference inside your object ? Like a graph or something ? You could also try to update to the latest version.
you can always use the eventsystems current object nad its bounds to check, where your mouse is on that object. if its top left, bottm right and so on, depending on that, show a cursor to tell the user that he can resize and then on mousedown for example adjust the size according to the distance of start and endpoint depending on the corner.
I had to build these kinds of wysiwyg tools in unity at my last job. This was an early prototype I can share, if you want to see one possible implementation of this for reference to get started. There's a live build you can play around with as well. We made this more nuanced over time but this might help get you started. https://github.com/galenmolk/studiosaurus
Specifically, check out the structure of resize-handles.prefab and its attached scripts.
So close to flipping my table.
My mesh cutter works perfectly on the default cylinder, but doesnt work on a cube for just 1 face.
Does anyone have any idea what could cause this?
Code is in forum post
So the green one is the correct result mesh with its edges?
No, thats the generated mesh collider. You can see the orange outline working for 3 sides, but not the last one. Here are pixtures of each side of the cube.
I just cut 1 kind of triangle in this example, so I dont see how this could happen
Is this the base cube you trying to cut?
Hmmm going back to the drawing board, the code only calls 3 times weirdly enough.
Not sure how or why...
Yep
What exactly are you trying to do? It might be easier do use blender if you are trying to deform the cubes mesh
I need to cut a mesh in 2 at runtime, so I am writing a mesh slicer (over a plane). I keep walking into walls generating the cut triangles
Can anyone with Unity Timeline experience give me a hand here? I'm getting a weird bug where two animations are being added instead of being blended as expected. https://forum.unity.com/threads/character-offset-issue-when-timeline-gameobject-is-not-selected-100-reproducible.1417596/
The issue only occurs until we select the Timeline Gameobject in the hierarchy so this seems to be a Unity bug
But I'm wondering if I'm doing something wrong anyhow. Any help would be greatly appreciated
I want to make a custom editor for a specific kind of gameObject, using a node graph.
I need to then serialize the node graph data, but I also need to create the gameObject components, depending on the graph data.
What would be the best way to do this?
I thought about having a component that references the node graph data, that then creates the gameobject, but remaking the gameobject from the node graph data everytime I instantiate it seems unnecesary
you start by, definint what you actually want
because "making creatures intelligent" in a game making context is wildly unespecific
i guess, yeah
im having issues describing what im even looking for, i guess my brain sorta defaults to simple intelligence, which yes, is wildly unspecific
I appreciate your help 💜. Was pretty busy today and didn't get back to you. I looked into your implementation and found it very useful. I managed to get everything I wanted working.
this looks like winding order issue
awesome, glad to hear it
i think you want to try poseidon CSG, which supports runtime mesh cutting
I feel like you are seeing this from the wrong side. The behavior and data should be inside your component while the graph should only be a UI to manipulate and visualize the components. In other words, your system should work without the actual graph.
A graph is only an alternate way to edit the actual object. Think of it literally as a Custom Editor and use it as such.
But the graph also contains information that the component doesn't (node position, comments, etc)
A visual representation should never ever have data present that is not coming from the source.
Shadergraph, vfx graph
Those graphs are just visual versions of shaders or other systems, still you do not add data on top in the graph itself, you just create inputs and outputs which are still inside the shader code.
They still contain info that the shader or the VFX don't
(node position, node grouping, comments)
How do i get the world as a matrix?
Ah, now I got what you mean. Did you elaborate how shadergraph is doing this? Is it in the meta file or in the graph asset itself?
Ok I think you just said all I needed to know
Didn't know of the existence of .meta files
That question is not really obvious to answer, what do you mean?
Please, no answers based on assumptions. I need answers from those who really have experience with both methods. Try to understand! Thank you!
I hope someone can give me the proper answers! Thanks in advance!
It’s about the comparison of a completely handwritten built-in character with pseudo physics, or a character controller that uses unity physics without kinematics!
In comparison:
Does the character controller with unity physics take more performance, especially when you plan to upscale actions and use it for mobile too?
With Unity physics these days, is it possible for me to encounter physical glitches, especially when two character controllers clash with their velocity? This brings up the main question, can I fully control unity physics without getting any glitches at all?
Or is a built-in pseudo physics written character controller still better, because of the full control, that allows a low overhead regarding performance and avoids uncontrollable glitches, despite it being more work at all, because every case has to be considered.
You want a guarantee no one can provide. First, you want to avoid ANY glitches? Its a game engine, on a computer, everything can glitch, low memory, bad performance in general and so on. Bugs happen on every version, so no guarantee here. You want us to compare a pseudo physics hand written code (which we dont know, cause you did not write it yet) to compare against unitys physics system. How should we go with that? If you are doing a better job than Unity with their physics engine, sure, go ahead and write it yourself cause its going to be better.
Please do not cross-post. Use one relevant channel at a time
Breaking internet etiquette in more ways than one
Please don't answer and destroy my questions because you didn't understand the question and you're actually just trying to counter everything with countermeasures. Especially you, who gives answers to everyone, because you have not anything else to do! Thank you!
It has a reason I posted it in both sections. I need the answer from people who have experience in physics, and those who have experience in scripting.
Both channels are relevant to that question!
that is irrelevant as the rules and guidelines state to not post your question(s) in multiple channels . . .
Wow, nice attitude. Keep on going 😄
sorry, I realized it was in both code sections. right
And also in physics
But what they said makes total sense. Your question is very ambiguous. Even someone that has experience with what you mentioned, wouldn't be able to give a definitive answer.
i'm confused about your previous response. if @midnight violet gives answers to everyone, wouldn't that indicate their knowledge and/or expertise with certain topics? i think the ppl they've helped would disagree about them taking their free/busy time to assist in their problems . . .
his first answer only gives others the same idea and negates any subsequent possibility of an answer. see dlich's answer and yours. everyone is already on this side.
thank you and adios everyone!
I was about to answer the same way when I've seen your question in general code. I only decided to not reply because I knew it would end up like this...😅
If you have any specific questions and willing to listen to what people have to say, then feel free to ask.
is there any way to load code in runtime in iOS? Seems like Assembly.Load doesnt work because iOS builds are with il2cpp scripting backend (correct me if Im wrong, im not sure if its because of this). How can I have a game in iOS, and load code in runtime? In Windows I have asset bundles of code and when I need it I do Assembly.Load, but I cant do that in iOS.
iOS App Store forbids dynamic code, all your code must be statically bundled in the app directly.
sry for my little knowledge, but what does that mean? I need to have all the code from the beginning?
I am creating a game which has downloadable content (dlc`s). This dlc´s can be downloaded and activated at runtime in Windows, but I cant do it in iOS.
You just have to have all the code (including what the DLC needs) in the app already
Other assets of the DLC can be loaded at runtime, not code.
Ok thanks. The problem is that the idea is to let people create the DLC`s and add them to the dlc catalog (im using a page called mod.io). I should have said mods instead of dlcs 😅 . So for every person that wants to create a mod, he needs to provide me the code to add it to the main game?
If you want your app on the App Store yes
Or you can try to cheat Apple's review, but I wouldn't suggest it.
IIRC the relevant part of App Store guideline is that, your app cannot alter its behavior so that it's significantly different from what's been reviewed by Apple.
What's "significant" is basically up to them, monopoly is great 😄
Ok, thanks ahah. But even if Apple would let me do that how can I add code in runtime in iOS? Because Assembly.Load doesnt work
Maybe someone else can answer.
Btw if you are trying to cheat pass Apple's review, just so you know that depending on how you try to load dynamic code, Apple has static analysis tools that detect these things, so it's an auto rejection.
Nah I dont want to cheat it, just tell them the idea and maybe they let me do it I dont know haha. Thank you for all the help!
Well the world is a 3d matrix
How do i get every node of it
Like 3,4,1 and do something with that world pos
To spawn an enemy there
Or somthing
Why can you not use these numbers as a position directly?
The 3D Matrix can be 1,2,3 but can also be 0.00001 and from there up... so the question is not really logical to answer, what are you trying to do with it? The world matrix is just set by transform.position = Vector3
So, I am not the most knowledgeable on this topic but I know my fair share.
First of all, the issue with the Unity Character Controller is that it is a general purpose controller, meaning that it can do a lot of things, but might struggle with more complicated scenario. One example of things that it might struggle to do is:
- Adding alternate means of movement such as: Climbing, Sliding, Flying, Swimming, Wall hoping, etc.
- Reducing the amount of check base on the actual gameplay of the game such as: Step Detection, Slop Detection, Side Collision Detection, etc.
- Usage of physics such as the Rigidbody. The Unity Character Controller does not support the usage of physics on the character itself.
For the Gliches part of your question. Glitches are not always, and most likely will not come from the Character Controller itself, but on the interaction between it and the rest of the world. A bug occurs whenever there is an unexpected behavior. So, by definition, it is guarantee that the Unity Character Controller will cause glitches because they cannot plan in function of what behavior you are expecting from your personnel project.
However, is doing your own Character Controller will prevent glitches ? No. There is no way to guarantee that something will prevent all glitches (Except using Formal Specification - https://en.wikipedia.org/wiki/Formal_specification, which still requires you to define all the specification (interaction) to insure that there is no glitches)
To make this decision, you need to evaluate what you want, and what you can do. Question like:
- What are the movement my character has ? Are they supported by the Unity Character Controller ?
- Does the Unity Character Controller do more than what I require ? How much does it cost in performance to do those things that I do not need ?
- Do I have the resources and knowledge to make a Character ?
- What is the desired quality ? (Prototype, School Project, AAA Project)
I'm sorry I was not able to be more descriptive, what you are asking could be an entire chapter of a Book, and I have little to no words/time to use. I had to delete some sentences to make it fit.
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
O
well good sir many didn't understand my question so i will draw it
Hey guys is there any tutorial for CICD pipeline for unity?
I wrote a yaml file for building my project for WebGL however, it seems like the editor removes the Build folder after building the project.
Development operations (DevOps) is a key group of tools and workflows that you can use to help you create and manage your game or other real-time experience throughout its lifecycle. You can complete this course as a guided learning experience or just explore the specific content that you need to support your DevOps journey.
Also, is it advised to run playmode tests in CICD pipeline?
thats admittedly not much, but maybe a start
that probably depends on your game and release plan
it is generally advised to do whatever gets you to iterate and deliver faster and reliably
@midnight violet here! i drew it all for you good sir
hopefully my question is clear as day now
are you asking how to snap stuff to a grid?
var gridPos = new Vector3Int((int)transform.position.x, (int)transform.position.y, (int)transform.position.z);
well doesn't transform as the explain you showed me
take the position of an object?
and yes
i would need to convert some specific world parts into nodes
if the grid origin is not at world 0,0,0 you would just add the offset to the world origin to the transform position before casting it to an Vector3Int
ye
but how do i get anything from the world?
is there a function as shown in example
like world.x
or anything like that
idk what that means, the transform of any gameobject returns it world space position and rotation
what does that mean?
let's say
that world is a world[][][]
as in a matrix
i would need world[x][y][z]
i am really getting confused, am i explaining it wrong ?
coordinate (0, 5, 0) in world space is just new Vector3(0, 5, 0)
world origin is always at 0,0,0
ye logic
so there is no need to have an object describe world space
yes
world is defined by convetion in unity
it has 3 orthonormal axes, expressed in float
Which is the correct way to increase the speed of a PlayableGraph? I found both solutions in internet, but I'm not sure:
int count = graph.GetRootPlayableCount();
for (int i = 0; i < count; i++)
{
graph.GetRootPlayable(i).SetSpeed(value);
}
Or:
int count = graph.GetOutputCount();
for (int i = 0; i < count; i++)
{
graph.GetOutput(i).GetSourcePlayable().SetSpeed(value);
}
Given the code, I would say one will increase the speed of a node while the other increase the speed of the whole graph.
Something like the: AnimatorStateInfo.speedMultiplier vs Animator.speed.
Which one is to increase the speed of the whole graph?
I should say, the speed of the whole sub-graph.
I simply want to take a PlayableGraph and change its entire speed.
But I hardly understand how it works 🤣
So how could I do that?
That allow me to set its update mode, but I want for example, update on each frame, at double speed.
I know I can use Manual and evaluate manually, but that forces running the graph right now, rather than during the Director Prepocess frame
Can you just do Time.deltaTime * 2 with PlayableGraph.Evaluate ?
yeah, you just use the manual update and do your thing on speed
than evaluate manually to update the graphs state
Director Preprocess Frame? Hm, gotta look that up
That would run the graph synchroniously, rather updating it in the Director PreprocessFrame.
AFAIK, the Director Preprocess Frame can run some stuff asynchronously
i.e: .Evaluate() uses a different workflow than letting Unity taking care of it
the Manual Update Option is already asynchronous, isnt it?
No afaik
It runs in the same moment you call it
"This can be useful for graphs that are completely disconnected from the rest of the game. For example, localized bullet time."
I am not firm with the playablegraphs that much, could you make it async with using Tasks?
Neither am I hehe.
I don't see how Task could be included there.
The idea would be to tell Unity to run it next to its own internals playable graphs, but using a different speed.
So from what I see, the evaluate is a problem cause you throw it out of the Jobs queue therefore as your forum post says, it will add overhead for every evaluate you are calling, correct?
`There's a clever user who figured out that you can put multiple animators in one PlayableGraph, connect an AnimatorControllerPlayable to each Animator, and then manually update the PlayableGraph.
Doing this will execute the Animators as a batch, which will take advantage of all threads. It requires a bit more work than just dealing with the Animators directly, but it might address your use case.`
I know that and it's what I am doing
However, running the PlayableGraph with .Evaluate is less optimal than letting it be run in the Director loop
As the graph is run synchronously (with multithreading, but synchronously)
Why would you chain your animator ? Can you not make them in parallel ?
That would be less performant, the whole idea of doing this for me it's to increase perfomance
Does not look like there is much option for you than evaluate manually if you want to decouple your speed from one playablegraph to another.
What you are even trying to do lol.
My idea was to enqueue them in the Unity director, but with a custom speed.
So you do not want to increase the speed, but decrease the number of update.
Instead of running stuff like animations on each frame, I run then each X frames or X seconds.
I use this on objects that are far from the player.
Sounds like a LOD system for animations
Yes
Kind of
My system has:
- Normal.
- Player is not looking.
- Player is in another "world" (the game has 2 worlds than run at the same time).
And yes... we must run animations even if the player is not in the same world due stuff...
At the moment, I use .Evaluate(timeSinceLastUpdate)
you need to run animations even when the player is not there?
Yes, we use root motion in enemies, plus animations has events that must be called, etc
So if I could update enemies that are in the other world each 4 or 5 frames, I would save resources
Oh they "worlds" run at the same time, got it
It seems to me that the issue is there.
Yes, and player can travel between worlds instantaneously. So it's really important that both worlds run in parallel.
So we you leave a world, and return in 3 seconds. The world must have progressed 3 seconds.
But since the player is not looking directly, we can afford a bit of precision sacrifice and update each a few frames
I am wondering, are the playablegraphs are updating correectly when you disable them and enable again later?
because they still evaluate with the current time values?
If I use manual .Evaluate(float), then that is not a problem.
If I let the director run them, it will use current time, which is bad. Hence I want to multiply the graph speed so I can compensate the current time + time since last update.
but what about that update option with time.time?
It seems to me that your "Worlds" might have to much element that are dynamic and updated for low-end console and should look into more aggressive way to cut out. If they are not even invisible.
Time.time will always be the same, so you could just disable and enable and the time.time evaluation should still work correct
I still need to multiply with a custom speed.
I.e, graphs are disabled, except in the frame which I run them when I call .Play. So I must to set the speed to take into account the missing updates
but that would just be a float to update
DirectorUpdateMode.GameTime will update the graph using the delta between this frame and the previous frame.
But since I only update each X frames, I can't use the "previous", instead I must the delta between this frame and the "Xth" previous frame.
I think Simferoce might be right, if you are running into issues with Evaluate, you might have to cut things or decouple animations and states. Does not sound like something easy to refactor 😄
Luckily, at the moment we are not suffering performance problems, but I was preparing the game for the future as currently we are playing with smalls "Worlds" but then we plan to make them bigger, with more stuff 👀
I am still not sure why you cannot make your animator in parallel inside the PlayableGraph.
I can, partially.
Parallel != Asynchronous
I want both
Also, some parts of the Animator an in Parallel, and other not
And .Evaluate has less Parallel parts than the director
Am I stupid ? Pretty sure Parallel is Asynchronous.
You can run stuff I parallel but force code to wait for completition
Parallel means to do thing at the same times.
Like Parallel.ForEach(1, 10, e => {}), this is in parallel, but the code can't continue until it's run.
Yeah, the animator is the same
It cannot continue on the next frame if the last frame is not done.
But all animator are update at the same time
I know, but it still can be asynchronious inside the same frame
The Unity Director does that, in part
Also, the Unity director run more stuff in parallel than .Evaluate
and run stuff in multiple player loops, so it can run asynchronously in part (schedule in a loop, complete in another)
Which is exactly what would happen if you update all of your Animator in 1 playable graph.
How do you know that ?
It's from the link https://forum.unity.com/threads/playablegraph-evaluate-performance-best-practices.639511/#post-4284553
And then, you have
I know, but the above still applies. .Evaluate is still synchronous and not split up and run in different points.
No ? If you have 1 Graph with all the animator, you have 1 batch.
For Animators, for example, the following trick works better, I guess because it still uses the default graph
But that batch is run synchronously rather than split up and run in different points, taking advantage of the asynchronous nature of jobs
Bro, how much performance do you need...
I don't want to reinvent the wheel for so marginal gain, but if there was a way to run them in the director with a custom speed I wanted to know. Hence the question 🙂
We are speaking of marginal gain in most scenario.
You gonna have other issue than animation performance.
We are not talking about speed, but update rate.
The real solution would be to completely deactivate the animator and do every other update whenever it is required.
I know, if I use .Evaluate(float) I must just feed it with the time since last call.
But if I want to run it in the director, I can disable the graph when not used, and then enable it only in the frames I want to update. And in order to update the delta correctly between this and the last update using the delta between this and last frame (which is not the same), I must be able to feed a custom speed mulitplier.
Yes, and I must to feed the time since last update
Explain me then, I don't understand
You do not evaluate between both.
You just restart from the new position.
Let's you have an NPC that is pathing to a location. Whenever the NPC is close to be visible, you activate the Animator.
If the NPC is not close to be visible, you do not update it visual.
You still "move" the NPC same if its visual is not there.
An alternative would be to teleport the NPC to the his location whenever is being visible. The location being estimate in function of the time he as been invisible.
You are talking about doing this outside the playergraph and animator, right?
Yes
I know you have issue with event and maybe other things. But this is what you should fix.
I see
guys, I have the need to do an object pooling system, and I need it to be able to pool multiple kinds of object but need to limit the total amount of objects exist
based on docs I guess I can use UnityEngine.Pool.DictionaryPool
but the doc on this is very limited and I'm confused on how to use it
I'm not even sure it does what I think it does
anyone have an example on how to use this?
but this one not using UnityEngine.Pool ...
This an alternative more easy to understnad
You can look into https://thegamedev.guru/unity-cpu-performance/object-pooling/ otherwise, if you really want to use the new pooling system
Could someone please assist here, I'm trying to center this text inside the red area.
GUILayout.BeginArea(new Rect(0, 0, 785, 75), GetBackground(785, 75));
GUI.skin.label.fontSize = 25;
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label("Kitchen Nightmare");
GUILayout.EndArea();
thank you, this looks detailed, I'll study this
If you are doing prototype/small project, you should maybe use the simpler approach that is describe in the tutorial.
Hello, I need some help with raycasting. I have grass over the terrain as independent objects, I want to detect the tag of those objects with raycasting, however grass is only detected when my player jumps, any advice?
not an advanced issue. but show relevant code in #archived-code-general or #💻┃code-beginner
Thanks
i just recently put assembly definitions into the project so that it compiles faster and has a bit better separation of concerns, ive got a few questions
- do you like assembly definitions in general or only in medium/large projects?
- I've got an assembly definition with code that uses unity's async systems. Now, wherever i include that assembly, i have to include the async assembly that unity uses. This is kind of frustrating, since i was imagining it would work similar to C++ header files where the includes would "trickle down" so to speak. This example goes for other external add-ons such as text mesh pro, and considering that my game is mostly text its kind of annoying to include that in every assembly. Thoughts/solutions?
use UGUI
I use them for the same reason and, yes, all dependencies need to be set up manually. I haven't tried it myself but I assume you could automate the addition of common dependencies with a script.
To be more specific, a lot of my code live as packages that exist in many projects, so assembly definitions are required
Yeah I unfortunately don't have a vast library yet but I do have some things I want to turn into packages and having them use assemblies will just make them better
The idea of automating assembly definition dependencies sounds pretty cool though, not sure but if I could extend the class definition of that that should be a pretty nifty editor tool
[field: SerializeField, HideInInspector]
public float VelocitySqr { get; private set; }
So I have this property inside my scriptable object.
I don't want it to be available in inspector but still be serialized..
but I see this inside inspector
Anyone know why?
Heya, I would although I'm doing everything at runtime, nothing is made in the editor.
I'm making a workshop mod for a game, and the only thing supported it .dll injection
the HideInInspector attribute is not applied to the backing field
is there a workaround to this?
field: apply it to the backing field
I tried it, same thing.
What I wanted was to save some perf by doing,
[System.Serializable]
class TestData {
[serializefield]
float velocity;
[field: ] //serialize this but also hide inside inspector
float VelocitySqr {get; private set;}
void OnValidate(){
VelcoitySqr = Velocity * Velocity;
}
}
//usage during runtime
Debug.Log(TestDataInstance.VelocitySqr);
However, that hide in inspector doesn't work with serialize or backing field. So everytime I need velocity sqr, I am not doing velocity * velocity;
It's not mandatory though, I will just cache the sqr during runtime Start() usage of TestData instance, just wanted to know if it was possible to have the behaviour I wanted
hmmm doesn't work for me in scriptable object though.
my TestData class is a separate data class,
so in scriptable object I have this:
[field: Serializefield]
public TestData[] testDataArray {get; private set;} //with Test Data having Sqr property defined inside it
The behaviour is no different in scriptable objects for me
I am looking at 2023.2 though, so something may have changed between versions
(it also makes little sense that it would since they're treated the same)
I don't see why it would though, because it's just lowered code, might as well be a normal field
Anyone knows how to do this?
Regarding performance, i currently wonder how to implement update / player movement logic, as there is a crossroad to decide on (both using the new input system):
A)
Regular Update() methods in the scripts constantly read values from unity's new input system and apply inside each script (the "classic" way), so WASD would be read inside the player movement script, Mouse would be read inside the script responsible for casting (rpg, mage, spellcasting), etc.
or B)
Event Driven + Global Manager: also new input system, all input events are referenced in one global script (for better overview), so if for example WASD is pressed, the script would call a public function move() from the player script. If Mouse is clicked, it will call the cast() method of the speel casting script. Benefit: in times where the player does no expensive movement or not pressing keys, there will be no processing of input in update() loops.
But not sure if i missed something. The goal is clearly the aim for performance benefits, as well of having all input references stored in one script, for better overview.
I believe this may be prevented because of security- if you could load assembly in an apple device, then that would be a major security flaw, as with assembly you could do bad stuff, like accessing the memory of other apps and their stored information.
Hi, friend, I was asking the question about startup time is too long on NX. I'm using NX CPU Profiler.
I've seen that the native profiler (instruments For IOS and Android Profiler for android) is able to auto start sampling at very beginning once the app launches, so that there is Unity Engine Initialization info.
But seems like there no such behavior on NX CPU profiler. No matter how I attach to my app, I have to manually click start sampling.
Did u do such analyze on NX before?
I usually use [Wait For Managed Debugger], but I never had to debug the beginning of Unity Engine.
emmm alright thx
If you are looking for performance, you should definitely use an Event base approach. In fact, I think this was one of the perk of the new Input System.
However, most of the time, input is not that costly. There should be a minimum of script reading inputs at a times and those script most of the time has something else to do.
Also, by looking at your example, I'm worry that you might implement the system in a non flexible way. The input should always flow from the logical owner to the deepest owned. What I mean, is that you should read input in such a way that you can amend the behaviour to be able to "consume" the input. This way you have better control whenever there is alternate context where you should not do an action such as when you use UI in game. Worst than that, in my opinion, you should also decouple the Input from the Character such as you can control a Character by faking input. This can be useful if you have to create cinematic or have to transform your Character in an "AI".
Why is calling a function from a different class/struct that only draws Handles laggier than if drawing from the Editor script itself?
Thank you for the valuable input, the last part i do not understand fully i think, option B would introduce a manager and prevents having the different controls distributed in the single scripts that make use of them, therefore i should have more control (which i think is what you meant?). Maybe i misunderstood something?
In my case i am planing to release my game on steam and so i try to squeeze out any fps i can, through the whole development phase. I agree there would probably no noticable difference for this change alone, but for HPC all these tiny bits matter. For the scenario i explained, the goal was to not have the inputs checked in update() constantly, i rather wanted to have them checked only if a key is pressed to avoid unnecessary code logic in update() loops. So the whole movement logic would only be executed when the user presses a key. Hope this explains it well enough.
Separate script can be a good idea, but I wouldn't necessarily make things "global". I would start from the example set by PlayerInput and PlayerInputManager, which supports features such local coop.
I wasn't actually talking about your code 😅
Thanks, i may have expressed it badly, with global i meant not global methods, i meant to have one script that globally (for the game) holds the input events and their connection to each function.
Ohh lol sorry mate, i got that wrong 😂
I was talking about an architecture more inline with that. There is multiple way to do it, I just do not think that the approach you seem to be doing was a great idea.
If you are targeting PC, you won't have any significant improvement over remove 1 or 2 update loop.
Wow thank you, yes this is exactly how i pictured it in my mind!!
No. The input manager would be ControlManager.
The buffer is an intermediate class which allow the interfacing of Character/UI with his controller (Player or AI)
It can also be useful for Cinematics.
The only part that would say is necessary is
Main platform target is PC, i try to cover console but i have no experience there, so i am not sure if the final build would run there. You are right, probably there no visible difference in fps, but i must keep the mainthread as clean as possible (as mutlithreading is not working yet, this is a story for its own).
imo smth plain like this would be all that's needed:
class InputManager : Singleton {
List<IInputUser> inputUsers = new();
Dictionary<KeyCode, KeyBinding> keyBindings; //populate somehow
// In-game input, UI input, cinematic input, or whatever could plug their input in and out dynamically whenever they are active/inactive.
public void Add(IInputUser user) => inputUsers.Add(user);
public void Remove(IInputUser user) => inputUsers.Remove(user);
void Update() {
foreach (var (keyCode, keyBinding) in keyBindings) {
if (Input.GetKeyDown(keyCode)) { inputUsers.ForEach(x => x.OnInput(keyBinding)); }
}
}
}
no cross references either -- and the dependencies are corrected
This would be Option A) of the two paths i have atm, where input sources are parsed each frame in update()
When I was talking about Cinematics, I was talking about faking the input, not redirecting the input to the cinematic component.
By example, you want your character to cast a spell in a cinematic.
ah, I see
Instead of directly calling the function, you use the input as if you were controlling the character.
ahh now i understand what you meant by "faking input"
That being said, there is other alternative.
Using a buffer inbetween is a way that worked for me.
In my opinion, something like casting a spell should already be a high level concept that should be easily invoked without faking input or digging into the internals of some script.
It depends. Some spell may have multiple stage where you charge the spell. You can either make the player manage the spell or let's the spell manage itself.
These are all interesting points indeed
Making the player manager the spell add unnecessary code to the player in my opinion. Whenever you have multiple way a spell can be use. It can start to blob the Player/Character
I've seen some bad input implementations that have led to bad performance. For example, I often see the OVRInput script in the Oculus SDK with 0.5-1ms in the profiler. This is because it's processing all input from all controllers, regardless of whether it's read anywhere.
It is sure can be an issue. Having best performance is most of the time the inverse of having the most flexible code.
This is why you should know what are your objective.
tldr you're dealing with ns of difference in both cases, but event-driven input would win. Input is one of the case in which you should be caring more about the architecture.
You can have very nice architecture with both, but option (1) sounds iffy the way you described it 😛
And what are your plateform.
This is what i am worrying about if i process inputs in update constantly, even if its just a milisecond, it would be worth to me to eliminate this "overhead"
No. Not on PC.
Oh ok
it's far from a millisecond 😛 0.05ms in worse case, and typically I'd say 0.01ms even if u have tons of input
and console?
Depends which
I would say low end mobile
But something like the Switch or a PS4 will be able to handle those just fine.
Guys, i thank you really much for the great advices, you all have legit points i will take in consideration for the decision. I tend to Option B) as i feel there was the most consensus from each of you who helped here. Thank you very much, great help! 💪
Hi everyone, I'm unsure if this falls into general or advanced but I was wondering is it possible to run multiple simulation with the same physics setup. I know you can do both:
Physics.Simulate(Time.fixedDeltaTime);
physicsScene.Simulate(Time.fixedDeltaTime);
However when trying to simulate something 200* a frame, things start to chug. I've looked into this a little bit and it seems that the major impact is the set up phase for the physics when calling simulate. Is there a way to avoid this or is it required?
What I need this for is just to render the trajectory of a projectile. I would usually use the Kinematic Equations and just do this as a equation over time, however since the projectile has custom physics running on it (in fixed update), I'm assuming the only real way of doing this is to create a new Physics scene, create the projectile there and then simulate and manually call fixed update from within a loop.
Is there any faster way of doing this? Or any suggestions that I could do this in a different less expensive way?
math-based simulation instead of full-fledged physics simulation? would be faster
Reduce the amount of simulation but increase the time step.
this isn't an advance code question. Delete and ask in #💻┃unity-talk
sorry I considered entity slightly advance and maybe it is conected to code, that's why I asked this. sure ill ask there
these code channels are for discussing code you write
@hardy sentinel I agree, though the problem is I am trying to match a trajectory of a projectile that was once fired. It needs to be accurate to the original path and also effected by collision. The problem with a mathematical approach is that it is too true to the real world physics. Comparing manually simulated physics to the projectiles path when using a pure maths based model I get ever so slightly different paths.
@dusty wigeon Much in the same way, I can't really decrease the simulation time, since that would also make the projectile no longer accurate to its original path (which was generated using fixed updates delta time). A projectile with a lower simulation time seems to fall a lot shorter then that of one with a higher / more accurate time.
As such I don't think changing simulation step time will work, instead I was wondering if there was a way to manually call the PhysX functions. Looking into the code it seems that physicsScene.Simulate calls Physics.Simulate_Internal. Which intern calls Physics.Simulate_Internal_Injected. Which finally ends here with the rest being called externally.
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Simulate_Internal_Injected(ref PhysicsScene physicsScene, float step);
I'm wondering that if Unity itself can call these functions and run its physics in the background is there a way that we can also?
I am almost 100% sure it is impossible to do what you try to do. (Prevent the setup phase of the simulation)
You will need to find alternative solution:
- Increase the time step
- Reduce the simulation time
- Use mathematical approximation
- Find an alternate physics engine that has more performance
- Do your own physics engine
Hmm, okay. Thank you, I thought it may be but wanted to check. I'll see if I can think of something else that can fit for what I'm trying to get done. Thank you both
GPU physics pog
No, you can ask your question in the most relevant channel here. If you're afraid your question will get buried, make a thread. Anyone can make threads here
ok amigo
as a suggestion not mentioned yet, can you simplify the physics in the separate scene? i.e cull irrelevant layers/objects, cut it down to the absolute minimal interaction your object will encounter?
can some one pleae help me
#💻┃code-beginner message
seam like my question got berried
is this an FPS?
@latent moss if the player's inputs are driving the camera...
- there is time between when the input is read and when the frame is presented to the user
- so if you read the input in
Update(which is the default when you use input events, so evented still means Update loop by default), and thatUpdatehappens to be very early... - the input you read may be dated at "time = 0ms". you position the camera
- then the rest of your scripts run for a duration of 5ms
- then you render for 5ms. so 10ms have elapsed so far.
- then you wait for vsync (on a switch for example), so another 6ms.
okay, regardless of what you are doing, your input was 16ms out of date. if you are targeting 30fps on a switch, it could be 30ms out of date. - so... it doesn't matter how long you spend processing the inputs provided it's less than 6ms in this example, if the moment you are reading them is far away from the time the camera picture is presented on frame
i don't know if you've been playing fortnite on the switch, but between 2018 and now there were huge changes to deal with input lag, including fixes from nintendo, because that platform is especially bad
i have no idea what input lag is like on a switch nowadays, but it has one of the worst architectures for FPS / input-driven cameras
Thats what I've done. Basically have a copy of a second scene generated through code on start that remains empty. Then I cache the physics scene.
On needing to start the trajectory test i create the projectile as a new game object. Move only the necessary geometry over and then inside a for loop run Simulate over and over.
Unfortunately the problem is the set up time used by simulate. Even with only one projectile and an empty scene the most I can get is around 100 framers per frame. Which I do understand is petty good. But ideally I would want around 500 -> 1000.
(But at 200 fpf we start hitting 15 fps).
yeah, it sounds like you're pushing the limit of what is possible already, there's some generic physics optimisations you might be able to do in the second scene that you couldn't in the main one, e.g setting static flags on everything except your object, fixing the collision matrix to only be checking collisions involving your object
I can't imagine that would increase performance enough to go from 100 to 1000 iterations though
think you'll need to consider one of simferoce's suggestions
Will do, defiantly thought it was worth asking though, learning in recent months that there is a lot more in the engine that can be done if the right sort of tools are used. ^-^
Thank you
is this known bug that 2 overlapping screen-space camera uGUI lose the canvas stuff from the one below?
How can i Check if a particle system is a subemitter within a script? 
I can check if it HAS subemitters... 
But not if it ahs parents
RPG Maker Runtime
I guess you have to manually extend the particlesystem to get that behaviour, like parenting the gameobjects to check if the parent has a particlesystem
Thank you for the valuable input! ✌️ It's an rts like game with many units (thousands), so i have to keep an eye on performance, even if its only a few fps here and there. I have no experience with platforms like Switch so it is great to hear what obstacles to expect, when building for consoles. Main platform will be PC, but if console works out too, then that would be great.
Will definately keep this in mind, thanks a lot!
The error message indicates that there is an issue with the serialization for the players script. Unity's serialization system requires that all fields in a class are marked as either [SerializeField] or [System.NonSerialized], and any fields that cannot be serialized will cause the error you're seeing. You could try to add [System.NonSerialized] infront of the autoStartServer variable, so like this:
[System.NonSerialized] bool autoStartServer;
Chances are good that this resolves the problem.
But a simple bool serialisable, isnt it
tbh thats what i thought too, as bool is a pretty native type, but for that specific, i too had no answer
I wonder what his assembly Shiryu.Saikin.ClientServerManager even is here. There seems to be more to it than just a simple prefab in the bundle
maybe he can post the problematic file(s) here, that could indeed give more clarity about the root of the problem
Is there anyone know how to use ObjectParameter<T> in srp VolumeParameter?
I get error(Object reference not set to an instance of an object) if I write like this
Ok
But aren’t bool serializable anyways
Yo I'm tryna make an advanced AI for my game
and rn i'm having the issue of not being able to keep the enemy away from the player (ie, at its stopping distance)
how do i make the enemy move backwards when the player comes too close
are you using navmesh or just full custom script?
navmesh
although i am working on creating my own a* pathifinding
would i set the new destination as player destination - stopping distance away from the player
or would i just find the distance between the player and the ai and then move the enemy the remaining distance
again by setting a new destination
i can't really think of anything else
Thats how I would do it, have something like a radius check and if thats getting hit, avoid with a new point away from the player
okay
tyvm
implementing that is going to be a bitch
but hey thats our job isnt it
is it a multiplayer rts?
I'm writing a converter for URP to HDRP since there is none found online. my workflow is that you take your mesh, materials and textures, package them and import them in a hdrp project.
The good thing is that the YAML is still the same so the object doesn't lose its data. But the problem is that when i try and debug the YAML values, they return wrong values. Any clue what could be the reason for this? that is doesn't have a shader? my current workaround is actually reading out the YAML file but this is a slow process.
Example:
Here you can see, the bumpscale is set to 1
when i log the bump scale
It returns zero
When I do the same in the urp project, i get 1
Any tips on how to get around this faster?
Hi all. Got a weird issue with Advertisement. When I use the Advertisement.Initialize (after saving the script) and run the game it initializes properly. If I stop the game and run it again it won't initialize at all or give any errors. If after that, I add a space to the script file and save it and then press play it will initialize properly again and then if i press stop and play again it wont until I save the .cs file again. Any ideas?
maybe Advertisement isn't set up to work properly if domain reload is off. Project Settings > Editor > Enter Play Mode Settings > Ensure Reload Domain is checked and test again
That fixed it! Thank you so much!
Thats what we (user twentacle and me) also wondered about, it should usually be serializable as bool is a native type. Is it declared like this in the code? -> "bool something = true;" ..or false. If everything looks normal there, i would check next if there any cast or type conversion in a later stage of the code. But honestly its hard to tell without access to the files that throw the error and further guessing could lead along a false path.
Luckily it's singleplayer (luckily, because i did multiplayer before and that has other obstacles in terms of performance). Here, it is a singleplayer, but rts mostly requires a lot of units and moving these costs already some fps, aswell as rendering, obstacle avoidance, etc. So i must save fps at all places. Regarding the initial quesiton, i have now followed the manager / event based approach of input system, and so far i am very happy with it, its clean and i was able to have almost all checks for input removed from update (some updates() even removed completely), now only left with the ones you've mentioned like WASD and camera, those two are still in update. But the rest, is pushed into the assoiciated scripts by events. It seems atleast like a working way imo, would recommend 👍
you can use a Physics.SphereCast() for this to detect all colliders within a certain radius. With that, you can also detect the colision point and get the angle from this using "normal" (so you can detect if a collision happened left or right from the AI). Here is a snippet implementing this, it's from a local avoidance AI i did in a prototype:
EnemyCollisionPoint = new RaycastHit();
if (Physics.SphereCast(transform.position, CollisionRadius, transform.forward, out EnemyCollisionPoint, CollisionRadius, nonObstacleLayers)) {
float angle = Vector3.Angle(transform.forward, EnemyCollisionPoint.normal);
// here we check if the angle is within a 180 degree range in front of the enemy
if (angle > 90 || angle < 270) {
// and here if the hit occurred on the left or right side of the enemy and turn player into oposite rotation
if(EnemyCollisionPoint.point.x < transform.position.x){
transform.Rotate(new Vector3(0,90f,0)); // we get a hit on the left side, to turn right
Debug.Log("Collision happened: left");
} else {
transform.Rotate(new Vector3(0,-90f,0)); // we get a hit on the right side, to turn left
Debug.Log("Collision happened: right");
}
}
}
Here is a pastebin, for better view: https://pastebin.com/PnRsZQ3v
You can use ".normal" also for a raycast, so if you shoot a raycast against a wall which you are not facing 90°, hit normal can tell you to what side the wall is rotated:
// RHitS is a raycast Hitpoint
avoidingObj = RHitS.transform.name;
float hitAngle = RHitS.normal.x; // hit.normal, super usefull in this case!
if(hitAngle<0){
transform.Rotate(new Vector3(0, 90, 0)); // we get a negative value for hit.normal, so turn right
//Debug.Log("HitS");
} else {
transform.Rotate(new Vector3(0, -90, 0)); // we get a positive value for hit.normal, so turn left
}```
As i am not sure if its clear from writing alone, here is a vague display of the concept (only to demonstrate the use "normal". For your case, which was player distance, refer to the SphereCast):
How much for a physical copy of your masterpiece?
I want to try to program my own simple lip syncing system. However, when I try to find resources I either find animators explaining how to manually lip sync an animation, or adverts for lip sync plugins. Does anyone know any resources for learning how programmatic lip syncing works?
Doesn't need to be specific for Unity, I just want to understand the underlying core concepts, I can figure the rest out myself
I have no xp with this, but i would probably look at this approach: if the face where the lips are recorded is looking straight into the camera, you can use that image as 2D space (x and y axis) and think of a square. Then if you put 3 dots on each lip, where one dot is in the middle, the others between side and middle. If the lips then move, the dots will move on an x/y axis (mostly on y) and you can measure the positional coordinates of each dots. For example an "o" would result in bots middle dots showing much movement, one dot going up on y, the other one down (so you get something like -1 or other negative float value). From there on, you have to capture each letter and maybe spoken words with their coordinates and associate those.
The actual animation part is pretty simple, but the thing that I need to understand better is how to actually capture the spoken letters/words. I'm curious if it's even possible without using some sort of speech recognition AI
I think maybe I'll take a look at some of the plugins and see if I can glean some hints from there
my answer was refering to capture
you literally put dots on a humans lip
this kind of is how hollywood performs motion tracking in general
ah wait, by capturing, was you refering to audio maybe?
You wouldn't need full speech recognition, just phenomes that are then mapped to mouth poses, usually done as blend shapes.
I am trying to create a remake of an old game and want to use the original game's assets. The assets primarily consist of PNG files that I want to use as UI sprites.
The problem is, because I don't have the rights to publish those assets, the built game and game repository needs to ship without the actual PNG files. During development, the assets need to be available in the editor so I can create the game using them, but I have to build the game without the PNG files being present in the binaries. When starting the remake, the PNG files should be loaded in at runtime from the original game's install directory. How can I do something like this in Unity?
You are asking how to avoid copyrights? This is the wrong place to ask that kind of thing cause neither the servers authority nor users will give you advice on how to rip off some game devs work...
What? No, that is exactly what I am trying not to do.
Just by loading the files from the original instead if including them is still USING them... you trying to fake your reality to justify using them
Do you know OpenTTD?
I am pretty much trying to do that, recreating a game from early 2000s because the original source code does not exist any more. And of course the project is open source and non profit.
And anyone who wants to play is required to own the original game.
How is that copyright infringement? It's basically a mod.
Why would you just assume I am doing something illegal and tell me I am "faking my reality"? 😂 That's pretty rude.
A mod is a modification to the original game. You are doing your own version of it but using the assets. I do not know about the games copyrights, but you should be either sure they allow it or enough time has passed. Also OpenTTD is based on personal use. I am not sure how personal it gets when you make it open for everyone. But if you are sure about that, go ahead.
Also OpenTTD is based on personal use. I am not sure how personal it gets when you make it open for everyone.
How is OpenTTD not open to everyone when I can simply download and play it lol
https://github.com/tonihele/OpenKeeper
Another example of what I am trying to do
As I said, it depends on the games copyrights, but if you are sure and with your examples "someone else did it too", go ahead. Seems valid if EA did not cry about OpenKeeper or others about TTD and similar
You are still assuming that I didn't talk to the copyright holders about this. My question was not whether this is something I am allowed to do, but how to use assets in this way.
And OpenTTD seems not to be using the original artwork "At this time (February 2022), proprietary data files from the original TTD are not required to play the binary packed game. " just for your interest
And you are right, if someone wants to hop in on that, feel free. I am out of this discussion
Anyway, I know I can use Addressables to load assets at runtime and exclude these assets from the build. But I don't think that would require the user to build the Addressables using the Editor themselves, instead of just running the game, which will then build the Addressables at runtime and use them. Is there a way around this?
You can read files from anywhere using normal C# methods
The original files wouldn't be in Unity asset format anyway so Unity asset loading methods are of little use here
(I'm assuming it's not a Unity game)
But that would require creating usable Assets (e.g. Sprite objects) at runtime for each file and configuring all the metadata like PPU and everything from a script. I don't think that is very practical. The PNGs are available to me during development, so I can import them and create the metadata in the editor, but they need to be omitted from the build and then loaded again during runtime.
You can make the game using the original pngs and then replace them with placeholder images and load the originals during runtime. The build then contains only the placeholders.
And how would I do that?
Which part?
I mean I could write a build pipeline that replaces every PNG file with some placeholder file and builds the game with those placeholders. But then all the sprites would be these placeholders. How can I re-replace the placeholders with the real PNGs after the game was built?
I don't think that's possible, because the PNG files don't exist in the original form in the build directory, but are encoded somehow during the build process, if I am not mistaken.
Read in the png file, change the SpriteRenderer to use that file
I haven't done it myself but it's definitely possible
Again, while this is possible, it is extremely inpractical. Imagine one of those PNG files is a spritesheet, which needs to be split up into separate sprites. This is normally done using the sprite editor. When the PNG file is read from disk during runtime, you would need to do the splitting in code. The same applies to all the other import settings.
Right, that's what your game would have to do
There are definetely better ways that will still allow me to use the inspector to predefine import settings for all the files. I know this is possible using Addressables as I explained above, but this would require the user to build the addressables using the Unity Editor, since it's not possible to build them from runtime, I think.
Yeah, I've understood that part, I've already done some manual lip syncing before. I'm not really unclear about how lip syncing works, I'm unclear about how one goes about programming the "detection" of phenomes. That's what I'm looking for resources on, sorry for not being more clear
ooh tyvm
I have a grenade game object that on collision will play a VFX and SFX. I'd like to destroy the grenade GO as soon as the SFX has finished. However I could not find any event listener on AudioSource for that. Any idea how that can be achieved? Destroying a gameobject after an audio source has finished playing the sound?
Not a event listener but you can use this
You generally need to poll with most Unity things
hmmm ok will try if that is nicey
Hm ok that works for SFX so far. Thanks! However VFX doesn't have that - I guess because it's running on the GPU?
Should be able to figure out something from that.
@dusty wigeon thanks. How did you find those so quick?
By using google. I knew that ParticuleSystem is one of the alternative for VFX.
https://www.google.com/search?q=particlesystem+api&rlz=1C1CHBF_enCA958CA959&sxsrf=APwXEddkXfKghsjLCnWyZm4kvzJ9Bf-KIQ%3A1680265607486&ei=h9EmZM2yHeudptQP9L-9uAE&ved=0ahUKEwiNkqaVlYb-AhXrjokEHfRfDxcQ4dUDCA8&uact=5&oq=particlesystem+api&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIHCAAQDRCABDIICAAQigUQhgMyCAgAEIoFEIYDMggIABCKBRCGAzIICAAQigUQhgM6CggAEEcQ1gQQsAM6BQgAEIAEOgQIABAeOgYIABAWEB46CAgAEBYQHhAPOggIABAFEB4QDToICAAQCBAeEA06CggAEAgQHhANEA9KBAhBGABQcFjwCmCHDWgBcAF4AIABYogBwwKSAQE0mAEAoAEByAEIwAEB&sclient=gws-wiz-serp
The other, I searched and found a link to some user response.
https://www.google.com/search?q=unity+VFX+Graph+how+to+know+if+it+is+playing&rlz=1C1CHBF_enCA958CA959&biw=1920&bih=1089&sxsrf=APwXEdeKQUAph62j7NPdEuCITmm_ndnpFw%3A1680265690688&ei=2tEmZJXdKY6HptQPsq-32Ac&ved=0ahUKEwiVsvy8lYb-AhWOg4kEHbLXDXsQ4dUDCA8&uact=5&oq=unity+VFX+Graph+how+to+know+if+it+is+playing&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIFCAAQogQyBQgAEKIEOgoIABBHENYEELADOggIIRCgARDDBDoKCCEQoAEQwwQQCkoECEEYAFDGBljNCGCdFGgBcAF4AIABb4gBlgKSAQMyLjGYAQCgAQHIAQjAAQE&sclient=gws-wiz-serp
Phoneme Detection
wow you are one explicit individual. I will hire you with big $$$ when I have some budget ⭐