#archived-code-advanced

1 messages · Page 64 of 1

thorny mortar
#

yeah right, But I am getting it in zip file because I get many audio clips and pngs by one request to the database instead of getting every file 1 by 1

#

you mean saving the AudioClip.getdata() samples and load it when needed?

scenic forge
#

Yeah, data in audio clip are PCM already, you can save and reuse them directly.

#

If you get things in one big zip though and you have no control over the audio format, then I don't see a way other than using an audio decoding library.

wooden niche
dusty wigeon
#

For the love of god, do not make Invoke(..., 0);

It seem that you have a dependence between "Piece" and "Board" but some reason you do not make the dependance explicit. This is terrible design.

#

Personnaly, I would have my piece hook to an event on the Board itself. Do not make things like afterRestart because you gonna have afterAfterAfterRestart at some point.

bleak citrus
#

yes, this is exactly what events are for

fickle zodiac
#

has anyone experienced their signing key for google play games, not working anymore?

regal olive
#

Hi yall I've got some unusual problem with Sprite Shapes. So basically i try to spawn bunch of collectible items using RaycastHit2D, but they end up being on wrong positions. It happens because Sprite Shapes for some reason don't update their colliders when they are off camera. When im observing gameplay through scene mode all Sprite Shapes update their colliders corectly because i see them. The problem Is that i have to spawn them ahead of camera because that would be weird for collectibles to pop into existence in front of player right 😛 ?

sly grove
regal olive
#

@sly grove that doesnt work, just solved this with extending render bounds

sage radish
austere jewel
untold moth
#

Wait, is the 2022 lts out yet?

austere jewel
#

Yes

buoyant dawn
#

Alright, so I'm trying to make chunk based procedural generation (sorta). basically, I want to have a bunch of premade say 100m x 100m blocks that I can procedurally generate a world out of. So I would just need to go left to right, top to bottom generating these. I want to also make sure that certain blocks only spawn connected to certain other blocks. What would be the best way to go about this?

bleak citrus
#

Sounds a lot like the “wave function collapse” algorithm

#

Give that a googling

buoyant dawn
#

Alright

frank peak
#

wave function collapse, or you could devise some sort of height map generator + grid builder (using 3 loops, nested to build it).

#

(assuming you're doing tilemaps or something for the grid builder method)

#

idk you could probably devise some sort of mesh builder thing too but the specifics elude me

sand wraith
#

Is there any way can have Coroutines in Zenject Dependency injection framework since service classes are not inheriting from Monobehaviour

glacial wedge
#

Hi. this will work? is this legit?

public void Method(){
  CancelInvoke(nameof(Method));
  [code executed only once, no cares about how many invoked calls]
}
dusty wigeon
# buoyant dawn Alright, so I'm trying to make chunk based procedural generation (sorta). basica...

Backtracking, WaveCollapseFunction is backtracking with constraint propagation and lowest entropy heuristic to choose the next "random" node. Start with Backtracking, then add constraints propagation, then modify your heuristic. Backtracking does everything that WaveCollapseFunction does, but it is way easier to understand at first. Their relation is comparable with A* and BreadthFirstSearch.

Also, you might find the variant of WaveCollapseFunction that generate your constraints base on a image/correctly made level. This is not necessary.

dusty wigeon
bleak citrus
#

I implemented the simple neighbor-based system. It works pretty well, although I did monumentally screw up the rotation calculations over and over

#

I want to give the image-based synthesis a try

glacial wedge
dusty wigeon
bleak citrus
#

CancelInvoke only makes sense if you are also using Invoke

#

it does not magically stop the function from being called

glacial wedge
#

to clear a bit the stack of methods that will be called?

#

it's on a pooled object so I want to be sure that a call started from his previous usage doesn't interfere with the current usage

bleak citrus
#

that is absolutely not what it does

#

it cancels all outstanding Invoke calls

#

this would only be relevant if you tried to call the method several times via Invoke

#

it also wouldn't stop you from calling the method again in the future

dusty wigeon
# bleak citrus The intuition is that you pick the tile that is least flexible -- the one that h...

What you describe is not the lowest entropy heuristic. Choosing the one with smallest domain is different.

Entropy is the measurement of Chaos. It quantify how things are certain. By example, a perfectly balance coin would have maximum entropy while an unbalanced coin would have lower entropy. To use this heuristic, you need to have non uniform distribution of your choice.

It is explained the difference in the following article:
https://www.boristhebrave.com/2020/04/13/wave-function-collapse-explained/

bleak citrus
#

That would be correct if and only if everything had equal probabilities

#

Least uncertainty, not least choices.

dusty wigeon
#

In that case, entropy would be equal for everything. Making it a useless heuristic.

bleak citrus
#

well, even if you used binary "can use this tile" or "can't use this tile" values (rather than storing the probability of getting a specific tile), entropy would still vary based on how many valid choices there were

dusty wigeon
#

Pretty sure it won't. I can be wrong, it is a while since I did entropy calculation.

bleak citrus
#

uncertainty declines as you rule out tiles

#

I've done a whole bunch of it for a cryptography class :p

dusty wigeon
#

So I did.

#

I would double check what you are saying.

#

I am not sure.

bleak citrus
#

entropy is the negative sum of p * log(p)

#

for all possible events

#

if there is only one possible event, p=1, so 1 * log(1) = 0

dusty wigeon
#

If you have more choice of equal propability, it will give you the same result.

bleak citrus
#

if you have x equally likely events, the entropy is log2(x)

dusty wigeon
#

What is the entropy of 25% 25% 25% 25% ?

bleak citrus
#

you can imagine that as the number of bits you'd need to identify the outcome

bleak citrus
dusty wigeon
#

vs
50% 50%

bleak citrus
#

and then 100% is 0 bits of entropy, because the outcome is completely certain

#

and 33% 33% 33% is...1.584 or so

#

if a tile has 10 equally likely options, then it's more uncertain than a tile that has 2 equally likely options

dusty wigeon
#

You are right, it does increase. Must have been an other concept that was normalizing the entropy.

bleak citrus
#

There could be some other term that's constant in that case. Maybe something that measures bias.

#

but yeah, collapsing the lowest-entropy tile means that you're doing least "surprising" thing possible

#

if you just collapsed random tiles, you'd get tons of little islands that don't mesh with each other

#

incidentally: making a priority queue to keep track of which tile to collapse next was a HUGE performance gain

#

in my case, I pushed tiles into the priority queue every time their entropy went down

#

(and then just ignored duplicates)

bleak citrus
dusty wigeon
#

If you have uniforme propabability, then you do not really need to calculate the entropy. Which makes it simpler for most people to understand. This is why I usually suggest to look into backtracking; It is the entry point.

bleak citrus
#

ya

#

although uniform probability can make it hard to generate maps with variably-sized features

#

if i were generating an island map, for example, i'd make the land-coast and coast-water connections less likely than land-land and water-water

dusky dust
#

Hi, Ive had a issue where in unity my game works, but when i build, there are errors like embedded, wondering if anyone would be kind enough to download the project and see if he / she can fix it

#

Those are the erros i got in the webgl build

#

DMs open

dusty wigeon
dusky dust
#

How do i look what is it trying to get? @dusty wigeon

dusty wigeon
#

By reading the code if it is possible.

#

hexmone.framework.js:10... You might want to check all call of the call stack as the first seem to only be the dump

#

If not, you might want to contact the support.
Alternatively, you could restart from scratch and redo the correct step.

dusky dust
#

thx

soft moon
#

does anybody know how to override Delete key in TMP_InputField so that it does not do anything?

soft moon
#

but if cannot be caught in onValidateInput

#
inputField.onValidateInput += ValidateInput;
dusty wigeon
#

You could modify the behaviour of the package by modifying it. If there is really no otherway

dusty wigeon
#

Better than that

#

You can just inherit.

soft moon
soft moon
# dusty wigeon You can just inherit.
using TMPro;
using UnityEngine;

public class CustomInputField : TMP_InputField
{
    protected override void LateUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Delete))
        {
            print("KeyCode.Delete");

            return;
        }

        base.LateUpdate();
    }
}
#

it does not work though

#

I do not know why 🙄

dusty wigeon
#

Yeah, I was looking at the following.

#

But is seem it is not virtual.

soft moon
dusty wigeon
#

Just take the package and put it in your asset folder.

#

Modify it there.

soft moon
dusty wigeon
#

Take the content of the package, and drop it in your own project.

soft moon
dusty wigeon
dusty wigeon
#

You copy that in your own project:

#

Then you modify KeyPressed directly or make it virtual.

soft moon
#

never mind, I have found it already

soft moon
empty shell
#

So I have a problem where I am suppose to have a object that is not null as far as the inspector goes, but the console still gives me a difficult time.

Basically, I finish my game, press the restart button when I finish my level. After that I finish the level again and an object that was set-up in the inspector says it's considered null.

Here is how I restart my level :

    public void RestartLevel()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
dusty wigeon
tired fog
#

Hi!

dusty wigeon
soft moon
# dusty wigeon No ? Use whatever IDE you normaly use.

I have modified this field I guess ?? I still cannot modify built-in packages. There is written:

After you move the package, you must remove it from theLibrary/PackageCache/ folder.
but.. what package should I move and remove ??

tired fog
#

I have N native arrays that I want to pass to a job, all the same length and size, I cannot do NativeArray<NativeArray<float>>. So, what would be a way to do it? the length of it might be really long, so, in case I need to flatten it, how could I do that in a job?

empty shell
dusty wigeon
soft moon
tiny pewter
#

UnsafeList<UnsafeList<>>
it may work, i havent tested it

dusty wigeon
tiny pewter
#

but if there is any data race, you need search how to implement a lock

tired fog
tiny pewter
#

or float**

dusty wigeon
tired fog
dusty wigeon
#

Then you can use array[i * width + j].

tired fog
tiny pewter
#

@tired fog try float** and pass a int* array which represent the length of each column and a int for row number

dusty wigeon
empty shell
#

So I have a problem where I am suppose

tired fog
tiny pewter
#

float** is pointer to pointer and it can represent a 2d array
or you are not familiar with pointer operations?

tired fog
#

do you mean a job for each copy? @dusty wigeon

dusty wigeon
tiny pewter
#

if you really dont want to flatten it you may need it or unsafeList<unsafeList>

tired fog
tired fog
dusty wigeon
#

You work with the same array all the way.

tiny pewter
#

since a array is a pointer (the array name is the address) and you want to store all the address of all 1d array in a single array so you need a array of pointer ie pointer to pointer

dusty wigeon
tiny pewter
#

so T**

tired fog
tiny pewter
#

i think you can limit the high and low index in each job

tired fog
dusty wigeon
scenic forge
#

Your array can just contain pointers to arrays produced by individual systems, and access them that way without needing any copying.

tired fog
#

I'm not sure how to create that pointer array

tiny pewter
#

you can treat pointer as T

#

i dont even know if i can pass a T** to job, let me try it

tired fog
#

something like

        NativeArray<float*> arrayPointers = new NativeArray<float*>(...);

is not allowed

tiny pewter
#

!code

thorn flintBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

tired fog
#

It's just isn't, it throws errors

tiny pewter
scenic forge
#

What errors?

tiny pewter
#

yes i test it you cannot have a pointer as type parameter

#

so i use malloc

tired fog
#

I'm not following

tiny pewter
#

sorry i didnt share my code

#

let me share it again

scenic forge
#

I have my own UnsafeArray<T> which really is just a wrapper for T* using UnsafeUtility.Malloc and UnsafeUtility.Free

#

Which then can be used in NativeArray just fine.

#

I don't see why you wouldn't be able to use NativeArray<T*>.

#

Have you looked at what the errors say? Do you have allow unsafe enabled?

tired fog
tiny pewter
#

same error
i am so lazy to write a new unsafe container

scenic forge
#

Huh

#

Well yeah just wrap it in your own struct, it's only a few LoC anyways.

tired fog
#

Mmm, okay, let's see

#

How can I get then the pointer of a NativeArray? XD

#

Or do I need to use UnsafeList

tiny pewter
#

nativearray is a struct, so NativeArray<T>*
if you want get the array (address) you need to use unsafeutility

scenic forge
#

Also, couldn't you already use UnsafeList inside NativeArray?

tiny pewter
#

no

#

you cannot put unsafelist in native list or vice verse
only unsafe list in unsafe list is supported

acoustic umbra
scenic forge
#

https://docs.unity3d.com/Packages/com.unity.collections@2.1/manual/collections-overview.html

It's best practice to use Native collections over the Unsafe equivalents. However, it's sometimes necessary to use the Unsafe equivalents because Native collection types can't contain other Native collections. This is because of how Unity implements the Native safety checks. For example, if you want to get a list of lists, you can use either NativeList<UnsafeList<T>> or UnsafeList<UnsafeList<T>>, but you can't use NativeList<NativeList<T>>.

#

I remember the reason I wrote my own UnsafeArray was because UnsafeList didn't exist back then, the wild west.

tired fog
#

Mmm

#

Any way to transform quickly a nativearray into a unsafeList?

scenic forge
#

Just use unsafe list to begin with so you don't need to transform at all.

tiny pewter
#

oh it is allowed to have a native<unsafelist>...

scenic forge
#

Why not? UnsafeList should have practically identical API surface as NativeList/NativeArray.

tiny pewter
#

to get the pointer

dreamy barn
#

Hey does anybody know how I can set camera borders for this endless runner and how I can fix this background issue. Seems like it always gets generated again

tired fog
scenic forge
#

Sounds like simple find and replace.

tired fog
#

I wish

scenic forge
#

I mean, that's what you need to pay for to get performance, not sure what else to say.

tired fog
#

And i just saw that unsafe list doesn't have the reinterpret method?

tiny pewter
#

idk if it is valid for you just declare a empty unsafe list and point the ptr to the address of native array

#

check if the Ptr property can be set

#

you can set it

tired fog
#

but how do you get the address of a native array?

tired fog
#

Aha, perfect, got it working now! Nice!

tiny pewter
tired fog
#

Ah, but I cannot get the unsafe ptr of a native array if the job is not fully completed?

#

Like

#
NativeArray<float> aray = new NativeArray<float>(...);
JobHandle ajob = something.Schedule(aray, dependancy = default);
UnsafeList<float> unsafeList = new UnsafeList<float>(){
  Ptr = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(aray),
  .
  .
};
JobHandle secondJob = something.Schedule(unsafeList, dependency = ajob)
tiny pewter
#

i remember there is a error like you cant read any data from the native array if the job havent finished yet

tired fog
#

It normally allows it when using the correct sequence of dependancies, but nativearray unsfe bla bla bla, doesn't allow to set the dependancy to after what should it be caled

tiny pewter
#

try to get the address right after the nativearray is created

tired fog
upbeat path
#

thats why, try persistent

tired fog
#

doesn't make a difference

tired fog
regal olive
#

How can I end a coroutine without having code execution wait until the end of frame?

#

I have Coroutine A, which waits for the results of Coroutine B. Coroutine B is a recursive method; it calls itself onto child objects. Naturally, recursive methods will be terminated when done with their children. However, instead of waiting until the end of frame directly, I want the parent calls to Coroutine B to still finish executing, and then Coroutine A to finish before the end of frame.

#

Right now, after the termination of an instance of Coroutine B, it instantly forces a frame update.

#

How can I prevent this? I.e., terminate a single Coroutine instance without getting a frame update?

#
IEnumerator CoroutineB(some params) {
   if (some check) {
       for (int i = 0; i < 8; i++) {
         //some code
         yield return StartCoroutine(CoroutineB(params again));
       }
   } //<- if the condition fails, and the coroutine comes to the end of scope, and it terminates, it also forces an end of the frame. This is bad as CoroutineB could be computing elements that shouldn't be done once per frame, but many per                   frame. What should be happening is that the parent caller should continue executing, finish, go to its parent, etc until all recursive calls are terminated and finished, at which point the next frame should start.
}
#

The reason I'm using Coroutines for this is because I have an indexer implemented that forces a (wanted) frame update after a given number of iterations. I'm traversing an Octree, and it's the easiest to split its traversal with this indexer and a Coroutine being able to break and continue next frame.

#

Actually, with each new recursive call, this indexer is incremented, and there are yield return null statements when the indexer reaches a said value.

dull raft
#

@regal olive I'm not certain that I'm understanding you correctly, but I think you could just manually iterate through the IEnumerator instead of running it with StartCoroutine(), as yield in a coroutine-operated IEnumerator will always suspend execution of the coroutine for some time. That is, I don't think your one-frame delay is the result of the coroutine ending - rather it's a result of yield return StartCoroutine(CoroutineB(params again)); - it's Unity's coroutine execution loop receiving a value from yield.

I was recently infatuated with the idea of allowing a coroutine to execute flat-out and throttling it by yielding a frame only when necessary. I wrote a little test code, but haven't actually had an application for it so haven't really tested it to any great degree, but this is what I came up with... it might provide some ideas https://gdl.space/fodataqiji.cs

In short, as best I could figure out, there is no means to yield a value in a Unity-executed coroutine and have it not suspend for a bit. If you need continuous execution, then I'm pretty sure you have to manually iterate through the IEnumerator yourself. If you do that from another IEnumerator which you do execute with StartCoroutine(), then you can still use yield instructions of whatever variety, but have full control over which are actually passed out to Unity

sly grove
#

There's nothing you can do with recursion that you can't do with a Stack

#

And without sub coroutines being started you will have full control of when to yield

velvet rock
#

I have the fallowing code that is grabbing the mesh from each instance of a component(SuperTextMesh), combining them, and making a material/texture to assign to them. I am facing a problem though that the generated mesh UV's don't match the generated texture? Anyone know how to fix this?
https://gdl.space/ezewucaray.cs

velvet rock
#

I fixed the UVs, I needed to grab the UVs off of every mesh I was combining. But now have a problem with the transform being off position.

#
combine[i].transform = superTextMeshes[i].transform.localToWorldMatrix;
#

I tried doing * worldToLocalMatrix, but to no luck. An issue might be the parenting of objects? RootObject/ComponentObject/HolderObject/TargetMeshObject

#

The new object is being added as a child of RootObject, but maybe the target mesh being that low is causing local to world space conversion issues?

#

Ah yeah if the root object is at (0,0,0) then the generted mesh is at the right spot.

#

Looks like the transform is being applied twice, but if I don't assign to combine.transform then no transform is being applied?

#

Instead of messing with the Matrix4x4 I just am moving the object to world space origin and then moving back after the new mesh is generated XD.

#

which ironically I think is what the * worldToLocalSpace solution was supposed to be doing basically.

slender quartz
#

using the cloudsave service, is there a way to search for all ids with the key "username"? if it helps im trying to use the friends service and add someone by their username saved in cloudsave, so others dont need to type out a huge id unity created to add someone

regal iron
#

Hey, is there any other way to get device's rotation degree ? Like the tilt control in many racing game (Asphalt, Mario Kart, etc)
I tried to use Gyro, but when i tilted the device forward, the output degree also changed. What I want is to control the MC by rotating the device. Like when you play racing game and use rotate to steer.

regal iron
sly grove
regal iron
#

what i need is to only get these value

#

so, tilting device backward (to yourself) and forward (away from yourself) wouldn't do anything on the input

sly grove
#

With vectors transformed by the gyro input

regal iron
#

this is what I have tried

                    //Quaternion referenceRotation = Quaternion.Euler(0, 0, -90);
                    Quaternion deviceRotation = DeviceRotate.Get(); //this is the Gyro input
                    Quaternion eliminationXY = Quaternion.Inverse(
                        Quaternion.FromToRotation(referenceRotation * Vector3.forward,
                                                  deviceRotation * Vector3.forward)
                    );
                    Quaternion rotationZ = eliminationXY * deviceRotation;
                   
                    float roll = Mathf.Ceil(rotationZ.eulerAngles.z);```
#

ah, SignedAngle? Let me try

dawn zephyr
#

Hey guys got a question of implementation, say I wanna use the same scene and only reload it upon completion and also increment an integer, based on that integer certain scripts' parameters will get set. How would you guys implement it? I'm currently thinking about a public static with a private setter, though that results in many scripts referencing it, would u guys consider it a problem and try to centralize it in one place? if so where? tyy ❤️

dusty wigeon
#

(For a small project)

dawn zephyr
#

And where would all the logic of the other classes' parameters be? currently I have it on the start method, and also where would i instantiate that gamemanager? unless you meant to make a singleton i cant think of a way for it

#

on the start method of each class that is dependant on that Level parameter**

dusty wigeon
#

You want to instantiate your object because you want to be able to reuse the setup code everywhere.

dawn zephyr
#

oh right idk how i didnt think of it

dusty wigeon
#

And the GameManager would be a Singleton as well.

#

Except that you control his instantiation.

#

Otherwise, you might have suprise lag spike.

dawn zephyr
#

would u make it a singleton even though all i need from it is the level parameter?

#

i have no use of anything else in the class

dusty wigeon
dawn zephyr
#

i see alright

#

then what about every class that is dependant on the level? do u think its fine for each one of them just do their thing with it on start?

dawn zephyr
#

yea but say i have 6 classes depending on that level, would all of them on start do their thing with the level? would u not put it all in one script in some way?

dusty wigeon
dusty wigeon
#

In thoery, you want to respect the Single Responsability Principle

#

Thus, having multiple object that holds the responsability of one composant.

dawn zephyr
#

so keeping as is in the start method is alright?

dusty wigeon
dawn zephyr
#

i thought maybe ill need to use DI for it in some way

dusty wigeon
#

It is hard to know without knowing everything.

#

DI is not necessary.

#

I hate DI, most library are to complex for what you need.

dawn zephyr
#

same.. a standard in my local industry though

dusty wigeon
dawn zephyr
#

in my country's local unity industry zenject is a standard

dusty wigeon
#

I see.

#

A lot of people works with that. I'm not fan.

#

But, if it is standard, you should use it.

#

Uniformity is better.

dawn zephyr
#

its a fluent api with clear naming though for someone who never used it ( such as me ) these names sound like ambiguities and big confusion

#

wdym uniformity?

dusty wigeon
dawn zephyr
#

oh yea gotcha

slender quartz
dawn zephyr
#

anyone familiar with unitask knows what im doing wrong here? i want to cancel the delay and start it from the beginning everytime im calling this function

compact ingot
dawn zephyr
#

so everytime i call the delay ill have to somehow set the token to that? also, where would i use continuation if u could expand? im very new to unitask and documentation.. has a big learning curve to say the least

scenic forge
#

Do you need StartFrightTimer to accept a cancellation token?

dawn zephyr
#

if i understood right, does that look right or atleast better?

scenic forge
#

Yep, was just typing that.

dawn zephyr
#

haha okay so when i fill in a cancellationtoken in these functions like delay when i cancel the token it cancels the function?

scenic forge
#

Yes, it cancels the task that's using the token.

dawn zephyr
#

wow okay

#

also would i need to dispose of it? i saw ppl saying to always dispose or?

scenic forge
#

Yeah

#

Also you should use TimeSpan rather than hardcoding _frightenedTimer * 1000.

dawn zephyr
#

ooo awesome

#

what does dispose do actually? is it just the IDisposable?

#

oh yea nvm

elder pagoda
#

guys, I remember seeing in some video theres some kind of tag that I can give a MonoBehaviour like [FormerName="ASDF"] so that Unity can automatically find the script after I refactor and rename the file, and I cant remember exactly what it was. Anyone know?

flint sage
#

PreviouslySerializedAs but iirc it's only fields and not classes

elder pagoda
#

wouldnt it be nice if there's a Refactor entry in the context menu for scripts 😄

dusty wigeon
#

Reference to script are base on guid, not name.

tender gust
#

hey

#

how can I get the angle between 3 points?

#

the middle point being the center of the angle

bleak citrus
#

Vector3.Angle computes the angle between two vectors.

#

compute two vectors from A-B and C-B

#

where B is the center point and A/C are the other two points

tender gust
bleak citrus
#

so you already hvae two vectors

#

the velocity vector and transform.forward

tender gust
# bleak citrus the velocity vector and `transform.forward`

something doesn't seem to work though, the code out of context may help

        var velocity = PlayerController.RigidBody.velocity.normalized;

        var charTransform = PlayerController.CharacterTransform;
        var targetDir = velocity - charTransform.TransformPoint(charTransform.position);
        float angle = Vector3.Angle(targetDir, charTransform.forward);
#

the angle is almost always the same in whichever direction I point to whilst moving

bleak citrus
#

this is wrong in several ways

tender gust
#

I assumed so

bleak citrus
#

you're trying to subtract a position from a velocity

#

this makes no sense

#

charTransform.TransformPoint converts a local-space position to a world-space position

#

the position is already world space

#

you also shouldn't be using positions at all

bleak citrus
#

that's all you need

tender gust
#

ok so then Vector3.Angle(velocity, character.position)?

bleak citrus
#

no

#

I did not say to use position

#

I said to use transform.forward

#

do you not understand what that means?

plucky sparrow
#

Quick questions does anyone here having any past knowledge on working on a C# chatbot?

tender gust
#

right sorry

#

@bleak citrus thanks it works, just got confused for a sec

tender gust
plucky sparrow
#

I am working on vr project where the npcs are all (in short) chatbots

#

so you can have organic conversations that don't repeat

tender gust
plucky sparrow
tender gust
#

you need a chatgpt API subscription, and it aint cheap

plucky sparrow
#

Exactly my reasoning

tender gust
#

or you can download a free low quality model

#

then run it on your own servers

plucky sparrow
#

I got it to understand (voice) english perfectly and also spanish but

tender gust
#

but you will need a GPU rental probably

plush hare
tender gust
#

which is > 500$ a month

tall ferry
#

unless you have some massive data source, there really isnt a way to make your own

tender gust
#

but they are low quality

plucky sparrow
#

I wanted to make a rpg game that is fully organic in nature

tender gust
plush hare
tall ferry
#

Especially with rpg dialogue

plush hare
#

there's a good reason it's wifi connected

#

and it's probably querying the supercomputers in whatever datacenters they live in

plucky sparrow
#

hmm ok interesting but I am still going to try

tender gust
tall ferry
#

you can make your game feel more "organic" in other ways. How many people are really going to sit there talking to your npcs

bleak citrus
#

i would start by making a game

plucky sparrow
#

thanks for the info though best of wishes on your own projects

tender gust
#

if your players want to speak to a chatbot, they will use bing or gpt

#

or bard

#

whichever

#

just make a game

#

that skyrim mod was just a demo, it's actually shit

#

@plucky sparrow

tall ferry
#

One thing you should really consider if you do get this working, you will seriously need to limit whats given as a response. Even chatgpt still has its issues with restricting responses, jailbreaks come out everyday and people have gotten it to say some very bad things

#

I imagine u could run into trouble if you dont restrict it

tender gust
#

someone trained gpt on 4chan, the results were quite peculiar

plucky sparrow
karmic carbon
#

llm trained on racists is racist, how peculiar =)

plush hare
#

It's really easy to underestimate the amount of willpower some people possess for strictly wanting to screw with other people

plucky sparrow
tall ferry
#

yea that wont be enough

plucky sparrow
plucky sparrow
tall ferry
#

thats the ice cube of the entire iceberg. people have had chatgpt tell them full recipes to make drugs for example

#

bad words are the least of the concern

plucky sparrow
#

so they wouldn't even start on a conversation in that reguard

plush hare
#

I don't think that's right

plucky sparrow
plush hare
#

I mean, you have proof that it's already happened before

#

to make a bot, it needs to learn

#

if it's learning from a bunch of racist people, it's going to be a racist bot

#

etc

tall ferry
#

wouldnt it be better to just have a long list of predetermined responses, even from an existing AI?
At least you can mass generate it and ensure that nothing is bad

plucky sparrow
plush hare
#

If it's not allowed to scrape the internet?

plucky sparrow
plucky sparrow
#

and the information it gets from a player is discarded unless it pertains to the story or a quest

tender gust
#

what we need is a chatgpt loop with direct API access to a mechanical body, with full unrestricted wifi and terminal access

plucky sparrow
#

but I bet people will probally find a way to get around it

tender gust
#

well, gptnet, but close enough

karmic carbon
#

I've already asked AI to generate code for me and ran it without comprehending it, so I'm doing my part to create skynet.

plucky sparrow
#

welp gl though I am going back to work

nova summit
#

In a event based architecture, do you have any suggestions on how to query existing contexts?
For ex: When a player spawns, his state machine's MoveState may need info about the current level so that it can handle it's path finding. For this let's say it needs to know about the world context(IWorldContext).
How can we get this world context which actually exists in the scene before player spawns?

I'm thinking about emitting an event like RequestWorldContextQuery which is consumed by LevelManager(in this context world) and fires an event RequestWorldContextQueryResponse with the IWorldContext. Is this a valid one to design or any better options?

To Summarise, In Event Driven Architecture, How to get events data if a subscriber enters later after an event is published?

rapid osprey
#

Example. Could be simpler in your case with just a null check. TL;DR use event keyword in C# to control the add and remove.

public sealed class VideoUIActivable : MonoBehaviour
{
    [SerializeField] private bool m_ActiveOnStart = true;

    [Space]
    [SerializeField] private UnityEvent m_OnActivate;
    [SerializeField] private UnityEvent m_OnDeactivate;

    public event UnityAction Activated
    {
        add
        {
            m_OnActivate.AddListener(value);
            if (m_State == State.Active)
                value?.Invoke();
        }
        remove => m_OnActivate.RemoveListener(value);
    }

    public event UnityAction Deactivated
    {
        add
        {
            m_OnDeactivate.AddListener(value);
            if (m_State == State.Deactivate)
                value?.Invoke();
        }
        remove => m_OnDeactivate.RemoveListener(value);
    }

    private State m_State = State.None;

    private void Start()
    {
        // Ignore ActiveOnStart if we have already Activated/Deactivated.
        // Which is possible if the GameObject was inactive when Activate/Deactivate was called
        if (m_State == State.None)
        {
            if (m_ActiveOnStart)
                Activate();
            else
                Deactivate();
        }
    }

    public void Activate()
    {
        if (m_State == State.Active)
            return;

        m_State = State.Active;
        enabled = true;

        m_OnActivate.Invoke();
    }

    public void Deactivate()
    {
        if (m_State == State.Deactivate)
            return;

        m_State = State.Deactivate;
        enabled = false;

        m_OnDeactivate.Invoke();
    }

    private enum State
    {
        None,
        Active,
        Deactivate
    }
}
lime island
#

what would you guys say is the most advanced question ever asked in this channel?

dusty wigeon
lime island
#

is there a specific question that took days on end for this channel to answer?

dusty wigeon
lime island
#

oh, what is your definition of an advanced question then?

dusty wigeon
#

I have no clean cut definition.

lime island
#

fair enough

hard siren
#

Hey guys! Not sure if this is the correct channel but was wondering if anyone would know how to implement a 3D voronoi map in unity programatically. I looked online and saw a couple libraries but I'm unfamiliar on how to import them into unity to work with.

hard siren
#

I don't even know how to import the libraries to begin with, never imported external libraries into unity before.

dusty wigeon
#

What is the library ? A dll ?

#

Is it in C++ ?

hard siren
#

No, it's a set of .cs files. Unity does C++?

#

Didn't even know that.

dusty wigeon
#

It kinda do it, but it was just to know what we are working with.

#

If it is C#, just drop the folder in ?

hard siren
#

Does that work?

dusty wigeon
#

I mean, why wouldnt it work ?

#

If it is only C# files.

nova summit
glass hill
#

Serializing and Deserializing some scriptableobjects with an XMLSerializer.

#

Serializing seems to work fine but Deseralizing gives me this error:
InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. UnityEngine.Transform does not implement Add(System.Object).

#

One of the scriptables inside contains a reference to gameobject prefabs, however, I've marked it with System.NonSerializable

#

What's the best course of action here?

flint sage
#

You probably need to handle serialization for GameObject and other Unity classes with a custom serializer rather than the built in generic catch all solution

visual spruce
#

Hello! I'm having a problem with writing an IEnumerator that turns an object towards another object.
Here's the code


    public IEnumerator Turn(GameObject targetObject)
    {
        Vector3 target_no_y = new Vector3(
            targetObject.transform.position.x,
            character.transform.position.y,
            targetObject.transform.position.z);

        Vector3 endingAngle = Quaternion.Euler(target_no_y).eulerAngles;
        Debug.Log(endingAngle);

        while (Vector3.Distance(character.transform.rotation.eulerAngles, endingAngle) > 0.01f)
        {
            Vector3 newDirection = Vector3.RotateTowards(character.transform.forward, target_no_y - character.transform.position, RotationSpeed * Time.deltaTime, 0.0f);
            character.transform.Rotate(Quaternion.LookRotation(newDirection).eulerAngles);
            yield return null;
        }
        character.transform.Rotate(endingAngle);
    }```
The problem is that object rotates wildly and changing the RotationSpeed variable either to very small or very high numbers seems to have no effect.
austere jewel
#

Also Vector3.Distance is inappropriate to compare two euler angles

visual spruce
#

Thank you so much! ❤️

austere jewel
# visual spruce Thank you so much! ❤️

also I don't understand what you're doing with Rotate, it rotates something, why would you want to rotate by the new orientation?
Surely you want to set it, character.transform.rotation = Quaternion.LookRotation(newDirection);?

visual spruce
#

But now it doesn't appear, weirdly

austere jewel
visual spruce
#

It's working now 😩 i can't believe it is working after 2 days of torture

visual spruce
#

so, the types simply need to be the same

#

it can't be vector.x = vector.x, it should be vector = vector

orchid marsh
# visual spruce so, the types simply need to be the same

It has to do with properties and how rotation is a struct. Pretty certain the link should have discussed about how properties are like methods and returning a value type from a method would be a copy of the variable's value and not the actual variable. Modifying the value would throw the error.

torpid birch
#

i have a problem with my unity

#

why she is building with errors in android

#

hellp

#

help

#

please

#

i need someone to fix my ploblem

austere jewel
# torpid birch please

stop spamming, and explain how this has anything to do with advanced code, or how anyone is meant to help with your complete lack of useful information

torpid birch
#

i have a error with my unity editor

austere jewel
#

Cool. Don't cross-post, and stick to the relevant channel, #📱┃mobile. Provide more context there.

finite pond
#

I don't see any fitting channel, so I hope this is appropriate here.
I'm creating a Linux IL2CPP build on my mac machine, but trying to run the build on an actual linux machine returns "exec format error".

#

I'm on a M2 silicon machine.

sly grove
finite pond
dusty wigeon
# finite pond I don't see any fitting channel, so I hope this is appropriate here. I'm creatin...

There is this in 2020.1 Documentation, it might be obsolete.

Otherwise, you might want to read: https://docs.unity3d.com/2023.2/Documentation/Manual/linux-IL2CPPcrosscompiler.html

Every operating system (OS) has its own build systems which vary from one to another. If you build using the headers and libraries of a particular OS, the built Player might not run on other operating systems. To address this, Unity provides a sysroot to build with which works on all supported Linux platforms.

#

I guess you could try if it works in Mono too.

bleak citrus
#

I forget the exact error, but it involvd claiming that it was trying to sign a 32-bit executable

#

(the offending file was a 64-bit binary, according to file)

finite pond
#

Mac IL2PP builds work fine on my end!

finite pond
bleak citrus
#

hmm, i'll give it another go soon

acoustic umbra
#

hello, I am trying to make an interpreter for a small programming language for a game that I'm making (first time making an interpreter) and I quickly stumbled into a problem.

How do I save the value of an in-game player declared variable in a var type variable in my code?

#

Is that enough info or should I append more, like a code example?

upbeat path
#

apart from the boxing and unboxing overhead anything can be saved as type object

tiny pewter
#

i havent write a compiler nor interpreter
but have you defined the syntax of your own programming language?
if it is static type then you will parse the type of the variable and convert it to a c# type, else you may refer to how python do it

scenic forge
#

Take a look at https://craftinginterpreters.com (the web version is free), it goes through implementing a full interpreter in Java which you can easily translate to C#, and a bytecode interpreter in C if you need speed but you probably don't need.

bleak citrus
#

ooo

#

or just write a LISP

#

we love a LISP

tiny pewter
#

compiler and interpreter are just the same thing, both are extremely difficult to wirte.....

scenic forge
#

Not sure what your game is about, but also consider just embed a runtime for a popular language like Python instead.

bleak citrus
#

Lua is also a popular choice.

acoustic umbra
scenic forge
acoustic umbra
scenic forge
#

The game I'm working on has my own low level language (with good reasons to not use an existing language), and recently I've actually switched from a tree walk interpreter to a bytecode VM

acoustic umbra
#

wow so much help, thank you! :)

scenic forge
#

Crafting Interpreter goes through all the same concepts as well, and if performance is a big focus of yours, you should definitely look at its C implementation

#

Apparently people have not been able to create a faster implementation even with languages like Rust.

tiny pewter
#

c++ maybe better since it provides some abstract data structure in STL

scenic forge
#

Oh many people have tried

#

Crafting Interpreter is golden introduction to this field for good reasons.

rough sky
#

What prerequisites are there for reflection and attributes? I'm making a tool that fills in a gameObject's references if you right click a class, by reflection and attributes. But, while it can find all the parameters, it seems to not be able to pick up attributes.

#

Am I doing reflection wrong?

thin mesa
#

SerializeField is an attribute on fields not properties

rough sky
#

I'm looking for properties, not fields

#

Yeah that was exactly it!

#

Thank you @thin mesa

thin mesa
#

i'd also go ahead and take a look at the link anikki sent as there's a method on that class for fields

rough sky
#

I'll do that too

#

For anyone else that might benefit from this:

#
using System.Collections;
using UnityEngine;
using UnityEditor;
using System.Linq;
using System;
using System.Reflection;
public class ChainFill
{
    [MenuItem("CONTEXT/MonoBehaviour/References/Chain References")]
    public static void ChainCreateFillInReferences(MenuCommand command)
    {
        MonoBehaviour target = (MonoBehaviour)command.context;
        Undo.RecordObject(target, "Reference Filled");
        Chain(target);
    }

    public static void Chain(MonoBehaviour target)
    {
        if (target == null) return;
        Type t = target.GetType();
        FieldInfo[] properties = t.GetFields().Where(prop => prop.IsDefined(typeof(Reference))).ToArray();

        foreach (FieldInfo p in properties)
        {
            object value = p.GetValue(target);
            if (value == null || value.ToString() == "null")
            {
                Component m = target.gameObject.GetComponent(p.FieldType);
                if (m == null)
                {
                    
                    Debug.Log("Trying");
                    m = target.gameObject.AddComponent(p.FieldType);
                    Undo.RegisterCreatedObjectUndo(m, "Reference Filled");
                    Debug.Log(m == null ? "Found" : $"Found {p.FieldType}");
                }
                
                p.SetValue(target, m);

                Chain(m as MonoBehaviour);
            }

        }
    }
}

[AttributeUsage(System.AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public sealed class Reference : System.Attribute
{

}
sand wraith
#

Hi I have been going through some quaternion articles online and found out that inorder to rotate a Vector P by Quaternion q, we need to follow the following operation,
q x P x q-1
.
When i try this in unity, P is not rotating at all, where as if i just multiply q X P, am getting the required rotation. Can someone explain why this ?

tiny pewter
#

since unity engineers implement it on this way

compact ingot
# sand wraith Hi I have been going through some quaternion articles online and found out that ...

presumably because the * operator is implemented such that it combines both operations, here is the code, you can try to decipher it 😛

public static Vector3 operator *(Quaternion rotation, Vector3 point)
{
    double x2 = rotation.x * 2f;
    double y2 = rotation.y * 2f;
    double z2 = rotation.z * 2f;
    double xxx = rotation.x * x2;
    double yyy = rotation.y * y2;
    double zzz = rotation.z * z2;
    double xy = rotation.x * y2;
    double xz = rotation.x * z2;
    double yz = rotation.y * z2;
    double wx = rotation.w * x2;
    double wy = rotation.w * y2;
    double wz = rotation.w * z2;
    Vector3 result;
    result.x = (float) ((1.0 - (yyy + zzz)) * point.x + (xy - wz) * point.y + (xz + wy) * point.z);
    result.y = (float) ((xy + wz) * point.x + (1.0 - (xxx + zzz)) * point.y + (yz - wx) * point.z);
    result.z = (float) ((xz - wy) * point.x + (yz + wx) * point.y + (1.0 - (xxx + yyy)) * point.z);
    return result;
}
bleak citrus
#

isn't it a compile error to multiply a vector with a quaternion that way

#

q * P * qinv shouldn't work

compact ingot
#

you still could do the M4x4 * someVec3 * M4x4'

visual spruce
#

Hello! I'm trying to figure out how to immediately transfer the slider's knob to a place where the user clicked on the slider. Can someone please help me?

dull raft
visual spruce
#

it does?

#

i never noticed, let me check

hearty garnet
#

Hello,

I want to create a UI menu that displays various items in their 3D form. Normally, with 1 items, I'd do a render texture. But I'll have 16+ items to display and creating 16 cameras seems like... The wrong thing to do.

I am experimenting with putting real 3D objects under a scroll-rect and layout-groups. It works (sort of) but because my camera is not Orthographic, I need to move the models slightly to make it look like they alighn on camera.

I also can't use Canvas Group to fade in and out these 3D Objects.

Is there another obvious way I don't know about? Is this how I should do it?

tropic vigil
# hearty garnet Hello, I want to create a UI menu that displays various items in their 3D form....

I think the common approach would be to make those items 2D expect of the selected/hovered one or zoomed one. The 2D versions are usually premade assets or some sort of realtime screenshots.

Sometimes games create an illusion of 3D graphic by using shaders or by running animations. Animated cards in Gwent were quite impressive ones. Shaders are more limited, but would take less disc space than animations.

hearty garnet
# tropic vigil I think the common approach would be to make those items 2D expect of the select...

I see. However, this is sort of an 'assignment' and it requires all items to be rotating on the UI. I think it's intentionally unreasonable to see how I'd tackle such a request. And frankly, I don't know! I can do it with putting real 3D objects and meticulously aligning them within layout groups and scroll-rects. However, that just seems like an ugly solution but I guess there is nothing else.

#

Shaders seem like a neat solution though. It's just not in my alley.

long ivy
#

personally I'd do it the ugly 16 camera-with-RT way first, it's simple and I don't think the the brittle alignment plan B you laid out is better unless you have a performance issue or other limitation from plan A. And you won't know if that's the case until you implement plan A anyways

hearty garnet
#

Thanks for your input guys!

long ivy
#

does the assignment require all the 3d things to be in motion or have active lighting? Or just 3D appearance?

hearty garnet
long ivy
#

all of them at the same time?

hearty garnet
#

Yup

#

"All items should rotate"

#

Doesn't specify "all at the same time" but since it's for a mobile project, there won't be a hover event. So, better to make it all rotate at the same time to be safe.

dusty wigeon
# hearty garnet Doesn't specify "all at the same time" but since it's for a mobile project, ther...

You have multiple alternative:

  • Make it works with 16 camera/shader. (For the shader, you would still need to do everything a camera does, I do not think you would gain much in performance)
  • Record a video. (Propably the best you can do)
  • Only render a single row at a time.
  • Only render the picture that has been "long press".

Having 16 render at the same time does not feel right in term of UX. There is to much things happening at the same time which would hinder the user. For performance and good UI design you should propose the other solution of having 2D image preview and a zoom/focus visualization system. (You could also make the user able to move the preview himself)

#

Also, do not forget to profile if performance is trully a concern.

celest mulch
#

Hey i have this scene where multiple enemies (bats) are following my player (big guy in the middle). Now the problem is that i dont want the enemies to overlap each other while following. Is there an easy way so that rigidbody push each other out of there mesh?

storm compass
dusty wigeon
surreal juniper
#

what general compression APIs or repository are available for use in Unity?
ideally something built-in or in a package, in any case it needs to have a permissive license
hard to believe I'll be stuck with GZipStream without having to install either a git repo (ZipSharpLib) or buy an asset

#

preferably something bursted & jobified

vale spindle
#

I want to make pathfinding with velocity (inertia). I will use that and normal pathfinding, which would be prevalent. if you look at the first reply here https://gamedev.stackexchange.com/questions/102214/pathfinding-with-inertia it seems like a solution. i guess you would add a field to node class that stores current velocity and then update it together with g cost, but still would like you to explain. The problem however is knowing what to do with velocity. You can arrive at the same node with different velocities and that would impact the rest of the path. say we have a linear path, and on each point an option to slow down or not. to get the optimal path we would have to make a binary tree and compare each of the branches which would probably kill my game.

upbeat path
surreal juniper
upbeat path
real vault
#

is migrating my project (2021.3.21f) to latest 2022 beta version safe ?
I am currently facing gradle build issues bcz of unity ads and people on stackoverflow says , migrating your project to latest version fixes it .

upbeat path
#

what stackoverflow says is usually, how should I put this? 'Terminologically inaccurate'

tiny pewter
#

@vale spindle (2D case) suppose you have K different speeds and 8 different direction (orthogonal and diagonal) .
At each node now the speed is k and you can change the speed to [k-i,k+i] when exploring all neigbhors (the neigbours' speed should belong to [k-i,k+i]) and the radius of turn at different speed are different, ie if the speed is the highest you can only go forward, slower speed you can explore the cells in +-45 degrees, more slowly then +-90 degree and so on, to limit the search space
O(8 different directions*vertice^(branch factor=8*(2*i+1)) (one node can generate 8 children vary from [k-i,k+i] different speeds)
and the visited are mostly cost memory O(8 different direction (a node can be reached from 8 different direction, since the neigbhors generated by different speeds from different directions are different so you have to store it)* number of speed's choice *number of node))

vale spindle
tiny pewter
#

a bit hard to tell without pseudo code....

vale spindle
surreal juniper
tiny pewter
#

I think your problem cannot be solved by just making binary decisions
i try to come up with a possible design here and analysis the possible run time and memory allocation, you may refer to my design

#

i havent write an non grid based path finding, but in this case the "direction to neighbor" can be changed to parent node

tepid vapor
#

Would anyone mind looking over my character creation controller and tell me if I missed anything?

bleak citrus
#

that sounds very challenging to do for those without context

storm compass
remote drift
#

I can't find any info on IL Postprocessing. Is there any resource or scripting API for that?

#

IL - language

bleak citrus
#

intermediate language, specifically

#

the result of compiling C#

#

are you thinking of CUDA or somethin'?

remote drift
#

that's not what you think it is

bleak citrus
#

IL has nothing to do with the GPU

#

GPU-accelerated compilation 🤔

#

i'm sure someone's done it

sage radish
bleak citrus
#

re: the question, I don't know anything on that front, unfortunately

remote drift
#

and entities switched over to roslyn codegen

#

afaik

sage radish
#

Entities moved most of it to source generators, but last I checked, it still has some ILPP.

remote drift
#

🤔

sage radish
#

An important thing to keep in mind, which isn't obvious, is that Unity will run IL post processors in their own isolated .NET Core app, in parallel. This means you can't access any information from the Unity project in ILPPs, other than the assembly you're given to modify.

remote drift
#

yeah, this is hardest part

#

no debugging

#

Do you happen to know whether it would be a trivial task to simply change declaration type from class to struct?

sage radish
#

This is for changing the compiler generated IEnumerator to a struct?

remote drift
#

I am looking for a way to use IEnumerator in burst by swapping declaration of generated type from class to struct and then swapping IEnumerator return to that type, as well as MoveNext calls on it

sage radish
#

Changing the class declaration to a struct should be the easiest part. The more difficult part will be to fix any IL instructions that are expecting a different type.

remote drift
#

yeah...

#

I really wish yield was easier. Can't even use source gen without rewriting compiler 😩

plucky snow
#

hello everyone!! im strugling tryng to implement Animation Curves on a 2D character Movement, i want to use them so i can change freely the way the player accelerates and decacelerates and things like that, anyone can help me?

bleak citrus
#

Don't crosspost.

plucky snow
#

sorry i think the question was more apropiate here...

remote drift
#
  "references": [
    "Unity.CompilationPipeline.Common.ILPostProcessing.ILPostProcessor"
  ]
#

"Unity.CompilationPipeline.Common" this wouldn't work either

#

🤔

lilac lantern
#

I'm posting this in advanced, but I'm not sure if it should go here. I have this class that's essentially a wrapper for a string so I can display a different inspector element for it. Since it only wraps a string, I want it to compare equal to a string if that string matches the id field.

[System.Serializable]
public sealed class TilemapID
{
    public static readonly string[] ID_LIST = new string[] { "base", "foreground", "background" };

    public string id;

    public TilemapID(string id)
    {
        this.id = id;
    }

    public override string ToString()
    {
        return id;
    }
    public override int GetHashCode()
    {
        return id.GetHashCode();
    }
    public override bool Equals(object obj)
    {
        return id.Equals(obj);
    }

    public static explicit operator string(TilemapID id) => id.id;
    public static explicit operator TilemapID(string s)
    {
        for (int i = 0; i < ID_LIST.Length; i++)
        {
            if (ID_LIST[i].Equals(s))
                return new TilemapID(ID_LIST[i]);
        }

        return null;
    }
}
```However, the above will not compare as equal when compared with a string (or another TilemapID class with the same string for id) that matches the `id` string. If I change the `Equals()` override to:
```cs
    public override bool Equals(object obj)
    {
        return id == obj.ToString();
    }
``` it works perfectly fine. My question is, why doesn't it work with the first implementation?
remote drift
lilac lantern
#

I'm confused on what you mean. If the hashcode is overriden to return the string's hashcode, and the equals is overriden to use the string's compare, wouldnt it be equivalent to comparing two strings?

remote drift
#

it doesn't compare by hash

lilac lantern
#
TilemapID t = new("hi");

t.Equals("hi"); // this would be false
```so this is expected?
#

even if t is using the string's .Equals?

remote drift
#

ofc

lilac lantern
#

why?

remote drift
#

whenever you compare 2 objects of different type it's guaranteed false

#

unless Equals implementation does something custom

lilac lantern
#

how is that comparing two objects of different types?

remote drift
#

obj.GetType() == other.GetType()

lilac lantern
#

but

#

id is a string. the Equals method of TilemapID uses id.Equals

#

so shouldn't TilemapID.Equals(string) be equivalent to TilemapID.id.Equals(string)?

remote drift
#

oh, let me see again

#

should be true actually

lilac lantern
# remote drift should be true actually

spent 4 hours on trying to figure out why (only landed on this being the issue at the end), came to the same conclusion, asked on stack overflow, and someone said that I need to change the Equals implementation. They got downvoted for being wrong because the first one "should" work, but... doesn't for some reason? I just checked ab 5 times right now. Having it the first way, false. Having it the second way, true.

remote drift
#

you can simply use debugger

#

to check internal implementation of comparison

#

of .net

lilac lantern
#

I did! (use the debugger) That's how I found out this is the issue

remote drift
#

and see why it returns false

lilac lantern
devout hare
#

t.Equals("hi") would be true but if you compare to another TilemapID object then it's false (because the string id is not equal to a TilemapID object)

remote drift
#

ooh, wait

remote drift
#

Equals assumes other object of same type?

#

yeah, I guess that's why

devout hare
lilac lantern
#

Could it have something to do with how unity uses serialization to expose things in the inspector? The string it's comparing is exposed in the inspector. I didn't actually type t.Equals("hi"), I had it doing t.Equals(variable) - variable being a srting set in the inspector.

#

I still don't see how that would happen though.

devout hare
#

Debug.Log($"Variable: {variable}, id: {t.id}, variable == t.id: {variable == t.id}, t.Equals(variable): {t.Equals(variable)}") and see what it prints

remote drift
#

Just tested this. Returned true

    public class TestClass
    {
        private readonly string _kek;

        [RuntimeInitializeOnLoadMethod]
        private static void Test()
        {
            var kek = new TestClass("id");
            Debug.Log(kek.Equals("id"));
        }

        public TestClass(string kek)
        {
            _kek = kek;
        }

        public override bool Equals(object obj)
        {
            return _kek.Equals(obj);
        }

        protected bool Equals(TestClass other)
        {
            return _kek == other._kek;
        }
    }
tall ferry
#

also idk why i bother trying it in unity, it will run the exact same in the compiler online

lilac lantern
tall ferry
#

Maybe u read the answers backwards 🤷‍♂️

#

the difference is just because of the type sent in the comparison

remote drift
#

Since my question drowned, I'll repeat:
How do I reference ILPostProcessor assemblies in my code?
I tried such asmdef, but Unity is unable to resolve
using Unity.CompilationPipeline.Common.ILPostProcessing;

{
  "name": "ILPP",
  "references": [
    "Unity.CompilationPipeline.Common.ILPostProcessing.ILPostProcessor",
    "Unity.CompilationPipeline.Common"
  ],
  "includePlatforms": [
    "Editor"
  ],
  "allowUnsafeCode": true,
  "overrideReferences": true,
  "precompiledReferences": [
    "Mono.Cecil.dll",
    "Mono.Cecil.Rocks.dll",
    "Mono.Cecil.Pdb.dll",
    "Unity.IL2CPP",
    "Unity.IL2CPP.Common"
  ],
  "autoReferenced": false,
  "defineConstraints": [],
  "versionDefines": [],
  "noEngineReferences": false
}
real vault
#

tried removing the ads package too , but still shows gradle build failed error on build

remote drift
final steeple
#

rare ping in this server, lol

#

I haven't personally used it before

#

I've always done the more manual IL postprocessing stuff

remote drift
#

sadge

#

I need ilpp to run before Unity runs burst compiler

final steeple
#

The annoying thing about ILPostProcessor is that it's not documented or actually intended for use outside of Unity stuff

remote drift
#

yep

sage radish
remote drift
#

🤔

sage radish
#

This was mentioned in the forum post I linked to you

regal glade
#

Is it bad to create new meshes frequently for the mesh filter? I keep leaking meshes and I'm not sure what's causing it. Should I be editing the mesh instead of creating new ones?

sage radish
regal glade
#

alright so the culprit should be my new Mesh() then. thanks i'll test.

#

just gonna do mesh.Clear and pass in the old one

#

yeah that fixed it thanks

lament salmon
#

Yeah any UnityEngine.Object that you create will need to be destroyed or you get leaks.
This includes Texture2D, Mesh, etc.

#

But yeah mesh.Clear is way faster than creating a new one

regal glade
#

thank you

#

rendertexture.Release() does not seem to reduce the texture count however?

sage radish
regal glade
#

ah

sage radish
#

So it depends on what the "texture count" is counting. GPU texture objects, or Unity texture objects.

regal glade
#

I see. So I should do Object.Destroy on it to get rid of it then

#

right?

#

seems to work

sage radish
#

Yes

rancid swift
#

I am trying to load a managed DLL for a dependency, but unity keeps giving me the following error:

Could not load image [...].dll due to Metadata verifier doesn't handle sections with SizeOfRawData < VirtualSize
Run the peverify utility against this for more information.
Any ideas how to resolve this? Turn off the validation?

sage radish
rancid swift
#

I just built that DLL fresh from source, and the error still persists

#

(and it works just fine in a non-unity C# project...)

#

specifically: this is about the Xbim.Geometry.Engine64.dll shipped in the XBim.Geometry.Engine.Interop nuget package

sage radish
rancid swift
#

but yeah, any way around that? We currently start an extra executable and communicate via an intermediate file, which is far less than ideal...

sage radish
rancid swift
#

looks correct?

sage radish
#

I have no idea how C++/CLI works either.

rancid swift
deep escarp
#

hey can someone please help me, i'm creating a mod for a game ( hold fast nations at war) it's a multiplayer game and in the mod i added a driveable vehicle and tested it in the editor and it works perfect but when i launch a server and try to test it in game it doesn't show up ( also now in unity editor the veichle goes half under the terrian and won't let me drive it anymore

glass hill
#

Not looking for someone to analyze this error message, but rather, is there a way to re-target the System.Runtime library? I know how to import DLLs, but even after importing an updated System Runtime, Unity doesn't switch to it. I assume it has something to do with the .NET version but some of this is new to me. Any ideas?

novel birch
#

Looking for some security tips+resources; mainly regarding RCE.

Using MoonSharp to load Lua script made by community. We currently load main.lua file and run that; we looking into supporting require such that a single script can load more lua files.

Anyone know any good steps to ensure the scripts wont load any nasty stuff?

sage radish
novel birch
#

Thanks @sage radish ❤️

I have seen that list -- I am looking for more "general" best practices. As in, only allow a-z script names, load only from root of your mods folder. etc.

I just won't be happy if people can simple upload a random .exe to the community mod and just ..\..\ until they can somehow place it in Windows Startup programs or whatever.

sage radish
novel birch
#

100% wont - way too fiddly to sandbox.

sage radish
#

Then they won't be able to do what you said, unless there is some unknown exploit within MoonSharp that allows them to bypass it.

#

The safe approach is to give your users only the bare minimum at first and then slowly expand capability when they ask for it, and after careful review.

novel birch
#

That's our current approach -- But we see a potential for community driven libraries and functionality to generalise stuff a little more.. So we wanna add the option for scripts to load other scripts.

#

Right now we just have people making monolith scripts which is rather crazy and hard to manage 🙂

novel birch
sage radish
sage radish
#

But understandably, that sort of thing is difficult to support in an official capacity as a developer, since you can't guarantee safety.

#

But if your game grows popular enough and users aren't happy with the restrictions, they will mod it themselves without restrictions. Most modded games are like this, with no official mod support.

novel birch
#

Exactly. We will go with disallow everything at first, but I simple have to figure out where those holes are so I can limit them 🙂 But sounds like I am on the right track at least.

Cheers!

dusty wigeon
# glass hill ```Assets\Scripts\Emailer.cs(54,31): error CS1705: Assembly 'Microsoft.Identity....

.NET Standard 2.1 and the .NET Framework does not possess any library name Microsoft.Identity.Client. You will need to "install the package" which is kinda more complicated with Unity as you cannot change the reference directly. There is nothing to "retarget" as far as I know. However, I know little to nothing in dependency management.

If you want to change between .Net Standard 2.1 and .Net Framework, you need to change the API Compatibility Level which is in the Player Settings.

You also, maybe, want to be sure that whatever package you install is targetting the correct API/Version.

https://learn.microsoft.com/en-us/dotnet/api/?view=netstandard-2.1
https://learn.microsoft.com/en-us/dotnet/api/microsoft.identity.client?view=msal-dotnet-latest

drifting flame
#

lol

dusty wigeon
#

🤷

tawny imp
#

Hello everyone, i did this groundcheck and gravity system on Unity, but i am experimenting an error. When the player touch the ground, still the velocity on y axis isnt 0. Someone knows what is going on?

#

And this is the Update

dusty wigeon
tawny imp
#

This method

#

To fix the velocity on slopes

dusty wigeon
#

Are you using FixedUpdate ?

#

Are you using a Kinematic Rigidbody ?

tawny imp
#

i am using character controller

#

my character doesnt have rigidbogy

dusty wigeon
#

Make your own character controller, that would be a start.

#

This way you could truly control the velocity

tawny imp
#

a character controller without the component?

dusty wigeon
#

Yes. Character Controller is a prototype component. Not something that you should use in your final game.

#

This way, you can truly manage the state/interaction of your character.

#

Optimize it to your needs.

#

Your case, is a case where having your own controller is way easier.

regal olive
#

Hey. Is there any way to clear the Input.inputString?

tiny pewter
#

you have asked it in code-beginner

regal olive
rancid swift
# glass hill ```Assets\Scripts\Emailer.cs(54,31): error CS1705: Assembly 'Microsoft.Identity....

Unity runs on a weird custom fork of dotnet framework 4.72 on mono iirc, with some features backported.
It's impossible to get a dotnet 5 or newer runtime with Unity (they are working on it), but you can install some packages that microsoft did release for earlier framework versions. For example, we use System.Collections.Immutable which is included in the dotnet 5 runtime, but also available as a nuget package. Just need to get your package from nuget (not via IDE, it's complicated. Google it) and hope for the best.

tired fog
#

Hi

#

could anyone explain to me how the ddx and ddy on tex2D method affects the sampling of a texture in unity?

#

And how could I include those two variables to affect it similarly when doing UNITY_SAMPLE_TEX2DARRAY

orchid lichen
#

idk how to explain what's happening here i think the game view is taking the rendered texture from scene view, the script works as it should in scene view and i'd want the game view to have that box rendered correctly from its perspective and not the scene view's perspective. idk if this is the right channel for ask for help for this kinda stuff but i'd appreciate if someone could help idk cus where else to go. i hope u understood something from this shitty explanation lol

tired fog
#

true, will move it there

umbral trail
orchid lichen
orchid lichen
#

i think i'll still need to get the render texture won't i?

umbral trail
#

that is part of what it does, though if this is for a 2d game I'm not sure if it's as appropriate

tired fog
orchid lichen
#

it's so sickening i've been trying to figure out a solution since like 8 hours ago 😭

dusty wigeon
orchid lichen
dusty wigeon
#

If you change your resolution, what happens ?

orchid lichen
#

sec

dusty wigeon
#

Just making sure that it is not a stupid error like that.

orchid lichen
#

yeah nothing

#

literally nothing

#

i can change the resolution to whatever i want it just squishes the texture as it should

dusty wigeon
#

Yeah, I dont know. I would need to do multiple test to correctly understand how it works.

#

Can't help sorry.

orchid lichen
#

yeah understandable np

dusty wigeon
#

Also, next time.
!code

thorn flintBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

dusty wigeon
#

Kinda hard to read

orchid lichen
#

oh

#

sure

#

ty

glass hill
rancid swift
glass hill
#

Maybe I can grab an earlier version of the security package and it just wasn't reflecting the proper dependencies

#

I'll just try a random one and see

rancid swift
# glass hill Does nuget's dependencies page reflect the dependencies of the earlier versions ...

to be honest, I've never understood the nuget page. it's a mess to figure things out.
you should just use the GUI in VS/Rider in a separate C# project to install what you need and then paste the package into your unity project.
there's also a nuget for unity plugin, but that one occasionally breaks for some dependencies and you'll have to do it manually anyways (https://github.com/GlitchEnzo/NuGetForUnity)

GitHub

A NuGet Package Manager for Unity. Contribute to GlitchEnzo/NuGetForUnity development by creating an account on GitHub.

rancid swift
glass hill
#

Sure

#

Yeah the video I watched originally just had me grab the package files and unzip them and grab the dll to put in the unity folder

#

Since Microsoft's SMTP stuff wasn't working. Gotta use MailKit.

rancid swift
patent glen
#

anyone might know why my resolution on simulator becomes pixelled? This only happens in simulator, in game mode is normal

#

i aint sure if it is for this channel to ask, but seems like it

#

forget it found it

regal lava
#

scale ;)

patent glen
#

yeah took me a while :). sort of new. trying to do a project with a deadline next week :')

#

but no mao

#

it wasnt scale

#

it was something in android build

regal lava
#

:O

patent glen
#

🧀🧀🧀🧀🧀🧀🧀🧀🧀🧀🧀🧀

spark raft
#

How can I refresh my gameview while being in the editor

#

Like through an editorwindow script or something

glass hill
#

_>

rancid swift
glass hill
#

Unfortunately that's beyond my expertise at this point

#

I'll have to do some more research

#

Am hmm

#

Seems if I update the unity version to 2022 and beyond, .NET 4.x is available as a scripting option

#

Maybe that will fix it

glass hill
#

Well that plus using the nuget extension did work

#

Thanks for turning me onto that @rancid swift

#

Now it's just a matter of getting the emailer to actually work

rancid swift
glass hill
#

The project was using an LTS version of 2021 since I was contracted last year

#

I had switched Unity versions a bunch on previous projects and caused problems so we hadn't updated yet

rancid swift
#

well, things should be a lot easier with 4.x compatibility wise

glass hill
#

Mhm

#

Now I need to figure out why the emails aren't sending x)

#

We wanted to use an in-program emailer to send a survey response from the user to their teacher by entering their teacher's email (it's for an educational program)

#

So I got the azure certs for the oauth, set up the SMTP code, all that based on MailKit, but not working at the moment

#

No errors, likely because it's an async operation and I haven't set up any callbacks yet, but still not seeing any emails coming through

glass hill
#

Does anyone have any experience with MailKit?

devout coyote
#

I've used it before but that was a while ago - are you trying to send emails from your clients?

#

Unless you have total control of the clients, as in you have full control over which clients have your application installed it wouldn't be wise to use passwords etc

#

Unless you are sending it on behalf of a user, who has their own credentials

#

@glass hill

glass hill
#

What would you suggest? I'm not sure how comfortable users would be entering their own credentials into the program

#

So we had set up an email that can only send, with no inbox, to email from- but that may have been the wrong approach

upbeat path
glass hill
#

I understand. What do you recommend is the most used friendly and secure way of doing an emailer?

upbeat path
#

ask for username/password and process it properly

glass hill
#

Should I just have them copy paste the formatted string and email it themselves?

#

I was hoping there might be some more streamlined way of doing the feature

tall ferry
#

If the fear is that users wont plug in their credentials, there really isnt much you can do about that. I'd even be cautious plugging in my password, no matter how popular the application is.

#

You could provide them the string to copy, though not sure what you mean by formatted string

#

It likely wont copy over too well

glass hill
#

We were trying to remove as much required user input as possible to make the process smoother, and yeah there was a concern about user security. He wants to remove our access to whatever data they have as much as possible to make it feel more secure and safe for schools adopting the program.

#

Copying the mail to the clipboard or launching an external email program would probably be the best solution then unfortunately

upbeat path
#

I've never used MailKit but generally you would have a user register/sign in process and that would register a user with your email server, then you are sending out emails in their name rather than your own this can still cause problems but is easier to secure

devout coyote
#

or if you are just interested in collecting some data

#

Just send it over to a back-end

#

Do validation on the data that you get

#

and send your emails from there

#

care that this still gives attackers access to your system, but atleast they won't have direct access to the email credentials

#

so the worst they can do is send the lecturer a ton of emails

#

but realistically that's always going to be a problem unless you add user authentication and invite them to do the survey specifically

#

I worked on a questionnaire system where we'd generate a bunch of codes, and send those out to users

#

That code could only be redeemed once, for a single questionnaire

#

But that kind of requires you to know where to send the codes to beforehand

#

If you don't know before hand, you could always have them type in a unique onetime code, but you'd have to make sure that their use is authorized, either by them being in a physical location (such as a class room where the code is on a beamer)

#

@glass hill

glass hill
#

We don't have a user system set up yet so for now it's anonymous

devout coyote
#

Sometimes a user system is a bad thing - but then youll have to use codes

#

you familiar with kahoot?

glass hill
#

I am not yet

tall ferry
#

Just curious what is this actually for? Because you mentioned school but university/colleges typically gives out an email to every student which you have to use

devout coyote
#

its an online quizzing program - one person makes room, gets a code, everyone else fills it in on their device

#

and they join that room

glass hill
#

Well this is program for training a specific type of student, and the questionnaire at the end is just for the lecturers to know what responses the students gave to the virtual experiencr

devout coyote
#

There are existing tools that solve this problem

tall ferry
#

You might not need email at all for this

devout coyote
#

or just a office forms app

glass hill
#

Yeah that's where I'm landing but I have to run it by my boss

#

He was adamant we cannot control whatever response system they use so that there's no concern we are collecting any data

#

Since unis are very secure about their students and networks

#

Hence why we don't have a use system or anything like that

devout coyote
#

so if htey don't trust you, then you'd have to use a third-party product that they do trust

#

or have it integrate with their existing products

tall ferry
#

I would stay away from email in this case, especially because itll be so vulnerable giving out credentials to your email made. And if you attempt to have the students send that formatted string to your server, which then sends the email to the lecturer, you might as well just upload the information to some server instead

glass hill
#

Yep. I'll do a little more research and discussion with my boss about it and let him know what yall suggested.

#

I haven't had to tackle a problem like this (mostly do games) so I appreciate the feedback and knowledge

#

👍

tall ferry
#

Thinking about it as well, schools would never allow a system where users type in their password. The only option would be a system where users create accounts if you need to attach some information to a person (like one person sends 2 responses in on different days/devices/locations).
If it doesnt matter who sent it, kahoot style should be fine along with verification. Kahoot did suffer from the fact users can upload the code publicly, then anyone could join putting in whatever bad names they wanted.

glass hill
#

Yep. That's why we didn't go that direction at first. A kahoot style solution might work, but I'll have to see what he wants.

devout coyote
#

People will always grief surveys though

#

Make the code only have x responses

#

Or allow teacher to close it

#

You ll never be able to 100% prevent

#

Without sacrificing the reliability of your survey

tall ferry
#

That wont help the overall issue. The most you can do is deter it by having an account system so that responses are tied to a person. If they grief it, it will be tied to their name. This is why u dont see school emails getting griefed often unless hacked

devout coyote
#

Non anonymous surveys are not good

#

Esp when negative feedback is issued

glass hill
#

Technically my code adds invisible tags to the email at the moment saying which student ID used the program so the lecturer can grade them

#

So it's not actually anonymous

tall ferry
#

How are u setting up those student IDs?

glass hill
#

Ah yes, and there's the issue there- it's entered by the student and there's no verification

tall ferry
#

What would stop me from putting someone elses ID in and doing a 2nd survey, writing bad things to get them kicked out

#

This system definitely needs accounts then

#

Which is annoying to setup but it really has to be used

glass hill
#

Nothing at the moment. Which is another issue we can't exactly address. I'm leaning toward just giving them a button to copy responses to clipboard and prompting them to email the lecturer. My boss seems to have an issue with it though.

#

I don't want to derail the chat anymore so if there was anything else we could make a thread but for now I just need to wait to meet with my boss haha

tall ferry
#

I too dont like the idea of a program giving me a long string to copy paste into my email tbh

glass hill
#

Agreed. But he has a lot of restrictions that we need to follow for whatever solution we do use.

tall ferry
#

Hope it goes well over with the boss UnityChanThumbsUp

glass hill
#

Thanks 👍

devout coyote
#

People should be able to be negative without consequences

#

Else your survey won't reflect the true opinion

#

I am not going to give negative feedback about something if I know I could get in trouble

glass hill
#

Perhaps survey was wrong in this instance- its basically a log of their responses to the virtual experience (the decisions they made in dialogues) appended with a short essay about the experience.

#

That they write in the text box at the end of the program

devout coyote
#

Could honestly just have them fill in their own email

#

Send them a one time code

#

To proof that they have access

glass hill
#

That's definitely a consideration 👌

wide elbow
#

Not sure if this is considered advanced or not but I want to use a render texture of a camera output that is pointing at a canvas with a button. How can I make that render texture register the button click events? Do I have to somehow pass the raycast to the other camera or is there a better way?

bleak citrus
#

loooooooooooooool

#

our student union site got backdoored

#

i reported it to the sysadmin

#

they fixed the defaced site

#

the backdoor was still there

#

i guess they are very big about checking boxes, so they'll be very annoying to deal with

tall ferry
#

now that u mention that.. there were multiple instances in my uni where people got hacked and messaged every single email associated with the school. Also i found some way to have the system spam me with emails, figured that could be potential lag (but ofc didnt try it)

glass hill
#

well yeah to be fair, I'm not speaking to their competencies- just on the front-loaded requirements x) I haven't worked with unis much but they have a lot of concerns and questions when adopting new technology

#

(even if they're not very good at enforcing them afterward)

#

and since this company is technically a startup they want to make sure we can get the widest early adoption customer base possible, so they're being very careful to not have any features that might require the institutions to give us information

bleak citrus
#

It renders a flat canvas, then displays that on a curved mesh

#

Oh yes, this'll be exactly what you need

#

IIRC, it would raycast onto the curved menu, look up the UV coordinate of the hit point, and raycast onto the original canvas

soft shoal
#

Hi guys, anyone knows how to trace how many bytes allocated in heap from a func call by log? Can't use unity profiler cuz I wanna check it in release build.

.Net provide an API, GC.GetAllocatedBytesForCurrentThread(), but it seems dosen't work in Unity, but works in pure .Net console APP.

#

This is what I code, and the log in unity (API returns 0...), and the log in console

soft shoal
#

One possible reason can be, GC.GetAllocatedBytesForCurrentThread only works in .Net Framework, but in Unity, C# runtime is managed by Mono. I'm not sure

sly grove
dusty wigeon
tired fog
#

What would be a faster way to do this?

    public static Texture2DArray GenerateTextureArray(Texture2D[] textures, int size)
    {
        Texture2DArray textureArray = new Texture2DArray(size, size, textures.Length, TextureFormat.RGBA32, true);
        for(int i = 0; i < textures.Length; i++){
            textureArray.SetPixels(textures[i].GetPixels(), i);
        }
        textureArray.filterMode = FilterMode.Bilinear;
        textureArray.Apply();
        return textureArray;    
    }
#

I was thinking with Graphics.CopyTexture, but I cannot manage to get the properties right on the method call

dusty wigeon
tired fog
#

Yeah yeah, I tried that, but cannot get the parameters right.

#

I was hoping that by just doing

            Graphics.CopyTexture(textures[i],0,0, textureArray,i,0);

It would do the trick, but not really

soft shoal
soft shoal
soft shoal
sly grove
#

UniTask is a pretty big thing, I'm sure they know what they're doing

soft shoal
sly grove
eager carbon
#

hi final ik has this feature called head effector which allows you to stabilize your head (useful for full body fps where you dont want headbob)

#

what would be the unity animation rigging equivalent of this?

sly grove
eager carbon
#

i was thinking multi aim constraint on each of those elements, but it didnt work properly

eager carbon
dusty wigeon
#

I mean, doubt any body will know.

#

I usually just do trial and error

#

with Final IK

#

Oh, nvm

#

There is no equivalent for that in Animation pretty sure.

eager carbon
#

yeah i know but i was wondering if i could simulate it somehow

sly grove
eager carbon
#

i thought it would be the same as adding multi aim constraint on each of those elements seperatly but nope

eager carbon
dawn zephyr
#

anyone familiar with UniTask catches whats wrong here? after 1 jump for some reason my token is being disposed

scenic forge
#

Probably the ??= at L4.

dawn zephyr
#

how come?

flint sage
#

If you dispose it, then it's not null and a new one isn't created

dawn zephyr
#

ahhh so dispose just clears the memory and not the pointer?

austere jewel
#

Nothing sets things to null apart from actually setting them to null.

#

Only UnityEngine.Object has the bullshit null equality going on

dawn zephyr
#

lmao

dawn zephyr
#

you guys are saviors tyvm 😄

#

wait so that dispose will never get called no? because its never null

scenic forge
#

Perhaps you are confusing ?. and ??

dawn zephyr
#

mb lol nvm

austere jewel
#

Dispose on the first line will get called if it's not null.
Therefore the assignment on the second line only ever work if the Dispose was never called.
As a CancellationTokenSource is invalid once disposed, then you have a problem, and should not be using ??=, just =

dawn zephyr
#

yea gotcha thank you very much 🙂

bleak citrus
#

The positional bob is way less problematic

bleak citrus
#

hm, implemented this a while ago, so I had to go look at it again

#

I'm using Cinemachine. The camera is set to follow and look in the same direction as an "Eyes" transform

#

The "Eyes" transform is parented to an "Eye Holder" transform

#

That object has a Rotation Constraint on it that copies the rotation of the player

#

I adjust the strength based on how much view bob I want

eager carbon
#

so eyes is not the child of player?

bleak citrus
#

It is. Eye Holder is attached to the head

#

At 100% strength, the rotation constraint will make the Eye Holder point in the same direction as the player's root transform

#

(The thing the CharacterController is on: not on the armature)

#

I rotate the player around the Y axis to do yaw and adjust the local X rotation of the Eyes object to do pitch

#

So, if the Eye Holder is pointing exactly the same direction as the player's root, it cancels out all of the rotation caused by the player's animations

#

and then the Eyes can pitch up and down as usual

#

I have it set to like 70% strength normally, so that there's a little sway

eager carbon
#

hmm i see, i will have to try that out thanks

minor valley
#

i tried that but it always return 1

[SerializeField] private Canvas canvas;


    private void Awake()
    {
        Debug.Log(canvas.scaleFactor);
    }
orchid lichen
#

i have this short snippet running in OnRenderObject() and i'd need it to run different resolutions for scene view and game view, is there a way to detect which view it's currently rendering and then adjust the resolutions accordingly? ik this is a very googlable question but i legit can't find any answers

#

or alternativery a function that returns right values for both scene and game view cus screen.height returns wrong resolution for scene view and SceneView.currentDrawingSceneView.camera.pixelWidth returns wrong for game vierw

sly grove
orchid lichen
#

it runs in edit mode

#

i need it to cover the whole editor view with pixel perfect resolution

sly grove
#

the scene camera

orchid lichen
#

yeah

#

ty

upbeat garden
#

I’ve got an absolute doozy of a problem:

#

I’m investigating a bug in which it seems like a value in a script changes out of nowhere, but only if I inspect the value using the VS debugger.

#

It’s Schrödinger’s variable. This is driving me absolutely insane

#

It gets weirder: while I’m debugging, a getter property on my script gets called, even though it has no call references anywhere in code.

#

But again - only when I debug and inspect certain variables

upbeat garden
#

Yup, I’m that stupid.

mellow plinth
#

How can I request the Burst compiler (in editor) to start jitting a certain method when asynchronous compilation is enabled?

sly grove
#

Which you might have recognized based on your subsequent message?

bleak citrus
#

did you have a getter that changed state

granite viper
soft shoal
granite viper
#

There is very clearly a number of messages after that one

soft shoal
#

I'm talking 1, we are in channel 2 right now. He ask question in both, so do I, but I basically never got answer from channel 1...

austere jewel
granite viper
#

oh I see

#

nvm then

high lake
#

I have a navmesh which is autogenerated by unity and I have extracted its vertices and indices. I want to split up the navmesh into a collection of meshes. (the nav mesh consists of multiple surfaces which are seperated, I essentially want to seperate these surfaces into individual meshes) Does anyone know how I can achieve this?

#

Further more I want to find the closest surface given a point in space. I was going to do this by using Physics.closestPoint and looping over each mesh post separation, but closest point doesn't work on concave meshes which a surface may be.

#

obviously I can iterate over each triangle but I do need this to be performant.

granite viper
#

iterating over each triangle can be plenty performant if you use broad phase filtering