#archived-code-advanced
1 messages · Page 64 of 1
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.
Also posted the question to JetBrains. They've created a feature request ticket for this: https://youtrack.jetbrains.com/issu...02.806161068.1685517004-1179846385.1685517004
Pls upvote this to make it happen 😉
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.
yes, this is exactly what events are for
has anyone experienced their signing key for google play games, not working anymore?
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 😛 ?
SpriteShapeController has a BakeCollider method you can call
@sly grove that doesnt work, just solved this with extending render bounds
Just going through the 2022.2 changelog and struck gold:
https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Physics.ContactEvent.html
Finally a static event alternative to MonoBehavior.OnCollision[Enter/Exit/Stay] (with some limitations)
Gotta keep up with the previews sections of the forums to find out about these things earlier https://forum.unity.com/threads/new-contact-dispatch-for-physics.1254033/
Wait, is the 2022 lts out yet?
Yes
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?
Alright
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
Is there any way can have Coroutines in Zenject Dependency injection framework since service classes are not inheriting from Monobehaviour
Hi. this will work? is this legit?
public void Method(){
CancelInvoke(nameof(Method));
[code executed only once, no cares about how many invoked calls]
}
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.
If it does work, this is terrible design. Use a boolean to safe guard your method.
public void Method()
{
if(methodHasBeenExecuted)
return;
methodHasBeenExecuted = true;
}
The intuition is that you pick the tile that is least flexible -- the one that has the fewest possible choices (maybe only one!) -- and pick one of the options.
You then constrain its neighbors based on the tile your chose.
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
should I use both?
public void Method()
{
if(methodHasBeenExecuted)
return;
methodHasBeenExecuted = true;
CancelInvoke(nameof(Method));
}
No. Why you want to use CancelInvoke ?
CancelInvoke only makes sense if you are also using Invoke
it does not magically stop the function from being called
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
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
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/
Ah, yes, good point. It's not as simple as "how many choices?"
That would be correct if and only if everything had equal probabilities
Least uncertainty, not least choices.
In that case, entropy would be equal for everything. Making it a useless heuristic.
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
Pretty sure it won't. I can be wrong, it is a while since I did entropy calculation.
uncertainty declines as you rule out tiles
I've done a whole bunch of it for a cryptography class :p
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
If you have more choice of equal propability, it will give you the same result.
if you have x equally likely events, the entropy is log2(x)
What is the entropy of 25% 25% 25% 25% ?
you can imagine that as the number of bits you'd need to identify the outcome
2 bits of entropy
vs
50% 50%
1 bit of entropy
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
You are right, it does increase. Must have been an other concept that was normalizing the entropy.
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)
the most surprising thing possible would be to just choose every tile uniformly randomly
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.
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
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
The error System.Linq.Enumerable.First means that it tries to get the first element of something but fails to do so as there is no element correspond. If you could look and see what it is trying to get, you might resolve your issue. Probably something about setup that you did wrong.
How do i look what is it trying to get? @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.
thx
does anybody know how to override Delete key in TMP_InputField so that it does not do anything?
Why would you do that ?
I am making typing game and Delete key should just do nothing
but if cannot be caught in onValidateInput
inputField.onValidateInput += ValidateInput;
You could modify the behaviour of the package by modifying it. If there is really no otherway
what do you mean?
yes, that's exactly what I am trying to do
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 🙄
yep, so..
I do not get it
Take the content of the package, and drop it in your own project.
so I should kinda copypaste the TMP_InputField code to e.g. CustomInputField?
Symptoms:
I cannot modify built-in Unity packages.
Whenever I try to edit a built-in package, the package is automatically rolled back.
Cause:
Being unable to modify a built-in package occurs b...
Not really.
You copy that in your own project:
Then you modify KeyPressed directly or make it virtual.
yeah, I cannot find TMP_InputField there
never mind, I have found it already
should I open it with Notepad for example and modify it there?
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);
}
No ? Use whatever IDE you normaly use.
Hi!
What is the actual error ? What is the object ?
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 ??
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?
Making a thread right now with everything
Take your time, you gonna find a solution. You have everything in hand. I cannot help you more.
You should load it by its name if you mean this. In your code you do: "LoadScene with name index"
public void RestartLevel()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
ok, thanks anyway
UnsafeList<UnsafeList<>>
it may work, i havent tested it
Can you not do NativeArray<float> ?
but if there is any data race, you need search how to implement a lock
The data is already as NativeArray<float> but I have N of those. How can I mix all NativeArray<float> into a single one? (without slowly doing it on the cpu by iterating each value)
or float**
By using a single array that is N x NativeArray<float>.size
yeah, but how do you copy the data from one to the other, without doing it slowly on the CPU
Then you can use array[i * width + j].
yeah, but doing that on the CPU is slow, and width might be really big, so it would be a huge bottleneck. ideally I would do that on a job, but I can't do that
@tired fog try float** and pass a int* array which represent the length of each column and a int for row number
You start with a single array...
So I have a problem where I am suppose
could you explain that further?
?
float** is pointer to pointer and it can represent a 2d array
or you are not familiar with pointer operations?
do you mean a job for each copy? @dusty wigeon
I do not know a lot about job system, but when I do Compute Shader, I use a single array.
if you really dont want to flatten it you may need it or unsafeList<unsafeList>
Since the length is fixed for all arrays, I know exactly where each array starts and ends without the need of a pointer. But not sure how the float** would work
Mmm, yeah, okay, well i think executing n jobs that copy data of a n array to a global array might work
You do not make any copy
You work with the same array all the way.
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
so T**
Ah okay, yeah no. The diferent arrays are results of diferent systems, I cannot make it from scratch as a single array
i think you can limit the high and low index in each job
and I can do that with the jobs system? I didn't know I could have an array containing the pointer of the other arrays without including the other arrays at the job
Ok, then I do not know. I did not have this issue myself and I did not really work with the Job System.
Your array can just contain pointers to arrays produced by individual systems, and access them that way without needing any copying.
I'm not sure how to create that pointer array
you can treat pointer as T
i dont even know if i can pass a T** to job, let me try it
something like
NativeArray<float*> arrayPointers = new NativeArray<float*>(...);
is not allowed
!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.
Why isn't it allowed?
It's just isn't, it throws errors
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
What errors?
I'm not following
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?
same error
i am so lazy to write a new unsafe container
Huh
Well yeah just wrap it in your own struct, it's only a few LoC anyways.
Ah yeah seems like you have to wrap it and then slap on https://docs.unity3d.com/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeDisableUnsafePtrRestrictionAttribute.html
Mmm, okay, let's see
How can I get then the pointer of a NativeArray? XD
Or do I need to use UnsafeList
^
nativearray is a struct, so NativeArray<T>*
if you want get the array (address) you need to use unsafeutility
Also, couldn't you already use UnsafeList inside NativeArray?
no
you cannot put unsafelist in native list or vice verse
only unsafe list in unsafe list is supported
Hey can I repost a question that that was "way out of scope for #💻┃code-beginner" here?
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.
Just use unsafe list to begin with so you don't need to transform at all.
oh it is allowed to have a native<unsafelist>...
Mmm, not feasable
Why not? UnsafeList should have practically identical API surface as NativeList/NativeArray.
to me unsafelist is easier to use since it has a Ptr property and you dont need to call https://docs.unity3d.com/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetUnsafePtr.html
to get the pointer
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
I need to change around 163 fields
Sounds like simple find and replace.
I wish
I mean, that's what you need to pay for to get performance, not sure what else to say.
And i just saw that unsafe list doesn't have the reinterpret method?
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
but how do you get the address of a native array?
^
Aha, perfect, got it working now! Nice!
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)
i remember there is a error like you cant read any data from the native array if the job havent finished yet
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
which Allocator did you use?
try to get the address right after the nativearray is created
tempjob
Oka, lets see
thats why, try persistent
doesn't make a difference
That did the trick
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.
@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
The easiest way to do this is probably to just not use recursion
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
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
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.
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
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.
this is what I refers to "tilt forward"
Gyroscope is the way. No idea what you mean by "the output degree changed" that's kind of the point.
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
Vector3.SignedAngle
With vectors transformed by the gyro input
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
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 ❤️
I would have a GameManager that has the responsability to reload the scene and would increment the integer.
The GameManager is a Prefab being instanced on the first scene and then being mark as DontDestroyOnLoad.
(For a small project)
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**
Usually, you have an entry scene. This scene is the setup scene.
You want to instantiate your object because you want to be able to reuse the setup code everywhere.
oh right idk how i didnt think of it
And the GameManager would be a Singleton as well.
Except that you control his instantiation.
Otherwise, you might have suprise lag spike.
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
For now, you do not have any other use.
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?
On Awake/Start of the level.
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?
If they depend on the level, I expect them to be instanciated in the level.
Otherwise, it depends on the what. Does it make sense for them to be in the same class ?
In thoery, you want to respect the Single Responsability Principle
Thus, having multiple object that holds the responsability of one composant.
so keeping as is in the start method is alright?
Normally, but it can be wrong depending on the situation.
i thought maybe ill need to use DI for it in some way
It is hard to know without knowing everything.
DI is not necessary.
I hate DI, most library are to complex for what you need.
same.. a standard in my local industry though
You do not mean Video Game do you ?
in my country's local unity industry zenject is a standard
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.
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?
You should conform yourself with what other people do so you all talk the same language.
oh yea gotcha
would anyone know about doing this?
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
You need to get a token from a new token source. If a token source is canceled it cannot be reused. Also using a continuation in a task is a little bit weird. You’d just put the continuation behavior on the next line after the await
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
Do you need StartFrightTimer to accept a cancellation token?
if i understood right, does that look right or atleast better?
Yep, was just typing that.
haha okay so when i fill in a cancellationtoken in these functions like delay when i cancel the token it cancels the function?
Yes, it cancels the task that's using the token.
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?
PreviouslySerializedAs but iirc it's only fields and not classes
wouldnt it be nice if there's a Refactor entry in the context menu for scripts 😄
You can rename files, there is no issue with that.
Reference to script are base on guid, not name.
hey
how can I get the angle between 3 points?
the middle point being the center of the angle
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
well basically what I'm trying to do is: I have a velocity direction for my character, and his rotation is independent from velocity, I want to get the angle between direction/heading and front rotation of character
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
this is wrong in several ways
I assumed so
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
again..
that's all you need
ok so then Vector3.Angle(velocity, character.position)?
no
I did not say to use position
I said to use transform.forward
do you not understand what that means?
Quick questions does anyone here having any past knowledge on working on a C# chatbot?
you mean a discord bot? try out discord.net library, they have good docs
Not a discord bot
I am working on vr project where the npcs are all (in short) chatbots
so you can have organic conversations that don't repeat
you do know that chatGPT has billions of dollars of investment
yes but all the software that work with it cost money
you need a chatgpt API subscription, and it aint cheap
Exactly my reasoning
I got it to understand (voice) english perfectly and also spanish but
but you will need a GPU rental probably
If it was this simple, customer service jobs wouldn't exist
which is > 500$ a month
unless you have some massive data source, there really isnt a way to make your own
there are some free models you can run on github
but they are low quality
I will die trying then XD
Chatgpt is required to be connected to wifi
I wanted to make a rpg game that is fully organic in nature
you cannot expect your users to run a model locally
unlikely that you're going to write a local chatGPT that people download on their computers
Especially with rpg dialogue
there's a good reason it's wifi connected
and it's probably querying the supercomputers in whatever datacenters they live in
hmm ok interesting but I am still going to try
for 1 user I estimate you need 15% of a RTX 3080 during a conversation using a big model
you can make your game feel more "organic" in other ways. How many people are really going to sit there talking to your npcs
i would start by making a game
already have but thanks for the heads up
thanks for the info though best of wishes on your own projects
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
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
someone trained gpt on 4chan, the results were quite peculiar
did not know that skyrim had such npcs but that is interesting
llm trained on racists is racist, how peculiar =)
It's really easy to underestimate the amount of willpower some people possess for strictly wanting to screw with other people
yea I have already set in place a blocker for certain words already
yea that wont be enough
I took the first version of my bot to a convention and people were interesting none the less
yea people will find a way
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
true the bots are limited to there "field"
so they wouldn't even start on a conversation in that reguard
I don't think that's right
fair judgement, nothing I say truly matters until you see proof but for now you're just have to take my word
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
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
Well yes if you allow the bot to learn from people
How do you plan on letting your bot learn?
If it's not allowed to scrape the internet?
yes but it becomes repetive
I feed it information released by open source free api that I find
and the information it gets from a player is discarded unless it pertains to the story or a quest
what we need is a chatgpt loop with direct API access to a mechanical body, with full unrestricted wifi and terminal access
but I bet people will probally find a way to get around it
then we will see skynet, finally
well, gptnet, but close enough
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.
welp gl though I am going back to work
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?
One way I did it in the past was to keep the event. In this case it would be the IWorldContext. If someone subscribe after the event, trigger the event directly with the value cached. Like that it doesn't matter when you subscribe and you are sure every components will get the call.
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
}
}
what would you guys say is the most advanced question ever asked in this channel?
Some question are advance, others are not. However, those that are advance are pretty much advance equally.
is there a specific question that took days on end for this channel to answer?
No. There is not. And it would not make it more advance.
oh, what is your definition of an advanced question then?
I have no clean cut definition.
fair enough
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.
Why they were not working ?
I don't even know how to import the libraries to begin with, never imported external libraries into unity before.
It kinda do it, but it was just to know what we are working with.
If it is C#, just drop the folder in ?
Does that work?
I have a MessageBus implementation for the message passing. Do you see adding cache within it makes sense? I'm worried it may put me in a confusion later from where the data came from 😐
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?
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
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.
I would normalize the direction vector you are passing as the second parameter to RotateTowards
Also Vector3.Distance is inappropriate to compare two euler angles
https://docs.unity3d.com/ScriptReference/Vector3.Angle.html is more appropriate
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);?
For some reason I was getting the Cannot modify the return value of 'Transform.rotation' because it is not a variable error, so I assumed you can't do the direct modification
But now it doesn't appear, weirdly
That occurs when you try to modify a struct's members directly via a property https://unity.huh.how/programming/common-errors/compiler-errors/cs1612
It's working now 😩 i can't believe it is working after 2 days of torture
Ah!... i understand now
so, the types simply need to be the same
it can't be vector.x = vector.x, it should be vector = vector
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.
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
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
i have a error with my unity editor
Cool. Don't cross-post, and stick to the relevant channel, #📱┃mobile. Provide more context there.
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.
What build target/ architecture/settings did you use
just linux and release
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.
I've been unable to produce macOS IL2CPP builds on my M1 macbook
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)
Mac IL2PP builds work fine on my end!
Good point, and i have! The resulting linux build produces the exact same error when trying to run it in Linux.
hmm, i'll give it another go soon
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?
apart from the boxing and unboxing overhead anything can be saved as type object
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
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.
compiler and interpreter are just the same thing, both are extremely difficult to wirte.....
Not sure what your game is about, but also consider just embed a runtime for a popular language like Python instead.
Lua is also a popular choice.
nah, want to challenge myself, wanna do everything starting from the bones all the way until I feel it's finished
A tree walk interpreter is actually pretty trivial to implement, but a compiler even for a simple VM is quite a lot of work.
yeah, considered doing that, but as said by the above, I'd like to try something hard
uuuu juicy
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
wow so much help, thank you! :)
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.
c++ maybe better since it provides some abstract data structure in STL
Oh many people have tried
Crafting Interpreter is golden introduction to this field for good reasons.
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?
SerializeField is an attribute on fields not properties
You may also want to look into this https://docs.unity3d.com/ScriptReference/TypeCache.html
ohh maybe that's it
I'm looking for properties, not fields
Yeah that was exactly it!
Thank you @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
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
{
}
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 ?
since unity engineers implement it on this way
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;
}
isn't it a compile error to multiply a vector with a quaternion that way
q * P * qinv shouldn't work
i suppose its more a question of why the math isn't 1:1 represented in its c# impl.
you still could do the M4x4 * someVec3 * M4x4'
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?
I think Slider has that behavior by default?
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?
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.
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.
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
I guess I'll do that. even though the assignment says "we look for optimisation" - because I just realised that 3D objects won't get masked with Viewport of a Scroll Rect, so that's a lot of hoops to jump through if I do it without render textures.
Thanks for your input guys!
does the assignment require all the 3d things to be in motion or have active lighting? Or just 3D appearance?
It's basically an inventory display and it requires items to rotate around
all of them at the same time?
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.
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.
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?
I mean you could just add a circle collider to the bat and then set it up in the collision matrix that they only collide with each other
Add a force on the rigidbody in relation to the proximity of other bats to make it a bit more smooth.
Ok thanks to both of you
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
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.
GZipStream needs no external libraries
I know but I expect it's not nearly as fast as a bursted implementation could be
true, but that's no big deal to convert the code. tbh in my tests the standard lib works fairly well
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 .
2022 is now LTS
what stackoverflow says is usually, how should I put this? 'Terminologically inaccurate'
@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))
what do you mean "you can change the speed to [k-i,k+i] when exploring all neigbhors (the neigbours' speed should belong to [k-i,k+i])" here?
a bit hard to tell without pseudo code....
I read this a lot of times and sorry but i'm not getting it. In general are you suggesting an algorithm that would solve my problem?
you mean whether it will kill anyone? probably not ... you'd have to define "safe" and you can only do so within the context of your project so the only one to tell you whether it is safe for you to upgrade your project to Unity 2022.2 is to give it a try (backup, source control, extensive testing, yada yada) 😉
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
Would anyone mind looking over my character creation controller and tell me if I missed anything?
that sounds very challenging to do for those without context
Don't ask to ask, also test your character controller, then try fix the errors yourself and with google, then come here
I can't find any info on IL Postprocessing. Is there any resource or scripting API for that?
IL - language
intermediate language, specifically
the result of compiling C#
are you thinking of CUDA or somethin'?
that's not what you think it is
IL has nothing to do with the GPU
GPU-accelerated compilation 🤔
i'm sure someone's done it
It's not officially documented by Unity. There's a bit of information about how to set up an assembly to work with ILPP here: https://forum.unity.com/threads/how-does-unity-do-codegen-and-why-cant-i-do-it-myself.853867/#post-5646937
And as far the code itself to define a processor, you can look at other libraries that use it, like Burst, Entities or Mirror Networking.
re: the question, I don't know anything on that front, unfortunately
Burst is not public though?
and entities switched over to roslyn codegen
afaik
The package contains the source code. An old mirror of it is hosted here:
https://github.com/needle-mirror/com.unity.burst
Entities moved most of it to source generators, but last I checked, it still has some ILPP.
🤔
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.
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?
This is for changing the compiler generated IEnumerator to a struct?
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
I would recommend using https://sharplab.io with IL output to see what needs to be changed.
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.
yeah...
I really wish yield was easier. Can't even use source gen without rewriting compiler 😩
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?
Don't crosspost.
sorry i think the question was more apropiate here...
sir. Any idea how to import package into project? Even though I reference it, it seems like Unity can't resolve it
"references": [
"Unity.CompilationPipeline.Common.ILPostProcessing.ILPostProcessor"
]
"Unity.CompilationPipeline.Common" this wouldn't work either
🤔
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?
because comparing string to non-string results in false
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?
it doesn't compare by hash
TilemapID t = new("hi");
t.Equals("hi"); // this would be false
```so this is expected?
even if t is using the string's .Equals?
ofc
why?
whenever you compare 2 objects of different type it's guaranteed false
unless Equals implementation does something custom
how is that comparing two objects of different types?
obj.GetType() == other.GetType()
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)?
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.
you can simply use debugger
to check internal implementation of comparison
of .net
I did! (use the debugger) That's how I found out this is the issue
and see why it returns false
how do I do that? I only really know how to do breakpoints and step into/over/out of stuff, as well as look at variable values, memory addresses, etc.
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)
ooh, wait
but t.Equals("hi") was false
I literally just tested it many times. Only change, one works one doesn't. It's not like there's any errors or anything. It just doesn't work. At least, in unity.
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.
Debug.Log($"Variable: {variable}, id: {t.id}, variable == t.id: {variable == t.id}, t.Equals(variable): {t.Equals(variable)}") and see what it prints
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;
}
}
can u show how u test this? because i try it in unity and t1.Equals("hi") gives true and t1.Equals(t2) gives false
also idk why i bother trying it in unity, it will run the exact same in the compiler online
I don't know. Three people saying that it works like that, I must have messed something up while testing it. I'll just believe you guys lol.
Maybe u read the answers backwards 🤷♂️
the difference is just because of the type sent in the comparison
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
}
did it , but now getting new errors on build , its says there are 2 same main functions cant exist in ggg.c and fff.c and a couple of more errors ,
also tried to export it as a gradle project and opened it in android studio to build apk , but the same error shows there , mostly bcz i am clueless about how android studio works.and their sdk , ndk , gradle versions and so .
tried removing the ads package too , but still shows gradle build failed error on build
@final steeple sir. I remember you mentioned ilpp as suggestion. Do you happen to know about ilpp in Unity? I can't find a way to get started.
rare ping in this server, lol
I haven't personally used it before
I've always done the more manual IL postprocessing stuff
The annoying thing about ILPostProcessor is that it's not documented or actually intended for use outside of Unity stuff
yep
The name of your assembly must be of the pattern Unity.*.CodeGen.
🤔
This was mentioned in the forum post I linked to you
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?
If you don't need the old mesh around, there's no reason you shouldn't edit the existing one. You have to call UnityEngine.Object.Destroy on created Meshes to release them.
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
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
thank you
rendertexture.Release() does not seem to reduce the texture count however?
This function releases the hardware resources used by the render texture. The texture itself is not destroyed, and will be automatically created again when being used.
ah
So it depends on what the "texture count" is counting. GPU texture objects, or Unity texture objects.
I see. So I should do Object.Destroy on it to get rid of it then
right?
seems to work
Yes
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?
Never seen this before. Sounds like the .dll might be corrupted or something. Where did you get it from?
https://github.com/xBimTeam/XbimGeometry uses a managed DLL to calculate geometry for complex 3D models
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
This seems to be a recent issue, which explains why I've never seen it before
https://forum.unity.com/threads/random-peverify-spam-errors.1398223/
To be fair, peverify spits out 15 errors when given that DLL.
but yeah, any way around that? We currently start an extra executable and communicate via an intermediate file, which is far less than ideal...
Maybe try building with different target frameworks or settings and see if it makes a difference? Are you building to .NET Framework or .NET Standard?
I wish I knew how to find out. Ideally I'd build for dotnet framework 4.72, but I haven't worked with dotnet C++ projects yet 
looks correct?
I have no idea how C++/CLI works either.
https://github.com/xBimTeam/XbimGeometry/issues/109 seems like this has been a problem in some way for about 5 years now
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
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?
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?
This documentation should be comprehensive on this topic:
https://www.moonsharp.org/sandbox.html
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.
Do you intend to give Lua scripts access to the file system? The page I linked mentions io as a dangerous module that shouldn't be included.
100% wont - way too fiddly to sandbox.
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.
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 🙂
But yeah; I guess this was my main point that I was afraid of.. A single exploit would be enough to fuck shit up.
Do we know any other big projects that use MoonSharp?
Ok, I understand. There's nothing inherently dangerous about require, as long as you limit what paths can be specified. MoonSharp might already do this, I'm not sure.
None that comes to mind. But when I think of games with big modding communities, those games almost all have full, unconstrained, (unsafe) scripting/plugin support.
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.
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!
.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
hmmm
i see
lol
🤷
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
Is ther a reason why you want velocity to be 0 ?
Make your own character controller, that would be a start.
This way you could truly control the velocity
a character controller without the component?
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.
Hey. Is there any way to clear the Input.inputString?
you have asked it in code-beginner
ye
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.
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
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
i think this is more of a #archived-shaders question?
true, will move it there
I would convert the full screen pass to use the post processing framework
can u link a few articles for me to look into all this rendering stuff is very undocumented and hard to find info on other than the official documentation
i think i'll still need to get the render texture won't i?
ill look into that thankss
that is part of what it does, though if this is for a 2d game I'm not sure if it's as appropriate
there it is
i don't think that'd work for me since i'd still need to draw gl calls on a texture, and that's the part where it breaks
here's a better vid of what's happening
it's so sickening i've been trying to figure out a solution since like 8 hours ago 😭
Are you using RenderTexture ?
yeah i posted the code above
If you change your resolution, what happens ?
sec
yeah nothing
literally nothing
i can change the resolution to whatever i want it just squishes the texture as it should
Yeah, I dont know. I would need to do multiple test to correctly understand how it works.
Can't help sorry.
yeah understandable np
Also, next time.
!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.
Kinda hard to read
That is where I've been getting them actually. I tried going to an early fork of the package to maybe lower the version requirement but no luck.
The 5.0.0 packages usually work, and I remember reading on some unity doc page that that's intended. No guarantees for anything later, though.
Does nuget's dependencies page reflect the dependencies of the earlier versions or only of the latest? When I check earlier versions the dependencies page didn't update.
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
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)
oh, and try the earliest version you can find for the best chances I suppose
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.
I recently asked bing and, well, it just told me to use the REST API endpoint that the GUIs use on the nuget page to download the nupkg files. So that works. Can't remember the exact URL tho.
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
scale ;)
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
:O
🧀🧀🧀🧀🧀🧀🧀🧀🧀🧀🧀🧀
How can I refresh my gameview while being in the editor
Like through an editorwindow script or something
I tried a bunch of versions but it seems all of them depend on a higher version of system runtime
_>
Then the last option: make an extra executable and launch it from unity. Communicate via files or sockets. It sucks but works for emergencies like these. But you might need a custom installer for the runtime you're using
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
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
oh wait you werent on that already? I just assumed
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
well, things should be a lot easier with 4.x compatibility wise
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
Does anyone have any experience with MailKit?
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
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
you really, really really do not want users sending email using your credentials
I understand. What do you recommend is the most used friendly and secure way of doing an emailer?
ask for username/password and process it properly
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
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
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
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
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
We don't have a user system set up yet so for now it's anonymous
Sometimes a user system is a bad thing - but then youll have to use codes
you familiar with kahoot?
I am not yet
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
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
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
There are existing tools that solve this problem
You might not need email at all for this
or just a office forms app
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
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
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
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
👍
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.
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.
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
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
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
How are u setting up those student IDs?
Ah yes, and there's the issue there- it's entered by the student and there's no verification
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
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
I too dont like the idea of a program giving me a long string to copy paste into my email tbh
Agreed. But he has a lot of restrictions that we need to follow for whatever solution we do use.
Hope it goes well over with the boss 
Thanks 👍
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
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
Could honestly just have them fill in their own email
Send them a one time code
To proof that they have access
That's definitely a consideration 👌
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?
speaking as an academic type
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
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)
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
this reminds me of how NeosVR does its curved menu
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
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
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
Unity profiler gc alloc thing will tell you I believe
Profiler.BeginSample - Profiler.EndSample will track the GC.alloc.
Maybe there is other function in the Profiler API that you could use too.
https://docs.unity3d.com/ScriptReference/Profiling.Profiler.html
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
Currently in Unity texture arrays do not have an import pipeline for them, and must be created from code, either at runtime or in editor scripts. Using Graphics.CopyTexture is useful for fast copying of pixel data from regular 2D textures into elements of a texture array.
https://docs.unity3d.com/ScriptReference/Texture2DArray.html
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
Right, I did use profiler for development build. But I want it on release build. profiler stuff only works on development build
I want it on release build, that's why I'm trying log
Specifically, I'm checking if UniTask.Delay can generate GC or not. Based on their doc, development build will have GC (I already saw it on profiler), release build won't. So I want to confirm it on release build\
I mean... I'd just trust them lol
UniTask is a pretty big thing, I'm sure they know what they're doing
emmm...my case, it's a long story...but yes, maybe this case I just trust UniTask, but I want to know if there's way to log GC info in Unity, that's what I'm focusing
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?
Not completely sure. Perhaps Aim Constraint or Multi-Aim Constraint?
But... #🏃┃animation might be a better place to ask
i was thinking multi aim constraint on each of those elements, but it didnt work properly
eh i doubt they will know
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.
yeah i know but i was wondering if i could simulate it somehow
Well there's all kinds of stuff in the animation rigging package https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/api/index.html
i thought it would be the same as adding multi aim constraint on each of those elements seperatly but nope
yeah thanks i will need to look into it
anyone familiar with UniTask catches whats wrong here? after 1 jump for some reason my token is being disposed
Probably the ??= at L4.
how come?
If you dispose it, then it's not null and a new one isn't created
ahhh so dispose just clears the memory and not the pointer?
Nothing sets things to null apart from actually setting them to null.
Only UnityEngine.Object has the bullshit null equality going on
lmao
Very based.
you guys are saviors tyvm 😄
wait so that dispose will never get called no? because its never null
Perhaps you are confusing ?. and ??
mb lol nvm
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 =
yea gotcha thank you very much 🙂
I eliminated most of my head-bob by just forcing the camera to point in the desired view direction
The positional bob is way less problematic
by just using LookAt or..?
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
so eyes is not the child of player?
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
hmm i see, i will have to try that out thanks
i tried that but it always return 1
[SerializeField] private Canvas canvas;
private void Awake()
{
Debug.Log(canvas.scaleFactor);
}
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
Camera.current is a good place to start
nope, ion want it to be rendered on the cam
it runs in edit mode
i need it to cover the whole editor view with pixel perfect resolution
Scene view is also rendered by a camera
the scene camera
nvm my bad it returns the scene cam too
yeah
ty
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
Yup, I’m that stupid.
How can I request the Burst compiler (in editor) to start jitting a certain method when asynchronous compilation is enabled?
The debugger calls the getter
Which you might have recognized based on your subsequent message?
did you have a getter that changed state
lol, this channel...noboby there
I think your discord is broken
y?
There is very clearly a number of messages after that one
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...
That they weren't answered in a completely different discord isn't relevant to this discord, and is just off-topic.
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.
iterating over each triangle can be plenty performant if you use broad phase filtering