#archived-code-advanced

1 messages · Page 27 of 1

ionic plover
#

is it possible to live stream a unity game to a rtmp server via the application? (not with OBS etc)

undone coral
#

without some constraints. what is the game?

ionic plover
#

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.

undone coral
#

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

harsh current
#

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

ionic plover
#

it's a game, but the part that gets streamed has no input except some data that runs the game in a simulation mode.

harsh current
#

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

undone coral
#

i develop an instant unity streaming solution

ionic plover
harsh current
#

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

undone coral
harsh current
#

I just think it's good to have a shared container for that

ionic plover
undone coral
#

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

harsh current
#

An asset so other people can add stuff in the editor

undone coral
#

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

ionic plover
undone coral
#

then i guess you don't need any more help

harsh current
#

You should train your social skills

ionic plover
undone coral
#

trust me, there are dozens of people who come to the chat room and do that

#

man people are being difficult today

undone coral
#

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

ionic plover
undone coral
#

like "players command real time armies to destroy each other's bases" (an example for starcraft)

undone coral
#

like what's the game?

#

is this a multiplayer game?

ionic plover
undone coral
#

or like, battle simulator?

#

huh?

#

so is there a unity client that people play, or no?

ionic plover
# undone coral huh?

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.

undone coral
#

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?

ionic plover
# undone coral okay

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

undone coral
#

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

ionic plover
undone coral
#

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?

ionic plover
undone coral
#

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

ionic plover
#

ya, if the asset exists, $60 is fine. which one are you talking about?

undone coral
#

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

ionic plover
#

ok, that's one on my list right now.

undone coral
#

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?

ionic plover
#

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"

undone coral
#

yeah

#

well i'm sorry about that

#

they probably expect no delay

ionic plover
#

like, in their minds, if it's an .mp4 - it's not live.

undone coral
#

which is really challenging to do

ionic plover
#

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.

undone coral
#

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?

ionic plover
#

its

ionic plover
#

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

undone coral
#

that's good

#

@ionic plover hope this helps!

#

i think this is going to be exactly what you need

ionic plover
#

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

wooden cedar
timber sky
#

Has anyone used Fmod audio tables? Id like to reference a Sound/Clip like an EventReference instead of just a String.

obtuse magnet
#

how would i go about adding jump corner/edge detection in unity (2D)?

elfin tundra
#

you can also use a really thin rectangle collider

obtuse magnet
#

neither of them give me what i need

elfin tundra
obtuse magnet
#

imma record a clip of celeste and show you

elfin tundra
#

ok

obtuse magnet
#

when madeline is under the block by a couple pixels

#

instead of stopping

#

she gets pushed to the left

elfin tundra
#

oh i see

#

you could use a rectangle collider rotated at 45 degrees

#

just for the corner

obtuse magnet
#

ok

#

i am a rectangle tho

elfin tundra
#

the player is a rectangle?

#

that shouldn't be an issue

#

the corner of the player should still slip along the block's collider

obtuse magnet
#

ok

#

oh one other thing

#

if i do that

#

i will still collide

#

and i will loose y velocity

elfin tundra
#

add a physics material to it

#

and set the friction to 0

obtuse magnet
#

still doesnt work the same

elfin tundra
#

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

obtuse magnet
#

yeah but

#

its like coyote time

#

doesnt make any sense

elfin tundra
#

the celeste video does

obtuse magnet
elfin tundra
#

looks like when the player is pushed off the corner they don't go as high as the previous jump

obtuse magnet
obtuse magnet
elfin tundra
#

oh ok

obtuse magnet
#

celeste does the same with dashing

elfin tundra
#

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

obtuse magnet
#

yeah

#

and there is no tutorial

obtuse magnet
elfin tundra
#

i would try the trigger and manual pushing thing

#

and see if you can get it to feel nice

obtuse magnet
#

ok

zealous ember
#

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

austere jewel
#

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

jolly token
#

I doubt FindObjectsOfType would work for ScriptableObject at all.

undone coral
#

🤦‍♂️

severe topaz
#

and the SOA holy war continues

compact ingot
cerulean spade
#

What's SOA?

cunning tapir
#

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 ?

cerulean spade
#

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

fresh salmon
cursive horizon
# cerulean spade Is there anything that can be done about the fact that there's no encapsulation ...

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.

hexed meteor
#

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.

cursive horizon
hexed meteor
#

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

hexed meteor
#

what is the return data here? Is 'Triangulation' a data type or a class or something?

cursive horizon
#

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

hexed meteor
#

ah sweet thank you

#

But if the struct only contains these fields, how can I calculate the surface area from this?

cursive horizon
#

math

hexed meteor
#

that's so helpful, thank you

errant plinth
#

I would try to see if every three values in the indices areay points to their corresponding triangle positions in the vertices array.

cursive horizon
#

the documentation is clearer about what each field represents

errant plinth
#

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

hexed meteor
#

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.

errant plinth
#

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

sage radish
# hexed meteor I know my a²+b²=c² but I don't know how to get to the point where I should apply...

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];
}
obsidian glade
hexed meteor
lethal flicker
cunning tapir
lethal flicker
undone coral
#

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

cunning tapir
# undone coral 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.

undone coral
#

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

cunning tapir
#

Not quite no.

undone coral
#

if this is meant to deliver a 2 hr story, a unity app will drain the battery before then

cunning tapir
#

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

undone coral
#

okay it sounds like the logical conclusion of that is people are making janet cardiff walking experiences

undone coral
#

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?

cunning tapir
#

I was drawn to unity as it seems easier to devleop the UI as someone with little code knowledge

undone coral
#

you can use https://expo.dev/ which is what all the creative technologists i know use

#

it is reactive native + bundling features

undone coral
cunning tapir
#

No I've been using XD

undone coral
#

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

cunning tapir
#

Cool, our back end is already in firebase.

undone coral
#

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

cerulean spade
#

Can someone help with a math related problem? Concerning 3D vectors

undone coral
#

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.

jolly token
cunning tapir
#

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.

undone coral
#

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?

cunning tapir
#

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

undone coral
#

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

GitHub

Audio reactive animation toolkit for Unity. Contribute to keijiro/Reaktion development by creating an account on GitHub.

GitHub

Audio reactive Unity VFX with LASP. Contribute to keijiro/LaspVfx development by creating an account on GitHub.

cunning tapir
undone coral
#

yes

cunning tapir
#

OK I've some experience with that. Does that integrate with expo?

undone coral
#

this is a very appealing, very audience friendly sort of presentation... but it doesn't sound like it will quite be for you

undone coral
#

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...

undone coral
cunning tapir
#

OK So Max integrates better with the Unity option

undone coral
#

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

cunning tapir
undone coral
#

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!

cunning tapir
#

Yes I will do her work looks very interesting. Again I appreciate your input here its been useful for orienting myself

regal olive
#

How to get nearest gameobject from a list

jolly token
rancid swift
jolly token
#

For example OpenUPM

#

You can take advantage of OpenUPM or define scoped registry yourself.

rancid swift
jolly token
dapper pumice
#

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.

dapper pumice
#

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

serene pawn
#

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!

dapper pumice
#

search for bezier curves

#

JohnSmith. Codemonkey has a good tutorial explaning it.

serene pawn
dapper pumice
#

yep

#

you simply put the 3. line in the middle of your a nd b position

serene pawn
dapper pumice
#

no there won´t that is why you need the 3. point to be some kind of moveable

serene pawn
dapper pumice
#

Vector3 c = (a + b) / 2;

serene pawn
dapper pumice
#

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

serene pawn
#

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

dapper pumice
#

Can you paint something or make some visual help. i am lost rn

serene pawn
serene pawn
serene pawn
warm forum
#

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?

regal olive
#

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]

dapper pumice
#
  Vector2 direction = (b - a).normalized;

  Vector2 c = Quaternion.Euler(0, 90, 0) * direction * someValue;

not sure JohnSmith but something like this?

obsidian glade
serene pawn
serene pawn
serene pawn
dapper pumice
#

hmm

hazy epoch
#

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?

obsidian glade
#

I haven't played auto pets and don't know what you mean by mouse dragging/arrows pointing

serene pawn
#

i know how to recreate this but only completely straight. i want it to curve in the exact same way

jolly token
#

You are basically using singleton.

obsidian glade
#

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

serene pawn
serene pawn
serene pawn
obsidian glade
#

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?

serene pawn
obsidian glade
#

the tip of the curve is not the third point of a bezier

serene pawn
obsidian glade
#

B is not on the curve

serene pawn
# obsidian glade

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

obsidian glade
#

there is no point B in image 1, it's invisible

serene pawn
obsidian glade
#

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

serene pawn
#

and how would i calculate this offset?

obsidian glade
#

does the image I linked look to be accurate?

serene pawn
obsidian glade
serene pawn
obsidian glade
#

there is no magic formula - you choose the formula, it is entirely yours to control

#

it can curve however you like

serene pawn
#

there is a magic formula for that but i don't know what it is

jolly token
#

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.

serene pawn
serene pawn
jolly token
#

Your game seems like 2D

#

abs(dot(right, dir)) is enough to get how horizontal your direction is

serene pawn
#

yea i meant vector2.angle

serene pawn
undone coral
#

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

warm forum
#

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.

undone coral
#

but you have the source right?

#

what are you trying to do

warm forum
#

yes i do

undone coral
#

what is the issue you are experiencing that you are trying to resolve?

warm forum
#

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.

undone coral
#

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

warm forum
#

currently its my pc that's acting as a proxy

undone coral
#

your android build... why didn't you build for PC?

#

there is something critical you are omitting here

jovial totem
#

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?

undone coral
#

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

jovial totem
#

not to interrupt, oops

warm forum
undone coral
#

okay

#

what are you omitting?

warm forum
# undone coral there is something critical you are omitting here

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.

undone coral
#

this is the first result

#

for many of the keywords

#

have you tried setting an all-pass certificate handler?

warm forum
jovial totem
#

the swizzling util gives me a vector3 but im not sure what the values mean in this context.

jovial totem
#

It’s obviously arguments for an equation. But what equation?

distant tree
#

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?

grizzled lake
#

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.

jolly token
#

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.

grizzled lake
distant tree
grizzled lake
scenic forge
jovial totem
# grizzled lake oh cool! What kind of game is it?

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

distant tree
# distant tree this isnt possible with the animator component is it? ive already got all the pl...

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.

jolly token
supple crest
#

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

jolly token
supple crest
#

I have not, looking now... is it a good fit for this sort of stuff?

jolly token
supple crest
#

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

jolly token
#

You don't have to adopt the whole thing, maybe check their source code 😄

supple crest
#

🤔 That's true...

sly grove
supple crest
sly grove
#

and use a single queue

supple crest
sly grove
#

vfx would become a captured variable

supple crest
#

ahh gotcha, that's cool

sly grove
#

you can't have parameters since it's a queue of Action

jovial totem
#

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?

jovial totem
#

Yeah I should probably be using a scriptable object

undone coral
jovial totem
supple crest
#

Fires off a play command to VFX graph

undone coral
#

they just have to run on the main thread

supple crest
#

exactly

undone coral
#

what are these other threads for?

#

you should use unitask, it's the most coherent

supple crest
#

Contact Modifications API, which lets you interface with PhysX more intimately, it operates on a worker thread

#

Unitask is very popular?

undone coral
scenic forge
jolly token
scenic forge
#

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.

jolly token
scenic forge
#

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.

jolly token
#

That would suck, yeah

#

Then again you can always embed script instead, if that happens

pulsar tapir
#

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?

GitHub

The polyglot bindings generator for your library (C#, C, Python, …) 🐙 - GitHub - ralfbiedert/interoptopus: The polyglot bindings generator for your library (C#, C, Python, …) 🐙

muted root
#

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.

sullen nymph
devout dagger
#

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]
flint sage
#

Doesn't mean it's part of mono/unity

#

So you gotta include it yourself

devout dagger
upbeat path
undone coral
#

and see what happens

devout dagger
#

I did that. I got another exception for a License. I'll probably scrap that solution.

undone coral
undone coral
devout dagger
#

mhm

undone coral
#

how important is having a working game

#

to you

devout dagger
#

Important.

undone coral
#

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

devout dagger
#

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

undone coral
#

are you trying to reuse xml associated with a different game?

devout dagger
undone coral
#

or are you trying to adopt another game's format

#

oh..

devout dagger
#

MusicXML

undone coral
#

well it's a dead end to use liquidstudio, what can i say

#

i'm not sure what it has to do with musicxml

devout dagger
#

Liquid Studio is kinda like an IDE for XML

undone coral
devout dagger
#

and XML is universally bad

undone coral
devout dagger
undone coral
#

alright well good luck on this journey

devout dagger
#

Thanks.

undone coral
#

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

devout dagger
#

Thank you again.

raven rock
undone coral
#

if it's the character, it looks like you mixed up your updates and fixedupdates, and animations are not correctly synchronized*

raven rock
raven rock
frail kestrel
raven rock
undone coral
raven rock
#

Got it, I think I posted in wrong threads

hardy nymph
#

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

sly grove
hardy nymph
#

But it's returning Null every time for some reason.

sly grove
timber flame
#

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

austere jewel
#

It's still not good for millions of tasks though.. that'd need something custom

sly grove
topaz moss
topaz moss
#

Ty very much

undone coral
#

nobody asked for that

austere jewel
#

They're not making a replacement, and what they're doing makes complete sense.

undone coral
austere jewel
#

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.

undone coral
#

i read the thread

austere jewel
#

That would be awful lol

undone coral
#

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

austere jewel
#

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

undone coral
#

because they don't know how to write good APIs

austere jewel
#

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

undone coral
#

well

#

lol

#

okay

muted root
muted root
stoic compass
#

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

muted root
#

If so, you could use a static instance of this class

#

if (CertainAnimationComponents.instance == null) {} else{}

stoic compass
#

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

severe topaz
sullen nymph
#

But they are expensive.
Way, still less than having a développer addressing the issue yourself

stuck onyx
#

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

upbeat path
#

I would disable the renderer, if the render is active the culling logic will still be run for it

stuck onyx
compact ingot
vocal dagger
#

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

long ivy
#

you probably didn't include the meta files

vocal dagger
#

I need to ? 😮

#

Thought they are in the .gitignore...

devout hare
#

Bad gitignore if they are

obsidian glade
vocal dagger
#

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 ?

obsidian glade
vocal dagger
#

Sorry, gonna move ^^

undone coral
compact ingot
undone coral
compact ingot
#

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

fair hound
#

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?

compact ingot
fair hound
#

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

compact ingot
#

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

fair hound
#

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?

compact ingot
fair hound
#

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.

compact ingot
#

so you plan to implement everything in the concept "automobile" in this class?

fair hound
#

yes, and to create scripts to control the generated objects when the game is run.

compact ingot
#

that is a contradiction

fair hound
#

Im generally trying to make it so when someone makes a change to the configuration it regenerates the components accordingly

wicked silo
#

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

fair hound
compact ingot
# fair hound 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?

fair hound
#

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

compact ingot
#

wdym "create"? you mean you add a component to that gameObject your auto-class spawned which then does the deflection handling?

fair hound
#

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.

compact ingot
#

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, ...)

fair hound
#

yeah, but this automobile script also controls the orientation of the components.

compact ingot
#

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"

fair hound
#

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.

fair hound
compact ingot
#

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

fair hound
#

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.

severe topaz
#

the only unity way is when one solution is deprecated and the other is experimental

severe topaz
compact ingot
fair hound
compact ingot
#

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

severe topaz
#

especially with how unity are pushing so hard for ECS

compact ingot
severe topaz
#

ok i scrolled up

compact ingot
severe topaz
#

i'm all the way for DOD but i can agree that @fair hound's thinking is fucking weird

compact ingot
#

imo DOD is situational and can't provide any magical performance boosts like many seem to believe

fair hound
#

the frick is DOD

severe topaz
#

it does, but it's definitely not magical

compact ingot
#

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)

severe topaz
#

if you have script instances that run update/fixedupdate/coroutine constantly, then it could've been a system

compact ingot
#

also we have to see how it affects game design iteration times... its potentially great but not if the affected code is performance sensitive

severe topaz
#

i think it'd still be better if more people thought in systems though

compact ingot
#

yes, but its a fundamentally opposite way of thinking (vs OO)

severe topaz
#

not fundamentally

compact ingot
#

so it will suck where OO is great and be great where OO sucks

severe topaz
#

you can make something similar to systems without actually switching to ecs

compact ingot
severe topaz
#

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

compact ingot
severe topaz
#

but it can be easily converted to ecs later

compact ingot
#

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

undone coral
#

you can use prefabs with EVP to make a variety of configurable cars

undone coral
#

after many years

compact ingot
undone coral
#

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*

compact ingot
#

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

undone coral
#

i see

compact ingot
#

its what you do if you have too many active gameobjects that mostly do nothing but can't be deactivated

undone coral
#

what real game has that kind of problem

#

like an RTS?

compact ingot
#

and it also leads to a code structure that for some reason ends up easy to change

undone coral
#

thousands still is pretty small

compact ingot
undone coral
#

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

compact ingot
#

thats not the point here

undone coral
#

i see

#

well rimworld definitely answered my question lol

#

as succinctly as ever thank you

compact ingot
#

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

undone coral
#

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

compact ingot
#

its a solo/small-team project that started as a hobby, so quite easy to track what probably happened...

undone coral
#

which might mean there are 10,000-100,000 game objects all doing something useful

compact ingot
undone coral
#

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"

compact ingot
#

i haven't seen the source code

#

and idk what specifically you mean by architecting it in a decoupled way

undone coral
#

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

compact ingot
#

but it wouldn't matter if those 10k c# objects are monobehaviours

#

so long as the monobehaviours have no engine callbacks on them

undone coral
#

yeah but nobody does that. if you wrote a game with 10,000 monobehaviour instances, they are usually mixing rendering and game logic

compact ingot
#

so you can have it all on gameobjects, it just matters how you update them

compact ingot
undone coral
#

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

compact ingot
#

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

undone coral
#

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

compact ingot
undone coral
#

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

undone coral
#

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

compact ingot
#

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

undone coral
#

it's true in unity it's going to be native v managed boundaries or whatever

compact ingot
#

all the logic runs entirely off physics collider triggers and that has no impact on performance (at this scale) as you say

undone coral
#

oh

undone coral
#

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

compact ingot
#

anyway, for me, this "poor man DOTS" scaled my test from 1k to 10k and this is 50x more than what i need

undone coral
#

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

compact ingot
#

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"

undone coral
#

yeah there are really few like, interesting emergent behaviors

compact ingot
#

but most people i talk to read it as the latter

undone coral
#

maybe if i had a game that was about ants or something

compact ingot
undone coral
#

yeah

#

but even there, the rules arne't necessarily, physics

compact ingot
#

it might be useful on mobile to reduce power consumption

#

but who cares about that 😄

undone coral
#

lol

#

and grab your* marble

#

are you in?

compact ingot
#

i try

undone coral
#

do you see me moving my amrble

compact ingot
#

yes

undone coral
#

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

compact ingot
#

yeah, for multiplayer i can see tons of applications

undone coral
#

just plain unity. there's no networking

compact ingot
#

because you can't cull based on a single camera

undone coral
#

i mean, it's networked, but not the way you expect

#

you don't have to engineer a networked multiplayer game

compact ingot
undone coral
#

lol

compact ingot
#

i think its great

undone coral
#

on these machines... you might get away with not having to worry too much about culling

compact ingot
#

just not very cheap 😄

undone coral
#

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

compact ingot
#

l8r

fair hound
#

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?

stoic compass
mental river
#

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 :)

severe topaz
# stoic compass tbh I'm not sure what people mean exactly when they say callback

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

oblique sail
mental river
# oblique sail That should be inside <#497874116246896640> or the mirror discord, but i'll try ...

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

oblique sail
#

I'll need the other script too

#

as it looks like it's a network script issue

mental river
fresh salmon
#

Those if statements are not necessary

#

Just enable and that's it

oblique sail
#

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

fresh salmon
#

If it's already enabled, it won't do anything

mental river
#

Well the problem is SPR2 if I don't have that they share the same camera

#

and same audio listeners

fresh salmon
#

Well no

mental river
#

Well yes

fresh salmon
#

If you don't have IsLocalPlayer they do

#

I'm talking about the 4 statements inside of that

#

Literally my screenshot

mental river
#

Yeah I know

#

But my Cam is in another script

fresh salmon
#

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

mental river
#

or am I understanding it wrong

unreal scarab
#

Wsg

fresh salmon
#

Huh? Stuff doesn't run on disabled scripts

#

The statement is not necessary here, since all they do is enable it

severe topaz
#

they enable it from outside though

fresh salmon
#

From outside what

severe topaz
#

actually no, maybe you're right

#

does OnEnable run only if it was disabled?

fresh salmon
#

No

severe topaz
#

it runs every time obj.enabled = true?

fresh salmon
#

No, only when it goes from disabled to enabled

severe topaz
#

then yeah you're right, it's better to just dump everything there

fresh salmon
#

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

stoic compass
severe topaz
#

yeah, on awake or start LogicClass.AddMeToList(this)
instead of invoking event, you call a function that goes through the list

stoic compass
#

Okay, good advice. I didn't think of that.

cerulean spade
#

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

severe topaz
#

@cerulean spade it's like you're trying to justify not using it, than the other way around

cerulean spade
#

@severe topaz wdym?

#

I'm just being cautious

#

I don't want to have to rewrite a bunch of code

#

For some reason

severe topaz
#

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?

cerulean spade
#

@severe topaz well, I'm just trying to see what the community thinks of it

#

Get a more informed decision

severe topaz
#

not sure if discord is a good place for that

cerulean spade
#

Why wouldn't it be 🤔

severe topaz
#

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

cerulean spade
#

Yes but it's quicker

severe topaz
#

if someone who can answer will appear

cerulean spade
#

More engagement

#

More back and forth

#

Both have advantages and disadvantages

severe topaz
#

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

cerulean spade
#

Ah

#

Fair enough

compact ingot
# cerulean spade How safe is it to use UniRx in what might become a production game?

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.

latent vessel
#

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.

compact ingot
regal olive
latent vessel
#

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?

latent vessel
regal olive
regal olive
regal olive
#

you dont move channels because they are busy

latent vessel
#

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

oblique sail
undone coral
#

is the one you should use

oblique sail
#

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

real hazel
#

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?

fresh salmon
#

Is it expected to ever reach the last else?

real hazel
#

yes

real hazel
#

Thank you!

#

that works!

fresh salmon
# real hazel that works!

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

real hazel
#

if (hit != default) is causing an error

#

how do you do the notation that you're using

#

with the code in a box

jolly token
fresh salmon
#

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

jolly token
#

Wait was the bool cast 2D only 🤔

real hazel
#

if(hit) is returning with a CS0029 error

#

Cannot implicitly convert type 'UnityEngine.RaycastHit' to 'bool'

jolly token
#

Yeah it's 2D only, what a inconsistency

real hazel
#

who thought of that one 🙄

jolly token
#

In RaycastHit2D it does hit.collider != null

jolly token
obsidian glade
#

or write your own bool TryRaycast(out RaycastHit hit), and return true/false for whether it was valid

cerulean spade
#

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

shut moon
#

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

sly grove
fair hound
#

if you have an array whose elements are arrays of derived classes can you access them all with a foreach of the base class?

compact ingot
sly grove
#

Sounds like you're trying to use polymorphism incorrectly.

compact ingot
#

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

true solar
#

Hello.

#

How do I load addressables from a memory stream ?

sly grove
true solar
#

oh lords. there is such chanel ? ... Thanks

violet valve
analog verge
#

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?

analog verge
analog verge
# summer jacinth you try

Thanks for replay. But 'scenes' variables in my code doesn't include entire scenes. That variable works fine.

analog verge
#

Anybody knows?

#

BuildPipeline.BuildPlayer doesn't work as what I expected

long ivy
#

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

analog verge
#

I decide to edit EditorBuildSettings.scenes and revert it after build finish

long ivy
#

I meant the literal contents, did you check it? I have a feeling you forgot to actually use the build options

analog verge
flint wraith
#

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

pale silo
#

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

flint wraith
#

know about IPointer interface? you can make your own swipe logic

#

but works on UI only i think...

pale silo
#

thank you

worn elm
#

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?

compact ingot
worn elm
compact ingot
worn elm
#

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

compact ingot
#

But check for json.net references if there are any. Those might hint at the offending ones

worn elm
#

Especially SteamVR caused some problems with this in the past

compact ingot
#

Cycles typically come from your own code

#

eg when you add a dependency with a quick fix in VS/Rider

worn elm
#

so the cycle has to be in packages

compact ingot
#

Which ones are listed?

worn elm
#

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

compact ingot
#

it makes no sense for unity packages to cause a cycle. So please do share which one causes it if you figure it out

severe topaz
#

linerenderer?

alpine adder
#

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?

flint sage
#

We built everything on macs but that was for android/ios

alpine adder
#

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

flint sage
#

I'd imagine it is

#

Since it doesn't need xcode

alpine adder
#

mac asset bundles come in all black

#

where the window ones work

sly grove
#

What are we talking about specifically?

#

MeshRenderers?

#

SpriteRenderers?

vocal dagger
#

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...

vocal dagger
#

Oh sorry, thought like this is an "advanced" topic... forgot the code, sorry 😄

severe topaz
#

i'm thinking of switching from SO to database before i get too deep, anybody got any recommendations or links?

severe topaz
#

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

undone coral
#

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

severe topaz
#

i only need 2 bools for each entry to be saved/loaded, but you're right about the updates

undone coral
#

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

severe topaz
#

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

undone coral
#

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

severe topaz
undone coral
#

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

severe topaz
#

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)

jade grotto
#

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

undone coral
#

why?

#

what is your objective?

undone coral
severe topaz