#archived-code-advanced
1 messages · Page 13 of 1
I'd say "single responsibility" as "responsibility you can summarize in one sentence, reasonable enough to convince other people and yourself"
There is no measuring tool, sadly
One day we will have AI programming bots and they will be able to give us a number value on how shit our code is.
I don't really understand what you're asking / saying.
public class Bear{ you have 3 of them you need to instance. That's easier than a god class.
So you want a pattern that 'perfectly fit', not too complex nor too simple, to your team size and application scale. That is normal approach to begin with, but when the application grows it will become 'technical debt'.
cluttered for whom?
unity is cluttered. making games is cluttered.
i would understand if you're making an extremely minimalist word based puzzle game, of which there are many, and for aesthetic reasons your editor has to be uncluttered because that kind of game is fundamentally about an organized vibe
but you know, you're in a lot of jeopardy over "feeling cluttered" right now
anyway in my engineering experience
1 scene
i've written about this before in this chat so i won't go into details
you just deal
you have a lot of tools to deal. you can use prefabs. you can use the hide and show eyeball icons in the hierarchy
not talking about eliminating clutter in it's entirety, everyone knows that's impossible but have you ever heard of using good practices for organizing development projects? haha, if you haven't, I'd hate to be you when you are looking for things in a project.
yeah i'm just exaggerating these issues
scenes is just another way i organize
i don't think it's that big of a deal
i don't think you should use scenes
scenes are obsolete
nah just slap stuff everywhere, maybe a few empty game objects to title. 💪🍻
nobody should be using them, nested prefabs have obsoleted them
you end up doing all this stuff to unwind how annoying scenes are, like don't destroy on load

and whatever you're going to have to do to make something as extremely basic as a loading screen
i think you dno't need a load scene
i described how simple it is to throw up a screen
without a separate scene for it
the loading screen isn't a scene, it's a GameObject, i am using it to transfer between scenes with DontDestroyOnLoad
you only saw one method in it so maybe that's why you were confused
that's the top portion and the only other thing in the script is just a method to start the coroutine
i didn't create a whole scene for a loading screen 
i think as soon as you use DontDestroyOnLoad
you are in jeopardy
and the reasons why are more #archived-code-general / #💻┃code-beginner
we can talk about how you can get rid of scenes instead
you should just turn the contents of your scenes into prefabs
prefabs are a superset of features of scenes
without any of these warts
@zinc aurora is that helpful?
i'm not sure why it has to be don't destroy on load, or even a singleton.
i contribute to com.unity.webrtc
do you need help with it?
okay, i don't think you are 100% there yet
in terms of understanding how this stuff works
i just couldnt find any example for external webrtc url render/display
what i am trying to tell you is that there is no such thing as a webrtc url
you have to use signaling
webrtc is a library that expects objects called offers and answers, which are essentially json blobs that you have to provide it via whatever method you choose
there is no adopted standard for those methods
there ARE standards which no one has adopted
hey,
when I use the command texture2D.SetPixel(2000, 3, Color.red); if the point is outside the texture boundaries it goes to the other side.
for example if the point is far beyond the left boundary (x), it goes to the beginning of the right.
how do I stop this from happening ?,(I want it to just return if the point is outside the texture2D boundaries. , I dont want to appear on the other side like pac-man) ....
anyone knows ?
You check your bounds first.
What's the issues?
I can also guess your ypixels are not set.
Can you break point.
how ?
Drop a red boi
how to even check if its on the texture or not?
I just need to know how to check if the pixel is exceeding any of the bounds
Drop a breakpoint and you will see what's the issue.
can anyone help me with a camera movement script?
I fixed my issue so thx
Breakpoint?
Hi, I have a little question, I don't know if it's considered advanced or not but I thought it would better fit this channel:
Would anyone happen to know how I can include some sort of compile in my code without having the user install a dev environment like visual studio?
Or would it be easier to make a pre-compiled executable and make the client run un-compiled source files? (If that can be done at all in csharp of course)
modding?
you can use lua/moonsharp lua lib, you can use roslyn compiler to compile on runtime, you can use csx roslyn scripting
Sort of, basically trying to make some custom editor, so I don't know if I can necessarily ask, but I thought I would try
most mods dont need a specific compiler framework, its all handled by bepinex or harmonylib
Basically I'm trying to make some game similar to how Frog Creator did it or Eclipse Origins (Some old softwares)
But using csharp instead of vb6 like they did
That's what I mean by sort of modding
if you want cs in the game itself, you have to study roslyn, there is everything you need to compile code jit
Oh I see, so it's sort of like hot-reloading the code without necessarily compiling?
That could work, many thanks!
no it compiles code as usual
- you cant unload the assemblies it compiled, each new compilation will generate a new assembly and it will take priority over the old
oh I see, will take a look into it then
oh It's already included in the codeanalysis library?
should be, scripting can be in a different one
Alrighty, huge thank you! 🙂
by scripting i mean csx files
Yeah, I mean the end product would have all the code already there, but the editor could modify their data and maybe add functionalities using scripts, so I didn't really know where to start to for compiling anything working at the end haha
there are lots of ways to skin this cat
what is the game?
it's best to support the modding that people who like to mod will actually do
It's more like a game editor than a full-on game, similar to RPG Maker if that makes sense
yeah
so you expect the end user to program inside your app?
in some sort of scripting window?
that is critical
Oh yeah, I mean the scripting part isn't necessarily a problem, I just didn't know how I could make the program so it would compile the project into a game executable with only the assets/graphics being uncompressed.
Or at least without having the user install vstudio for it
Yes packaging, sorry haha my brain is super slow
for windows?
For now yes
and would the end product itself be, in disguise, a unity player?
or do you plan to author some kind of your own executable?
what is the thing that people are making?
Sort of yes, Basically it would compile in a single executable like unity packages it, but with the possibility to modify the game without having to install unity and all the dev environment stuff
concretely
that doesnt sound like something unity eula allows tbh
Yeah taht's why I wasn't sure I could ask
single executable like unity packages it
android and ios have a single package file, macos has a special directory and windows is not a single file
there are plenty of other engines/frameworks you can use for this that dont put restrictions
but specifically what is it that users are making?
I'm basically making a Game Editor of sort similar to RPG Maker but MMORPG.
okay so
in this editing application
well, it sounds like you are trying to create roblox studio
to create roblox games
not Roblox, but roblox with a lower case r
like that yeah but for retro games like Final Fantasy and such
okay
i'm sure you're aware this is extremely ambitious lol
let's talk about how roblox studio works
first, there is no packaging
because it's redundant
pangloss goes on a tangent 🍿
Lol to be fair I often go on tangents
so why do you need packaging?
I'm not planning on selling this, it's literally just a fun project for not completely stopping programming
i know
yeah
well
is it like networked?
does it have to be networked multiplayer?
or single player final fantasy experiences
probably both
okay
I mean I know how to do most of that stuff
I was just unsure how I could "package" so it wouldn't require installing anything other than either runtimes or .net framework
you would have an end user binary that is the only binary you download
yeah of cours
but you would hae a grid of games that people have authored
in the menu screen
and the end user would choose it to play it
the "package" would be a deep link into your application
the most an end user would have to distribute is a URL
it doesn't make sense to do it any other way
so it would be onemorequest://application-id/199910921
gmod?
that will tell the binary that everyone has to download all the assets you host at https:/jfido2u901hf.cloudfront.net/mygame/apps
no i get what you want
if you want to do it that way
you would have to have 1 binary that is used for all the packaging
that loads the asset bundle or whatever
i think this is a bad idea though
I mean I want to basically remake a RPG Maker but for both mmo and rpg
because it is worse in every way
for the end user, for the game author, for you
to make it that way
it makes more sense to host the assets for the modder and the end user
the end user launches OneMoreQuest.app and picks the game from a list, or arrives at it directly via a deeplink
anyway that's all, that's my perspective
I want to basically allow the end user to simply export the project for release without having to bother with vstudio.
In the end they will be able to use their own assets if they want to.
Same as how rpg maker does it basically
well that's a colossal amount of work
more than hosting it yourself
and doing it the way roblox does
But I think I have an idea on how I could make it happen.
Worst case I can always try and reference from Frog Creator's source even though it's in old vb6 stuff
and the experience for everyone would be inferior to how roblox does it
But I'm not trying to make a new roblox necessarily
I just want some sort of editor that they can export a game with like rpg maker's games for example
that is hard to do
you are making an engine
you should start with maybe making your own example game moddable
Sort of, which is why I wasn't sure if I could ask here haha
and using unity as a library for your engine
and expect people to distribute the binary + mod
then you can turn that into your template
which makes me ask why use unity at all
I don't necessarily plan on using unity, I just didn't really know where else to ask since usually unity people are really knowledgeable on such stuff
Also, the only part I consider harder to do is simply the packaging at the end, the rest is all more or less simple code to implement that I've already done in the past.
But yeah I might be better off asking on stackoverflow so I don't break rules here since my goal isn't to make anything to compete with unity, simply a simple editor for funs of programming from scratch haha.
Still huge thank you for the help 🙂
the only part I consider harder to do is simply the packaging at the end
hmmm
I mean I come from making games from scratch completely using sdl2 and opengl, so all the logic stuff is fine.
I just never got to adding such a feature to compile a game from within the application
the networked persistent world part sounds hard to me lol
that you want to let people script
It's not hard doing it the way Rpg Maker did it, which is the simplest way to make it work out even on a multiplayer
They use events in the map to trigger that script, where as I would add a global event area that runs throughout the entire game to allow those scripts to run without more work than scripting.
But scripting isn't a problem for a long while still.
I plan on having preset actions they can use in events before adding that.
But yeah I think I already have an idea on how I'll package the game whilst allowing for changes.
Many thanks for trying to help!
not a particularly advanced question, but the general channel is currently taken by an argument. I have this problem:
I have an object that should keep its position relative to the main camera (moon), and then rotate about the camera's position by a certain amount. However, I cannot simply parent the moon object to the camera because then it inherits the camera's rotation, which I do not want. (and also the camera is marked not to destroy on load which could present its own set of moon duplication issues.)
How should I go about solving this problem, or should I take a different approach to having a moving sun and moon?
There is position constraints, but sun and moon usually just on the skybox tho?
yeah they are and that's perfectly achievable but I don't know how to make a dynamic skybox... (URP)
I remember this asset has urp version of dynamic skybox if you want to look into it https://assetstore.unity.com/packages/2d/textures-materials/sky/allsky-free-10-sky-skybox-set-146014
Wait maybe it was the this one? 🤔
https://assetstore.unity.com/packages/vfx/shaders/polyverse-skies-low-poly-skybox-shaders-104017
I don't know if unity has that, but can you select a light source for the sun?
If so you can control it's position through that light and the skybox should update with it. Just need to make sure it's a directional light source and you can most likely update the skybox images whilst using the same method if you want a better effect. For example having a starry night and a cloudy day. But depending on the skybox material you use in the first place, those might already be there.
And if you don't have that by default, you could always make a script update the skybox rotation according to your light source's rotation.
Hey gents, what's the best process for token based auth in unity at the moment? My server passes back my webapps a token and also a JWT (login auth, and project auth). Just want to know the best way to go about it at the moment.
JWT should do it, there is no ‘standard way’ to do token authentication in Unity really.
Fun
I am using django and i simply store encripted the auth token, i think it was easier option then jwt
Then is it possible to use wss? I can also display the stream with wss in browser
That defeats the purpose of a JWT though.
You should just use a token.
i have implemented a tilt of camera while wall running but for some reason sometimes when i get off the wall it tilts my camera permanently nad my controls are wierdly inverted
am using this code to drag objects in my scene
the problem is when i use Mathf.clamp
is that my object change orgin
any ideas?
i used the DOTween for the camera tilt
I'm self taught and have tried to seek that information myself recently... Didn't find a whole lot. Specifically how to do Unit Testing
My guess is that it's too specific per game project to give general advice for? Not sure
Except for people like me who build their own engine on top of Unity in order to bypass it's shortcomings
This is a debate we had regularly at a studio I used to work for. I'm all for unit testing and try to add tests where ever possible. The argument against it in games is that the fundamental "Success" condition for a game is not testable. The real strength of testing is making sure that recent code doesn't break old code, but if, for example, the code you broke just makes the particles look like crap, you wouldn't be able to write a unit test for ParticlesLookNeat. Obviously there are very testable parts of all games, especially if you do a good job of architecting your views away from your models and controllers. I'm just giving you the devils advocate version of why some devs avoid it in games.
A lot of the game logic is not graphical though !
Once the decision was made not to use a proper automated test suite, I started loading up my code with Asserts. Proper tests would be better, but you can get pretty close with asserts.
There are not shortage of arguments for tests. Especially when working on a team. It essentially makes it impossible to break things, even if you don't know the whole code base. But the real advantage comes with Test Driven Development. When I started organizing my thought process into TDD terms, my productivity and code quality went through the roof.
I've never looked into BDD. I should probably spend some time researching it.
Just read a little right now. Seems like it addresses higher level issues than Unit Tests usually would, so I guess it's not a "One or the other" type thing.
I am a firm believer in having core game systems entirely separated from their graphical counter parts, so what I meant by game logic was making sure the game systems classes pass that testing
in my experience, testing logic is less challenging than testing the graphics
or the user interactions
I totally agree. Just to help with separating View Code from everything else, I got really into StrageIOC for a long while. I had used Ninject in the past, and I was really excited to have Inversion of Control in Unity, but unfortunately the dev behind StrangeIOC didn't keep up with it, so I stopped putting in my projects.
Yeah how I do it in my current game is the game logic classes are not Monos but take a GameObject as a constructor - but they don't need it to function. Then on the prefab I put Monos that control the animations and such (that reference the game logic class)
That plus events it's pretty easy to just keep my core game logic independent from whatever unity is doing
same, all the object logic and system logic resides in plain classes and monobehaviors only have view logic, and some of them also controller logic
This is a tough question, so I'm not exactly sure how to ask it.
I'm using PUN to make a networked game and I want to introduce Agents that can play in place of players.
My problem is, I don't know how to call PhotonNetwork to actually add these agents because the Photon.Realtime.Player class is internal protected. I can't actually instantiate the class outside of Photon it seems? What would you do instead then?
In order to call AddPlayer() on a room I require some Photon.Realtime.Player derived object.
a Player in Photon is specifically a connected client
there won't be one for an AI character
you need to introduce these characters at a different abstraction level
Hm
Any tips on how to do that?
When I google around I keep seeing people asking similar questions on forums but not getting an answer from PUN developers or others
Well first of all
PUN is olllld
it's their oldest, crappiest networking solution
idk why people are still using it
Photon has a lot of much newer, much better solutions
secondly, it's a networking framework, not a game framework
you'd make your own abstraction if you want. Like:
class Character {
public Player owner; // If null, this is a server-controlled AI
// everything else.
}```
I'm kind of new to networking and I didn't pick the framework
I just have to work with it
Third - #archived-networking
This is the kind of thing I was trying to find out about how to do
Is there anyone that has a strong knowledge of physics with collisions and detections?
Anyone here used C# as a scripting language for a game? Advantages, disadvantages?
Generally a bad idea because it's difficult/impossible to properly sandbox it
It also won't fly on platforms like iOS
That's what I thought
What happens if you just don't pass any assemblies like System to it? It wouldn't be able to use any "dangerous" calls like writing to files
I've only really used LUA/MoonSharp in Unity for this, but I'm sure there's other approaches
I'm not actually sure how you'd approach that. The usual way I think of using C# as a scripting language would be via something like this: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.loadfile?view=net-6.0
Which loads it into the same virtual machine, right?
And not sure how to practically prevent the loaded assembly from containing references to System etc.
The roslyn compiler lets you execute strings as C# code, but you need to explicitly make assemblies available to it
hmm.. maybe something like that is possible then? I've never seen that approach in action so not sure
if it works as you say I could see it maybe being possible to just pass them your custom "game interface" assembly and they can only interact with that
I'd still be a little wary because I feel like there's probably a way they could just include a binary payload that manages to access things even without having access to System assemblies.
Seems relevant, not sure there's good answers here though
Yeah that was basically my idea, just expose pre-defined (gameplay) functions, pass that assembly to roslyn, and then use C# as the scripting engine and call those. Basically what I would do with LUA too
yeah ofc, I'm just not totally confident about how sandboxed that actually is
I have no idea how it fares performance wise though
Depends on how long the compilation takes I guess
It hangs the editor for like 5 seconds
it's also an upfront cost
yeah I could easily see a "mods" menu in the game where you load a mod (and do the compilation there) and then it's gtg. that's a fine user experience
Yeah that would be fine. Gut feeling would be that runtime performance would be pretty good (at least faster than python / lua), but that's just guessing
agreed
Other thing though is... does this force you to use Mono, or at least include Mono somehow in your game?
I have no idea, I started playing with it like 10 minutes ago 😅
Definitely
Did you have to do any specific sandboxing for MoonSharp? If the C# approach doesn't work out, I was planning on using that with hardwiring
nah with MoonSharp it's more like the other way around. The LUA code can't do anything except what you explicitly expose to it
I used it shortly a few years ago but non-hardwired performance was terrible, and iirc I never tested the hardwiring
tbf reflection is just slow
So I can't really blame them
Yeah the thing I used it for was not performance sensitive at all so I believe it.
I was basically building a dialogue system with it
Hey,
I have lots of tools that reacts to collision (hammers, shovel, electric drills , laser drill... etc) , some of them physically, others are raycast or projectile.
my current setup is that I have script for projectile with the collisions function within the same script, and the same for every other type of item ( total of 5 I think)
is it a bad idea if I separated the collision part in a separate file ? would that negatively impact the performance specially for fast tools ?
I was planning to use it for addon scripts from modding, so it needs to be at least passable if I call stuff each frame, but I think with hardwiring it should be fine
The file layout should make no difference, essentially you are just calling a function with is (basically) free
thanks, because sometimes I modify the collision on file and forget to do the same to the others and I end up in confusion, since there is no down in performance, having a shared file between all of them would make much sense
You should definitely just have one shared script for it
@woven kettle also don't worry about performance at this stage. Get the code working and then profile your project if you start having FPS issues.
oh but how about the difference between public void fn() and public bool fn() or public void fn(bool b) ?
i think I might need to return something bk to some tool , because the tool also needs to know what it hit and reacts on it
not worrying much but if i'm modifying it anyway, might as well do my research and do it right
Wdym?
@woven kettle have a base ToolCollision script, make different Tool collision types (triggerEnter, Raycast, etc) that derive from that base, and have your tools just listen to an event from ToolCollision based on the result of the collision, which sshould more or less be the same between all collision types
Tool shouldn't care how the objects it's target where found
when the projectile/physical hit a special object, I need to return some bool/int value to the function that caused it to react on it. .. like if an electric hammer was hitting sand just fine then it hit a metal rock, it should tell the hammer that it hit an "unbreakable" object .. and the hammer will temporarily disable then and deflect a bit.
would returning a small value like bool or int between 2 different scripts impact the update function much?
No
@woven kettle Nope that wouldn't impact performance at all. You're going to drive yourself crazy preemptively optimizing trust me. Also, I don't see why you would need it in an update method. Just rely on Unity's built in Physics to find your collisions when they occur and pass along the results to your Tools.
thx, i only give optimization those 30-120 seconds .. of my time just to make my mind around a better decision if possible.
thank you for all ur help @crude isle @sly grove
have people online already experimented with this?
I'm assuming so, it's been possible for quite some time. Why?
well i wonder if the thing you are looking for + keyword "github" will appear
I'm sure it's possible, I was more looking for potential pitfalls in the context of a videogame to watch out for if anyone here has used it to a more extensive capacity
Ah @crude isle since you are online did you got the chance to look into the sample code?
#archived-code-advanced message
@jolly token Yeah I'm still digesting it in my brain (im slow). My confusion right now is how I would structure my components and the actual ItemEffect behaviors within this type of structure. I'm probably gonna have to actually try to implement it before it clicks.
I see. Interfaces are just another way to abstract things. Update me how it went if you tried 😄
@jolly token or more like what the workflow for making a PassiveItem would be like. Interfaces make serialization annoying and I prefer to make my components very lego-blocky.
@jolly token ill be diving into it soon™. For sure, Ill let you know how it goes!
You don't have to use interface for serialization, you can just use them as kind of attribute if you prefer.
@jolly token True, EventTrigger is a class anyway I could just make it abstract monobehavior I guess and wrap the rest into base classes. That is... if I understand your code correctly at the moment lol.
I've never used contravariance or w/e it's called before. I need to read up on it and make sure I fully understand whats going on.
my current basic understanding is it's just a generic constraint that accepts derived classes, right?
No contravariant is the opposite actually
"covariant" is accepting derived classes
for example IEnumerable<object> can accept IEnumerable<string>
hmm... I thought thats how normal generics worked too though lol.
"contravariant" is opposite
@jolly token Oh okay. I think I get it.
contravariant is to accept less derived class, specifically
If you see the sample code, I made IItemEffect contravariant
So IItemEffect<SpecificEventParam> can accept IItemEffect<GenericEventParam>
@jolly token That makes a lot of sense and I'm think I'm starting to get it
you constrain to a derived type but a contravariant constraint can accept the base type.
going backwards along the class heirarchy
Yes, and that means you can only use it as input parameter type. That’s why it use in keyword.
Covariant is opposite. You can only use it for return value and it uses out keyword
Is it not possible to have multiple draggable GUI.Windows?
Only one of them is draggable while I have multiple open
They do :[
#archived-code-general show code there
interfaces are cool and can solve many problems 😄
variances are only possible in interfaces btw 😄 (and delegates)
But it's all about type safety, it shouldn't cause more problem if used correctly
I have a mono which creates an object and passes a delegate to through the constructor. The delegate references a method of the mono. When calling the delegate in the constructor everything is fine( I store it in on the delegate in the obj), but when I call the delegate later on in that obj it is null. Does unity loose the reference to the mono ? I am little bit lost here 🤔
when you say "creates an object" do you mean a GameObject?
Nope normal c# obj from normal class
Hmmm, I can't think of any reason that the delegate you described would only be available in the constructor. Do you have any code you can share?
I'll try to paste it from plastic sec
Mhm seems I cannot reach any code from mobile here
Bummer, I hope I'm around when you're able to post it. I'd like to know what the solution is.
If it is ok for you I'll pm you and post it when I get back to a PC tomorrow
Yep, Sounds good.
did you look at those games xmage or spellsource?
@undone coral Yeah I looked around in there for a bit. Cool projects, but I haven't deep dived them yet. I'm sure I could learn something when I take the time
the architecture you are pursuing is hard
your Binding of Isaac esque game, is all the game logic centralized in one place, separate from unity
or is it spread around a bunch of monobehaviours attached to game objects?
like is it "decoupled"
@undone coral I guess you could call it decoupled. At least by my definition of the term lol. I was going for the whole composition/lego blocks strategy with my scripts.
okay because this event trigger thing
it's really really hard to do with things being decoupled
it's basically impossible
if you wanna keep doing the decoupled thing
your best bet is
i guess i need an example that makes sense for you
like what is an item in your binding of isaac: decoupled that you want?
describe the pill
or whatever it is
the effect
a concrete effect
@undone coral One idea is an Item that drops an AoE zone at the start of a player Dash. The zone applies a slowing status effect on enemies that pass through it.
okay
I could just make that extremely easily.
yes
you have to!
you went with decoupled
you have no choice
it adds and removed components to the enemies as they enter and leave the zone
or whatever
it checks which enemies are inside in an update and modifies their speed, or everything's Speed property queries for SpeedModifier components on the same game object
i just want a more design time friendly setup that lets me mix and match triggers and effects in creative ways
I have a StatusEffect system already in place
Well I don't have the system yet 😢 Unless you meant the StatusEffect stuff, in which case it's very friendly imo.
working on that lol
{
"class": "Item",
"name": "Slow on Dash",
"triggers": [{
"class": "DashStartTrigger",
"eventSource": "PLAYER"
}],
"effect": {
"class": "SpawnEnchantmentEffect",
"location": "EVENT_LOCATION",
"lifetime": {
"class": "FixedLifetime",
"seconds": 3
},
"enchantment": {
// lots of ways to do this
"class": "PassiveTargetMembeshipEnchantment",
"target": "ALL_ENEMIES",
"filter": {
"class": "CircularDistanceFilter",
"radius": 5.0,
"center": "EVENT_LOCATION"
},
"effectOnMembershipAdded": { "class": "ModifySpeedEffect", "operation": "MULTIPLY", "value": 0.8},
"effectOnMembershipRemoved": { "class": "ModifySpeedEffect", "operation": "MULTIPLY", "value": 1/0.8}
}
}
i know this is what you want
but this is really really hard to set up
since you've gone decoupled you just gotta make all these as components and slots and stuff
That type of system is definitely way too complex. I just wanna be able to Drag a "OnDashBeginTrigger" and then a "SpawnObjectItemEffect" and it "just works" (after lots of blood, sweat, and tears...).
Yeah with components and stuff
the details outside of the architecture I already have in place mostly. I just can't find a comfortable solution to handling the event data from the trigger to the ItemEffect. I need to experiment with the interface approach linked above and see if I can use it properly.
Is there a way to calculate the closest point to a point on any collider (both from inside and outside the collider)
Physics.ClosestPoint only works on BoxCollider, SphereCollider, CapsuleCollider or a convex MeshCollider, so no non-convex mesh colliders.
Not only this, but Physics.ClosestPoint only works when the point your checking is not inside the collider, if it is inside it just returns the original position instead
By "closest point to a point" do you mean how to get a vertex that is closet to a given point?
Or any point on collider surface?
any point on a collider surface, Basically what Physics.ComputePenetration does to find the shortest distance to prevent two colliders from intersecting, except one collider is a point
Technically I could use Physics.ComputePentration and make one collider a tiny SphereCollider but that just seems a bit of a weird workaround to me
especially since I would need to create a SphereCollider everytime I want to get this closest point
This also only works if the two objects are intersecting, and if I used Physics.ClosestPoint to accomodate for this, it will fail for non-convex colliders such as planes
I guess you have to use sphere collider, I don't see any appropriate API for this
darn, thats unfortunate. thx for taking a look into tho
so no non-convex mesh colliders.
you can use vhacd to create a bunch of convex mesh colliders from a concave mesh
is that helpful?
well if it's all centralized
@crude isle then you do
class GameLogic {
void Move(GameContext context, Actor actor, ...) {
var baseSpeed = actor.BaseSpeedBeforeModifiers;
context.PushValue(baseSpeed);
FireEvent(new OnBeforeMoveEvent(actor));
var modifiedSpeed = context.PopValue();
... blah blah blah
FireEvent(new OnAfterMoveEvent(actor, ...));
}
}
class ModifySpeed : OnBeforeMoveTrigger {
float multiplier;
public override GameEvent[] interestedIn => new [] {GameEvent.ON_BEFORE_MOVE};
protected override void OnFire() {
var baseSpeed = context.PopValue();
baseSpeed *= multiplier;
context.PushValue(baseSpeed);
}
}
but then all the moving has to go in the same place Move
why pop and push value?
because it should be clear that you can do
class ModifySpeed : MultiplyValueTrigger {
public override GameEvent[] interestedIn => new [] {GameEvent.ON_BEFORE_MOVE};
}
@crude isle the science of all of this isn't "i make a thing called triggers and events" and litter your codebase with these things
the secret is realizing that your game effects are functions, and the signatures are like, it takes a value
and you shouldn't have a speed and a damage and a healing, you have a value and a value and a value
anyway i hope this is helpful, feel free to share more detailed code and we can talk about it 🙂 @crude isle
anyone know why NodeAdapter in the GraphView package produces a 404, anyone know what that data type does? https://docs.unity3d.com/2020.3/Documentation/ScriptReference/Experimental.GraphView.GraphView.GetCompatiblePorts.html
lol
ouch
💀
What is the good way to add 'hook' to pre-loading timing of scene?
Context: I'm building DI container and want to inject some dependencies before Awake or OnEnable timing.
runtimeinitializeonload beforesceneload
or a bog standard static
which will execute on the main thread and be run at the "right time" in a sense
as soon as you touch the type
or script load order.
you can do a RunOnLoad editor script to programmatically set script execution order to -1000000000000000
00000000
000000000000000000000000
It'd only work for start-up scene. I'd like to support LoadScene though you don't support scenes XD
lol
you can register a SceneManager.activeSceneChanged
This is what Zenject is doing and kinda ugly
probably too late though
Yeah sceneLoaded was too late
yeah but they obviously didn't add enough zeroes
To make it beautiful?
exactly
I'll make sure to add plenty of those
you can try to use static constructors
to side-effect loading everything in the right order on demand
Real Dependency Injection
It might feel dirty but Script Execution Order is not a bad choice
static constructor per scene?
yeah that might work
What about when reloading 😂
Maybe I'll have to do this eventually
i am struggling to come up with something simpler than script execution order
You can with the undocumented attribute...
the whomst've?
lol - it's liable to break though - being undocumented and all
my dependency injection searches Resources at a well known path and instantiates all the prefabs with the right types on it
this has been the most reliable for me
since it always works 100% with il2cpp
Thanks I'll have to look into it
because otherwise you have to [Preserve] or modify link.xml
I do this public class InjectAttribute : PreserveAttribute
all the stuff in all Resources folders everywhere gets the right amount of code stripping
Resources is dependency injection lite
Is it even you set stripping as High or something?
i think i've last done that for webgl games
but yeah if i was doing "a mobile"
Hey guys. I have following problem: P is the player, E is the enemy. CAM is the camera.
The player is looking to the Enemy.
So since I multiplied the Cam.forward vector with the input, I already get the Player to move according to the viewing angle.
Now I have the problem that the animations are off.
For example on the picture:
When I press the forward button, I want the player to play it's "walk left" animation (float horizontal = -1)
I don't know how to do the maths... Can somebody help me?
In the picture's example, when I press forward (W), the player plays his walk forward animation because the input is not relative to his rotation
I hope i describes it understandable 😅
When I move the player relative to his rotation, the animations work, but the movement feels off. (He will not move in the direction relative to the camera. This is crap)
For reference: I want it to feel like in assassin's Creed
Vector3 horizontalVel = new Vector3(someVelocityX, 0, someVelocityZ);
float magnitude = horizontalVel.magnitude;
Vector3 localVelocity = transform.InverseTransformDirection(horizontalVel);```
Thank you!! I will test is as soon as I am back from work^^
The horizontalVel is my normal move vector?
(Cam.forward*player.forward + cam.right+ player.right?
Looks like it aye
Okay so I am pretty close now. I think I just need a nudge in a direction. I have 2 solutions for pushing or pulling a cube. 1 uses vert because I also want to drag the verts of a face in the x or z axis using my forward or back motion of my Oculus controller.
Solution 1 : Verts
Problem is that I can't seem to get the verts z or x position to line up with the ray point
for (int i = 0; i < surface.Vertices.Length; i++)
{
surface.Vertices[i] = new Vector3(surface.Vertices[i].x, surface.Vertices[i].y, posZ.z + 1);
}
selectedObject.GetComponent<MeshFilter>().sharedMesh.vertices = surface.Vertices;
selectedObject.GetComponent<MeshCollider>().sharedMesh = surface.filter.sharedMesh;
```
Solution 2 : Transform
Problem : The isSide is a bit of a hack but it will only work if the walls ware separate objects. What if its an inverted cube and I want to push/pull the sides in or out?
``` Vector3 posZ = primaryController.transform.position + transform.forward.normalized * primaryController.rayDistance;
if(surface.isSide)
{
selectedObject.transform.localPosition = new Vector3(posZ.x,selectedObject.transform.localPosition.y, selectedObject.transform.localPosition.z);
}
else
{
selectedObject.transform.localPosition = new Vector3(selectedObject.transform.localPosition.x, selectedObject.transform.localPosition.y, posZ.z);
}```
Any help would be great.
I am almost there
hey i need help with my code please
i made chicken invaders 3 and sometimes when 2 bullets hit an enemy it kills it twice
and everything after that gets wierd
it's like every script doubles itself
just mark your enemy as dead when it dies
and use an if statement to check if it's dead already
I don't think "number of components" is really something to think about.
there's no number you would reach where you say "this is too many scripts"
as long as you stick to the single-responsibility principle and make modular, reusable scripts
you have nothing to worry about
I didn't say make it too complex
making modular, resuable scripts naturally leads to script re-use and composition
which simplifies things vs trying to shove a lot of unrelated behavior into few scripts
also reinforced by the single responsibility principle
its ok, i fixed it 🙂
Going for an "ideal" number of SOs smells a bit like going for an ideal LoC
Trying to aim for metrics based on LoC is where it's potentially harmful
Can be an indicator of issues when it's different from expected. Can be useful
But when used as a KPI it'd be more likely to lead you astray
I'd only allow SO when I have specific editor needs for it 😛
(e.g. Animation Curve, Behaviour Tree editor, etc)
Otherwise I go for spreadsheet
Though about classes, I can't say more than "You don't need more abstraction than you need"
I have an IPostprocessBuildWithReport inside of an assembly which is constrained by a define DISABLE. This is supposed to handle removing native libraries which do not belong in some build configurations. Those build configurations include DISABLE in BuildPlayerOptions.extraScriptingDefines which is passed to BuildPipeline.BuildPlayer.
If I manually add DISABLE to the scripting defines list in Project Settings, this works correctly; the native libraries are removed from the build. However, when that define is only added to extraScriptingDefines, the native libraries are not removed.
It looks like extraScriptingDefines does not affect editor assemblies? Is there a better way to go about this?
I'm afraid extraScriptingDefines will only affect for build, not for editor script. You'd need to find another way to pass flag, or you can set with https://docs.unity3d.com/ScriptReference/PlayerSettings.SetScriptingDefineSymbolsForGroup.html, but the latter would cause assembly reloading.
Alright, thank you. I need this to be compatible with our local build system and also Unity Cloud Build, so I think I'm going to have to go the route of very specific post-export methods, for each store and platform combination.
This kind of thing solved with Environment variables most of times. I did a quick google and Cloud Build has API to set envvar, but not through GUI, if you want to do that approach. https://answers.unity.com/questions/1580580/is-there-any-way-to-set-environment-variables-to-c.html
Thanks!
Okay so I believe I actually figured out my issue with Passive Items... Took me a while to wrap my brain around it. Thanks to everyone who helped, it got me out of my tunnel vision. @jolly token @regal olive @undone coral (sorry if I missed anyone, way too much chat history to go through)
Here's a link to 4 (very large) pics that show my script setup in case anyone is curious. It's a bunch of Code screen shots since I'm not sure the best way to share this stuff... :
So far I haven't found an issue with it. I have several test Items working! I can do some pretty cool shit with it I think (and hope).
Are you offering hourly?
$30?
just need some explanation from someone good with linear algebra
are quaternions part of linear algebra?
You can post video here
usually you use the checkboxes on the native library itself to prevent it from appearing in different platforms
Thanks, but unfortunately this isn't sufficient: We are deploying to different stores. Specifically, I am trying to exclude the Steam library file from non-Steam builds
yeah
i don't know is that essential?
i see it all the time
in asmdefs you can have it ignore based on preprocessor defines as well
anyway i think there's a checkbox
That is only available for asmdefs, not native libraries, sadly
ah did not read enough
Honestly I am tempted to leave it at this point. You're right, I see cross-store libraries in games all the time (Galaxy and Steam libraries sitting side by side, for example)
yeah for native libs its a pain in the ass
yeah
best i have done, is a stupid branching scheme
could ignore the libraries in there proper locations in vcs. store them elsewhere in the project, then on build move copy the correct ones into your plugins folder
tedious though
I've actually encountered a different, potentially worse aspect of this issue though: Scripts which use the define are not recompiled. I suspect this is a bug in the incremental build system somewhere... The non-Steam build became stuck with the Steam-exclusive build UI changes, until I either cleared the Library folder or modified the UI scripts that had the #if statements
I haven't had to work with this code in a long time, so I don't know at what point it broke. I'm on 2021.3.8f1, using IL2CPP
Forcing a recompile with CompilationPipeline.RequestScriptCompilation(RequestScriptCompilationOptions.CleanBuildCache) after calling PlayerSettings.SetScriptingDefineSymbols did not resolve the issue
Hey guys,
I am experimenting with compute buffers and the drawmeshinstancedindirect function to achieve some LOD related results. My plan is to have one compute buffer that will store data that several drawmeshinstancedindirect calls will utilize with different meshes.
Is there a way to tell the GPU only use a subsection of the compute buffer when rendering?
Could you pass a index to seek the "Subsection"?
pass the parameters you want to your shader such as start_index, offset, count etc..
In the drawmeshinstancedindirect function there is an argsoffset parameter that acts as an index offset but the issue is that it doesnt state where it should stop
Are you calculating your types size as well?
that's just for an offset into the arguments buffer
you can pass whatever data you want into the actual rendering shader via the material
the type size is uniform
what do you mean exactly?
ah I understand, so I can pass into the shader start index = X and stop index = Y
and using the instancedID, find the actual index into my compute buffer (X + instancedID) and if the actual index > end index, stop
yep something like that
I guess a follow up question is how to stop lol, how can I abort an instance call in the shader?
you can't
If you don't want to draw something, don't call Draw
if you don't want to run the compute shader, don't call Dispatch
@undone coral In response to your question emote: We use defines to switch some things in the UI, depending on if it's a Steam build or not. We also use defines to disable the in-game cheat commands in release builds. When switching from a Steam debug build to a non-Steam release build, the Steam-specific UI was still in use. I didn't think to check, but I am assuming the debug-only cheat commands were also still enabled in the release build.
Running a clean build solved this problem. So it looks like this is a bug in the incremental build system in 2021.3.8f1
im a beginner and i was wondering what kind of math is recommended to learn
Trigonometey, vector and matrix math are a must
when you get into more advanced scripting, what kind of math should one expect to learn and apply?
Depends on what you're scripting
is there a certain way you recommend beginners to learn this by any chance? sorry if the questions are annoying
Calculus and Linera algebra, very useful for vector maths
but I've stumbled a person at work, he can't do advanced math etc... But what he can do was scrapping SO for algorithms, and luckily he can applied to the game or the system he's working on.. He's been working at the same company as mine for more than 2 years now 😆
lmaooooo
for someone like me who has a good understanding of calc 1 and is learning calc 2, what should my progression of learning certain maths be?
having a solid foundation is likely decent enough. working in production, you never really know what you may have to build. I'd say the close you are to graphics, the more granular your understanding of maths, the better. as for general gameplay programming, i find a solid primer of linear algebra, and trig can help you intuit a lot of the cases where you'll need to apply a solution to match a development need. if you can help describe a desired result with a concrete mathematical example, chances are there's a starting place in a library or already there in engine for you to mess around with.
Once you know linear algebra and euler‘s formula, you largely don’t need trig anymore. In game dev I find this one of the greatest simplifiers. Not a day passes where I don’t need LA. So imo, invest heavily into linear algebra. Basic calculus (single variable function analysis and integration, emphasis on polynomials) is all you’ll ever need. Discrete math is also very powerful but generally neglected or taught as component of other disciplines; it also forms the basis of statistics together with calc. Personally I’ve never had much use for statistics but I can see it being useful when doing certain kinds of AI and for gathering user feedback. One major skill is to be able to compose/design closed formulas that do exactly what you want.
I have this code to minimize the player window, works great in Unity editor but does not work on build. Any ideas why?
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();
public void OnMinimizeButtonClick()
{
ShowWindow(GetActiveWindow(), 2);
}
nevermind, code works fine, my mouse is just offset for some reason
Hi everyone, online there are a lot of tutorials about save-load systems. This systems work even for Android?
Is your game running in exclusive full-screen mode?
Probably won't work if it is
like i said the code actually works
its running as a borderless window
and the mouse is offset
not sure how to fix that
Maybe your resolution is different between ingame and windows?
frame based system commonly used in fighting games
If you want a frame perfect game then sure but unity is probably not the best engine for that
Or rather, you'll need some custom systems
I think he meant as in frame-based system, like in fighting games
take SFV for example, a Standing Heavy kick will have 12 frames, to complete, and with 4 active frames at the end... so during this 12 frames, it is vulnerable to be getting hit by lower count frame moves such as Medium Kick
Yeah I know, but e.g. The animator won't let you do that by default
also frame-based system will have some sort of priority system, which is another different beast... frames based system isn't easy to make.. especially in single threaded engine like Unity
Not sure what I'm supposed to do with this error message from Unity about a Unity package
Library\PackageCache\com.unity.render-pipelines.core@12.1.7\Editor\Volume\VolumeComponentEditor.cs(469,59): error CS1061: 'TooltipAttribute' does not contain a definition for 'tooltip' and no accessible extension method 'tooltip' accepting a first argument of type 'TooltipAttribute' could be found (are you missing a using directive or an assembly reference?)
You can do with some tweak like manually calling Animator Update etc
we made similar to this, but had to resort to UE instead due to complexity of frames queuing in Unity.. frame based is just heck hard to make
Is it better in UE?
Depends, tbh UE makes more sense than Unity for frame-based system
in our case that is.. others may have their own opinion on this
Name one frame-based game made with Unity, If there is one, I'm curious how they implement this in their game
Not specific game but Photon Quantum does deterministic physics/networking that can be used in fighting games.
There is also this boy
http://www.ufe3d.com/doku.php/move:activeframes
yeah, I said it already about active-frames above.. those are common in fighting games
Ah I meant the UFE asset
ah okay 😄 , never heard about that assets.. looks nice 👍
I take my word back, they use capsule colliders for both hit-box and hurt-box 😄 ...
never ever use non-box colliders for both hit/hurt boxes in fighting games
there's a reason behind why it must be box shaped in fighting games.. proly google it if you want to know it better
I think you have options to choose in that asset, but I got curious so I should google xD
For a client-server game that works around different instances, is it better to build a different executable for each instance for the server or just one executable with different scenes for each instance. I know managing one build is easier specially if want to automate scaling based on load but does it have a performance impact that would be relevant?
Wdym by a different executable per instance?
What would be different?
For dedicated server? I don’t think there is any practical benefit of making executable per scene, else than lot of struggling
you are at the start of a very long journey
since you've been doing IPostprocessBuildWithReport you are probably trying to customize a lot of parts of your build
if you need sophisticated building with correct caching, you can use gradle or bazel
We use defines to switch some things in the UI, depending on if it's a Steam build or not.
while you probably have something like
public static bool isSteam =>
#if ENABLE_STEAM
true
#else
false
#endif
;
instead do
public static bool isSteam =>
// contextually determine if you are running in steam
// not sure if this works
Steamworks.SteamUtils.GetAppID() != 0;
how can i reload native plugins?
ive been fighting with this for a while, but cant get it working
i have found this: https://github.com/mcpiroman/UnityNativeTool
Allows to unload native plugins in Unity3d editor. Contribute to mcpiroman/UnityNativeTool development by creating an account on GitHub.
but it doesnt seem to work, even if i unload the dlls the dll is still locked and cant be removed
you close the editor
update the dll
and reopen it
is that what you mean by reload?
is this really how all plugin developers do it?
yes
isnt that insane? especially after this much time
i mean, isnt unity supposed to make development easier and faster?
i think it's better not to stress about stuff that doesn't matter
i work on a native plugin all the time. i am just sharing a POV
it doesn't really matter
you don't mind all the time wasted and super slow iterations?
are you trying to make a native plugin for procedural terrain generation?
and are you doing that because you feel more comfortable writing C++?
doing voxel data generation and meshification, but a big point here is to not be limited to unity and be able to use the library from any rendering engine
yes, so this is your mistake 🙂
i'm kidding it's not a mistake
but it's An Approach
if you were using unreal engine, you'd be sitting staring into dead space waiting for long compile times, and constantly starting the editor again because of exceptions or programming errors during iteration
writing anything iteratively in C++ is a huge chore, in any complex application
if you want to reload quickly, write your thing in C#
use burst compilable jobs, it's faster than C++ anyway
on some important end user* platforms
so what i'm saying is you are limited by C++ and its ecosystem
in the long term it doesn't matter - people can make innovative stuff many ways
and the reload times don't matter
i dont want to get too much into details, but it is never "other tech" its always unity that is limiting
tbh, if i have spent all the time that i used unity writing custom engine, id have a full featured engine by now
i have heard this perspective before
i agree that in order to do something innovative, you often have to leave other things behind
i guess i need to come back to unity sometimes to remind myself why i have left
that said, if your goal is to make an interactive game, especially one where you take a 2d input like a mouse click or touch, and interact with a 3d world, you will fail without Unity
if you want to make a renderer, that is different
imo, it is way more innovative to figure out how to integrate Your Rendering Thing into HDRP / URP and make stuff for phones
and do something cool for 2d interfaces to 3d worlds
it is 100x more compelling than realtime rendering of photoreal stuff or whatever, because if that is essential just make a pre-rendered movie
that is a perspective informed by working in academic research and what i am personally excited about
i can have efortless hotload in c++, asset swapping, full threading support, without having to fight the engine all the time
i imagine i sound super grumpy right now, but im just tired of this stuff
i think if you are making an FPS or something that already exists
you know, go for it
i would use Unreal if you want "C++ rendering innovations for FPSes"
exhibit A: the realtime caustics demo NVIDIA did. but that required like 1 extremely experienced person and 4 interns, work that was done intensively in 6 months out of 2 years
by basically the world's foremost expert in realtime light simulations
and you still can't like, download it as a plugin. it's right at the border of usefulness
do i think there's a future for Microsoft Visual C++ on Windows developers? no
if you want to make a renderer from scratch or whatever, a game engine, do it in swift on Metal for the iPhone
"bUt tHeN i CaN't uSe C++ aNd vIsUaL sTuDiO"
our tools are obstacles, i agree!
that is what you are saying
well, if you really were sincere about doing something innovative, why the hell are you targeting a shitty dying platform
with the cheapest users in the world
i think i will go the custom engine way and implement unity/unreal when its done. the idea was to focus on the important stuff while unity handles all the boring stuff
my target is pc
yes, because this isn't really about unity
it's about microsoft visual studio for C++
i've heard your perspective from other people before
and dont get me wrong, im a huge fan of c# and prefer it hundreds times over c++
you should buy a mac, and develop for the iphone, if you are going to write a native engine
but there are some things that you just need the extra performance
because the ROI on such a thing will be 100x bigger
the GPUs on M1 and M2 are incredible, and doing something innovative there will pay much bigger dividends
do you see what i am saying?
you are talking about native and blah blah
you're not.
you're JUST talking about Microsoft Visual Studio for C++ GUI .sln blah blah
cant really compare pc and mobile games, mobile input is extremely limiting
do you own an iphone?
mobile input is extremely limiting
depends, are you trying to do something innovative? or are you making an FPS?
like how do you plan to explore your world?
that you are meshifying and voxelificating?
a first person camera with WASD controls?
do you see what i mean?
this is beside the point that minecraft PE on the phone, which has those exact cranky controls, is immensely popular and kids use it just fine
it sounds like you own an android phone
i am trying to encourage you that, if you do something native
doing it with unity
and making it work well with unity means you can make it work on phones, Which Matter
there is a very, very small audience for innovative rendering experiences on PCs
you should get an xbox dev kit if you are interested in that
and then, you'd still want to do it in unity
cant wait to have to deal with that in unity
i don't htink we need any more FPSes
i think it's really easy to make a world explorable on a phone
this is coming from the perspective of someone who tries new things, and also does a lot of research into rendering
visual studio is your obstacle
you have to stop using that incredible shitty IDE
you don't want to be a Windows Android drone
we have enough of those
lol
this is a stylized opinion
obviously you are going to make something cool 🙂
you are forgetting about software and different industries
i am trying to free you from your Microsoft Visual Studio for C++ Android shackles
especially in game development
where all those people were left behind
i think the first thing you should do is buy a mac
and next you should use the jetbrains IDEs
like appcode, CLion and Rider
@feral cedar buying a mac will unlock your potential
@feral cedar how can i help the most
cant you see that we drink the same kool-aid, but of a different color?
lol
yes my dude
Anyone ever used Facepunch Steamworks?
Attempting to push an item to the workshop, calling this
var result = await Steamworks.Ugc.Editor.NewCommunityFile
.WithTitle(CurrentLevelSaveLoadName)
.WithDescription( "Test" )
.WithTag( "Map" )
.WithContent(path)
.WithPreviewFile(imgPath)
.WithPublicVisibility()
.SubmitAsync();
However its giving me a null reference, inside SubmitAsync() internally when it calls
SteamUGC.Internal.CreateItem(this.consumerAppId, this.creatingType)
anyone knows a good resource to practical uses of the relationship between the compute and append / consume buffers?
I really don't understand what the deal is with you mate, you give some weird advice some times if you're being serious. 😄
Yeah they're like that. They like monologues with weird stuff in it
Is ther some lib to play http-flv media stream in unity?
i see you have made some progress
comprehending how to do this video stream thing you want to do
i'm sure you've searched the asset store
but generally no, http-flv is obsolete enough that i don't think you will find a maintained wrapper for it
there are asset store assets that work for many video sources.
the most robust will be HLS using the preexisting VideoPlayer, but that will have 10s latencies (like typical streaming video online)
@hushed moth is that helpful?
It have like 30sec
Webrtc is not good for 40m bitrate, max 8, rtmp not supported, so i tought the http-flv could work
are you trying to make a streaming video player?
or what is the application
/ the game
I have the streamer server i can cast it to rtmp, hls,wss, webrtc and http-flv so far
what's the objective?
And i would like to play it in 360 (quest 2) with the lowest latency as possible
Hls works but 30s latency
what ar eyou trying to make though?
a VR video player?
is that the goal?
from e.g. youtube or something?
Lets say livestreaming 360, i have my server for that
livestreaming what though?
a prerecorded video?
a live camera?
a different 3d rendered game?
there's nothing sensitive about "i want to render a game on the desktop and send it to the quest remotely"
but on the other hand, if that's what you want to do, you definitely, absolutely should use Virtual Desktop or wait for Meta to release the streamed gameplay feature
which is it?
is the server also rendering the content? @hushed moth
so many questions
It can be prerecorded, live 3d render, whatever, the end is that i have rtmp, hls, http-flv, webrtc mediastream and i can play them with ffmpeg on linux, and the latency is important. I can play hls in unity w/o problem but the latency is 30s
why would the latency be important if it weren't a game?
it really shouldn't be 30s
HLS is typically 5-10s
is it like group watching a video?
help me comprehend what the purpose is
then i can give much better advice
The latency is 30s with ffmpeg play too, i will check the nginx config, maybe there is something wrong
When you watch something live, then the lower latency is best e.g. football
yes but what is the game / app
lol
what are you making
don't be shy! it'll be helpful to know
alright well i've helped as much as i could without knowing anything about what you are trying to do
I don't see anything wrong with passing a reference from the calling manager.
new Boss(this) seems fine to me.
Whatever instances the boss.
In terms of your question, that's what I called it, yes.
No, but I'm assuming you're going for some type of manager if you're holding references like that.
I try to keep the logic to the system that needs it. A boss can spawn mini bosses, so I would keep that tied to the boss. But that also asks the question should that be on a spawn system.
Exactly, I've had this question before too. A spawn system should be a "Global" system BUT if it's on a specific entity what should you do.
If you figure it out, let me know 😄
SpawnSystem.Spawn(miniboss)? No?
It's how GO are instanciated in the API.
Fair.
It’s quite wrong because boss has to know about spawner and spawner has to know about game manager
Well "Employee shouldn't tell manager what to do"
No the flow is obviously: GameManager manages Spawner, Spawner manages Boss lifecycle
So boss's lifecycle event should be exposed without knowing spawner
It's okay to pass reference if Spawner has interface that listens to Boss lifecycle, and Boss only knows about that interface
Exposing event is one pattern, having listener interface is another pattern
What I meant is this: class Spawner : IEnemyDeathHandler
And boss/enemy script only knows about IEnemyDeathHandler
can think of plenty of cases, since it would make sense that a object should know when to pool its self again into the spawner
It's completely same approach as registering event.
Only difference is that you passing reference of interface instead of reference of method
If the boss is removed then who is doing timesheets?
There's functionality that the boss does for the sub bosses.
I'm not sure that the boss should be in the business of explicitly executing a list of functions
Let's say you have event calledonDeadand if boss callsonDead?.Invoke()it's exactly "explicitly executing a list of functions" defined with events
The difference using concrete reference vs interface is obviously the listener can be any class other than Spawner, so boss doesn't have to care about how Spawner implementation changes.
There is no better/worse concept about this, that's all up to details. Using interface can force you to implement some other events. Also you don't have to have assumption of multiple lister. Calling single listener method is sufficient in this case.
No, it's not Boss telling Spawner to what to do. It's Boss notifying it to listener. Even if you use events it's same, Spawner's method will be called by Boss's event in call stack. 🤷♂️
I don't know why would you have problem with common Observer pattern but not with events
Using interface listener is observer pattern
Well that's all about preference and what kind of details you have in system.
For example if you have sub-boss then you might want to pass ISpawner for real this time 😛
But ISpawner only have Spawn. Not sending lifecycle event through that interface
It's a case that makes more sense to have interface than an event
Im deep profiling my game which is lagging during some network events... anyone knows how to get the stacktrace of this shit ? I already have deep profiling on, but it still just throws nonsense at me
I also dont know what the heck "EntityCommand'2" is... i have a generic of that struct, but what the hell is the 2 ?
Honestly I wouldn't design to make Spawner to manage spawned objects, though XP
That's probably the number of generic type argument like EntityCommand<T1, T2>
Thanks ! Is there any way to get more detailed info ? Like what generic override ? What classes/strucs T1 and T2 are ?
I don't think so, it probably just aggregate them.. Is it deep profile?
It is deep profile already 😦 but thanks... guess i just need to check EVERY EntityCommand out there to identify the issue xD
My preferred design is having CombatModel which is all data/event, no logic.
It contains EnemyModel, PlayerModel, and each model has info like Position, Health
And all system like WaveSpawnSystem or GameOverSystem, references model only.
No systems references each other. They only see/subscribe to model state.
If they have to somewhat communicate, they send Command to model instead.
Why are triangles in Mesh list of type int, not uint? List of vertices cannot contain negative indices after all
because C# arrays use int as indices and using uint would require a bunch of annoying casting
Actually I was wrong about this. it works implicitly.
Actually it seems like it uses ushort/uint internally
https://docs.unity3d.com/ScriptReference/Rendering.IndexFormat.html
You're not going to have more than 2 billion triangles anyway
or I guess 1/3 of 2 billion
My code allocates a lot of memory due to closures...
prefab.InstantiateAsync(pos, rotation.value).Completed += handle => {
// Assign MonoEntity and the go itself to the entity :)
var manager = World.DefaultGameObjectInjectionWorld.EntityManager;
var go = handle.Result;
var monoEntity = go.GetComponent<ECSEntity>() ?? go.AddComponent<ECSEntity>();
monoEntity.Index = entity.Index;
monoEntity.EntityReference = entity;
manager.AddComponentObject(entity, go);
};
Anyway to instantiate a adressable and passing values to it WITHOUT them being allocated on the heap ?
In this case the passed "entity" gets allocated which results in a lot of gc when executed frequently...
what's your use case?
Hmmmm Calling LoadAssetAsync first then your InstantiateAsync will be synchronous.. 🤔
from fixedupdate i call a static function that runs some raycastall and i want to see all the hit.point
save it in a variable that you will use on OnDrawGizmos OR use Debug.DrawXXX functions
But this doesnt solve the insane amount of garbage problem right ? It happens due to the closure and passing stuff into it :/
If InstantiateAsync is synchronous then you don't need to pass lambda
Just get .Result and use it
Debug.Draw* is nice, I didn't know about it
thanks, now the scene looks like hedgehog
Hm thats right... But instantiateasync is actually great because it reduces the lag when i spawn in dozends of entities :/
Do you think its worth that ?
Calling LoadAssetAsync first will do the same job
After all the prefab you need has been loaded, then InstantiateAsync is always synchronous
Im actually a adressables noob ^ so i dont really have an opinion on this.
Ahh i see, do i need to call LoadAsset everytime ? Or just once ?
Once per prefab should be fine?
Thanks ^^
Actually thought once in total, since i heard adressables reduces the loaded asset amount
https://docs.unity3d.com/Packages/com.unity.addressables@1.20/manual/MemoryManagement.html
You might want to see this page for that info
They do reference count, but it only decrease when you do Release the handle
https://docs.unity3d.com/Packages/com.unity.addressables@1.16/manual/MemoryManagement.html
For whatever reason old version doc seems more detailed
Thanks ^^
However i think the issue is not fully resolved.
I wanna instantiate the asset once it was loaded... So i actually need to hook into the OnComplete event to then instantiate it and fill it with data... Another closure which allocs memory xD
Put it in coroutine or something, maybe?
How many prefabs are you instantiating?
Hundreds, thats why those damn closures are a real problem... Why the heck dont they add a method to pass custom payload to it ? Who designed this shit ?
Lol.. and how many entities?
Maybe just load when game loading and don't worry about rest of game?
you don't have to use a lambda/closure. Using a regular method to subscribe to the delegate is an option.
you can map the operation handle to whatever data you want to associate with it to a Dictionary or something
Hmm static method with static dictionary then maybe
Restarting your assembly or fork process beforehand? 😌
Why? Use instance of a class instead.. as in singleton
do you mean a static class or a static variable that refers to a class instance?
Storing any kind of state in an actual static class is a bad idea
and reinstantiating the static You can't instantiate static classes, best you can do, is to make a wrapper to reset the static constructor
We do use static methods and states in Unity all the time, tho
static state in Unity is all over the place, true:
Time.timeScale
Time.fixedDeltaTime
Cursor.lockMode
I'm not disagreeing, static state is bad
Well avoiding static is a good practice
Being Testable is also a good practice
Though in real world some class has to be singleton
You just hide it with dependency injection 😌
Yes Composition root is where you set up your dependencies
and DI container is the class that stores/resolves dependencies
You'll need to load that prefab somewhere 😄
Problem of Unity is that there is no single point of entry
That makes many things has to be static
No I'm saying many Unity API has to be static because absence of single point of entry
Would you mind dropping the titles of the testing and DI book/s you mentioned here?
Where the hell do they come up with this cover art lmao
@regal olive Thank you!
For whatever reason programming books has random cover most of time..
I like how o'reilly books having random animal on it
Sweet, I'm definitely going to order it.
i need some help with the fbx exporter in unity
i'm trying to do a runtime fbx export
when I do this, the KeyModifyBegin() function throws a null reference exception
same with this, but with the addMember() function
i was checking the docs, and it said that in GetCurve, and GetCurveNode, if the bool is set to true, it will create a curve if it doesn't exist and the eAnimatable flag is true
I've set the flag to true and the bool parameter is also true, but it still is null
Under the hood does anyone know what's going on with pixel values when you transform.scale? If you had a 2k image and you scaled it down does it still hold 2k resolution?
I've started writing a Dependency Injection Container project and want to hear some opinions. The major concept is being simple as possible and providing static API as Unity does. Wherever you instantiate a GameObject, the context will be inferred from the hierarchy (Global>Scene>Parent) and then injected.
Also meant to be used for injecting hierarchical model structure, supports object pooling and UI bindings, etc. It's very early stage and mostly biased to my own use case, so I would appreciate if anyone has feedback or criticism. 😄 https://github.com/cathei/PinInject
Features you’d expect from DI container, or something they shouldn’t do, anything helps
you dont clear statics? or i missed it
Global context (static) should remain static for application lifecycle as they are replacement of Singleton. Though you can manually call reset if wanted (for test mainly).
(im on the "im only curious" side)
i mean domain reload handling
Ah that one I am clearing it
found it, partial yep missed that
Sadly Zenject and other projects are not well maintained anymore 😞 and too much verbose configuration they have IMO
For anyone looks into code fun part: I’m making hidden cache component to prefab root and saving internal references of ‘injectable’ components. When I instantiate the prefab they are converted to reference to the instance’s components and I just inject by looping them 🙌
What is the best way of removing the interpolation between colors of each vertex of a tri?
I want each tri here to be eather cyan, or black
split them
is that pure vertex color?
looks weird i cant understand if the gradients are result of a shader or vcolor
pure lit vertex color
so I have duplicate vertices
thats the only way to cleanly separate triangles that i know of
dang
thats sounds really complicated for my little brain
I'm using someone else code to genorate low poly procedural terrain you see
But I'm having to change the terrain from displaying a texture to displaying vertex colors
if i explain the principles will you apply them?
I understand the basics of mesh genoration
sorry for the late response
*I understand the basics of mesh generation
I've done a bit of it myself
but something as complex as procendural map genoration is more dificult for me to create than its worth
I would be able to do it would just take me ages
tldr probably not lol
I think I've found another way of fixing the issue tho
basically inside my vertex shader (made with shader graph) I just round the color to one of the ones I am using
so I doesnt use a blend between multiple colors
I think that should work
hopefully lol
Shadergraph doesnt support float4 arrays (color arrays)
So I will have to make a really basic written shader i think
time to get complicated!
I think what you are looking for is the nointerpolation modifier.
AFAIK it is not supported by shadergraph, but if you are going to write it manually it is worth checking
Hello everybody, is it possible that the Script of a ScriptableSingleton is already an instance of ScriptableSingleton? When i create ScriptableSingleton Object it seems this is another instance of the ScriptableSingleton. I am confused about ScriptableSingleton, getting an Error when clicking on the ScriptableSingleton Object -> ScriptableSingleton already exists. Did you query the singleton in a constructor?
Best asking in #↕️┃editor-extensions
ok, sorry
hey everyone, i have a main menu where you can select a weapon to play with. but i also want to save this gameobject as "LastUsedWeapon" so you dont have to always choose it. How can i serialize an whole gameobject?
oh ok thank you
ok
I have a questsion is mesh.SetTriangles((int[])(object)newIndices, 0); the same as mesh.SetIndices((int[])(object)newIndices, MeshTopology.Triangles, 0); and if it is not, why ?
also ignore the ugly hacky casting
I need test cases too xD
Though I’m not sure how to reset static if I run test parallel
I am writing PlayMode tests for a Unity package. I need to create test assets, models, textures, scenes etc to be able to test the functionality. I normally, for play mode, would just create Test scenes I could load and run manually and check the test results but I would like to give the TestRunner a go in PlayMode.
The problem is that I want to make sure all these Test assets and scenes do not pollute the builds on other projects (This is a package to be used in many projects).
Anyone know what is the workflow for that? If I put all the assets used for testing in the test assembly folder and before releasing disable the assembly on all build targets does it make the assets not included in the build of the host project?
Unity test is single thread so it’s fine for me 😄
Ho wait... if I only reference the assets in test scenes that are not in the build settings.... nothing would be referenced.... therefore not included.... Right?
So I might not have a problem to start with....
I just have package developing project and put all test related stuffs there
No I think you are right indeed
But if you make play mode tests you have to add test scenes in build settings (assuming you’re using unity test runner?)
The only problem I see now is that I do need Addressable assets, and those get built into the bundles independently if they are directly referenced or not......
Yes, I am ok with adding them on my own dev project only. The host pojects just import the package and do not include the scenes.
Yes, It's not a game, it's a dev tool.
So all assets will be test only
Ah then just making package without test stuff should be fine
If you use Package’s Test folder it has some limitations 😦 so I just put my testing stuffs in Assets folder
I would like to be able to run the tests on the host project too if something goes wrong or for QA purposes so I need to include all the tests and test assets on the project. I just want to make sure it does not pollute builds though
That's why I decided to put them on the package's test folder
So they get pushed to git, and loaded into the package when imported
I’m not even sure if you can open scene from Packages folder unless it’s embedded package
Good point, I haven't tried that.
If it’s git package you’ll get something like “you cannot open readonly scene”
That's why I have been avoiding playmode tests honestly
I can't find a tried workflow
Specially for a package
Ha yes! Samples folder is a special one for packages right?
Yes, you can import them with package manager UI
Good luck 😄
I am very curious now.... 🙂
your git repository should look like
Packages/com.davidjonas.mypackage
Projects/Test_Project
manifest.json for Test_Project looks like
{
"dependencies": { "com.davidjonas.mypackage": "file:../../../Packages/com.davidjonas.mypackage" },
"testables": ["com.davidjonas.mypackage"]
}
tests on the host project too if something goes wrong or for QA purposes so I need to include all the tests and test assets on the project. I just want to make sure it does not pollute builds though
i don't htink this provides value the way you think it does
while i wasn't aware you couldn't ship a scene in a package, you can ship a prefab and use a 3 line script to instantiate it in. you can create a scene on the fly. it sounds like you want to use the real host project scene though
it's better to cp -r the host project into Projects/TestProjectB or whatever
and set it up properly for CI if this is what you really want to do
so my takeaway is, you have developed apackage that is used by 1 project
that has tests that only really make sense in the context of that project
so write a test scene in the project. why are we using the word "polluting"? it won't pollute builds. your package is part of this project end of story
@tropic locust does that make sense?
Any one know why tilemap.hasTile(position) might return false, even though the tile exist?
Figured out why, it seems the z - axis of a tile does matter, so the positions (2,2,0) and (2,2,1) are different even though they look thesame on the map
My package is a generic developer tool for use in many projects. It helps devs manage procedural asset libraries in runtime and stuff like that. So it will be used in many projects of which some are in my control and others not
hmm
is it though
is this package online and public?
Probably not public. We have a B2B model at the moment. Maybe one day.. 🤷🏻♂️
But in practice it is the same as if it was public
i know it will be used in many projects
but is it currently being used in many projects?
it sounds like you have a specific frustration with a specific project of yours
😊 its currently being developed
But also yes, its being actively tested in 2 projects at least
and you had this specific frustration, the only real frustration word is "polluting"
in my experience the development lifecycle looks like
1 repo
Packages/com.davidjonas.package
Projects/DavidJonasProject
Projects/CollaboratorProject
then, once you actually have something where you no longer need to have the two projects to know if the package is working, these three things can be separated into their own repositories
Not frustrated at all, I am just planning out ways to not make the host project builds bigger