#archived-code-advanced

1 messages · Page 43 of 1

echo timber
#

Its a FPS with soldiers, tanks and helicopters.

#

Is that so? 😮

untold moth
#

Yes.

#

Anyways, without checking the profiler, it's all speculations.

echo timber
#

Very true. I will look into this. Thanks for your help, I appreciate it!

dusty bolt
#

Currently when i switch scenes render thread is taking a lot of time, i tried with async but lag is too much to cover and sometimes it starts interfering with the current scene as well. Is there any way to do it completely on different thread.

raw goblet
#

Most of you probably know that if we use using UnityEditor; outside of Editor folder (or outside #if UNITY_EDITOR) we will get a compilation error as soon as we try to start the build, because UnityEditor does not exist in builds.
Does anyone know of a method to force Editor to give us this error without starting the build? The reason I’m asking is because I want to add a unit test to check for this.

frail parrot
#

I solved it with this, but instead of the count, I just assign "chunkID"'s to them, to keep track of which chunk of points they're in. That way if the chunk ID's are ever different, I know instantly they don't connect. It's better than using the count cause you don't get the problem of "what if they have the same amount of nodes"

untold moth
dusty wigeon
dusty wigeon
lusty basalt
sage radish
#

This doesn't cover cases where the namespace is used directly, like UnityEditor.AssetDatabase.SaveAssets();

raw goblet
raw goblet
# lusty basalt

Interesting, thank you, but it still has the same problem I stated above

#

I almost feel like at this point we should just start the build process and see if it fails during the first stages, then cancel it

lusty basalt
lusty basalt
raw goblet
lusty basalt
#

I think that is intended behaviour, encapsulation on a class level rather than a method level. So any class like bar that touches foo directly is burned by association. you could maybe try writing a editor script that brackets all the connections to foo with UNITY_EDITOR ifdefs# and then run that before any test or build?

#

or maybe just spits out which files have connections to Foo-like files and then add the ifdefs manually might be less work

#

realistically

dusty wigeon
lusty basalt
dusty wigeon
#

To be honest, you should implement good work practice and that would be much easier.

raw goblet
flint sage
raw goblet
olive cipher
#

Oh as we are on this topic, is it possible to exclude a complete folder from compilation (and just remove the one call into this folder with a define) without manually deleting it before building?

flint sage
raw goblet
olive cipher
# flint sage AsmDef files are probably the way

I'm building a little multiplayer thing with server + client in the same project and just dont want the user to be able to get their hands on the server stuff, thanks I'll try if I can do that with AsmDefs

dusty wigeon
#

In fact, that is probably the solution that would be the best in my opinion.

fallow sentinel
#

Hey everyone, i hope u r great 😄 Do you know how i can convert a struct as a byte[] ? I try to save my data in Switch but unfortunately, i don't know how to do

dusty wigeon
olive cipher
fallow sentinel
fallow sentinel
fresh salmon
#

Could also serialize to JSON and get the bytes out of the string, but if you're looking for small files, MessagePack is the way

fallow sentinel
fresh salmon
#

Optimized as in file size, or serialization performance?

fallow sentinel
#

everything

flint sage
#

You usually can't have that

fallow sentinel
#

really ? :(

#

excuse me, i'm a newby on this subject

scenic forge
#

Data serialization is indeed a solved issue and there are plenty available solutions you can Google.
There are many solutions precisely because they each excel at different things, there isn't a golden solution that fits every use case.

#

Some of top of my head you can look into: JSON, XML, Protobuf, MessagePack, and Flatbuffers.

#

Or you can just invent your own (probably don't do that)

fallow sentinel
#

i will take a look at everything !

flint sage
#

Depending on hwo complex your data is, manually packing it into a byte array is a good option as well

scenic forge
#

Unity has built in JsonUtility if you don't know, I would suggest write your code with clean separation so you can swap out to a different de/serialization solution later.

flint sage
#

Gives you (probably) the best performance and smallest size

scenic forge
#

I feel like you are in the process of premature optimization.

flint sage
#

But most places don't do that

fallow sentinel
#

Actually, i just want to save file in switch, but it only allows byte[] and have a lot of restriction

#

i never did theses kinds of things, and i'm lost with that ahah

flint sage
#

You can just convert a json string to bytes pretty easily

fallow sentinel
#

i will try that, thank you 😄

flint sage
#

Something like encoding.something.tobytes

fresh salmon
#

Oh well that's pretty much what I said but got hit with the "not optimized enough" one

#

Weird lol

fallow sentinel
#

sorry

raw goblet
dusty wigeon
#

The first step of executing unit test in continuous development is to build the project.

fresh salmon
#

Most CI environments can also run tasks on push

raw goblet
dusty wigeon
#

In fact, buiding is part of the "unit testing"

fresh salmon
#

They probably build in "editor mode" before running tests

#

Instead of building a release and testing

lusty basalt
# raw goblet well, in our case unit tests passed successfully, but the build failed

I think the easiest solution would be to write a script that runs pre build and temporarilly comments out all the in method code(but not names or signatures, inside all of the scripts in the editor folders

  1. Save a temp backup(copy file, add .orig or something to the original)
  2. Use something like below to find all of the cases where unityeditor is mentioned, comment those out.
  3. search line by line(in fields and function bodies specifically) and comment out anything that isnt a method signature or scope operators
  4. Save files.
  5. Build.
  6. Restore backups

Fairly certain you could do this from a single editor sript with an hour of work or so

dusty wigeon
raw goblet
lusty basalt
raw goblet
#

might assign this to one of our new devs

#

I think I might create an investigation ticket and copypaste your advice if you don't mind

#

some quite promising options here

rancid peak
fresh salmon
#

ChatGPT or any other AI should not be used to answer questions here, unless what it said can be verified it's truthy and working

lusty basalt
lusty basalt
raw goblet
lusty basalt
# lusty basalt I think the easiest solution would be to write a script that runs pre build and ...

If someone ends up doing this, some pitfalls:

  • Check if there is some dirty flag you have to set so that the 'empty' files are actually fully recompiled at build, so you dont end up tearing your hair when it doesnt work even though it should
  • I dont think this solution works if any of the editor scripts have function arguments or return types that specific to the Unityeditor namespace, but in that case the non-editor caller scripts would probably need to touch unityeditor aswell so maybe its a moot problem? Otherwise you could probably hide the dependency in a struct that you send in and out somehow
  • make sure to restore backups even if the build or tests crash
undone coral
#

that's your goal?

#

i understand you have "unit tests" or hwatever, you're interested in tests because you right now have a checkbox in github actions or jenkins or circle ci or whatever, it's not that it has to be a test

#

is this describing what you want*?

#

personally i think this is a colossal waste of time. if you are responsible for doing a merge, you should try building the game before you click the merge button. that will very quickly show you if someone has referenced UnityEditor in a player build.

#

there are other users who have wanted to write linters for all sorts of misbehavior and it is such. a. waste. of. time.

#

your CI should build the game as part of its tests. this is soimething another user recommended

#

that is the way you test if UnityEditor is referenced

undone coral
raw goblet
raw goblet
raw goblet
raw goblet
undone coral
#

it's up to you. your time is valuable. don't author a linter.

#

it's not going to take 5 minutes. the 5 minute version is adding a step to build the game

#

which, imo, seems like it will catch a lot more issues than only editor assemblies being referenced from the player

#

it's unavoidable. eventually you'll want to know: before you merge something, does it build?

raw goblet
# undone coral it's up to you. your time is valuable. don't author a linter.

you're not gonna like this, but we already have linter set up 😄
And yeah, it will yell at you for leaving unnecessary using <namespace> , redundant empty lines, whitespaces, missing brackets etc
I was an individual contributor back when it was done and I was so pissed at first. But with time, I have to admit, I started liking it quite much. Cleaned up code is so nice to work with

#

it also checks for following some naming conventions and stuff

#

It actually has a benefit that we now can more easily move devs between projects within the company since they won't have to get used to new codestyle and naming conventions

undone coral
#

okay well it sounds like you have no further unknowns you wish were known

raw goblet
#

thank you btw

undone coral
#

is the game fun?

#

lol

#

okay

#

well this is a long journey

#

🫡

raw goblet
# undone coral is the game fun?

nah just casual match3 kind of thing, the ones where the target market is 40 year old american housewives, aka the most lucrative gamer demographic 😂 (not a joke). I prefer to play much different games in my spare time.
It has been fun to develop though, considering how big the codebase and the team is.

undone coral
undone coral
#

like they're almost at the end of the first act. at the end of the first act, your bosses decide to stop developing games altogether.

#

they might be like 5-6 years in

#

that's how long act I is

raw goblet
undone coral
#

really hard to say without knowing what it is

raw goblet
raw goblet
undone coral
#

i am trying to find unknowns that you might want to be known

raw goblet
undone coral
undone coral
#

i don't know it's just funny

#

here's a good one: "NDA" stands for "Not Doing Anything"

raw goblet
undone coral
#

well there is nothing sensitive you've written here, and the name of the studio and the game are not confidential... it's up to you

#

i'm not sure you want to know what i could say

#

the 40 year old american housewives line appears almost verbatim (it omits housewives and says women) in a deck about game development mistakes

undone coral
#

how can you tell the difference between

  • your UA guy does something good
  • a general change in the market?
#

here's another question: are you familiar with simpson's paradox?

#

so your bosses, the thing they care about is "person good" or "person bad," and also, at the end of Act I, the UA team changes. it doesn't shrink or grow, but the kind of person that runs it is very different.

#

at act II, the people that know what simpson's paradox is, leave**

#

@raw goblet so if you don't want to quit your job near the start of Act II, don't read what simpson's paradox is lol

#

@kindred remnant this might be one of those interesting conversations you were looking for

raw goblet
#

I'm trying to make a conclusion from what you wrote, is it "what looks like a good UA team might just be a good movement of the market and once market changes everything will crash"?

undone coral
#

and you have some kind of intuition that these guys don't know anything, so how is it possible that they stumbled upon some kind of strategy? really they are taking credit for noise

#

it's not crash versus rocket ship or whatever

#

the "know anything" part is knowing what simpson's paradox is.

#

that's the real* issue with 40 year old housewives

#

did your UA people look at some dashboard, and that dashboard has a demographics tab, and it has a way to do a chart that segments at most two ways, and they choose age and gender because that's something they comprehend, and they compare a bunch of things with that chart, and see that the thing with "the most money" (or whatever) happens to have 40 year old women as the largest group?

#

yes

#

that's what actually happened

#

and now they've imparted this pseudoscience onto you @raw goblet

raw goblet
undone coral
#

is it actually TRUE that a match 3 game appeals to 40 year old women? YES!

#

i mean i think it appeals to everyone

#

and that what that chart is saying is simpson's paradox, followed by, you're just discovering who more-slightly-frequently clicks on ads in facebook, and is numerous enough in facebook to matter (or whatever)

#

this is all Act II stuff

#

people who know simpson's paradox don't stick around for Act II!

raw goblet
#

I've just read about simpsons paradox but tbh I'm struggling to understand what do you imply with it in the context of gamedev

undone coral
#

that i can cut up your data in many ways, and actually give you opposite opinions about whether or not a certain demographic is "the most lucrative"

#

one cut makes a group look the "most lucrative" and then cutting it again suddenly makes it look like the least "lucrative"

#

even in a way that would make sense to braindead business people

#

it's to refute the idea that you should be writing games for some seemingly underserved demographic like 40 year old women. that sounds so unorthodox - some of the people who leave at the start of Act II will know that, but pretty much everyone who leaves at Act III will know that

#

lots of steps on this journey

#

hardly any of the same people from Act I will be around for Act III... not even your bosses

#

Anyway I’m not a psychic

raw goblet
# undone coral one cut makes a group look the "most lucrative" and then cutting it again sudden...

I see your point, and tbh I'm not sure I know enough about our company to give an opinion on whether or not something is sus.
I only have anecdotal evidence from my own life and surrounding. I've got plenty of friends working in big studios for AAA projects. I see how they work with super complex projects, do overtime constantly and they don't get paid that much. On the other hand, in my company the games are far less complex (== easier to work with), the pay is higher and in my 2 years working here I did not have to work a single minute overtime.
So, from my humble point of view, whoever is sitting in the UI/Marketing are doing a good job to make us all fed 🙂

raw goblet
undone coral
#

My god it’s like you’re straight of of Culver City central casting

#

I’m just teasing but seriously without knowing like, a concrete studio

#

I’m not a psychic

raw goblet
#

well since you're describing Act 1 and Act 2 as somewhat concrete things you do have some concept

#

what does the general case look like?

undone coral
#

It’s like all the knowledge evaporates

#

And they keep it to themselves

#

And some of them happen to be nepo babies and go do their own thing and fail, and those guys don’t know anything

#

That’s like the B plot

#

This is sort of true at any media company

#

Like it’s happening at Netflix right now - can you believe they’ve been in Act I all this time?

raw goblet
undone coral
#

Yeah but it doesn’t look like that

#

It looks on the outside like cranky people leave

raw goblet
#

got it, thank you, I'll be on a lookout for that 🙂

#

I've got more from this chat then I came looking for indeed 😂

undone coral
#

Also all those AAA game devs are paid much bigger bonuses than the mobile games people

#

I mean of course if it was as simple as you say

#

In your Culver City central casting featured extra line

raw goblet
undone coral
#

It’s not so black and white

raw goblet
#

true

undone coral
#

Maybe they don’t know

raw goblet
undone coral
#

Lol

undone coral
#

like one of the old bosses, maybe THE old boss, has been effectively replaced by seemingly a professional

#

and whether or not you stick around for act II is, do you think he's the villain? if so, you're gone. if you think the people who are leaving are the villains, you're in for the ride

#

like if you're still in act i, probably a few of your bosses are some kind of very lucky fuck ups

#

hard to say

#

maybe one if them is a nepo baby even. i don't know if that plays a big role in your community, but it does in Los Angeles

#

also since your bosses might change all the time, you'll know this is the Act II boss when you stop hearing things to the effect of, "do the successful thing"

#

@raw goblet like right now your bosses, most of the time, will say, "do whatever is going to be more successful"

#

they may say stuff like "it doesn't matter as much where the ship is going, it's more important* that everyone is rowing in the same direction"

#

you're going to stop hearing things like that at the end of Act I

#

you'll stop hearing "there are unlimited ideas, you prioritize them and try each one and test them, and keep the ones that work well" <-this is from the director of engineering at twitter, circa 2017,* which JUST went into act II!!

#

like isn't that funny? twitter just began Act II

#

it's a media company!

kindred remnant
#

never change, doctor

raw goblet
#

but I get the feeling that they give quite high degree of autonomy to important people, and they realize that talent is the most important thing for the company

zenith quarry
#

When I change the saving system a bit it rejects the .json.
Is there a plugin or ready script that parses the old json to the new json (what it can parse, others are initialized with 0)?

kindred remnant
zenith quarry
#

Something that coverts it to xml or so, adds everything it can to the new xml file and coverts it back. Something like that

undone coral
#

opinionated people don't pour resources into match 3 games (an important part of Act I)

undone coral
#

like if he says "it doesn't matter if the game is fun so long as it makes money"

#

that's what i am talking about

#

or "it doesn't matter if the code is written well so long as it's delivered on time" or "it has to work"

#

"(because things delivered quickly will make more money)"

#

you ask for an opinion about whether or not something is engineered well, and someone like me will give you one. your bosses might not!

#

when i was very early in my journey i used to say "it doesn't matter" a lot about whether or not code was well written, so long as "it works"

#

you know i was once the villain

regal glade
#

If I bitshift a max value uint << 8 are all the 1's that are shifted out just deleted/ignored and we basically get 0's on the right?

regal glade
#

Thanks yeah I already tested it, just got lazy on the end bit of the work day sadblob

zenith quarry
kindred remnant
undone coral
#

and i said something like "as long as it works" to a subordinate and i feel like i set him back a lot. in retrospect, if the product is going to fail anyway - most games fail or zero people play - you might as well write it well

undone coral
#

and it can be fun and zero people play, which is why i also ask if the game is fun

#

it takes a long time and not much respect for money to make a fun game

kindred remnant
#

what do you do nowadays?

undone coral
#

most of my day to day experience comes from building games, almost all "branded" games, or supporting other small teams that do, via an instant games delivery platform i develop and relationships with advertisers.

#

if i didn't have this technology i would probably try to make a game for apple arcade

kindred remnant
#

very cool

#

did you develop your platform solo?

undone coral
#

my one full time colleague was a modder of one of my games

kindred remnant
#

not an easy feat at all

#

but yeah cool, ty for sharing, can’t say i’m not jealous - feels like the work would have lots of satisfying moments

#

at least for me, being Just Another Web Dev ™️

burnt lichen
#

err, well unless you have a map of the fields, it would come out the same?

frank peak
#

so I'm working on some code to generate an isometric castle, and rn its patterened in a builder pattern to make the castle and it uses method chaining to return the object between each generation method pass/call.
Currently i'm on the MakeRooms method but I'm not sure if I should use random walks thru a block of tiles, or if I should use binary space partitioning

#

I'm thinking BSP as it seems like a cleaner way to divide the space, and then I just drop doors on the partitions, well inbetween them really

#

cuz rn I just have a block of usable space in the middle of an outer ring wall and corridor, with walls and floors separated out onto their own tile maps.

#

and a list of the tiles positions

frail parrot
#

For something like a castle BSP makes more sense imo

#

Looks cleaner and already fits into a rectangle

frank peak
#

yeah thats what I was thinking, the random walks might just lead to a bunch of dead space or like.. "caves" or something

dusty wigeon
sand cargo
#

Using unity editor window, I make changes to references in my scene objects it all works but when i change the scene and come back it is gone, do i need to write specific code to serialize it? Cheers

copper cypress
#

SerializedObject.Update() and SerializedObject.ApplyModifiedProperties() to the object you're modifying should help.

SerializedObject.Update() -- Call this before any lines of code that display the values of the object
SerializedObject.ApplyModifiedProperties() -- Call this after changing the values of the object, possibly at the very end of the method call for OnGUI if it's all in the OnGUI method.

#

If you need to create a serialized object, the object you're serializing must be a class that inherits from UnityEngine.Object - which would be done by doing

SerializedObject serialized = new SerializedObject(objectYouWantToModify);

kindred remnant
twin wing
#

if I extend RawImage and add some values, do I have to write a custom editor for them to show up? I already tried [SerializeField]

sour crag
#

A'ight y'all I need a genius to help me please. I've been stuck on this mf problem forever

#

Since nobody answers me when I type it out

#

here's a gif

#

this needs a solution cause i've been stuck on it for 12 days

empty shell
sour crag
#

at least not the local values

#

idk how to check the world values

#

but the world position of the target moves with the gun itself

#

but the arms don't

empty shell
#

Maybe, you need to rewrite something yourself so the arm follows the other object

sour crag
#

is there a way to do that without making it jittery and lagging behind?

empty shell
#

If you write code that works on every frame yes

#

I got a problem like that at some point, but it had nothing to do with 3D animations

sour crag
#

hm i've tried that before but it lagged behind

#

lemme try it again

sour crag
#

the code I'm using doesn'twork

#

i did iktarg.localPosition = lgrip.localPosition
iktarg.transform.position = lgrip.transform.position

#

neither of those work

#

the arm does some weird stuff

#

and it's jittery

empty shell
#

I am really confused as to why the arm can move around in the video then 😕

sour crag
#

well the arm moves with that code but like

#

it's not the position of the grip

empty shell
#

Can you send a video?

empty shell
#

It looks like it doesn't follow the right transform(position)...

#

But it seems like it would work

#

That's really weird how it looks like

#

I don't think I help more than that sorry

sour crag
#

no idea why i'm running into these issues and apparently it's impossible to fix

empty shell
#

Are you sure as to what the transform actually is?

#

Because the code seem to work

#

I really feel like it's an editor thing.

sour crag
#

that's the object that it's supposed to move to i'm 100% certain

#

and the target it at that specific position

#

but the arm isn't

empty shell
sly grove
empty shell
#

That's what I though, and also sorry, I didn't see that channel.

dusty wigeon
# sour crag A'ight y'all I need a genius to help me please. I've been stuck on this mf probl...

I may not able to help you directly, but I most say that if you are stuck on this issue for more than 12 days you may want to try something else.

Instead of solving your actual issue, you could try to replicate some example that are supposed to work. By doing so, you might find was is wrong with your current setup. Personally, I have used Final IK and it is definitely not easier to setup and I had to take a step back multiple time to try to understand the asset.

There is a lot of documentation online. Here are some that could be useful:
https://m-ansley.medium.com/setting-up-an-ik-weapon-system-in-unity-1-f354ba13ff52
https://www.youtube.com/watch?v=fB0P0C_3sPU
https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.1/manual/constraints/TwoBoneIKConstraint.html
https://medium.com/nerd-for-tech/tip-of-the-day-ik-101-in-unity-3f79c42ae0ce
https://docs.unity3d.com/Manual/InverseKinematics.html
https://www.youtube.com/watch?v=acMK93A-FSY

sour crag
sour crag
dusty wigeon
sour crag
#

why's that 😂

dusty wigeon
#

It is a really powerful tool, but every powerful tool is not necessary the easiest to use. In other words, you are going to be able to do more thing, but you won't do them because you won't have the time to do them.

#

If you are in a company setup, you have more leeway for such extravagant thing.

lilac lantern
#

Hello, I need quaternion help. I have this code:

Quaternion dif = Quaternion.Inverse(t.lastRot) * t.transform.rotation;

if (dif != Quaternion.identity)
{
  float mag = t.points[i].position.magnitude;
  t.points[i] = new PointsList.Point((dif * t.points[i].position.normalized) * mag, t.points[i].rotation);
}

Which i am using to update some points around an object. The Point you see me creating is just a struct holding a Vector3 and a Quaternion, and points is just an array of these.
When I rotate my object 360 degrees, my points rotate around the object twice. When I rotate my object 180 degrees, my points rotate around the object once. Therefore I've concluded I need to somehow "divide" the difference I'm getting by two. I tried doing Quaternion.Slerp(Quaternion.identity, dif, 0.5f) but to no avail (it looks like that rotates it 1.5 times per rotation instead of twice. How do I get it to rotate around the object 1 for 1?

spark raft
lilac lantern
lilac lantern
#

I don't understand how that would be used to rotate the point around the object, sorry. Can you explain?

spark raft
#

I thought you wanted to rotate some points with the gameobject not seperatelly around them..

spark raft
lilac lantern
lilac lantern
spark raft
lilac lantern
spark raft
lilac lantern
spark raft
spark raft
lilac lantern
#

hmm, I'll try that.

hazy epoch
#

Looking for a second opinion here. I'm working with a team on a game (slated for mobile and PC) that has a ton of skills (moves that characters execute). So far there are 350. At first I thought to use scriptable objects for the skills and their effects (buffs and debuffs), but they're too complex and too unalike, in what they actually do for SO's. So I opted to go with setting them up as classes...and the characters are SO's that have an array of Skills and each Skill has an array of Buffs and an array of Debuffs. It looks like this...

public class Costume : ScriptableObject
{
    public Skill[] Skills;
}
[Serializable]
public class Skill
{
    public string name;
    public string description;
    public SOGem requiredGem;
    public int requiredGemAmount;

    public int damage;

    public Buff[] BuffsGiven;
    public Debuff[] DebuffsGiven;
}
[Serializable]
public class Buff
{
    public Skill skill;
    public BuffType buffType;
    [Range(0.0f, 1.0f)] public float chance;
    public int duration;
    public int turnsLeft;
    public int amount;
    public int stackLimit;
}
[Serializable]
public class Debuff
{
    public Skill skill;
    public DebuffType debuffType;
    [Range(0.0f, 1.0f)] public float chance;
    public int duration;
    public int turnsLeft;
    public int amount;
    public int stackLimit;
}

Problem is the more I comb through these skills and what they do, they more complex and specific they're getting. Forcing me to have to add more fields to the classes, and more if checks in the game's logic. I'm thinking it might be better to just make each skill it's own class, and write specific logic inside that skill for what it does when used. Looking for insight because as I said, we currently have over 350 skills, and more will be added.

lilac lantern
frank peak
#

I say writing the logic that handled for each skill, and putting that in an "action" class is a good way to handle this. Which would be using whats known as the command pattern.

#

yeah with an ability system you basically have to design an entity component system from the ground up

#

and at a certain point ECS can be difficult to maintain with a large enough code base

flint wraith
#

you sure you need 350 skills? maybe you can condense them to much less.

lilac lantern
#

If that's the design of their game, that's the design of their game. Personally I would probably set up some sort of system with events or delegates that I can then just invoke to run whatever code I want, and have a base set of variables modifiable on the character. I have no idea about the design of your game, but if there's bullets for example if a skill replaces bullets it could simply replace the delegate that is usually invoked when a bullet is created.

frank peak
#

so you could redesign some of the skills to remove redudancy and use more inheritance as a way to reduce complexity

#

cuz buff and debuff could both become affect or effect or whatever, which could have a either positive or negative (1 or -1) field

hazy epoch
frank peak
#

ah so fair, if you are programming but don't have control over the design you might have issues. so much of coding is either making smart design choices or living with someone elses less then smart choices.

hazy epoch
frank peak
#

like you almost need a flag system and a conditonal check parser/handler

#

like if flag X Y and Z are present then do behaviour A, but if X isn't then do B type of stuff?

lilac lantern
#

hrmm, that kind of reminds me of bitwise operators and how Unity uses them with enums. Maybe that could be of use?
Like this:

currentEnumVal = enum.valAll;
if(currentEnumVal & enum.val1 == enum.val1)
// runs
#

of course with 350 skills that would get pretty complicated

hazy epoch
#

YUP! 😣 That's why I thought making each skill its own class would be simpler. More work, but simpler.

frank peak
#

I would probably use a flag system that reduces the amount of possible checks I have to do, or atleast attempts to simplify them

lilac lantern
hazy epoch
#

Well actually it would be making the CHARACTER its own class, that holds the skills and logic for them.

#

There are far less characters than there are skills.

frank peak
#

yeah, thats basically an entity component system

#

you have entities, ie characters

#

with skills ie components

#

and they mesh together, each its own class, to handle the logic

lilac lantern
#

Then you could search through idk the list off buffs/debuffs applied and if that predicate returns true for being able to be applied, apply it?

frank peak
#

you almost need like a...

#

uh

#

truth table

#

like you write all the abilities into the columns, and all the abilities into the rows

#

and write a 1 or 0 if it can activate for the other ability

#

tho that doesn't necessarily map out multi conditional checks beyond 2 at once

hazy epoch
#

That's exactly why the logic is getting out of hand and slowly becoming unreadable code.

frank peak
#

cuz you gotta look at the big picture and see where you can simplify

fair wolf
frank peak
#

ye

#

this is a difficult problem tho, thats why none of the answers feel like a perfect fit

lilac lantern
#

I think either your system will have to be very large or very complex tbh.

frank peak
#

cuz there is no easy answer, and the problem itself is thus hard.

fair wolf
#

i would create the table dynamically btw

frank peak
hazy epoch
# lilac lantern opinions on this Doc?

Well the reason we strayed away from scriptable objects is because the values of the data in the buffs is so wildly different. While we have 350 skills...there could very well be 10,000 buffs because of variations. Sure the buffs might have the same effect, but the amount of turns they last are different. The chance of it sticking is different. Etc.

fair wolf
#

create the conditions based on a for that loop the skill tree

lilac lantern
hazy epoch
lilac lantern
#

yes but why would the time remaining matter when checking if a buff can be applied?

#

maybe I did not convey what I meant good enough?

#

Not a scriptable object for each buff

#

a scriptable object that contains a predicate to search the list with.

hazy epoch
lilac lantern
#

count how many buffs in the list of the specified type, and if it's less than the max let it be applied

fair wolf
#

use an index or something like that

#

to match the condition

#

you can use a table or a list too if the list is filled like a 2d array you can access it such as it is a 2d array

lilac lantern
hazy epoch
#

Okay. I see where both of you are going.

lilac lantern
#

for having buffs stop other buffs from being added, you could create a field in the buff and bitwise that with the current buff.

like this maybe?:

compareBuffExclusion = 1;
thisBuffExclusion = 5

if(thisBuffExclusion & compareBuffExclusion == compareBuffExclusion)
// can't add

Which would give you a very large amount of flexibility.

#

so 1 would exclude every odd number, but no even number. Meanwhile 7 would exclude 15 and 31 and 63 and so on. And 0 would exclude nothing, meaning it's never blocked. And 2 would exclude every even number. Make sense?

#

That's just a solution for buff/debuff type, not the other situations

spark raft
lilac lantern
lilac lantern
dusty wigeon
# hazy epoch Looking for a second opinion here. I'm working with a team on a game (slated for...

By looking at your code, I already see multiple thing that could be "generalise". I currently work with a system that hold a large variety of Skills. What we did is we divided the code in multiple module that are organise in a workflow. We then customise each part of the workflow independently. For the skill that are the most unique, we have specific class/module for them. In fact, most skill start as "unique" and we then refactor them to be more generalise when it is necessary/useful.

Something like:


public abstract class Visual
public class MultipleTarget : Visual
public class LineTarget : Visual

public abstract class Condition
class Range : Condition
class TargetType : Condition

public abstract class Effect
class ManaCost : Effect
class Damage : Effect
class Buff/Debuff : Effect

public class Skill
private Tooltip tooltip
private Visual[] visuals
private Condition[] conditions
private Effects[] effects

public class ReallySpecificSkillThatCanNotOnlyBeExpressWithTheRegularWorkflow : Skill```
pale pier
#

Anyone know if it's possible to embed a Roslyn static code analyzer in Unity?

dusty wigeon
# lilac lantern Hello, I need quaternion help. I have this code: ```csharp Quaternion dif = Quat...

To rotate a point around an other you can use Transform.RotateAround or simply use a localPosition and rotate the parent.
If you are not able to use this function because you do not use directly a transform you need to

First, translate the point such as the coordinate of the point is express by the second one.
Second, you apply the rotation to your point.
Third, you re-translate your point.

Vector3 a;
Vector3 b;
Quaternion r;

Vector3 delta = b - a;
Vector3 rotatedPointInFunctionOfA = R * delta;
Vector3 result = rotatedPointInFunctionOfA  + a;
dusty wigeon
pale pier
pale pier
#

To be exact, Inside my Unity project I have some certain methods I need to track usages for (everywhere the method is called, I need to know the arguments).
So I created a separate .NET 6 application that use: Microsoft.Build.Locator & Microsoft.CodeAnalysis.Workspaces.MSBuild.
I launch that application from within Unity, with arguments for the Unity solution file, from within the application I load the Unity solution, perform my analysis, and send the data back to Unity through a NamedPipe.
Now instead of performing the analysis externally in a separate process, I'm wondering if I can do that analysis right from within Unity, basically move my .NET 6 application code right into Unity.
I tried to do just that, but the libraries need for static analysis are giving me trouble, specifically MSBuildLocator & MSBuildWorkspace; they keep giving me type loading errors.

spark raft
lilac lantern
spark raft
#

lol

dusty wigeon
#

Are you sure you really need static analysis ? Can you just use the "Find All Reference" function of Visual Studio Code or Reflection directly from C# ?
If you are doing this to keep your Code clean I strongly suggest to use light tooling/linter and focus on better practice.

regal lava
#

So on the topic of a more unique ability system, I'm walking into a roadblock with mine currently as I'm trying to figure out ways to make some abilities that are beyond a simple fireball or spawning a pool of lava. Currently, I've my ability class split into different subclasses: projectiles (chain, fork, homing capabilities), area effect (size of area, incremental damage), and direct/instant damage ability (just apply effects and debuffs).

It all works out pretty well, and I can create a large amount of abilities with SOs this way, but now it gets to the point where I want to make something like a meteor spell that creates pools of lava when it falls from the sky, or perhaps an area effects where my pools of lava spew out fireballs nearby. There's this mixed logic going on and I'm feeling like I can probably achieve it doing the ecs way, but if anyone has a better way setting this up or any information to create a better ability architecture class I would appreciate it.

cerulean minnow
#

Can anyone here help me to create a CJK font asset so that player in China , Japan and Korea can play my game please? I'm using a main font with 4 fallback Chinese fonts and I still don't get all characters/glyphs to show ( random white squares in some otherwise translated text) I would be very appreciative.

untold moth
regal lava
# untold moth Not sure what ecs has to do with it, but you could create a class for "compound ...

I do have some functionality for chain execution, but even then, it's similar logic with a few differences written to each of these sub classes. I've a few ideas to how I may want to rewrite this. One, ditch the abstraction and just make a super class, but this would allow the possibility for creation of abilities which would fail to work if not careful. Another idea would be keep the abstraction as I have and go a little deeper into the hierarchy, creating classes for abilities which share more similarities.

untold moth
regal lava
#

There's just so many small problems I can think of like, what dictates when the ability is finished? How should I handle the GO destruction if I am combining abilities and such.

untold moth
regal lava
#

Here's an idea for an ability. A simple projectile which can collide, and when it does then we destroy the GO. But let's say I want to add like a trail effect, which leaves like poison behind. How would we go about creating a class to handle this specific combination logic?

untold moth
#

Not sure what GOs have to do with anything though. We're speaking about abilities execution logic. If there is any go instantiation(particle effects) and destruction involved, that should be handled by the ability that needs these GOs.

untold moth
#

The second ability in the chain could have access to the info of the first ability for context. It could retrieve the start and end points to create the area from it.

regal lava
#

Yeah, easy enough, but this we get to the question. If I have these sub classes which dictates which is the primary functionality of these abilities (projectiles will always have that specific logic in the update), then what do you think would be the best way to combine both of these logics if I were to make a ability that starts as a projectile with area effects, and an area effect that shoots projectiles

#

If you understand what I mean

#

Because I find myself rewritting similar logic for both of these classes

#

Because how it really is, the sub classes are the conditions on how the ability behaves primarily

#

Projectile sub class has access to tags such as chain, fork, home, ect

untold moth
#

The area of effect ability could have an optional action on tick(or on certain timer) that it could execute. You could hook another ability as that action into it.

#

I'm not sure what kind of logic you're rewriting. I didn't see your code. That's why I was asking about specific cases where you have problems.

#

Ultimately, you'll have to hard code something. An algorithm, logic. There's no ultimate generic solution that would magically fit all your cases.

regal lava
#

Yeah, the logic is looking is becoming entwined with the other derived classes. Since you see if you do area spell to projectile chain, then you have to factor that transition and write specific logic for that.

#

So I'm trying to figure out if just keeping it as a super class would make more sense.

untold moth
#

Or use some kind of context object that you pass between the abilities.

regal lava
#

A large reason why the classes are divided as well is because there is logic specific on that ability type that is casted, such that it can be forward from the caster, or spawn at the location of the mouse.

untold moth
#

If it's "spawn at a location", that doesn't sound like a projectile anymore

#

Unless, you mean that it then proceeds to fly towards another point

#

In this case, it would be solved easily if the projectile had a start and end point properties. This way it wouldn't matter for the ability where it is executed from. It only acts upon the data that it is given.

regal lava
#

Oh, I've logic for fireballs spawning at a location which then disperse in a direction I give it. Just some extra fluff.

untold moth
#

Yeah, in this case what I said above.

regal lava
#

Probably most complicated thing I've worked on so far. Just not many good examples out there to get an idea how people are doing theirs.

untold moth
#

The idea is to inspect your implementation and find points that you can make more generic/abstract and eliminate dependencies on specific implementation.

regal lava
#

But then you want to make something unique and you go "ehhhh".

untold moth
#

You just find a way to fit that something into the current model or extend your model to be able to fit that specific case in a generic way.

regal lava
#

I think overall writing double logic if I need to when chaining abilities is the right idea though. I think I would need to implement some defaults because otherwise the code may become a little too discreet and ill stuck on it forever.

untold moth
regal lava
#

Similar projectile logic but with minor differences to compensate such as where the first ability is and such.

untold moth
#

Why do you need double logic for that?

#

There's only one logic for spawning a projectile:

SpawnAt(startingPoint);
//...
Update()
{
  MoveTowards(targetPoint);
}

I don't see why you'd need a double logic for that

regal lava
#

Right right, I think I may have an idea now, let me see where I get with that

#

Overall, what I have right now is pretty nice for something simple, I just want to make a sweet meteor skill, heh

untold moth
#

Very simple. Area of effect ability that executes a fireball ability on tick.

#

For the starting points of the fireballs it provides a random position within it's area for example. For the target position, either one target point or a something in proportion with the starting position or just random position around a target point.

regal lava
#

It's more that I want the meteor to land, then deal a pool of damage. You can cheese like an area damage ability by just using vfx and making the meteor itself not included in the ability, but rather a delay before the damage.

#

Think of a shower of meteors maybe, and each projectile that hits does damage and spawns a pool of lava.

untold moth
#

The one that is actualy being executed is areaOfEffectA which is the meteor shower ability.

regal lava
#

Yeah, projectile to area is ideal. It looks like I'll have to expand out how I'm doing the targeting logic a bit more, but other than that I think I've got what's here for that to work. If I have more questions ill post my code later when I expand on it a bit more ;)

#

ty tho

jovial totem
#

Okay, so I have a central static class that handles all the events shooting around the place. The problem is... I have a lot of events. Is there a way I can make this less... verbose... and tedious, since C# doesn't have macros (rust user alert)

#

can I one-line define a delegate or something

#

I realize since a lot of delegates are void with no parameters I can reuse some delegates, but not for all of them

untold moth
#

Can't see shit on that screenshot. Upload it to a paste site.

flint wraith
#

I used central system before and just moved to system where script handles all of its stuff. Central system had benefits on small projects but larger, it was shit. Also you can write 2 lines in one, if thats what youre asking

jovial totem
jovial totem
flint wraith
#

Yeah

jovial totem
#

how so

untold moth
jovial totem
#

oh, okay

jovial totem
jovial totem
untold moth
#

Yes, you could use an action instead of defining a delegate for each event

#

Also, I wouldn't group all the events in one class like that. Some could be moved to QuestManager, WeatherManager, CommandsManager, etc...

#

Encapsulation and single responsibility principles can keep your code cleaner.

flint wraith
#

And you should not use central system i think. You get lost here so easily and just move quest delegates to quest namespace and script

#

Yeah ^

jovial totem
#

yeah fair enough

#

would subclasses be Acceptable

#

Also yeah I like the actions idea...

jovial totem
flint wraith
jovial totem
#

How would subclasses be different from distinct classes though

untold moth
#

Before that, ask yourself what's the purpose of the subclass in the first place?

#

I don't see any reason do have subclasses here.

jovial totem
#

fair point. however, I am neurotic

flint wraith
#

It would be in terms of "using" namespace you need and specially in term of organizing. If you need to see event for quest, you go to quest folder

#

I mean its suggestion. Honestly use subclasses and then if its shit again, move them to controllers

jovial totem
#

I made the centralized system to avoid referring to classes specifically, even if they are static methods

untold moth
#

Subclasses are for extending and/or overriding certain functionality. I don't see how it can help with completely different events like what you have.

jovial totem
#

not inherited classes, like classes within the classes.

untold moth
jovial totem
#

it wouldn't be much different really but it would make me feel goof

#

good

untold moth
#

I get that it's what you're used to from Rust, but that's something you'll need to change your thinking about.

#

It's like using a fridge to store your clothes. Sure you can do it, but it's not intended for that.

jovial totem
#

Also with the action syntax and now that I've learned that functions can be defined with a fat arrow I can make the code Much shorter and more readable

untold moth
#

Any sane person would have questions as to why you keep your clothes in the fridge. The same applies to your code in C# context.

jovial totem
#

my brain just kind of needs it this way, unfortunately? I dont have a solid reason. But I'll do a compromise. I will do the subclasses, but I will have Metro be a partial class, and then I will split up each subclass into its own file so it's easy to look for stuff without scrolling for a million years.

untold moth
#

Still not sure what subclasses have to do anything with it but whatever.🤷‍♂️

jovial totem
#

yeah sorry

pale pier
lost dome
#

I'm not sure how advanced this is but I've been trying to make a save system that saves the exact state of the scene for hours, probably harder than just saving values. However I want the saving to be exactly the same similar to the style of the 3d fallout games

jovial totem
#

He also added that he wished the guys who designed that system had "used ring/circle buffers" so do with that what you will.

#

My current solution Works but it kinda sucks and is inefficient, but here's how it works:

  • I have an interface that marks a class as a "Save data blob"
  • All the classes I want to save data for, I give a subclass with this interface. The subclass contains all the stuff I want to save; position, combat state, etc.
  • A central save game routine invokes a message that all objects that want to be saved are subscribed to, which asks them to pack and send back that interfaced class
    -All of this is serialized and written to disk.
    When I load the game, I
    -Unpack all of the data
    -Send the data blob to the appropriate object
    -Use reflection to determine the type, to make sure it's the correct save data blob
    -If it is, unpack and apply to the object.

However, if I were not totally incompetent, I would write a custom binary serializer that forewent the reflection and type checking and all that but that's above my pay grade.

#

When designing these save game blobs, or whatever approach you plan to do, make sure you think about what Actually needs to be saved

#

like a sword on the ground should store its position, rotation, velocity, item ID, etc. A ragdoll would store all its bone positions so it's still laying there when you load the scene

flint sage
#

Chances are you don't care how a ragdoll lays on the ground though

#

(unless it's a main character maybe)

jovial totem
#

that's true, but Creation Engine games do that so I was using that as an example

#

I still have yet to figure out how I will go about persistence of dead enemies in my project, but I'll probably do something similar to Bioshock where after a time the enemies vanish and become a lockbox with their loot in it

#

Another tip is if you have a Lot of stuff like I do, determine if the object has changed at all from its default state. A book in a dungeon you've never visited isnt goign to have changed since you started the game, so no point in saving its state]

#

otherwise your save file could get real big real quick

jovial totem
#

update to this: It's very late and I'm going to bed, but for debugging purposes I'm using YamlDotNet for my save files for now, and it has trouble deserializing abstract classes, which is why I do a bunch of reflecting and serializing and deserializing, but this looks like a promising solution I will have to look into later: https://gist.github.com/atruskie/bfb7e9ee3df954a29cbc17bdf12405f9

Gist

Inferring abstract/interface types for YamlDotNet Deserialization - AbstractNodeNodeTypeResolver.cs

#

now that I think about it, I kind of came up with something a bit like this, but less... professional.

#

been a while since i wrote it.

buoyant nacelle
#

This is for my MOBA game. I made a finite state machine for my animations and logic. I have a PlayerInputController that send an event with an order (attack, move, cast) into StateMachineManager. StateMachineManager changes the state. It also has logic for changing the state according to the order. So, If an order was an attack it would do a move state until the range of an attack is reached. My problem is that usual behaviour is that a unit can be in one state at a time. However, some spells and attacks allow to be in multiple states (move and attack, move and cast etc). How can I approach implementation of this feature? I use Animancer, so I have access to animation through code.

regal lava
#

Two separate enums, one being for movement, the other is for actions perhaps?

#

Otherwise just extend your statemachine with attack and move and cast and move.

lost dome
finite swan
#

is it possible to setup automatic Syntax Transformation with Roslyn in Unity ? I got Source Generation working, but by its design it cannot modify existing definitions.

#

I want to be able to find all instances of a particular syntax node and replace it with another.

#

Now i suspect because what I want to do hasnt been done; its probably not possible.... but for context,
I want to be able to replace all null-coalescing statements with an if statement at compile time.

pale pier
#

Yeah, by design that can't be done, but you can try utilizing partial classes and methods to work around it

#

Not sure about your specific work case tho

finite swan
#

for my specific case it wouldn't be possible with just partials. I need to actually change the node itself within the tree as it compiles

#

or well i suppose after it compiles

#

I was suggested IL weaving but i really dont want to touch IL for obvious reasons

pale pier
#

You can also make a seperate .NET executable that analyzes the entire Unity solution, do the modifications and overwrites the Unity solution, but it seems like you want to keep the original null-coalescing statements in the original code?

#

I'm guessing you're trying to circumvent the Unity object null comparison issue ?

finite swan
#

which i think it might not actually be possible; as it probably would've been done already

pale pier
#

Good luck with that, lol, that whole comparison thing is a lost cause, might as well bite the bullet and keep writing code like it's 2017

finite swan
#

yeah its entirely microsoft's fault for not allowing the overload

#

which i can understand their reasoning

#

but like... surely Unity could "hack" it in their compiler pipeline... but i guess that isnt really a place you want hacks

pale pier
#

Doesn't C# by default use the Object.Equals for the null-coalescing operator?

finite swan
#

no

#

it checks if it is literally null

#

thats the entire problem 😛

pale pier
#

Oh!

finite swan
#

and its a reserve keyword, so you cannot overload it

#

( like ?: , &&, or ||)

pale pier
#

Oh well, maybe with future updates

finite swan
#

i guess in regular C# development you would have this issues with Disposables too (?. wont act on if it is disposed)

scenic forge
#

I would say it’s Unity’s fault for curving nulls for a different purpose, rest of the C# ecosystem work just fine and overriding equality is frowned upon.

#

Null means null, “this object no longer exists on the native side” should be a separate property not piggyback off of null.

finite swan
#

having to check if every object is "actually destroyed and actually not in the scene anymore" is annoying enough with the overloading

#

can you imagine if they didnt?

#

if (collider != null && collider.ReallyDoesActuallyExistInTheScene)

pale pier
#

If "this object no longer exists on the native side" was a separate property; the null-coalescing operator still wouldn't work

finite swan
#

also objects could exist but reference the assets not a scene object too OhNo

#

to be fair, object references in Unity are messy to begin with lol

scenic forge
#

They wouldn’t work like how you want it to but it would be consistent with rest of the C# world.

finite swan
#

🔥 we shall line the streets in riot and demand Unity 2
it shall be C# first, with redesigned conventions
properties shall be PascalCase
It will be data oriented
The editor will be multi-threaded
Serialization will support all the types
and it will be glorious
we will all weep

#

it will have a multiplayer solution built in

#

and only 1 UI framework

#

SMUG one can dream can't they

scenic forge
#

Unity objects are stubs to communicate with the actual C++ objects on the native side, “null means this stub is null” and “the other side hanged up the phone” should be a separate property.

finite swan
#

if they do this i would just implement equals overload myself SMUG
its just too useful.

#

the main issue i see is Unity trying to use C# as a scripting language

#

it's just... not...

#

no matter what C# 9 introduces

scenic forge
#

Unity wasn’t designed to be C# first and carried a lot of baggage from back when it had to also support fake JS and Python.

finite swan
#

by scripting i mean they use it to "script" gameplay and actions. They design it not to really be a framework or a engine, but rather just glue between your items

#

well actually, it was more closely resembling Microsoft JScript

#

and TBH did anyone actually use Boo?

#

Unity JScript was nice tho; it was missed.

pale pier
scenic forge
#

But in the wider C# ecosystem, it’s universally agreed upon that you shouldn’t override equality to be inconsistent, not only it affects things like null checks, it affects pattern matching, collections, and lots of other features in .NET.

hardy sentinel
#

I mean joke's on whoever used unity js instead of C# :p word was already out that js is not a good programming language

finite swan
#

to be fair, unity been chilling in .NET FX 2.0 for like... up until the last 5 years

#

got a lot of catching up to do

finite swan
#

the naming was horrible, everyone stealing from eachother
Java > JavaScript > Microsoft JScript -> Unity JScript (or whatever they called it... I like to call it UnityScript).

scenic forge
#

It would be amazing to have Unity 2.0 and rid of all these mistakes but at this point it’s probably never going to happen and we kind of just have to deal with it.
The fact that Unity has to have analyzer rules specifically telling people not to use some C# features like ?. and ??= is just sad.

hardy sentinel
#

what I would love from Unity is some way to maintain and extend the standard C# learning curve

#

it already kinda alters it by having the update loop, but it eventually grows messy with all the methods the MonoBehaviour contains

#

type this. in your IDE and see what pops up lol.. beginners won't mind but once you've had a taste of a raw .NET app dev you'll get salty

#

Assembly/Namespace management, all this stuff aren't enforced or even recommended in Unity's workflow

finite swan
#

intelisense is great

scenic forge
finite swan
#

i wish the latest unity didnt break the default configuration for VS

#

ugh i can recite how to restore intelisense by memory now

hardy sentinel
#

this leads to a huge Unity assembly that will eventually take a lot of time to load

finite swan
#

Edit -> Preferences -> External Tools -> change the dropdown to Visual Studio, hit regenerate, restart unity

hardy sentinel
#

instead of a lot of standalone assemblies whose references you have to manage

scenic forge
#

I’m looking forward to Unity moving to .NET Core and keeping up with it so we aren’t permanently 2 year behind, that would be very nice QoL 😄

dusty wigeon
hardy sentinel
finite swan
#

big brain move by unity to write that.

hardy sentinel
#

I was using alexzzz's C#7.2 compiler for Unity since Unity 2017, and it only became available natively on Unity 2019

finite swan
#

AOT is pain; so many headaches when porting my game lol

#

TOO MANY TRAMPOLINES

#

still dont know what it means

scenic forge
#

I mean yes you can always hack things together yourself but having official support is better.

finite swan
#

but my favourite error

scenic forge
#

IL2CPP is amazing yeah.

finite swan
hardy sentinel
#

virus

finite swan
hardy sentinel
pale pier
pale pier
finite swan
finite swan
#

other than the trampolines running out or something

#

i am working with mostly standard .NET stuff tho

dusty wigeon
pale pier
finite swan
finite swan
#

it aint very smart with that

pale pier
#

Absolutely, 99% of my problems with it are code stripping issues, and it not generating the right generic variants

finite swan
scenic forge
#

I haven't had any issue with IL2Cpp, but I heard they recently changed something regarding generics and broke code.

hardy sentinel
pale pier
# hardy sentinel lmao the issue looks so specific 😂

It very much is, couldn't even find the Forum post until I had basically figured out the entire problem.
At least there is a simple solution to this.
Most of these IL2CPP problems are easy to fix, just difficult to figure out to begin with

dusty wigeon
finite swan
#

hmm sounds messy

#

but thanks for the suggestion 🙂

dusty wigeon
dusty wigeon
pale pier
#

Photon is very limited serialization wise. Network for GameObjects (terrible name btw) and Mirror do IL weaving, a good solution, but not something I'm willing to do at the moment.
Oh well, guess I'll just stick with the external application approach.
Thank you for your help.

undone coral
#

also there isn't a point to write all this automation for video game serialization. you'll transfer closer to 10-20 distinct different types, which is easy to maintain by hand

#

so it's kind of pointless when in 30s i can write a file that instantiates those 20 types in a Start that il2cpp seems to be missing

#

if you're trying to transfer generic lists via the network, well you have other issues with representation. why reinvent protobufs

pale pier
#

Why do something in 30 seconds, when you can spend 2 daya automating it 🤷‍♂️

undone coral
#

you will look at your List<?> usage and see it will have like three derivations

undone coral
#

it is telling you there is a flaw in your approach, not that the decision is between automation or not

#

anyway do you have a screenshot? just wondering

pale pier
#

I can give you source access if you send me your email

#

Screenshots are kind of hard because it's a big project

undone coral
#

is there art in the game?

#

what is it?

pale pier
#

It's not really a game, just a networking solution

undone coral
#

ah

pale pier
#

That's why I'm trying to make it as generic as possible

sour crag
#

Can anyone share with me how they structure their IK system when creating an FPS system? These tutorials on YouTube all show for third person and it’s not necessarily the same thing

sour crag
#

If I wanted to know how to animate the IK I’d ask in animation

#

I want to learn how to program it

sly grove
#

IK is inherently part of animation. Unless you're writing a custom IK system yourself

sour crag
#

^^

#

Like I said if I wanted to learn how to animate it I’d ask in animation

sly grove
#

Look into the FABRIC and CCD algorithms

sour crag
#

I want to learn the programming side

sly grove
#

First/third person doesn't really matter too much

sour crag
#

Since Unity’s animation rigging package is kinda wonky when it comes to the structure

#

I thought so but when I set it up like they do for TPS

sly grove
#

You just need a chain of Transforms and an effector

sour crag
#

it doesn’t act the way I need to

#

And the arms kinda go wack

#

So it doesn’t need bones to work?

sly grove
#

TBH you might just be setting it up incorrectly

sour crag
#

Nah man unless every single YouTube video is doing it wrong

sly grove
#

The chain of Transforms are the bones

sour crag
#

Oh

sly grove
#

Bones are represented in unity as individual GameObjects with transforms

#

That's what the skinned mesh uses to deform its vertices

sour crag
#

I get that but the issue is that the only way I can get the arms to move when the parent of their targets move is by actually putting the entire shoulder down inside the gun model with the targets

#

But as you can imagine when you shoot or aim everytbing moves and not just the hands going backwards

#

I’ve tried using the multi-parent, and transform but no matter what it’s dead set on being difficult

#

I tried setting the position of the targets to the grip positions but it didn’t work well

#

But it worked better programmatically than it did with just the constraints

sly grove
#

Doesn't seem correct

sour crag
#

Where did my gif go from yesterday 1 sec

#

In that gif

#

The targets for the hands are in the gun models

#

Model*

#

You move the targets directly the arms respond accordingly

#

You move the gun model that is the parent of the targets

#

Only the gun works

chrome kraken
#

Any idea how to implement mvvm architecture with unity?? Are there documents on it?

worn elm
#

I am currently trying to render multiple layers with different frame rates with HDRP. Has anybody experience with this? It feels like every way is leading to a dead end.

#

I kind of got it to work with two layers via a render texture and a custom pass volume but this solution seems to break apart with more than one layer

#

Compositor seems like it would be the goto solution here but the compositor does not allow me to manipulate the cameras in a way to effect their framerate

#

And when using textures (render textures) they have to exist as assets which leaves me unable to scale them to screen size at runtime.

undone coral
#

what is the effect or purpose of this

dusty wigeon
# chrome kraken Any idea how to implement mvvm architecture with unity?? Are there documents on ...

UI Toolkit give you binding capacity. I'm still using the hold UI System and I have yet to test the new solution (UI Toolkit). If I remember correctly, the solution is not production ready for realtime UI.

You can also develop your own widget and add binding capacities.

Also, MVVM might not be the best pattern to be use in video game development.

https://docs.unity3d.com/Manual/UIE-Binding.html
https://docs.unity3d.com/2020.1/Documentation/Manual/UIE-Binding.html

worn elm
#

I am building an animated desktop wallpaper. The background is not changing often but uses a lot of performance. So I want the front which needs to change more often to render independent of the background

#

The wallpaper reacts to spotify changes so most of the stuff only needs to update for a few frames when the song changes

dusty wigeon
undone coral
#

okay based on your message history it sounds like you've been at this for a while

#

the solution depends on how you are drawing to the desktop

#

what is the command line for starting the unity application that you use?

worn elm
undone coral
#

okay

#

this is kind of a moot point then because then it's up to wallpaper engine to draw as frequently as it wants

#

you can call Camera.Render() at any frequency

#

everything else follows

worn elm
undone coral
#

the rest of your approach doesn't make sense

#

it's not significant how many cameras you have

worn elm
#

I can render 3 render textures at different framerates but I cannot merge them

undone coral
#

it depends on how you are drawing to the desktop 😦

#

you would have to know more about how wallpaper engine works

worn elm
#

But rendering the 3D background takes a lot of time. If I only render it once and than just update the foreground rendertexture and batch them it is a lot more performant than rendering everything every frame.

undone coral
#

i know

#

anyway it sounds like there is a lot for you to figure out

#

you should explore the meaning of clear flags

worn elm
#

I know how clear flags work. Thats why I use mutliple render textures. Otherwise the foreground would overwrite the previously rendered background

dusty wigeon
#

Why you cant merge them ? It seem like something pretty easy. Shader/Stencil buffer.

undone coral
#

when rendering with multiple cameras all drawing to the backbuffer, they do so directly. this is a limitation of your approach. render textures do not need to be assets

#

you shouldn't be interacting with a stencil buffer or anyhting like that

dusty wigeon
#

Why not ?

undone coral
#

you can request a "correctly" sized render texture using RTHandles

#

from the core rendering package

#

you can also take a look inside the hdrp package to learn more about how rendertextures are allocated and how they deal with resizing the screen

#

in custom passes using rthandles happens automatically

dusty wigeon
#

Yeah, right we are working with foreground and background

worn elm
#

I am currently doing that with a CustomPassVolume

dusty wigeon
#

That would be a shader. At least, in my opinion.

worn elm
#

But that does not work quite as expected

worn elm
undone coral
#

if you are doing that, you are going to have bugs

dusty wigeon
undone coral
#

if you are manually calculating the render texture sizes, that is the wrong approach - however it does seem unavoidable. like i said it depends how Wallpaper Engine presents to the screen

#

the problem is it sounds like you don't know

#

or you haven't told me yet

#

so it's very hard to be helpful

#

does your application work without trying to modify the framerate change?

#

i feel like you've written a lot of code, a big cathedral, for something that is way simpler than you thought :/

worn elm
#

Wallpaper engine just grabs the render result from Unity and it looks exactly like it is displayed in its standalone window

undone coral
#

it's okay if you don't know

#

do you have multiple cameras rendering correctly at default frame rates right now?

dusty wigeon
worn elm
#

but wallpaper engine is not the problem here. it might be able to limit the overall framerate but it will never be able to render different lalyers at different framerates

undone coral
#

okay well

worn elm
#

Which makes it problematic to use with compositor for example. As the compositor expects a RTAsset

undone coral
#

you shouldn't use the compositor

undone coral
#

you don't need render texture assets

#

or whatever you're talking about

#

you don't need shaders. you shouldn't author a shader

worn elm
worn elm
undone coral
#

of course

#

so what?

worn elm
#

it is recreated

undone coral
#

okay well i think you can figure this all out, sorry i can't be more helpful

worn elm
#

I tried doing that with an existing RTAsset. It looses the reference to the asset. It is not the same RT anymore

undone coral
#

you should try to make your code work very simply in the beginning, without modifying framerates or authoring a custom pass. you probably want to revert in git to this stage of your visualization

#

you don't really need ui camera stacking

#

i am showing it as an example of something else

#

but it sounds like you have written a lot of code, and there's a lot of inertia

worn elm
undone coral
#

you can simply disable cameras and call Render on them at the right time. use a target texture "of the correct size" (lots of ways to achieve this). the RenderTexture object, when you call Destroy and Create, does not change, only the underlying native texture pointer does. but that's not your concern

worn elm
#

Thats most of the code I use to render at custom frameworks atm:

private void OnEnable()
   {
      this.camera = GetComponent<Camera>();
      this.camera.enabled = false;
      //this.camera.forceIntoRenderTexture = true;
      this.renderTexture = new RenderTexture(1, 1, 0, this.graphicsFormat, 1);
   }

   void Update()
   {
      bool forceUpdate = UpdateRenderTexture();
      if (!this.Render && !this.firstFrame && !forceUpdate) return;
      this.firstFrame = false;
      
      this.elapsedTime += Time.deltaTime;
      if (this.elapsedTime >= 1f / this.TargetFramerate || forceUpdate)
      {
         this.camera.Render();
         this.elapsedTime = 0f;
      }
   }
undone coral
#

but i think you probably experimented with that

#

you also should not be doing this in an update

#

it should be in a LateUpdate. ideally, you would do this using unitask in LastPostLateUpdate

worn elm
#

The RT size is correct. Its basically a copy paste from the UICamera package

#

LateUpdate is a good point

undone coral
#

you have to do this all in one script too

#

since you need to carefully control the order the cameras are rendered in

dusty wigeon
undone coral
#

buuuuut to mix it you should extend the default draw custom pass instead. because you still need a reference to the backbuffer, and in the right order

#

anyway i gotta go

#

this is... pointless to be honest

dusty wigeon
undone coral
# worn elm LateUpdate is a good point

before you waste your time anymore on what you think is an optimization, try setting Application.targetFramerate = 1, and see if this has any meaningful improvement on the metrics you are measuring

#

inside wallpaper engine itself

worn elm
undone coral
#

i'm saying in wallpaper engine

#

gpu utilization doesn't mean what you think it means

#

i don't know what sort of subjective metrics you are after either

#

if you don't want a dynamic experience, don't use unity

worn elm
#

well I will figure it out. thanks for tying to help

worn elm
# dusty wigeon Also,

Thats intersting as I was sure that I read elsewhere in the docs that resizing is not possible 🤔 And the UICamera package is also releasing and recreating it.

dusty wigeon
#

To be honest, I do not think Unity is the correct Engine for what you are trying to achieve as you gonna deal with a lot of overhead. I would agree with doctorpangloss that if you do not really required Unity functionality, you should try to find out an other engine that has less overhead. You could even try to come up with your own and it should be pretty easy as you do not seem to have a lot of functionality that you require.

That being said, you can definitely use Unity if you just want to poke around.

worn elm
#

Well atm I do not know any better engine or technology to render dynamic realtime 3d objects with post process effects as a wallpaper 🤔 Maybe URP would have been the better choice though...

analog temple
#

Hello everyone.

I am having issues adding the following script for my multiplayer "Pique Pegue" game in Unity using the Mirror asset. The script is meant to check for collisions between players and change their respective "Player" and "Caught" classes, where "Player" is the "not caught" and "Caught" is the "caught one".

The error is that nothing happens after I attach the script to the character, even though I have added a Box Collider and made it a trigger by checking the "Is Trigger" option. What could be the issue and how to fix this error?

#

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using Mirror;

public class PiquePegueSystem : NetworkBehaviour
{
    public GameObject canvas;

    private string _playerTagInocent = "Player";
    private string _playerTagSus = "Caught";

    void Update(){
        if(gameObject.tag == _playerTagSus){
            canvas.gameObject.SetActive(true);
        } else {
            canvas.gameObject.SetActive(false);
        }
    }

    private void OnTriggerEnter(Collider _col)
    {
        if (_col.gameObject.tag == _playerTagInocent && !isLocalPlayer && gameObject.tag == _playerTagSus)
        {
            gameObject.tag = _playerTagInocent;
        }

        if(_col.gameObject.tag == _playerTagSus && !isLocalPlayer && gameObject.tag == _playerTagInocent)
        {
            gameObject.tag = _playerTagSus;
        }
    }
}
worn elm
analog temple
#

I can fix this error now.

timber shadow
#

I'm trying to get a better grasp of the Playables API. I'm wondering how to set the starting length of a playable when creating it so that when it appears in Timeline it will have a default length (clip length).

#

The SetDuration extension method doesn't have any effect.

chrome kraken
timber shadow
#

The start time of the clip is another story. My custom playable seems to have an arbitrary start time on the timeline..

dusty wigeon
# chrome kraken Why do u think mvvm might not be best and what u think cld be a better architect...

I'm not sure about what is CLD, but I do not think that MVVM is the best approach for game development because the flow information is mostly from the game to the UI and that the game usually does not have a clean structure that can be easily bind which give the ViewModel component an extensive and not optimal task. Finally, MVVM requires the usage of data-binding which can be annoying to deal with even more when you work with complex data structure like you usually find in games.

MVVM, in my opinion, is better suited for application that requires intensive input from user and that have pretty simple structure. Something like a Survey.

chrome kraken
dusty wigeon
#

If you are a solo developer, I would even suggest you to keep it dirty unless you really need to refactor because you are not able to get the functionality you want.

chrome kraken
#

Yea, I just trying implement different patterns and see on a dummy projects

dusty wigeon
#

UI Toolkit is definitely something you should experiment if you have not.

versed coyote
#

Is there a good way to search for Mesh assets via script? I have an item spawn system that receives item data from a server. I kinda want to instantiate those items dynamically without having to attach 100 [SerializedField] properties that represent all my meshes in the asset directory

jolly token
versed coyote
#

I just found AssetDatabase.FindAssets that works fine so far

#

However - anyone has an idea what type the select asset is in the screenshot? It's an .fbx file and it contains a Material and a Mesh. But what is the name of the asset log itself here?

dusty wigeon
versed coyote
pale pier
versed coyote
dusty wigeon
#

@pale pier, I was looking around for my own research and found this piece of documentation that maybe could be useful for you. It kinda look like what you are trying to do.
https://docs.unity3d.com/Manual/ScriptingRestrictions.html
When the compiler encounters the explicit call to OnMessage with a T of AnyEnum, it generates the proper code for the runtime to execute. The method UsedOnlyForAOTCodeGeneration does not need to be called; it just needs to exist for the compiler to recognize it.

jovial totem
#

Question: If I have a class that starts to exceed 800 lines of code, should I start splitting it into partial classes

#

or, rather, make it partial and split it over files

jolly token
jovial totem
jolly token
jovial totem
#

I've Sort of done that with a few things... but you mean like, separating out pathfinding, and AI, and scene presence, into separate classes, and then having the NPC class be a bundle of the other classes?

jolly token
#

And you can reuse those classes for player if it has shared behaviour

jovial totem
#

I’ve been doing housekeeping the past few days and I think that an issue I’ve realized I have is that when I designed this system I created a large inheritance hierarchy but now I realize I should have been using interfaces and composition but man restructuring the Everything will be such a pain

#

God help me

#

Curse past me for not knowing what an interface was

#

But I suppose it will be worth it for scalability and maintainability

dusty wigeon
#

800 lines of code is not that bad though.

jovial totem
#

And I guess if I ever port everything to DOTS it will be a lot more copy and paste

dusty wigeon
#

That is a whole paradigm you change. It won't help you to have cleaner code. Except maybe for readability.

#

And, what is your scope/vision.

#

Maybe, refactoring should not be something you should do.

jovial totem
#

The thing is though is that my system for simulating everything actually works better with a component-y system, since it was Originally designed with DOTS in mind

#

Okay. So my project is an open world RPG codebase (because I am insane) and to solve the problem of persistence of world outside of a scene, everything is actually a set of classes kept in a large dictionary, and all of the gameobjects are merely puppets being controlled by the classss inside the dictionary. However, because of the variety of tracked objects, there is a complex inheritance chart that requires a lot of reflection and casting and a mess of code to process

dusty wigeon
jovial totem
#

It’s kinda dumb but it’s the best I could come up with without being able to use DOTS. And yes I already tried using a hybrid system, it wasted 3 months.

dusty wigeon
#

Why are you not using more plain approach/standard (Object Orientated Programming) then using Reflection and Dictionary to represent classes.

jovial totem
#

Because I need to be able to access them by an ID, but then I need to check what kinds of entities they are

dusty wigeon
#

Did you divide your class, (Character, Object, Whatever that is being persist) and their actual representation in the save ?

jovial totem
#

…save?

#

Me might be talking about different things here

dusty wigeon
#

solve the problem of persistence of world outside of a scene

When you are talking about persistence outside of a scene, you are talking about saving the state of the game right ? Otherwise, you can just use DontDestroyOnLoad or additive scene.

jovial totem
#

If the player puts down an item in one room, and walks over to another, the player should be able to return to the first room and find the object still on the ground

frank peak
#

well you need to represent that persistence in the background somehow

#

like the NPC still exists in game but their gameobject/any 3d or 2d model/texture is destroyed until they re-enter some radius around the player where the world is loaded?

#

Idk that kinda stuff is pretty complicated. you have to be already handling stuff like map chunking and loading and the like

#

but otherwise you are reallly just looking at extending whatever AI you are using, to function in the background, ergo the world that is not currently being rendered

#

you could also do some sort of lazy system where you save the position of the NPC, and then, depending upon various factors, you run some update code when you get closer to the NPC. like say you save position, and time since last encounter, and use that to determine what the NPC is doing the next time the player enters the area, but you dont call the update until you are nearby. Just an example tho.

jovial totem
#

I have designed all of these systems

#

but yes tyou are correct

#

I did all of this already it's just a bit of a reflection mess

frank peak
#

so fair haha

#

you know your codes become spaghetti when its harder to navigate than the london underground

#

(see: the london underground transit map xD)

#

tho honestly I'm working on a binary space partinioning algo, for procedural castle generation in isometric, and its starting to feel like spaghetti

#

I was able to refactor the castle code into a builder pattern

#

but its meant writing then rewriting everything, atleast so far lol

#

even then, it feels a bit unruly already

#

I guess we'll see

naive field
#

today was the day I learned that if you call Graphics.Blit on a shader that doesn't have a _MainTex variable (yknow, like 90% of shaders) it just has undefined behavior!

dusty wigeon
# frank peak well you need to represent that persistence in the background somehow

So, we are talking about saves, differed update and lod/culling group.

Save: When you leave the door, you save the state of the room. When you return you load the state of the room.
LOD/Culling Group: When the object is too far you deactivate it, when it is in range you reactivate it.

There is no need for big framework or usage of Dictionary/Reflection. If you prefer to do it your way, I have nothing against it. I still prefer to tell you that, from my perspective, it seem that you are over engineering things.

https://docs.unity3d.com/Manual/CullingGroupAPI.html

frank peak
#

Depends upon your goals I suppose, but I get what you're saying in principle

barren ore
#

I have already been able to set pixels of Texture2D due to hours of research and errors (WOW). Now I need to be able to get position of pixels in a 3D unity Space by clicking an object via. raycast. Anyone have ideas or unity doc links?

barren ore
#

Thanks :D. I've been stumpped for a long while.

#

This is the silly code I tried: Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;

    if (Physics.Raycast(ray, out hitInfo)) {

        print(texture.GetPixelBilinear(hitInfo.point.normalized.x, hitInfo.point.normalized.y, 1));

    }
jovial totem
trail cloak
#

Hello there! I am currently finding a way to convert a Unity AudioClip asset to a Wave file (Runtime)

#

This is the code I am currently using, however it doesn't work with Audioclip that loaded from (by UnityWebRequest) a 32 bits WAV file

#
protected override async UniTask WriteSerializedAssetAsync(AudioClip asset, FileStream stream)
{
    await UniTask.SwitchToMainThread();
    var data = new float[asset.samples * asset.channels];
    asset.GetData(data, 0);

    var intData = new short[data.Length];

    var bytesData = new byte[data.Length * 2];

    var rescaleFactor = 32767;

    for (var i = 0; i < data.Length; i++)
    {
        intData[i] = (short)(data[i] * rescaleFactor);
        var byteArr = BitConverter.GetBytes(intData[i]);
        byteArr.CopyTo(bytesData, i * 2);
    }

    await stream.WriteAsync(bytesData, 0, bytesData.Length);
    var hz = asset.frequency;
    var channels = asset.channels;
    stream.Seek(0, SeekOrigin.Begin);

    var riff = System.Text.Encoding.UTF8.GetBytes("RIFF");
    stream.Write(riff, 0, 4);

    var chunkSize = BitConverter.GetBytes(stream.Length - 8);
    stream.Write(chunkSize, 0, 4);

    var wave = System.Text.Encoding.UTF8.GetBytes("WAVE");
    stream.Write(wave, 0, 4);

    var fmt = System.Text.Encoding.UTF8.GetBytes("fmt ");
    stream.Write(fmt, 0, 4);

    var subChunk1 = BitConverter.GetBytes(16);
    stream.Write(subChunk1, 0, 4);

    const ushort one = 1;

    var audioFormat = BitConverter.GetBytes(one);
    stream.Write(audioFormat, 0, 2);

    var numChannels = BitConverter.GetBytes(channels);
    stream.Write(numChannels, 0, 2);

    var sampleRate = BitConverter.GetBytes(hz);
    stream.Write(sampleRate, 0, 4);

    var byteRate = BitConverter.GetBytes(hz * channels * 2);
    stream.Write(byteRate, 0, 4);

    var blockAlign = (ushort)(channels * 2);
    stream.Write(BitConverter.GetBytes(blockAlign), 0, 2);

    ushort bps = 16;
    var bitsPerSample = BitConverter.GetBytes(bps);
    stream.Write(bitsPerSample, 0, 2);

    var datastring = System.Text.Encoding.UTF8.GetBytes("data");
    stream.Write(datastring, 0, 4);

    var subChunk2 = BitConverter.GetBytes(data.Length * channels * 2);
    stream.Write(subChunk2, 0, 4);
}
timber shadow
#

I was working on a playable behavior. In ProcessFrame I was using FrameInfo.evaluationType to determine if timeline was playing or not (it seemed to work in OnBehaviourPlay and OnBehaviourPause). Unfortunately in ProcessFrame it reports the evaluation type differently.

#

Can anyone tell me a way to know if the frame the behaviour events are executing because of user scrubbing vs the timeline playing?

dusty wigeon
#

Do not map the timeline directly with the real duration/time. I'm not sure you want to wait 40,000 years to play your whole animation. Anyway, I'm pretty sure timeline is mapped to 0 seconds as the start.

The first chart/model that is shown should be at the position 0. At least, if you do not have an introduction. You then position the rest in respect of the time you want them to be present. Not in function of the real time they have been around in history.

At the same time you are showing your chart/model, you can then show a label specifying the time it has been around.

dusty wigeon
torn basalt
#

Is there a way to use reflection or something else to signal what class has deactived a GameObject? I have been tasked with finding a bug in a rather large code base and I am having no luck just by following the flow

dusty wigeon
#

Then use the callstack.

worn elm
dusty wigeon
#

It might work or not, I do not remember.

worn elm
#

I managed to get different fps per render layer working btw. Both via compositor and via custom effect volume. And it drastically decreases GPU load. Overhead is still to high though. Oh and resizing Render Texture Assets actually worked without loosing their reference. I guess it was a different problem breaking my reference when I first tried.

dusty wigeon
#

Yeah, like I said, you might want to find an other engine/construct your own. Unity is not made for this.

worn elm
#

I could use WebGL but that would require me to do a lot of stuff from scratch that Unity already does

dusty wigeon
#

You can use OpenGL/C++ natively... The amount of people that made tutorial on how to create your engine is insane.

pale pier
undone coral
#

it doesn't look like there's anything wrong with yoru code

#

also i don't think WAV format uses UTF8 strings

#

it's too bad kaitai struct doesn't support writing

pine yacht
#

Is there a way to use the color swatches in the editor in the code ? I tried to put the color preset library in a scriptable object but it is not accessible through script. Or maybe there's a better way to use the same colors in code as well as in editor that I am not aware of.

cedar moss
#

Hey guys I'm building my own controller,instead of relying on a character controller component, using the new unity input system. I got collisions working correctly(afaik) including the "wall slide", but now I need help with something. In the video below you can see the collisions working but I want to make it so when I get to the stairs(near the end of the video) instead of colliding it goes up the stairs.

#

Does anyone know a way to accomplish this ?

#

uhm I see but I'm not using a rigidbody, do raycasts can you get a contact point from a capsule cast ?

undone coral
#

which I'm not supposed to change in any way, it is supposed to work
what do you mean by this?

#

based on your code it looks like you are a unity general / unity beginner

#

your Neighbours implementation is wrong in a computer science sense. it will give incorrect answers at borders

#

causing an infinite loop in the graph

#

without the AStar class it's impossible to know why it gives null or what that means

undone coral
dusty wigeon
#

Are you sure you are adding correctly the Neighbours ?

undone coral
#

okay it's alright

#

can you see the error in your neighbors function?

dusty wigeon
#

Oh, and your EstimatedCostFunction is wrong. The heuristic must always be lower or equal to the real cost.

undone coral
#

it's better to test with estimatedcostfunction 0 for now

#

and try to get things to work

#

it's okay i think it's in alright shape

dusty wigeon
#

Euclidean Distance would be a valid heuristic, might not be the best though.

obsidian glade
#

for what it's worth you don't necessarily need a valid heuristic, it just guarantees you will find an optimal path - without one you will still find a path and that may be good enough depending on what it's used for

sly grove
#

You will always find the shortest path / most optimal path no matter what

#

The heuristic is there to help find it quickly

dusty wigeon
#

No. You won't find the shortest path no matter what. You need a valid heuristic for that.

obsidian glade
#

without a valid heuristic you run the risk of ignoring the best path, and finding an alternative that is longer and exiting first

sly grove
#

your heuristic just can't return an overestimate of the distance

#

if it never does that

#

it's good

obsidian glade
#

it's not really important, just a little intrigue/curiosity - for some games a "good enough" path might even be preferrable

dusty wigeon
cedar moss
undone coral
dusk gyro
#

I don't really know if this is code related, but basically I'm trying to connect a sword to my player's hand using a FixedJoint2D and I want to align the sword's rotation with my player's hand, but when I rotate the sword it rotates back to the original rotation it was in when the game started, as in if I start the game when the sword is at a 45 degree angle, when I pick it up it's going to rotate back to a 45 degree angle. It's pretty hard to explain what's going on but I have no clue what's causing it or how to fix it.

Here's what I tried:
Setting the sword's rotation to align with the hand every frame - it just keeps trying to rotate back to its original position and ends up spinning uncontrollably.
Using a HingeJoint2D - same issue as FixedJoint2D
Attaching the FixedJoint2D component to the sword rather than the hand - still trying to rotate back to its original position

And probably some other stuff I don't remember, I've been at this for hours. Does anyone know how I could fix this?

undone coral
#

what is the effect you are trying to achieve?

dusk gyro
#

I'm making an active ragdoll game so I want to connect it with a joint

undone coral
#

it should be pretty straightforward to use the constraints

#

it sounds like you want to emulate a hand holding a sword, in 2d... and then, like what exactly do you want it to do? try to go back to a position when it is knocked out of place?

#

that's not really a hinge (freely rotate about a point)

#

it is a relative joint ("Use this joint to keep two objects offset from each other, at a position and angle you decide.")

#

i think you can achieve this used a fixed joint

#

so it's not clear whyt you are updating the sword's rotation

#

is this helpful?

#

i don't think you need scripting to achieve this

#

you can use a relative or a fixed joint

dusk gyro
#

I'm gonna try using a relative joint now, wasn't aware of it so i'll see if it works. After doing a little testing I learned that the fixed joint tries to rotate back to its original rotation when the component was first enabled which is why I wasn't able to get the rotation to align with the hand

undone coral
#

"Fixed Joint 2D cannot modify the relative linear and angular offsets in real time. Relative Joint 2D can." but i don't think you need to

dusk gyro
modern cradle
#

Has anyone had success getting NodaTime into a project?
I'm getting some weird errors about the Unsafe class.

alternately any other recommendations for date math libraries that "just work (tm)" with unity?

limpid prairie
#

Hey guys, doing string manip for an app,

I was curious if anyone here knows how to detect if a certain word was modified, and if so, then remove that entire word (or the remains of that word) from the string?

#

For example, let's say the string is: "The quick brown fox jumped". And let's say we marked the word brown.
In code, we have access to all marked words.
let's say, the user now modified the 'brown' and made it 'bron'. Then the app should remove that word entire, and text should be "The quick fox jumped"

undone coral
#

what is the idea

#

what is the game?

real galleon
#

Are there many C# implementations? If so, are they compatible with Unity? Or does it have to be the default implementation loaded onto VS

limpid prairie
limpid prairie
#

Yeah.

undone coral
#

hmm

limpid prairie
#

This doesn't work for the case where, if the user, instead of turning "brown" into "bron", they just add a space to make it "bro wn".
Now comparing old string and new string are different sizes so you can't only delete the next word after the incorrect index match.

#

I actually already found a solution, and implemented it.

limpid prairie
#

The only downside is that with this method I cannot add duplicates of the marked word.

undone coral
#

it "has to be" the "default"

undone coral
#

so i can better understand what your goal is

undone coral
limpid prairie
#

Think the "@mention" functionality in apps.

The idea is the player can type a few letters of a friend. For ex: I will type @doctorpang and the app will auto-fill that to your full name to replace that string to then be doctorpangloss.

Now, if the user in any way corrupts that text, then the app should remove the whole word.

#

Think Facebook.

#

I have a solution working, but the only downside of it is that I can't attach a mention of a user more than once per user (aka, no duplicates).

limpid prairie
#

Discord does.

#

And Facebook does, too. And my app is a similar one that has traditional posts/threads/replies, etc, so it should have that feature as well, it's in the feature spec list.

#

I am not talking purely from auto-fill.
On Discord or Facebook, when you type "@", it opens up a mini menu with users that you can click to add to your message. I have that.

#

I am on PC (Desktop application), and it seems to be doing that.

#

Tag me and remove the s in my name.

#

You tagged a real user.

#

That just happened to be a real user,

secondly, your message looks messed up due to the hashtag and weird text at the end.

Thirdly, what you did was on phone(?)

#

I cannot delete a single letter on Desktop application. It deletes the whole mention.

#

This is actually poor from Discord.
Firstly, it looks malformed because the hashtag and remaining text looks weird.
Secondly, you did not mean to tag Fau, but it did, so this is poor design on Discord (phone).

#

I just verified this is also not possible on Discord web version.

limpid prairie
#

Yeah, I have something working so far.

Where, I use the inputField's OnTextChange callback, and I call my function from that event.

And with this, I get the final string after every single key press.
After a keypress, I just check if any of the marked words do not exist in the new string, if so, use the string from last frame and just remove the marked word that's missing from new string.

#

Only issue with this is that I can't use duplicates of the same word. So I can't use like the same name 2 or more times.

random dust
#

I doubt it would give you specific details of where the except comes from, though. It will just return the characters that are not in the original string.

#

My guess, iterate both strings, find the changed characters, and then do whatever you want

misty walrus
#

Hey 👋 I'm trying to get the ResourceLocations of all assets with a label in Addressables. When the play mode script is set to "Use Asset Database" it works correctly, when it is set to "Use Existing Build"(I have a fresh addressables build), it returns an empty list. Does anyone have an idea of why this is acting weirdly?

hybrid plover
#

Get float uniformscale always returns 0, while I can see uniformscale has a value of 2 in the material, how can I get the current value of the material? Do i first need to get the uniform scale of the material, then set that in the property block and then continue further after that?

final dirge
#

Hi! Any ideas how to include UnityEngine.dll as a reference in a .Net Class Library? I grabbed the DLL from the Editor installation path, and added it in my project but I'm unable to use Vectors/Mathf and stuff like that that Unity provides

#

It's showing up in my references

#

Found the answer: UnityEngine doesn't contain that, it's in UnityEngine.CoreModule.dll

languid canyon
#

the gameobject "SunShroom" is running a animation clip which changes the sprite of its children, or alteast, it should change, but it doesnt, why does it happen?

#

the animation clip is legacy and not running trough animator

#

the sprite field doesnt even light up in its children

#

is it just not possible to do so?

#

ngl it seems the animations just cant change the sprite property

glacial wedge
#

I found a bug!
Create a script with [ExecuteAlways] and you will see that OnEnable is called twice when entering playmode.
It should be called only once.
Unity version: 2021 lts (2021.3.12f1 to be precise)

sage radish
glacial wedge
#

yes

#

I have only one object in scene

#

it's fast to test it out

#

It doesn't happen to you?

sage radish
#

It does indeed

#

You could report it, but I wouldn't be surprised if it ends up being labeled as "By Design - Won't fix"

glacial wedge
#

I works a lot with listeners added onEnable and removed onDisable. the double call would be terrible to me until i test on editor:
like that:

        protected virtual void OnEnable()
        {
            lightProperty.onChanged += OnLightPropertyChange;
        }

        protected virtual void OnDisable()
        {
            lightProperty.onChanged -= OnLightPropertyChange;
        }
#

but it's strange because the method is called only once (correctly) but i expect to be attached twice

#

I don't know what to think