#archived-code-advanced
1 messages · Page 27 of 1
yes, but it's really hard to do
without some constraints. what is the game?
it's a game we have developed. but client would like it to livestream on a schedule to their rtmp server.
one specific instance of the application would stream once a day.
well i'm telling you. it is possible and i can suggest the easiest solution for you, but i have to know what the game is
it is incomprehensibly complicated in the general case
I am from the field of mathematical optimization, and there, we understand that it's the job of the decision maker to define the best solution for problems with multiple objectives. Monobehaviours and ScriptableObjects have different purposes and fulfill different objectives, so I wouldn't advocate to make one or the other obsolete
very reasonable
it's a game, but the part that gets streamed has no input except some data that runs the game in a simulation mode.
If Prefab architecture is better for the objectives I think are priority, I would just try to promote it, but without saying the other side is completely useless
okay, i think it is impossible for you, i am sorry
i develop an instant unity streaming solution
I have an asset that records game footage in realtime
In my case, I just like to have a collection of objects, and let each object add themselves ro the collection on creation, so they are all easy to access.
There are other ways to do the same thing
without knowing what the game is, i can't give you useful advice, i'm sorry
I just think it's good to have a shared container for that
why is the game itself important? essentially we are talking about a video/audio stream.
you're probably going to punch this into google, and find a plugin that, a month later after a harrowing implementation, the plugin is fundamentally flawed and there is no way to improve its performance into something decent
An asset so other people can add stuff in the editor
there is nothing sensitive about what the game is
it matters if it's X or Y or Z
i don't wanna play guessing games
there's a big difference if it's "Modern Warfare 2 but with ants" versus "Civilization V, except instead of cities you're building Burning Mans"
you'll actually find other people who have asked aobut this in the discord, and some have found the plugin that i would not recommend you use, and then they ask, "why isn't this working"
it's up to you
modern warfare 2 but with ants is pretty good
the plugin we have already works for the purpose of creating an mp4 - works in realtime, we are already using it.
then i guess you don't need any more help
You should train your social skills
the issue is instead of storing to a .mp4, stream instead.
the user can't give a log line. he's not going to thrive at making this game
trust me, there are dozens of people who come to the chat room and do that
man people are being difficult today
listen i've told you what would be most helpful. there is nothing sensitive about what the game is
i really don't want to play guessing games. based on everything you've said so far, i have a few guesses
but please, it would help so much if you could sort of describe the game in a logline
what is there to guess about? it's a game that just has characters that march in a formation based on data - it's completely a visual display, it's not being played.
like "players command real time armies to destroy each other's bases" (an example for starcraft)
okay so... characters in a formation
like what's the game?
is this a multiplayer game?
the game itself is an rts, but again, all it does is have a daily cinematic that is based on what happened that day in a given game.
or like, battle simulator?
huh?
so is there a unity client that people play, or no?
yes, there is a client, but this part is just something they want to display to all users each day. it's not even gameplay. it's basically a cinematic. but it gives players information about matches that were played.
okay
like a desktop client?
or it's meant to be played e.g. webgl?
but it gives players information about matches that were played.
for what reason?
i mean if you have it recording video, you can upload it to youtube with an api, surely, and use the youtube player
but you must know that
so there is something i am missing here
you haven't really described the game enough yet to help me understand
like is this a crypto game?
and people have to bet on the outcomes or something, in the matches? or what is really going on?
the cinematic is dynamic, so it needs to be delivered each day. the game plays on webgl, windows, macos. but nothing is being played in this scenario. it will sit on a computer at the client's location and each day they want it to fire off a livestream with a live cinematic.
no, it's not crypto
fire off a livestream...
how long of a delay can they tolerate?
i mean i don't know, there are assets that do this
i just punched it into google
https://answers.unity.com/questions/1718680/send-live-camera-from-unity-game-play-to-youtube-o.html here is an example
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
they want to not even think about it -- someone will be creating a file that it feeds on -- the file is just to define what the map looks like
okay, so they want to think about it enough that they will double click something
on a desktop computer
bu they don't want to think about it enough that there might be like, 3 clicks to get this feature in like, an afternoon
and they don't want to not think about it enough that this would be automated on a backend, because... that would be beyond your abilities and way too expensive to engineer?
no, a person not on site, will create the scenario to be played. they'll send that file to the computer with game running an at same time each day it'll use the file in that folder to generate the scenario to livestream. no one at the client location will click anything
okay
the game running at the same time each day...
well it sounds like you should use the numerous unity assets that do this
that can stream to youtube. you can also script OBS
or even the built in windows game streaming
if you are already going to script a Windows PC to start the game at the right time or whatever
you might as well script the other pieces of the puzzle
and besides, if you have it in a video, why not upload the video?
because it has to cosmetically appear to be live?
you can also use ffmpeg to do this
it can take a video file and copy it to whatever servers it supports, that will make it, cosmetically, appear to be live
but you know, you should use the asset. there's no way you are doing this For Free
the $60 it will cost or whatever
ya, if the asset exists, $60 is fine. which one are you talking about?
but really i don't think this will work in the general case
i think if you have the video already recorded
you can google "copy video to live stream ffmpeg"
maybe something will come up
ok, that's one on my list right now.
good luck out there
i've never used it
so i can't vouch for it
it is good for, "contractor has to check feature box that makes no sense"
like i'm sure it will work horribly
but then again you're being asked to do something that makes no sense
you could just upload this video to youtube
@ionic plover what do you think about that?
yea, thanks for help. i am trying to convince the client to just create the .mp4 and live stream that. but they are being stubborn and i'm not clear on why that's important -- ie live stream vs .mp4. there is a language barrier, so i believe they are stuck on the term "live stream"
like, in their minds, if it's an .mp4 - it's not live.
which is really challenging to do
right, well, I did have FMETP on my list to check out. I want to understand what is possible. they have an rtmp server and they want to stream from a location, to that server. The fact that the game currently records .mp4 realtime while playing the game, is what has them wanting that to happen.
keijiro has an ffmpeg pipe github project you could use
it will get you very, very close to simply streaming to an end point, provided you can figure out the ffmpeg invocation to do it
on the other hand, i suggest hiding the file 🙂
you're not saying Unity Recorder right?
like some other package?
thanks for your suggestion. I am also looking at ffmpeg for another part of the project.
its
https://assetstore.unity.com/packages/tools/video/video-capture-pro-155663 -Video Capture Pro
sorry, had to check what exact name was. it works well for what we are currently using it for. - let me know if there are others you would recommend
that's good
yeah take a look at https://github.com/keijiro/FFmpegOut
@ionic plover hope this helps!
i think this is going to be exactly what you need
ok, thanks, i already grabbed the keijiro one. thanks for the links
i have been checking out what ffmpeg some more, used it for a few things in the past but nothing too complex. I believe that VideoCapturePro is using it as well. thanks again, big help
We are also using this one as an FYI
https://assetstore.unity.com/packages/tools/video/fmetp-stream-3-0-221362
Has anyone used Fmod audio tables? Id like to reference a Sound/Clip like an EventReference instead of just a String.
how would i go about adding jump corner/edge detection in unity (2D)?
there's an edge collider component
you can also use a really thin rectangle collider
neither of them give me what i need
ok what are you trying to do specifically and why do those not work?
imma record a clip of celeste and show you
ok
when madeline is under the block by a couple pixels
instead of stopping
she gets pushed to the left
oh i see
you could use a rectangle collider rotated at 45 degrees
just for the corner
the player is a rectangle?
that shouldn't be an issue
the corner of the player should still slip along the block's collider
ok
oh one other thing
if i do that
i will still collide
and i will loose y velocity
still doesnt work the same
oh right ig 0 is the default
you could tag that collider with something like corner
then in oncolliderenter check if the collider is corner
and if it is then reset your vertical velocity?
seems a bit jank but it could work
but like you should lose vertical velocity in that scenario no?
seems logical to me
the celeste video does
no
looks like when the player is pushed off the corner they don't go as high as the previous jump
but when player does it and it stops there jump it is bad
i think its cause i didnt hold button as long
oh ok
celeste does the same with dashing
idk if there's a way to do that effectively
ig you could make the corner collider a trigger and then manually push the player left or right depending on the way it's facing
whenever the player enters the trigger
that would work but might be a little buggy
https://youtu.be/yorTG9at90g?t=579 also there is a timestamp but the effect is way exaggerated.
i would try the trigger and manual pushing thing
and see if you can get it to feel nice
ok
i have no idea how to get a reference to an interface on a scriptable object
all i can find is this
ScriptableObject[] allScripts = FindObjectsOfType<ScriptableObject>();
for (int i = 0; i < allScripts.Length; i++)
{
if(allScripts[i] is Iobjective)
m_AllObjectives.Add(allScripts[i] as Iobjective);
}
this cant be the best way right?
ScriptableObject doesn't have getComponent
there are no components on scriptable objects so of course not
if (allScripts[i] is Iobjective objective)
// Use objective
That will attempt to cast the element to an Iobjective and store it in the objective variable
I doubt FindObjectsOfType would work for ScriptableObject at all.
🤦♂️
and the SOA holy war continues
Everyone should just have a look of any of my old SOA infested projects to get a tangible experience of what hell looks like 👹
What's SOA?
I'm also looking for a decent maps SDK. Google seems to be depreciating its gaming services and mapbox hasn't been updated in ages and appears to be buggy. Did you find anything @lethal flicker ?
Is there anything that can be done about the fact that there's no encapsulation on the level of the gameobject?
Any other gameobject can edit stuff it's not supposed to on any other game object
Add and remove components, edit compoments
A much better approach I think would be subclassing gameobject for each type of object in game
But this can't be done in unity
Hm that's false, you can make members private or protected, and they won't be accessible
Encapsulation is of limited value in games, especially at hobbyist scale. Unity's component model exists because a subclass for every type of object is a nightmare in practice. You'll have multiple objects with similar functionality that don't fit into a neat hierarchy.
Use prefabs to build 'classes' with grouped behavior and instantiate them as 'instances'. If you don't want to edit components at runtime you don't have to, but I would be careful what strict lines you draw in your code because inevitably you'll want to implement a mechanic which subverts them.
Anyone know how to calculate navmesh surface area? The bounds.size.magnitude is easily readable but it doesn't seem like there's an equivalent method to easily get the surface area.
bounds aren't surface area, you probably need to sum the area of each triangle
yeah I figured as much, it's not obvious to me how to do that though. It doesn't seem like the navmeshsurface is treated the same as a meshfilters mesh data
what is the return data here? Is 'Triangulation' a data type or a class or something?
the documentation contains the method signature
you can see there what the return value is
if you click it, you can see what that class is
ah sweet thank you
But if the struct only contains these fields, how can I calculate the surface area from this?
math
that's so helpful, thank you
I would try to see if every three values in the indices areay points to their corresponding triangle positions in the vertices array.
the documentation is clearer about what each field represents
Be sure to check whether you want to calculate the area in world space or a local space.
I have gotten those mixed up before which lead to some rather interesting bugs
That's a good point. In my case, I don't have the programmer iq to make sense of this, even though I vaguely understand some of what's going on here.
I know my a²+b²=c² but I don't know how to get to the point where I should apply that. Sadly I cant just get an array containing all tris and then iterate through them.
I use transform.TransformPoint() and transform.InverseTransformPoint() to convert. (Spelling might off)
I would find the two cathetus of the triangle, multiple them together and divide by 2 to find the area of one triangle.
Assuming no overlap between triangles their areas can simple be summed up
The triangles are encoded in the indices array. The first 3 elements in the array represent the first triangle, the next 3 elements represent the second triangle, etc... So, the length of the array is 3x the number of triangles.
So to iterate through all the triangles, it would look something like this:
int triangleCount = navMesh.indices.Length / 3;
for (int i = 0; i < triangleCount; i++)
{
int index = i * 3;
int i0 = navMesh.indices[index + 0];
int i1 = navMesh.indices[index + 1];
int i2 = navMesh.indices[index + 2];
Vector3 v0 = navMesh.vertices[i0];
Vector3 v1 = navMesh.vertices[i1];
Vector3 v2 = navMesh.vertices[i2];
}
also be aware that triangles are not right-angled in general - you might get a better idea for how to do what you want by looking up how to create a mesh rather than extracting one from navmesh
that's also a good point, my pythagorean theorem assumes a right angle, thank you for mentioning that!
Nothing that would be really great in terms of covering as many features as the Google Maps SDK.
What are you trying to do?
Nothing too tricky I don't think. Basically I've had a version of my app developed in native code for both platforms but I want to see if I, as a coding beginner can recreate it in unity. You can find links to download the app here: www.theoverhear.app. We basically geotag audio to location for people to collect either my their coordinates matching or by scanning a qr code.
No idea to be honest. I'm using Bing Maps at the moment, but it really depends on how you want to create your stuff. I dont know if it will go well with your project
that looks nice
very Janet Cardiff
imo the maps widgets in native iOS are very robust
it depends what your goals are for the experience. will it be a 2d UI app? for solo developers, Reactive Native is a good choice for making 1 app for both android and ios. however, in my opinion, your audience is probably using primarily iOS, so you can focus on just that too.
if you want to do something in 3D or AR, unity is the only game in town
you can also try ARDK
Thanks! As I understand it UNity has a very good audio engine that we can use to develop the audio seamlessly as they move through location like moving through scenes in a game. ARDK looks fun I'll have a play with that.
hmm that's true, but it sounds like you want to make an AR experience then
also there should be ambisonics / spatialization libraries for ios
if you have some geometry modeling the world that could be interesting. in ARDK you can use their modeled monuments (VPS), if that's where you want your janet cardiff experience to take place. but those are outdoors
you can maybe make something where it's the eifel tower and you're behind a part of it, and you look around the corner and can hear the distant sound. but that is going to be pretty subtle and a colossal amount of engineering
the audio engine is generally pretty primitive and people with music engineering backgrounds use a substitute engine - steam audio and fmod for example. as far as i understand though you want to have talking characters around a space right?
also an AR experience that has the camera turned on throttles after a few minutes, and kills battery
Not quite no.
if this is meant to deliver a 2 hr story, a unity app will drain the battery before then
do you mean something like this - https://cardiffmiller.com/walks/
Thanks for your input here by the way I appreciate it. We are using the map just to display locations where users can collect audio. We usually work with festivals or large spaces to commission poets to write poetry about the location. We actually want the user to put their phone in their pocket and be as present as possible in the space gathering insights from the creative audio
okay it sounds like the logical conclusion of that is people are making janet cardiff walking experiences
festivals or large spaces
so outdoors, not in a gallery. there are artists who use bluetooth beacons to localize one room versus another, and there's an iOS library specifically for that
put their phone in their pocket
i think your best bet is to use react native if it's essential to support android and to deliver a 2D UI. although really i don't think there is an audience for an android app
if you need to write this from scratch
your existing app, is it already react native?
the existing app is Kotlin and swift
I was drawn to unity as it seems easier to devleop the UI as someone with little code knowledge
you can use https://expo.dev/ which is what all the creative technologists i know use
it is reactive native + bundling features
it depends what the workflow is. do you use figma?
No I've been using XD
it depends what the learning goals are then
while in my opinion the UI design tools are kind of a waste of time - people are making glorified lists in them after all - figma has a lot of appeal because it is (1) collaborative and (2) supports outputting content usable in an e.g. reactive native project
so if your goal was to learn how to rapidly make original and pretty looking 2D experiences, figma -> expo -> ios & android is a well worn workflow. firebase is also very well supported for any sophisticated backend stuff you want to do
with the caveat being, every idea in 2D has already been had, you will never make something original in 2D 🙂
it will look like a list
Cool, our back end is already in firebase.
if your goal was to do something interesting in 3D, yes, you have to use Unity
but i mean like, 3D presentation
or 3D UX especially
Can someone help with a math related problem? Concerning 3D vectors
like to me personally, i can see how you can do something innovative in AR with the "Virtual Positioning System" feature in ARDK, with sound
there are no invite links permitted, but you can find the Lightship AR discord invite somewhere online, and chat directly with niantic folks. i'll warn you though, it is extremely complicated to get started
and this is one of the more interesting SDKs for AR experiences
maybe the big picture takeaway is, you better start believing in becoming a coder
lol
because that's what this is
it is much easier to program for reactive native than for unity.
Don’t ask to ask 😌
OK amazing this has been invaluable. To recap if we are staying 2D a figima -> expo -> iOS Android workflow is best but if we want to leave open the option for 3d presentation in the future use ARDK with unity.
another perspective is if you are excited about more experimental sound, like, "can i make a gamey / 3d ux driven experience around a Max graph...
yes
i wanna just make sure you got your ground covered in Audio
like what are you personally interested in?
I'm personally interested in giving people a moment to be present in location, to be grounded in space using audio as a vehicle to set that experience up.
Hence we have a fair bit of poetry commissioned specifically for location
you can put keijiro on your radar - https://github.com/keijiro/Reaktion https://github.com/keijiro/LaspVfx - as an example of someone who does the complete opposite, it's very abstract
By Max are yo referering to Max msp?
yes
OK I've some experience with that. Does that integrate with expo?
this is a very appealing, very audience friendly sort of presentation... but it doesn't sound like it will quite be for you
no. you would have to tremendously improve your coding to achieve that
however there are interesting things already done for unity with it
it's much more VJ than what you are talking about
@cunning tapir there's a video game about a blind protagonist - https://en.wikipedia.org/wiki/Perception_(video_game) - by a team with energy more similar to your creators
Perception is a first-person survival horror adventure video game developed by The Deep End Games and published by The Deep End Games and Feardemic. It was released for Microsoft Windows on May 30, 2017, followed by the PlayStation 4 and Xbox One versions on June 6, and by the Nintendo Switch version on October 31. The story follows Cassie Thorn...
i think maybe the best thing to do would be to ask the poets if there's something visual they would like to show, as a starting point. maybe the answer is "nothing" and then you definitely would not use unity
OK So Max integrates better with the Unity option
yeah, if someone wanted to do something more experimental like that
because it's a powerful 3D game engine, the kind of peopel who are excited about procedural sound and graphics are really attracted to it
@cunning tapir this is a good example of something more experiential developed in unity, by a bonafide artist - http://mountain-game.com/
there are a lot of narrative games developed in unity, tens of thousands, so you don't need specific reference for spoken word. they tend to follow certain specific narrative video game traditions that make no sense for this, uh, brief. they are often developed by people with Low Code Experience
unity has a lot of assets specific to making those narrative games, with audio, like Dialogue System, and there's a whole no-code toolkit for point and click adventures
that i have seen used in an academic context successfully. but it will still take longer to use that tool than to build on expo, even for someone with limited coding experience
OK neat, lots here for me to get stuck into then
if you need reference for music-driven games - https://en.wikipedia.org/wiki/Masaya_Matsuura - parappa the rapper is really good, it's a game about spoken word, of course in modern days you'd make that in unity
Masaya Matsuura (松浦 雅也, Matsūra Masaya) (born June 16, 1961) is a Japanese musician and video game designer based in Tokyo, Japan. He was born in Osaka on June 16, 1961, and majored in Industrial Society at Ritsumeikan University. He has worked extensively with music and images, and has been active with the J-Pop band Psy-S. Matsuura has been cr...
but these are Games for People Who Play Games
by virtue of looking lowfi - https://en.wikipedia.org/wiki/Vib-Ribbon - this LOOKS a lot more experimental than it actually is
Vib-Ribbon is a rhythm video game developed by NanaOn-Sha and published by Sony Computer Entertainment. It was released for the PlayStation in Japan on December 9, 1999, and in Europe on September 1, 2000. Although the original PlayStation version was never released in North America, the game was re-released on PlayStation Network in North Ameri...
The game was initially commissioned as an advertisement for the Mercedes-Benz A-Class car.
pretty wild
@cunning tapir anyway lots for you to think about on this journey. listen to a janet cardiff walk if you haven't yet!
Yes I will do her work looks very interesting. Again I appreciate your input here its been useful for orienting myself
How to get nearest gameobject from a list
Wrong place to ask.. #💻┃code-beginner
Any experts on unity package development here? I'm looking for guidance
#💻┃unity-talk message
To configure dependency between packages you have to use scoped registry.
For example OpenUPM
You can take advantage of OpenUPM or define scoped registry yourself.
thank you, I will look into it. Do I need my own hosting solution for that, or I can I use e.g. github to setup a scoped registry?
If you want to create own scoped registry you might need to host a server with proper domain.
Not sure, since I haven't create one myself, but you can see implementation from open sources like OpenUPM or UnityNuget
Been trying to solve this for a few hours now. How can i get the name of the current gameObject the mouse is over(ui raycast). In the Debug Modus there is this small field called Current Focused GameObject. Trying to get it via code but no idea how. Tried so much.
might be able to get some information out of the EventSystem too
well i really messed around with it so muhc. i went throught all the methods and fields of the Eventsystem
thank you i will tell you more
Help!
I'm trying to make a curved line renderer. I got 2 points. I want the line to have a slight bend in it, except if its pointed straight upwards or downwards then it doesnt bend. But the more horizontal it is the bigger bend it has. I know a curved line requires 3 points but I don't know what the mathematics behind the 3rd point should be to get this effect.
Help is much appreciated!
I know bezier curves and i know how to make them with the line renderer. but a bezier curve needs 3 points
that means there will be no curve at all though
no there won´t that is why you need the 3. point to be some kind of moveable
i want to put in 2 points into my script and i want a formula to automatically find out where the 3rd should be
Vector3 c = (a + b) / 2;
i tried this one but its not curved at all no mather what a and b are tho
it is not bend because it is exactly in the middle
so as mentioned , make it controlable. no idea if you want this in the editor or at runtime
but this is what im asking, i want a formula that automatically decides where the third point should be
i want it to be completely straight when the line is vertical, and get a bigger bend in it the more horizontal the line gets
the line moves around at runtime, its dynamic
so i cant have a pre defined third point
Can you paint something or make some visual help. i am lost rn
its exactly like the arrow in super auto pets which you use to feed your pets or something
so basically the player drags his mouse from the object and an arrow goes to where his mouse is
and the arrow should bend a bit instead of being completely straight
Hi so I am not sure id I should ask this here or not, but I am trying to bypass my ssl pinning certificate on my unity project to check my network traffic using mitmproxy for debugging. I couldn't find a reliable way to do this could someone point me in the right direction?
Well since i asked in both code-beginner and code-general and i couldn't get the solution maybe you guys could help. Here's my problem : Too high speed of player = jerky,stuttery,forth and back movement. Core of problem is that i need the gravity of rigidbody2d so i cannot directly set velocity just on [x] because its not platformer and my movement direction range is wide on [x,y] as you can see in the video [slopes] and that would require to override gravity which i don't want. Have you guys encountered anything like that? You can see in the video when its set to high speed like 50 [5 for eg. works perfectly fine no jitters] . Camera rigidly follows player so when in-game its not noticeable , that's why I show u how it looks in scene view. But that IS a problem because sooner/later i would want to add "smooth camera" not one that rigidly sticks to the player. To anyone who's willing to help i'd be thankful, I feel soooo soo stuck on that one. [tried interpolation,vsync,switching delta times fixed update,update,manually adding gravity which doesn't work well because of collisions]
Vector2 direction = (b - a).normalized;
Vector2 c = Quaternion.Euler(0, 90, 0) * direction * someValue;
not sure JohnSmith but something like this?
ill try it, one sec
you probably want a cubic bezier curve and 4 points, not 3
with this it bends weirdly at the tip
why? and do you know how to calculate the 2 extra points then to get the effect i want?
it goes above my mouse and then bends straight down onto my mouse
hmm
Question about ScriptableObjects. If you have let's say 10 units in the game, and they're all sharing some data via a ScriptableObject (like a weapon). If there's a method that handle's firing that weapon in the ScriptableObject, and one of the units calls that method, it'll end up calling it for all of them, right?
cubic typically looks nicer and you have more control over the curvature - although to be honest after rereading your description I don't really understand exactly what effect you're hoping for
I haven't played auto pets and don't know what you mean by mouse dragging/arrows pointing
i know how to recreate this but only completely straight. i want it to curve in the exact same way
Well there is only one ScriptableObject instance and that will be shared, so 'all of them' sounds weird. It will call that one and only SO. And ScriptableObject should not have such method anyways.
You are basically using singleton.
and it has a bigger bend when completely horizontal (and no bend at all when its vertical) https://www.slythergames.com/wp-content/uploads/2021/11/Super-Auto-Pets-How-to-Use-Sleeping-Pill.jpg
Ok. That's what I thought.
for this you can probably just use a quadratic bezier, with the third control point set to some fixed y offset from the centre of the two points
i tried giving it a y offset, it doesnt get this effect unfortunately, so it needs something more complex im guessing
when pointed straight up for example it should have no offset at all. and when pointed slightly up it should have an x offset
on image 1 you can see the third point has both an x and y offset
I don't understand what you're saying - when pointed straight up it should have no offset and when pointed up it should have an x offset?
what third point in image 1?
third point as in the tip of the curve. a bezier has 3 points
the tip of the curve is not the third point of a bezier
call it the second point then
do you see where point B is on image 1 though? it's not on the curve, its further away from it on both the X and the Y axis. so a Y offset isn't enough
there is no point B in image 1, it's invisible
yes but can you imagine where it would be, to accomplish such a curve? this is what i need to know
what I already said?
for this you can probably just use a quadratic bezier, with the third control point set to some fixed y offset from the centre of the two points
and also what you can see in the image I linked
you said y offset, but it's not enough. it needs an x offset as well
and how would i calculate this offset?
does the image I linked look to be accurate?
almost, but in the case of my images it seems like the tip of the curve is at the middle of the line (and offset slightly on x and y) while yours seems to be closer to point A
https://www.geogebra.org/m/YGqtDGzK will leave this link here and you can play with the minutia of details
but the question still is how would i calculate the point B through code? i can't give it a fixed offset since depending on where the mouse is, the curve changes. when pointed straight up or straight down, there is no curve for example. point B can not be predefined, it needs some kind of formula. and i don't know what that formula is
there is no magic formula - you choose the formula, it is entirely yours to control
it can curve however you like
but if i want the same effect as in super auto pets, as seen on my example images? i want it to curve like that
there is a magic formula for that but i don't know what it is
You can generate vector orthogonal to your direction then offset alongside that vector.
Amount of offset you can Lerp to make it zero when it's vertical and max when it's horizontal.
how do i do that? can i somehow detect how much verticality and horizontality it has to decide how much to change the offset?
You can calculate angle..
ah, vector3.angle?
Your game seems like 2D
abs(dot(right, dir)) is enough to get how horizontal your direction is
yea i meant vector2.angle
ill try it, i think the method you suggested should work. thanks!
network traffic to what?
there is a google result for this, so i'm sure you tried it, and it didn't work, which means it's probably not the issue
so i am i was able add the mitmproxy in between using wireguard but the build has pinning which prevents me from monitoring my data.
okay
but you have the source right?
what are you trying to do
yes i do
what is the issue you are experiencing that you are trying to resolve?
the issue is my game takes up too much bandwidth and i am trying to see what is it going so i can pin point on what things i need to optimize.
okay
and this is a connection with what?
a server you authored?
why can't you observe plain http (non ssl) traffic? you control the servers
currently its my pc that's acting as a proxy
your android build... why didn't you build for PC?
there is something critical you are omitting here
Mkay so I'm trying to get the light level of a point in space using Lightprobes and Spherical Harmonics L2. I understand the basica I dea of the fourier transform etc and I have the utils to split the coefficients into each color band, but I am not sure how to make sense of the vectors it returns. How do I turn 3 numbers into a light level for a channel?
like i said, you must have found the ssl certificate handler stuff online, and you must have tried that, and discovered it doesn't work
not to interrupt, oops
connections with internet in general as i am using playfab, unity web requests, azur blobs to get my data.
so there are mainly 2 issues with the game one as i said is my network cost and second is long loading times on my mobile build i am trying to figure both out currently and just trying to see how my app behaves in general. what kind of request is it making. As I am working with a team and I have written all the code it will be really difficult to go through the code to figure stuff out. that the reason i am trying to do this.
okay so does this help? https://forum.unity.com/threads/unitywebrequest-report-an-error-ssl-ca-certificate-error.617521/
Hi,
when Android API >= 28, Google does not allow plaintext HTTP requests, but if I change the request to HTTPS, an SSL CA certificate error will...
this is the first result
for many of the keywords
have you tried setting an all-pass certificate handler?
hmm no let me look into that.
can someone tell me what the coefficients mean for each channel of a light probe, and how I can derive value from that? A quadratic equation needs 4 values I thought, but it seems to be 3 for each channel.
the swizzling util gives me a vector3 but im not sure what the values mean in this context.
It’s obviously arguments for an equation. But what equation?
trying to make moving platforms in my game using the animator with update mode set to animate physics, but since physics animations update after fixed update, the player physics are a physics update behind which causes some major problems especially on fast-moving platforms. i tried the hacky fix of just offsetting the mesh object and camera positions based on the kinematic rigidbody's velocity, but since it's still a frame behind, there are still problems with the platform changes velocity. i also tried setting the tangents in the animation to linear, but not only is it not what i want in my game, there are also still problems when it changes direction. anyone able to help?
Do you have experience with IronPython in Unity?? I've piddled around enough with it to get a proof-of-concept working, but haven't really come up with a practical use case. I'd love to hear about any of your experiences with it.
Not really, I haven't done anything more that research.
I've also seen Lua being used as script language for Unity (mobile)
For Lua it's mostly used for UI, due to slow process of getting approved for app update, with interpreter language you can just patch it with CDN.
what I've seen done is to animate the platforms during the regular animation update step. From there, the player would react to OnCollisionEnter. When the player settles on the platform, they need to inherit the velocity of the platform. Or, often, make the player a child of the platform and adjust physics accordingly.
this isnt possible with the animator component is it?
ive already got all the platform physics figured out just need to fix the physics update lag
my game uses lua
oh cool! What kind of game is it?
iOS or Android? I thought iOS forbids code transmitted over network (but you can bundle interpreted code and interpreter in your app)
An RPG. Lua in my case basically fills the role that Papyrus does in Skyrim and Fallout: giving me a way to make things do unique stuff without having to make a mess of C# scripts that are only used once
kind of fixed it, it's a little hacky but it works well enough.
just moved the mesh of the platform to a different game object and made a script to set the mesh's position at the same rate the character's position is being set, so at least the mesh is kind of accurate to the collisions.
the biggest problem with this solution is it's using the velocity of the platform to predict where it will be the next fixedupdate, but since velocity is still a physics update behind, it's not perfectly accurate. doesnt seem to be noticeable at all so far, but im only testing with platforms at relatively low speeds.
Both, I don't think the policy apply to interpreter language, because you know, all web browsers are also JS interpreter 😄 Also since it's not code generation either and cannot do more than given app permission
Lol I like the statement
I'm working on a main thread event dispatcher since I have some worker threads that want to invoke events that deal with visual effects and such that must be run from the main thread.
Someone mentioned concurrent queue in the Unity3D sub. I've prototyped this and it does appear to work... just wanting another pair of eyes to sanity check this
[SerializeField] private Shrub shrub;
[SerializeField] private VisualEffect vfx;
private ConcurrentQueue<Action> eventQueue = new();
private void Awake() =>
shrub.OnHit += OnHit;
private void OnDestroy() =>
shrub.OnHit -= OnHit;
// OnHit gets called using the contact modifications api, which runs on a worker thread
void OnHit() =>
eventQueue.Enqueue(OnHitMainThread);
void OnHitMainThread()
{
if (shrub.Runner.Simulation.IsForward)
vfx.Play();
}
private void Update()
{
while (eventQueue.TryDequeue(out Action action))
action.Invoke();
}
Thinking I'll end up making a centralized singleton manager or something of the like that dispatches any events that must be run from the main thread, instead of having a bunch of concurrent queues and update loops all over the place
although once parameters enter the equation... then I think things get tricky
Hm. Have you checked UniTask out?
I have not, looking now... is it a good fit for this sort of stuff?
Your code could be simplified to:
private async void OnHit()
{
await UniTask.SwitchToMainThread();
if (shrub.Runner.Simulation.IsForward)
vfx.Play();
}
That does look quite nice... hrmm, don't know if I'm eager to load up new APIs but I'll look into this further
You don't have to adopt the whole thing, maybe check their source code 😄
🤔 That's true...
I've used this pattern in the past, it works well enough for simple stuff.
Cool, that's kind of what I'm seeing. If I have a whole bunch of parameters, I think I'd need to make a separate concurrent queue for each one, then TryDequeue each one. I'm not sure how many of these I'm going to need... may be easy enough to refactor in the future.
You could either use the Command pattern (with polymorphic commands) instead of delegates, or wrap your parameters up in captured variables in lambdas.
and use a single queue
Something like this? I'm not sure how to make the queue accept parameters though... I don't frequently use lambda expressions
no more like () => vfx.Play() where vfx is defined elsewhere
vfx would become a captured variable
ahh gotcha, that's cool
you can't have parameters since it's a queue of Action
Question: I have my own asset class for saving stuff via ScriptImporter that is a child of TextAsset. The reason for this is so that I can restrict what type of asset you can drag into a field. It's functionally the same.
The thing is, after my ScriptImporter creates the object and then attaches it to the asset, it saves it as a TextAsset, which means it doesn't work with fields that are expecting it.
Here's the class definition:
public class LuaAsset : TextAsset
{
public LuaAsset() : base() { }
public LuaAsset(string data) : base(data) { }
}
and how I import it:
public override void OnImportAsset(AssetImportContext ctx)
{
LuaAsset textAsset = new LuaAsset(File.ReadAllText(ctx.assetPath));
ctx.AddObjectToAsset("lua script", textAsset, Resources.Load<Texture2D>("lua_icon"));
ctx.SetMainObject(textAsset);
}
Why is this happening? Is it because it's a class exposed from c++? If so, how can I create my own version of TextAsset?
Should I be using a ScriptableObject instead?
Yeah I should probably be using a scriptable object
do you want to wait for the animations to complete before processing the next event?
this worked
In this case, it's not necessary no
Fires off a play command to VFX graph
so these things do not need to be in order
they just have to run on the main thread
exactly
Contact Modifications API, which lets you interface with PhysX more intimately, it operates on a worker thread
Unitask is very popular?
let's go with, yes
JS isn't a good example though, all iOS browsers have to use the same engine as Safari (hence why people say iOS browser apps are just reskinned Safaris)
🤷♂️ Then maybe it's just that Apple didn't check what is downloaded from CDN
It's quite debatable about what should be considered as 'code' or 'asset'
Yeah the line between data and code is very blurry
App Store policy is always ambiguous, there aren't many talks about it online either, so I'm mostly curious how people's actual experience are.
Well in my honest experience : You don't have to ask them, it's on them if they passed your app 😄
Of course
But it would be very bad if you design something say a whole dialogue system based on Lua or even just your own scripting format, and they hit you with a no.
That would suck, yeah
Then again you can always embed script instead, if that happens
Hi!
I am trying to call some Rust code from Unity.
Simple stuff like ints and floats work great. However I am running into issues with collections (arrays / vecs).
Using this crate to generate my rust -> c# bindings
https://github.com/ralfbiedert/interoptopus
Does anyone have experience doing this kind of stuff / general tips about passings collections over a C FFI?
Hi everybody, what would be the best way to handle rope grabbing physics? Meaning the game has a rope on the floor, the player click on one end of the rope to grab it and can lift this side up or down and the rest of the rope moves along. Is it possible in Unity?
Same question for a round sheet, grab any side would drag the rest along.
I've read about the cloth component which does allow to apply cloth like feature to the rope or sheet but I'm not sure how to handle the grabbing part.
Wouldn't the grabbing part just be an animation, and you could with the code move the gameobject with the cloth component in the direction of the animation ?
Hello, anyone had any issues with missing .NET Framework DLLs? Using a NuGet package to do some custom XML (de)serialization using Liquid Studio (look them up) and it seems Unity can't find the specific DLL even though it's part of a .NET Framework distro, so I'm not sure if it's just that. I would rather avoid having to include such a DLL if possible into the project's assets or its builds.
DllNotFoundException: mscorwks.dll
LiquidTechnologies.XmlObjects.Serializer..cctor () (at <314a39f0e3764e7fa2ce467d8df3c0de>:0)
Rethrow as TypeInitializationException: The type initializer for 'LiquidTechnologies.XmlObjects.Serializer' threw an exception.
LiquidTechnologies.XmlObjects.LxSerializer..ctor (System.Predicate`1[T] classRegistrationFilter, System.Reflection.Assembly[] assembliesToScan) (at <314a39f0e3764e7fa2ce467d8df3c0de>:0)
LiquidTechnologies.XmlObjects.LxSerializer`1[T]..ctor (System.Predicate`1[T] classRegistrationFilter, System.Reflection.Assembly[] assembliesToScan) (at <314a39f0e3764e7fa2ce467d8df3c0de>:0)
LiquidTechnologies.XmlObjects.LxSerializer`1[T]..ctor (System.Reflection.Assembly[] assembliesToScan) (at <314a39f0e3764e7fa2ce467d8df3c0de>:0)
[REDACTED User Code]
It's a core .NET Framework DLL, I'd think it'd be best if I would include it some better way than adding it in the project. Or is that the best and/or only way?
I doubt very much that a LiquidTechnologies namespace is part of .Net Framework
what is the issue?
if you have the dll file, add it to the project by dragging and dropping it into your Assets/ folder
and see what happens
I did that. I got another exception for a License. I'll probably scrap that solution.
handle rope grabbing physics?
maybe try a unity asset store asset first, then see what their approach is
you mean a liquid studio license error?
mhm
Important.
okay
i don't comprehend why you are using this Liquid Studio editor in a way that gets its libraries included in your unity project
there is no reason to do that that makes sense
so you don't have to necessarily explain why
my suggestion is to adopt a data model for your game assets that does not require complex serialization/deserialization
They have a custom serializer for their weird generated XML classes, but which are substantially better than the generated classes from solution provided by Microsoft's XSD tool
are you trying to reuse xml associated with a different game?
It's a W3C standard. That is quite a tall order in this direction or your direction, because this involves sheet music.
MusicXML
well it's a dead end to use liquidstudio, what can i say
i'm not sure what it has to do with musicxml
Liquid Studio is kinda like an IDE for XML
i see stuff like https://github.com/vdaron/MusicXml.Net
and XML is universally bad
outdated
The standard is now 4.0
alright well good luck on this journey
Thanks.
the approach taken by these repos is the right one
i suppose you should update the code in them
and contribute back
because what they are doing makes the most sense
this does point to be a better tool most likely than Microsoft's XSD.
Thank you again.
I'm sorry I have posted this before but I still want to ask that anyone know why my animation is somehow jittering flicking like this ( for this character, I'm using Character Controller)
https://www.youtube.com/watch?v=uj696avcoQI&ab_channel=MegalzAzure
it's hard to tell if it's the camera jittering or the character
if it's the character, it looks like you mixed up your updates and fixedupdates, and animations are not correctly synchronized*
It is the character because I have used Rigidbody and the character run smoothly
Lemme check it
I have disable the animation to check and change to Update but the jittering still happening, pretty weird
As doctorpangloss mentioned, it's hard to tell. To me it looks like a camera issue. Do note when using physics that you need to update the camera after physics update. I think it's LateUpdate() function for camera movement. Does the same happen when the camera is still and you move the character?
It happened to be camera issues. When the camera is still, the character movement is fine. I have change the camera Fixed Update to Update then it is okay now. Thank you all for your time
@raven rock next time #💻┃code-beginner !
Got it, I think I posted in wrong threads
Is there a way to check if there's already and Event System in the scene programmatically ? I cannot find any answer online
I tried this
Debug.Log (UnityEngine.EventSystems.EventSystem.current);
But it returns null even if there's an Event System
This will work just fine.
But it's returning Null every time for some reason.
then you don't have an active event system in the scene
To perform some tasks periodically and update player assets (e.g. producing resources every n sec in RTS games)
I have implemented a thread + job queue (concurrent queue). It is perfect for millions tasks
Task is awful in unity, sync context is expensive (after await)
I have not tested update or coroutine (for each task), result is probably worse
One update/coroutine is better clearly to manage and run all tasks
Have you had any experiences that you like to share?
Also, I am lazy to learn job system perfectly
UniTask is a cut down Task system for Unity https://github.com/Cysharp/UniTask
Unity is making their own, which is in 2023 alpha right now as Awaitable
It's still not good for millions of tasks though.. that'd need something custom
a big loop with timers and/or the job system is how I do that kind of thing.
Do you happen to have to link to the Unity task system on the roadmap? I've been looking around but can't find it :(
https://youtu.be/T6HhePbyAsg?t=2429
and comments from this giant thread https://forum.unity.com/threads/unity-future-net-development-status.1092205/
Ty very much
unity is making their own replacement for unitask? jesus christ why
nobody asked for that
They're not making a replacement, and what they're doing makes complete sense.
do you have a link? it is hard to find
https://forum.unity.com/threads/unity-future-net-development-status.1092205/page-23#post-8496152
(note it's called Awaitable now)
It makes complete sense for them to have a first-party solution for async operations that isn't like the random legacy stuff they've been using for ages.
It'll allow them to unify the async APIs, and have a common developer experience. They're not planning to be exhaustive like UniTask is, just to provide the basics required to make them comparable to the coroutine-based stuff they already have.
they should have added unitask to the built in package repo...
i read the thread
That would be awful lol
nobody asked for some nebulous "native" performance enhancements
native, to me, is always bad, because it is really, "closed source" and "unspecified"
why would i want that, for something like a Task?
why not start by fixing Task
.net also supports desktop apps, which have a single UI thread, there already exists all these things
it's baffling
i don't want unity developers making any more stuff! i want them to make less stuff!
they should NOT be making a .net feature
they just don't know how to do that. why did they think that is a good idea? nobody on that team is going to be as good at doing that as neuecc is, and he's doing it for free, so it's like, infinite yield to use UniTask
they are chickens with the heads cut off
I disagree with everything you're saying, and you also don't seem to understand how it would actually be integrated with the APIs, something that cannot be done with your suggestion of just randomly integrating a third party extension
people in that thread keep asking, "what about await UniTask.SwitchToMainThread()?" and the guy at unity who keeps replying wants to talk about the name of the type, and doesn't have an answer for that question
because they don't know how to write good APIs
You can create an angry post on that forum thread if you'd like
I don't care for you to rant at me here about it
I'm not sure that would work, because the grabbing might not always be exactly on the end of the rope but maybe a few centimeters away, in which case the edge closest to grabbing should still be affected by gravity and aim down a little too, like a real rope.
Hm, good point, I'll give it a shot, thanks
I have a situation where a LogicClass fires an event that CertainAnimationComponents in the scene listen for and then do an animation. But CertainAnimationComponent may or may not exist in the scene (some units will have it, others won't). If it doesn't exist then LogicClass needs to proceed along, whereas if it does exist, LogicClass needs to wait for its animation to play (animation event) before continuing. But the problem is, LogicClass doesn't know whether it exists or not, so it can't know whether it should wait or not. Anyone know a good architecture/solution for this?
or is this too general to the point no one knows what I'm talking about
Is there only one CertainAnimationComponents in your whole scene at a time ?
If so, you could use a static instance of this class
if (CertainAnimationComponents.instance == null) {} else{}
No, there could be multiple or none. I came up with my own, possibly jank, solution. The CertainAnimationComponent fires an event back to LogicClass which sets _waitingOnAnimation to true. If that bool is true, LogicClass doesn't do anything until it gets an animationIsFinished event back.
starting to wonder if I have too many events
i don't understand why it's even a problem, events don't care about what's subbed to them or not as long as they're not null
you just need a callback, but i'm not sure if events are what you need in the first place
I know there is obi rope and obi cloth with good review that has been here for a long time so they probably already addresses your issue
But they are expensive.
Way, still less than having a développer addressing the issue yourself
I have a doubt about performance. When building road tiles over land tiles here:
Should I always disable the meshrenderer of the landTile below the road one? or is not needed since is not visible and it wont be rendered?
the landtyle is at height 3.1 and the path tile is at 3.12
i dont know if i should create a function disabling the meshrender of the landtile below or this is unnecesary
visually the landtile is not visible but im wondering if its still using resources
I would disable the renderer, if the render is active the culling logic will still be run for it
yeah, i thought so, ill do it. Thanks a lot
discussion was bike-shedded into talking about the name /sigh
I just pushed my project to git, downloaded it on my second pc... and opened it.
References to meshes are gone, aswell as audios and stuff... So my meshes dont show up.
Why is that ? What did i miss, pushed the scene and the asset folder to the git
you probably didn't include the meta files
Bad gitignore if they are
meta files contain all of the guids for your asset settings & references, they are very much not something to ignore on git
Alright thanks ^^
Next problem
I have a rigid body with a collider... which clips trough another collider once that other collider moves around
How do i prevent that ?
Sorry, gonna move ^^
i wrote something then deleted it, because vertx is right that the rants don't do anything. if i really wanted to improve X, i would work there
and then people would rant at you for moving their cheese 😛
sometimes i wonder if i should have built my stuff on unreal. i wish it were written in anything but C++.
i think everyone wonders that at times... but you'd probably wonder about the bare bones minimalism of unity if you were over there
random quote from their community
if you have a serialized child class, is it possible to set an inspector field for the parent to one of its children? If not, whats the best way to allow a user to pick which child to use when configuring an entity?
wdym by child? a derived class?
yeah, like if I want to have a "suspension" class, and to have variants like "independent" "dependent" "semi-independent" all which can be chosen from while configuring the overall vehicle
a derived class is the base class with the derived stuff added to it, there is no parent/child relationship beyond the code files you write
so you cannot make such a distinction in the UI because it doesn't exist, if you want two options you need to make two options
so, could I just have an array of each type so I can just have none of a certain version and that of those I do?
i don't understand what you are saying there
okay so, Im trying to make an overall "automobile" script, assigning this script to a gameobject creates the inspector which allows for the configuration of every element before it is actually made into a gameobject/rigidbody. I need to distinguish between certain types of suspension in order to structure these systems of parts so I therefore need a way to pick which systems to use.
so you plan to implement everything in the concept "automobile" in this class?
yes, and to create scripts to control the generated objects when the game is run.
that is a contradiction
Im generally trying to make it so when someone makes a change to the configuration it regenerates the components accordingly
I have a game that will use a store, in this store you can buy new weapons that you will own permanently.
Im thinking of how i should save these, I thought about making a register with IDs for every weapon, then use that list of IDs to save the IDs along with an int/bool in a playerData cs file. In the case of using a register, (simply a cs file with a key value pair or simple a string with IDs i can also keep track and order my store section with theese IDs
Am i over complicating things? Using only a few weapons i could store a "flag" that i own the new weapon, but the register thing is probably better when it comes to slightly more weapons. I mean, i dont want to have 25 different values and all having the name "shotgun_01_isOwned = false / true"
It's not too much different than an inventory system really i guess, but in the case of permanent things rather than amounts of consumables. In my case i dont really want to be able to have a "shotgun_01" to the amount of 2x, and a boolean is also the most straight forward cause that ill use in the store to determine if its "buyable" or not
Sry for such a long msg
wdym?
you cant implement everything in one class and then have other classes do parts of it
so i wonder which is it?
one class or many components?
Well the automobile only lets you configure the parameters of the generated objects, like size, joint properties, etc, then I create a script on the generated object so I can calculate stuff like Deflection(whether a part is extending or compressing) and health and whatnot
wdym "create"? you mean you add a component to that gameObject your auto-class spawned which then does the deflection handling?
I want to say where a gameobject is going to be and toward what it will point in automobile, also any additional values its components are going to need. Then when I run the game, it creates a gameobject using those properties, gives it its joints etc.
okay
so you want a prefab with an Automobile-component which your game interacts with for moving it around. The Automobile component then controls various subcomponents on that prefab to implement the movement inputs based on its configuration (type of vehicle and some properties like mass, power, grip, ...)
yeah, but this automobile script also controls the orientation of the components.
a component is just an instance of a script on a gameobject, it does not have orientation unless you make a property on it that is called "orientation"
none of the springs wheels or any of that exists unless the game is running, ive overall been trying to avoid generating objects in edit mode because I feel like thats messy and inefficient.
I have two vector3s that I use to determine position and rotation once the object is created.
i have no clue what your object setup is, the words you use don't make sense to me, i get vaguely what you want but you seem to have no interest in doing it the unity way, so i can't help here
what is the unity way
to my knowledge the "unity way" is to create everything in the editor as gameobjects, but it seems like that would be a lot of akward dragging, dropping, and transforms.
the only unity way is when one solution is deprecated and the other is experimental
but using vector for rotation in 3d is really weird, why not straight up quaternions?
the unity way is making gameobjects with components on them whether you use the editor for that or not is irrelevant here
jokes on you, its neither, its head and tail based
the editor is a magical productivity tool if you use it to make tools for yourself or a waste of time and effort if you expect it to give you a readymade toolbox for things specific to your game
man, DOD community would get totally angry at you if you said it to them
especially with how unity are pushing so hard for ECS
yes, naturally, but DOD is way advanced and the GO-way will always be the entry level drug
ok i scrolled up
they've staked a lot on it, so they have to push it hard
i'm all the way for DOD but i can agree that @fair hound's thinking is fucking weird
imo DOD is situational and can't provide any magical performance boosts like many seem to believe
the frick is DOD
it does, but it's definitely not magical
eventually a hybrid architecture is the only sensible way to stay productive, do DOD where it matters (many indentical components), and GOs where it doesn't (many different components)
if you have script instances that run update/fixedupdate/coroutine constantly, then it could've been a system
also we have to see how it affects game design iteration times... its potentially great but not if the affected code is performance sensitive
i think it'd still be better if more people thought in systems though
yes, but its a fundamentally opposite way of thinking (vs OO)
not fundamentally
so it will suck where OO is great and be great where OO sucks
you can make something similar to systems without actually switching to ecs
there is nothing more fundamentally non-OO as data oriented programming
e.g. if most of units in game can regenerate, you don't have to actually make regeneration inside the class itself, you can add the unit to regeneration list, and for each unit do regeneration
that's halfway to DOD without switching to ecs
yes, that is the non-performant DOD that is an interesting architectural pattern which can improve design iteration time
but it can be easily converted to ecs later
not really, because making it performant will break it
you can to a bunch of convenient things with DOD if you ignore concurrency and the cost of breaking out of a batch or iterating over minimal chunks of data
i'm certainly using that approach all over the place (to speed up my iterations) but attempts so far at doing it with Entities is always a hard slap in the face in terms of productivity and dealing with constraints
you can use Edy's Vehicle Physics from the asset store if you need high quality, tested and configurable vehicle physics
you can use prefabs with EVP to make a variety of configurable cars
i think ECS is dead, because it has essentially zero adoption
after many years
not ECS we're talking about there, but custom update scheduling
you mean like, "player loop subsystems"
or the entites package thing where you can call an "update" on a "system" "whenever you want"
i don't know if you ever played supreme commander, but it would also slow down simulation time near the end of a 8 player multiplayer match, it was built with data oriented design, probably by the greatest and most performance oriented game developers in RTS development... people have way too high expectations for the player-affecting performance payoffs of these approaches*
if you maintain lists of objects based on state or composition and invoke update on those instead of doing conditions in update methods on all instances which are called by unity
i see
its what you do if you have too many active gameobjects that mostly do nothing but can't be deactivated
and it also leads to a code structure that for some reason ends up easy to change
thousands still is pretty small
rimworld
it is never a good idea to make a gameobjects decoupled world simulator
you always wind up recreating a distinct, pure C# model of your world somewhere, somehow
thats not the point here
i see
well rimworld definitely answered my question lol
as succinctly as ever thank you
the point is if you have an update in various components on those, lets say 10k gameobjects, even if they are just for visuals, the conditions that check whether it should update become significant
what if there were a distinct Update versus UpdateIfVisible
i'm focused on rimworld
since it is a real game
i can see how they got into this predicament
even if there are only a thousand game objects visible, they are simulating their whole world using the component system, decoupled
its a solo/small-team project that started as a hobby, so quite easy to track what probably happened...
which might mean there are 10,000-100,000 game objects all doing something useful
they don't because they ran into that problem i described
you mean their game is not architected as, a bunch of decoupled game objects
or that they created void RimworldUpdate()
in a bunch of scripts, and call that at the "right time"
i haven't seen the source code
and idk what specifically you mean by architecting it in a decoupled way
well strongly coupled would look like, a react web app, where you have this other code (like a backend) that computes all the game logic, and it hands stuff off to be rendered
a "decoupled unity gameobjects" game has the rendering and the game logic bits in the components themselves. for example, there is usually something meaningful about the transform from both a rendering and game logic perspective, for most games
like having an Enemy class that has both an Attack method and a reference to a SpriteRenderer
there is nothing wrong with this in a general sense
but it's very different than having an EnemyView, which only has a reference to a sprite renderer
and no Attack method. maybe that exists on your RimworldGameContext class
so like, if they wanted to add a new creature to rimworld, they'd create a new prefab, and add components to it, and there would eventually be a class NewCreature : MonoBehaviour or whatever that does the specific bits of the new creature
both its game logic and its rendering
if you build things this way, you're going to get into the jeopardy of, well it is too slow to simulate the 10,000 active bits of my world every frame
it DOES scale, just not very high
i'm not going to say they made a mistake authoring their good game 🙂
and like you're saying, there are strategies to deal with that
if you merely had a RimworldGameContext with a Tick method that iterated through 10,000 plain c# objects, it can have all sorts of logic to save time, it is reasonable to assume it would be faster
but it wouldn't matter if those 10k c# objects are monobehaviours
so long as the monobehaviours have no engine callbacks on them
yeah but nobody does that. if you wrote a game with 10,000 monobehaviour instances, they are usually mixing rendering and game logic
so you can have it all on gameobjects, it just matters how you update them
what if you use the physics colliders as part of your sim?
it would be painful to avoid Update on a monobehaviour that does some kind of rendering
yeah
that's really tough
i only test on extremely highly specced machines lol
you can have rendering and sim on the same GO and still have them completely ignorant of each other as far as code execution and references are concerned
so in my experience i don't encounter scaling issues with 10,000 rigidbodies - i experience issues with scaling rendering up to there, but not the physics, but i can see how that will happen a lot - and i agree, if you want to have really really rich physics on a huge number of objects, that can only be solved by ECS as it is shipping today
on the flip side, you know, 10,000 rigidbodies is used to simulate like, dust and things crumbling... you might as well precompute that.
i've seen a handful of real games, total war style huge army simulators, where you get interesting emergent behavior from doing that kind fo simulation
well, ive just recently made a test for a simple sim of 10000 objects moving around based on some scheduling of jobs (think workers in a colony sim), and at around 10k agents the time to update the sim became significant because of things like native/managed boundary crossing
but those are so rare. i wouldn't be wrong: ECS pretty much makes the most sense for that kind of game, and networked FPSes - which no indie developer is making anyway
yeah i think the impossible.io people spent a huge amount of time thinking about a useful SDK / approach for huge world sims
and like, how to make the right boundaries to parallelize the simulation, which is the only approach that enables further scaling. like i said Supreme Commander, a "native" game, it's all in C++ obviously, with all its talent, still experienced these issues
so to save some frame time, while one of those workers is inactive, i just update them based on a list that contains them if they have a job and otherwise doesn't, so the sim tick scales with the number of jobs active and not with number of instances of workers
it's true in unity it's going to be native v managed boundaries or whatever
all the logic runs entirely off physics collider triggers and that has no impact on performance (at this scale) as you say
yeah for a lot of real games, you can memoize the list of triggers an event applies to or whatever, that will not need to be "Checked" every time
oh
yes
well if you wanna do "Physics is my game logic and i want to scale to 100,000" you're sort of a perfect candidate for DOTS the unity package
anyway, for me, this "poor man DOTS" scaled my test from 1k to 10k and this is 50x more than what i need
but yeah
it sounds like it's more than you need
who knows though
there are probably a lot of very interesting, very innovative sim games if the physics were more performant
my issue with DOTS is that i cannot come up with 100k things that a player could ever care about
suppose DOTS will get used a lot for gratuitous stuff like water simulation with maybe an odd game or two turning that into critical gameplay
and for multiplayer
i'm just not sure on the "performance by default" aspect, it seems to mean "do it this way and then you get performance by default" but its not saying "do whatever and it will be better"
yeah there are really few like, interesting emergent behaviors
but most people i talk to read it as the latter
maybe if i had a game that was about ants or something
stuff like TABS
it might be useful on mobile to reduce power consumption
but who cares about that 😄
lol
https://appmana.com/watch/unity-starter-hdrp here visit this
and grab your* marble
are you in?
i try
do you see me moving my amrble
yes
i think the most interesting thing would be
multiplayer TABS
which you get the multiplayer for free
this way
as you can see this is just rigidbody physics
yeah, for multiplayer i can see tons of applications
just plain unity. there's no networking
because you can't cull based on a single camera
i mean, it's networked, but not the way you expect
you don't have to engineer a networked multiplayer game
yes, i know how your thing works 😄
lol
i think its great
on these machines... you might get away with not having to worry too much about culling
just not very cheap 😄
it will scale to 10,000 without culling
lol
make a branded game! then it doesn't matter how much it costs
anyway i gotta go
l8r
is it possible to show the correct inspector fields for derived class types that are determined by a variable? Like if I made an enum field to represent which derived class to use could I configure the derived class from within the base class reference?
tbh I'm not sure what people mean exactly when they say callback
Hey so I dont know where to type this question but I assume its here.
So im using mirror for multiplayer in my game. And I have this Third Person Controller Script that uses a GameObject called CombatLookAt.
When the first player connects it works fine the CombatLookAt rotates with the player, But when the second player joins it does not rotate with the player its just stay in the same position.
I hope someone can help :)
look up delegates, but it's the reverse of what you need (events send additional details, not the called methods returning details)
so again, i'm not sure that what you really want here is an event system, but maybe more like adding objects to the list so that you can get a return value from them
try looking up observer pattern, it's probably closer to what you need
That should be inside #archived-networking or the mirror discord, but i'll try to awnser anyway, we can't awnser without code
Alright my Third Person is set up with two files the Controller and the cam
Here is the cam which is also controlling the CombatLookAt which I will mean the problem is in
public class ThirdPersonCam : MonoBehaviour
{
[Header("References")]
public Transform orientation;
public Transform player;
public Transform playerObj;
public Rigidbody rb;
public CinemachineFreeLook CombatCam;
public float rotationSpeed;
public Transform combatLookAt;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
CombatCam.m_YAxis.m_MaxSpeed = rotationSpeed;
Vector3 viewDir = transform.position - new Vector3(transform.position.x, transform.position.y, transform.position.z);
orientation.forward = viewDir.normalized;
Vector3 dirToCombatLookAt = combatLookAt.position - new Vector3(transform.position.x, combatLookAt.position.y, transform.position.z);
orientation.forward = dirToCombatLookAt.normalized;
playerObj.forward = dirToCombatLookAt.normalized;
}
}
Let me know if you want to see the other Script
Here you go and thanks for will helping me :)
try to setup the camera inside that method, as it's best practice
public override void OnStartLocalPlayer()
{
}
That might be a "race condition" because of that, but you would just create a single camera inside the scene, make the player grab that inside that method, look at the mirorr quick start guide, as it does this on part 5 :
https://mirror-networking.gitbook.io/docs/community-guides/quick-start-guide
If it's already enabled, it won't do anything
Well the problem is SPR2 if I don't have that they share the same camera
and same audio listeners
Well no
Well yes
If you don't have IsLocalPlayer they do
I'm talking about the 4 statements inside of that
Literally my screenshot
Yeah there's a misunderstanding here
if (obj.enabled == false)
obj.enabled = true;
// same as
obj.enabled = true;
Since when you enable objects that are already enabled, nothing happens
No need to check that they're disabled prior to enabling them
So what you saying here is that In my Cam Script I need that function and then put the cam out in the scene and when LocalPlayer join it will add the cam to the player?
or am I understanding it wrong
Wsg
Huh? Stuff doesn't run on disabled scripts
The statement is not necessary here, since all they do is enable it
they enable it from outside though
From outside what
No
it runs every time obj.enabled = true?
No, only when it goes from disabled to enabled
then yeah you're right, it's better to just dump everything there
If you enable twice in a short succession it goes (disabled -> enabled -> enabled), but OnEnable is called once
Yeah that's how you usually do things in networking, either you have everything disabled and enable what you need, or all enabled and disable what you don't need
So maybe when the AnimationClass (the subscribers in this case) are added to the scene during runtime, they should add themselves to a list which the publisher has access to? So the publisher can send them info and wait for them to finish?
yeah, on awake or start LogicClass.AddMeToList(this)
instead of invoking event, you call a function that goes through the list
Okay, good advice. I didn't think of that.
How safe is it to use UniRx in what might become a production game?
I see it hasn't gotten any updates in some years, and the github documentation sucks
Leaving so many methods with just blank documentation
@cerulean spade it's like you're trying to justify not using it, than the other way around
@severe topaz wdym?
I'm just being cautious
I don't want to have to rewrite a bunch of code
For some reason
no updates, documentation sucks, if one of unity updates breaks something then it'll be a headache fixing it since they probably won't
you made all the correct arguments against it, why not just search for alternative?
@severe topaz well, I'm just trying to see what the community thinks of it
Get a more informed decision
not sure if discord is a good place for that
Why wouldn't it be 🤔
compared to stackoverflow/reddit/forums, questions and answers in discord are harder to see in the first place since they'll float away before most people can read them
Yes but it's quicker
if someone who can answer will appear
but either way my answer is the same, if you have doubts about something then it's better not to, until you understand the thing better
If you have concerns for the future you could think about it this way: A) you won’t be making a major unity version update for the life of your game anyway, so what works now will continue to work, B) you could also use System.Reactive and DIY the unity integration, or C) you could assume UniRx is not in need of updates. D) Many consider Rx an over complication in gamedev and rather use async/await. Lastly E), Rx is open source so you can fix it if it breaks.
Hello! I tried posting this in the beginner code chat but got nothing, thought maybe I would escalate it to here since it seemed outside the scope of beginner concepts.
I am instantiating a gameObject, and then in Start() in a script attached to that gameObject, setting freezeRotation to true. What happens is that only the z rotation ends up being locked. This only occurs on instantiation. If I have the gameObject in the scene upon starting the scene, the rotation locks on all axes as expected.
My code is here https://gdl.space/zebalegule.cpp
I thought maybe it was a race condition, but I can't see how since I set freeze rotation both in Start() and after instantiation.
Also if this is inappropriate for this channel I will gladly move it
Also, when I set freezeRotation to true within Update() it works properly as well, but I dont want to be doing that on every frame.
The problem is not in the code you shared
I dont know what you're doing but if you are worried about race conditions you also have Awake which is where you should be initializing anyway, start runs after for whatever else
I moved the line where I freeze rotations to Awake and it still does the same thing. Is there a better channel for me to be asking this question?
Basically, I am creating a new instance of a playable character in the place of a non playable character to simulate "taking over" the NPC
lol no- and to be honest you're not looking for code-extra-advanced you're looking for beginner because this is basic all due respect
yeah, not enough context as someone already said code you shared is fine.
you get more answers providing more context, more code, etc
you dont move channels because they are busy
I provided quite a lot of context before and the issue wasnt that I didnt get a response its that none of the responses were helpful
No just have it in the scene somewhere, but grab it for the local player and use it locally client side
Watch the links i sent, and the examples on camera handling, also i don't see anything that sets the rotationSpeed anywhere or makes the camera move
Where's the inputs? where's the rotationSpeed set at?
I'd recommend you find a youtube tutorial on that, there is some and free assets for mirror
Can i return a null raycast?
RaycastHit Ray(RaycastHit hitted)
{
if (Line(hitted))
{
Physics.Raycast(orientation.position, orientation.forward, out hitted, maxDistance, whatIsGrappleable);
return (hitted);
}
else if (Sphere(hitted))
{
Physics.SphereCast(orientation.position, aimAssistSize, orientation.forward, out hitted, maxDistance, whatIsGrappleable);
return (hitted);
}
else return ??????;
}
if im calling this function what can i return in the case of the raycast not hitting?
Is it expected to ever reach the last else?
yes
default
As RaycastHit is a struct it cannot be null. You use default so it returns the default value for that type. Same as doing default(RaycastHit), just less verbose
And for completeness, if it was not expected to reach that last else, you would throw an exception
if (hit != default) is causing an error
how do you do the notation that you're using
with the code in a box
RaycastHit defines bool cast. Go if (hit)
How about you return a nullable instead? If it can be null treat is as possible, return a RaycastHit?
Then you'll be able to check if hit.HasValue
And get hit.Value if it does
Wait was the bool cast 2D only 🤔
if(hit) is returning with a CS0029 error
Cannot implicitly convert type 'UnityEngine.RaycastHit' to 'bool'
Yeah it's 2D only, what a inconsistency
who thought of that one 🙄
In RaycastHit2D it does hit.collider != null
Surround code with backticks `
or write your own bool TryRaycast(out RaycastHit hit), and return true/false for whether it was valid
Decided to use it partially for now...mainly I only really need ReactiveProperty for the game mechanics
Anything else is just syntax sugar
And I can make my own implementation of that if there's any issues down the line
But I didn't know its a thing to not make major unity updates during game development
I have one silly issue that causes an unresponsive state when loading the next scene. I have a loading screen with an animation that freezes before the next scene is loaded for more than 20 seconds. Does anyone know how to prevent the animation from freezing? I am loading this scene with Async and I assume the scene is pretty heavy as it is the first scene that initiates Adventure creator plugin which is pretty much an engine inside an engine
You should use the profiler and see what's causing the holdup
if you have an array whose elements are arrays of derived classes can you access them all with a foreach of the base class?
You need to try cast to all potential types, then you can access all public members of the derived classes
Sounds like you're trying to use polymorphism incorrectly.
Also, making a datastructure that stores multiple types (i.e. a blackboard pattern) which provides type safe access is not really possible without a few quirky hacks, if that’s what you are after
#📦┃addressables maybe the best place to ask?
oh lords. there is such chanel ? ... Thanks
Not a terrible question, but it's a bit specialized.
Hello, I'm trying to build with scenes that only what I want but BuildPipeline.BuildPlayer doesn't include what I specified only. It includes all scenes that are written in 'Scenes In Build' in 'Building Settings' on editor. How can I exclude scenes from build via script?
you try
What I expected in this code was to include scenes contained in the 'scenes' variable to the build.
Thanks for replay. But 'scenes' variables in my code doesn't include entire scenes. That variable works fine.
What is the contents of scenes and when do you actually use the buildPlayerOptions? there isn't anything wrong with what you've posted so far
Include contents for Demo build
I decide to edit EditorBuildSettings.scenes and revert it after build finish
I meant the literal contents, did you check it? I have a feeling you forgot to actually use the build options
I think it is applied properly 🤔
DOTween has this system where you can chain your options
ShakeTween = barTransform.DOShakePosition(shakeDuration, new Vector3(1f, .7f, 0f) * shakeAmount, shakeIntensity)
.SetDelay(1);
Wanted to replicate that in my own health bar tool but I have question
if(imageBar.gameObject.activeSelf) imageBar.SetAdaptiveShake(-1f, -1, -1f).UpdateHealthBar(health);
I have this system where i can call SetAdaptiveShake to set settings and then call update health bar
but how would i call update and then set settings for that health bar?
basically postpone running of update until all chained functions are complete
Seems bit clumsy to have to set settings then run update
DOTween system seems better with just adding settings on top of the system
hi... my game runs on webgl and i will make a phone version, is there a way for me to get the swipe input and tapping WITHOUT needing the new input system or do I have to? if yes what is it ??
thank you
know about IPointer interface? you can make your own swipe logic
but works on UI only i think...
sorry just saw this ... i will google it
thank you
I just got a cyclic dependency error after upgrading the Unity version: One or more cyclic dependencies detected between assemblies and listing all assemblies in the project afterwards. Anybody ever encountered this or has a clue how to track down this cyclic dependency?
Look at each of the listed asmdefs and check for direct or transitive self-references
Couldnt the reference chain basically go through a lot of assemblies? That would mean the search could take really long
Potentially yes, but usually it’s quite obvious
I have the suspicion it must be connected to a unity package. As they are the only ones that changed (updated) due to the engine upgrade
Very unlikely
But check for json.net references if there are any. Those might hint at the offending ones
Yeah that could be the root of the problem as some of the packages use their own json implentation
Especially SteamVR caused some problems with this in the past
It wouldn’t cause a cycle but jus#t as a heuristic, they often also cause other dependency issues
Cycles typically come from your own code
eg when you add a dependency with a quick fix in VS/Rider
Just deleted my whole assets folder and it didnt fix the issue
so the cycle has to be in packages
Which ones are listed?
Just started removing packages and it seems to go away when removing entities package
I only have that for the Platforms package to manage builds
I guess I now have to figure out how I can still use this
it makes no sense for unity packages to cause a cycle. So please do share which one causes it if you figure it out
Yes I will. Thx so far
linerenderer?
hey all we are creating asset bundles that we are pulling in at runtime. the issue we have is we are creating the asset bundles on windows and they do not work in our mac version of the app
is there a best practice for multi platform asset bundles?
can you build mac asset bundles on a windows device?
We built everything on macs but that was for android/ios
yeah that was my previous experience as well
was curious if the inverse was at all possible
dang mac always having to be unique lol
In what way do they not work?
wdym by this?
What are we talking about specifically?
MeshRenderers?
SpriteRenderers?
Does unity have a future ?
Unreal engine got some incredible updates the past few years... nanite, lumen, they even have a ECS in the making...
not really a #archived-code-advanced question though, more of a #💻┃unity-talk question
Oh sorry, thought like this is an "advanced" topic... forgot the code, sorry 😄
i'm thinking of switching from SO to database before i get too deep, anybody got any recommendations or links?
what's your use case?
single-player, all platforms possibly including WebGL
scene-loading gates and quick-travel points that can be un/locked and un/discovered which needs to be saved, and sharing the data with map to actually use them for quick-travel
it sounds like a lot of people use sqlite, and some have tried generating a typed client for their schema
for a save format you probably need the flexibility of treating it like a database and not use strictly typed queries and data transfer objects, so that you can more easily migrate your saves and update your game
the sql ecosystem is really good too
i only need 2 bools for each entry to be saved/loaded, but you're right about the updates
in my experience, you eventually have a non-c# file that describes your data. this can be sql "DDL" or a protobuf spec or... something, whatever it is. the experience you want with that decides the framework/data ecosystem you wind up adopting. then people feel like this is "heavyweight" and they go back to using JSON
which is sort of the worst of all worlds - it's just delaying the inevitable, if your game is ever played by anyone
reading and writing protos, including generating the C# protobuf classes, is easy nowadays, but still very arcane
choice paralysis
either way i realized that i can start getting rid of SOs with just a list of structs for now
whatever gets me unstuck
a list of structs in c# code right?
that's a good idea 🙂
i don't think you should memory blit them into saves. although if that was important to you, katai struct is a good data description language for binary formats
doesn't support writing though (https://github.com/kaitai-io/kaitai_struct/issues/27)
i can just save them in json for now
protobuf is the most robust format for migrateable, serialized data like game file saves, imo, and you will eventually need some part of it - for example, if you need to remove a field in the json, or create a new field with the same name as an old one
but really depends on the game
it's not that bad. you can download a protoc.exe , run it on a .proto file, and get your C# files that implement everything
but the way i decided keep it for now should still give me plenty of time to procrastinate, correct?
and if i can procrastinate, i will procrastinate ✨
but on the other hand keeping stuff as SO for now will be a pain to migrate
either way, if nobody playing the game will see the difference then fuck it
for now (tm)
bump? if somebody sees 😦
Any idea if there's a way to set a RectTransforms properties without it firing OnRectTransformDimensionsChanged? I'm saving the rects pose, moving it, doing an op then restoring its pose within a single frame, but it gets marked dirty so the performance is terrible
pose...
why?
what is your objective?
you can return the component in the Update method
you don't pause updates but you can make a bool, and dotween should have a method to call another method when it's done