#archived-code-general
1 messages · Page 168 of 1
I remember getting this error in my project randomly without using any of those methods when I was working on using the gui system, try restarting the editor
im not using the find statement. im kinda new. is there something else i have to watch out for.
That should be the case unless he's really working with Editor scripts
do all three of em have the same issue?
will try thanks
dunno. Only the players have rigidbody2ds.
all 3 of the casts I mean
and this is the physics2D settings:
If you aren't writing Editor scripts, it may be a false positive. A restart of Unity would fix the issue.
I want an interface to force anything that implements it to have a specific static method. is there a way to do that?
lets start with the individual casts, which one is failing? all of em? ground? wall?
thanks what do you mean with false positive?
you cant have an instance of a static method
Something went wrong
not until c#11
wait what
holy shit brb I gotta go read about that one, thats zany
it's how they implemented generic math. you can even overload operators with interfaces
just tested by removing gravity from the players and moving them over each other: both checks are triggering when colliding with a player layer object, without other collisions happening
so "all of them"
ahhhh, interesting
I know. I want the class that implements it to have to have a static method that I can call without an instance
what I really want them to add at some point is a Self constraint one day
and yes, it does make sense for it to be static.
like
public interface ISomething
{
public TSelf DoAThing<TSelf>()
where TSelf : Self;
}
and literally all the Self constraint is, is that the generic is literally the thing itself
@pure cliff I've been called for dinner, can we continue this after in DMs? Sorry about this. ^^'
I prefer not to do DMs, in case other folks have a similiar issue its good to be able to link em to it, and other people can chime in if they know an answer
thread might be more appropriate
ah okay. I'll make one real quick
not really. more like
public static int DoSomeMathSpecificToYourImplementation(int x, int y);
to build on above: then if you implement:
public class Something: ISomething
{
public Something DoAThing() {
}
}
would vaguely satisfy the conditions. Something roughly like that I hope exists one day
can I use public static virtual? and override?
whats the method you are trying to make
I have an electrical grid. Certain types of course parts will take in input for a direction they are getting electrified, and output a new set of directions to electrify, which will have ints for intensity assigned to it (like a big Vector4Int).
shit needs a static method. do not need an instance
CastFilter incorrectly triggering
@pure cliff made the thread #1138613253971398666
whats your reasoning for that, so Im on the same page
because it is going to be on a monobehaviour that does not need to be instantiated
if I have like a diode, I don't need an instance of a diode for the diode to tell me : if left, output right. If not left, ignore
that is tied to the definition of the class
MonoBehaviour that does not need to be instantiated
well that can't possibly be correct
not possible. static methods cannot be overridden
strategy pattern
as it often always is XD
You're issue is you are trying to put this method on your class itself, but it has no need to be there
well I have no need for it to be in an instance
You just need a single Dictionary<Thingy, ConductivityBehavior>
you know, some of these functions are going to get big
A way to map between the two
and each of these classes that implements this interface will need to be implementing other interfaces with more behaviours
what got you tripped up was that you wanted to put this static function on the class itself, but thats not necessary at all
sir, if I make a capacitor script, I do not want definitions for what my capacitor does in 4 different files
just so I use the right lexicon, whats the class of your block thingies called
TileMonobehaviour
bro nothing makes sense, I have a game object tagged, and yet there is no collision. My head hurts man
thanks
aight, so you basically want this:
public class ConductivityManager
{
// Fill this however you need to
private Dictionary<Type, ConductivityBehavior> BehaviorMappings { get; }
public ConductivityBehavior For<TTile>()
where TTile: TileMonoBehavior
{
return BehaviorMappings[typeof(TTile)];
}
}
@hard viper
And then ConductivityBehavior is just a readonly struct, and the really slick part is you can re-use em with params
Or even just have 1 single struct and its purely paramaterized
im fairly new to this so, as a student I want to be able to fully understand these code chunks before I absorb them into my games
And you just go
var behavior = ConductivityManager.For<MyConcreteTile>();
as of now this is what I have,
{
public Rigidbody2D rb;
public float jumpAmount = 10;
public int jumpCounter = 2;
public void Start()
{
jumpCounter = 2;
}
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "JB1")
{
Debug.Log("Jump Boost Obtained!");
Destroy(collision.gameObject);
jumpCounter++;
}
}
I have my item tagged aswell which is what confuses me
#854851968446365696 so you know what to include when asking a question, and #💻┃code-beginner for this type of question. The link boxfriend gave you goes into MANY reasons why your code may not work
- use the CompareTag method to compare tags rather than string equality
- go through the link i sent, it takes you through everything you need to check to make sure that collision messages will be sent
I just checked it out, ill take a look
@somber nacelle I am also now realizing those static methods on interfaces mean that implementing strategy pattern will now be a little bit easier, as you can map the relation between Strategy <-> Consumer without needing instances of the Strategies up front, and can instead build the map first and then load the strategies on demand lazily, thats slick
so abstract/virtual static members of interfaces were introduced in C#11
so they are supported. but not for us
I figured out a workaround. I can just give the base class TileMonobehaviour the static virtual method.
I could try the strategy pattern, which is what I originally wanted, but some of this stuff is going to grow really wild, so I need to keep each part more centralized. I will keep that in mind tho
what do you mean by "grow really wild"?
that class can have multiple methods in it
and I do not want the definitions to get very separated
You can put more than 1 method on your strategy
again: I do not want to go to 4 different files to see the definitions of what a tile is supposed to do
You can more than 1 strategy also
you... wouldnt
like for your FooTile, youd have a FooStrategy, and it would have 4 methods on that one FooStrategy class
If you ever needs to have that much strategy, you might have over generalize your object.
Also, you can create a custom editor if you want to centralize the serialization of different parameters.
I have a tile SO with a bunch of flags for a tile. It can have a prefab associated with it, it can have a monobehaviour tied to it. and several situations need all 3
which is why I want to keep actual script tied to one tile to one class
I do not see the issue there. Flags are flags. It can be a list.
I'll need to think this over for a bit
If you have shared behavior, how would you "keep it together" ? You cannot define things in multiple class.
Are we talking about more behaviors in general and not purely just this conductivity problem now?
the way he described it earlier was that I’d have a conductivity controller class which contains all definitions for all tile, which I am not doing
it could take references to functions. Having that map is ok.
Cuz I would say based on how complex your tiles are, I think you need to just get used to the practice of encapsulation and abstraction, it is not a bad thing at all for your 1 "thing" to be spread over multiple files, because that way usually leads to being able to re-use stuff and it means your principle "concepts" have been decoupled and encapsulated
but I won’t make one mega file with all the functions for every tile in one scenario.
Im not sure what you mean here
Maybe you are generalizing before needing it ?
i’ll need to read more on the strategy pattern
my game requires a lot of generalization
If you do no need multiple strategy, you do not implement the strategy pattern
Otherwise, you spread over multiple files
Yes, however you should not feel like things are too spread out.
If so, you probably have overgeneralize.
It is like doing an interface for every interaction between classes
its pretty much just a Dictionary at the core of it
basically i am making a 2D game, i wanted to implement a jump animation to my character so i tried two different ways
Did you follow a tutorial on how to make 2D games ?
If not, start there.
yes but wait
one way worked fine, the other didnt, im not sure why the other one didnt work
i will post both the codes here
📃 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.
can i not send it as an image? it is small
No.
It's funny that these channels are separated into code beginner, general, and advanced, since there are beginner questions in all channels
Just a thought
True
is that the right format?
(However, most people that are above beginner are able to answer themselves)
if this is the right format, then im not sure why this code doesnt work
oh
It's pretty difficult to filter correctly but it is expected that folks who post here know a bit of the api and code - although not always.
I think it's the slanted quote
Yeah true
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
if (isGrounded)
{
if (Input.GetButtonDown("Jump"))
{
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
animator.SetBool("isJumping", true);
}
else
{
animator.SetBool("isJumping", false);
}
} ```
Also, ask your question
i see
yh so im not sure why this code doesnt work, when i run it, the jumping animations dont trigger
I would start by attaching the debugger and putting a breakpoint just inside the if (isGrounded) check, to verify you are at least passing that part
basically, putting the breakpoint on this line:
if (Input.GetButtonDown("Jump"))
i was hoping that by pressing the spacebar, it would trigger the animator to set the "isJumping" bool
but it doesnt
im not sure why
if you never hit the breakpoint, then you know isGrounded is always false for some reason and your logic is off there
i see
I'm using the XR interaction toolkit and I'm trying to get the interactor that is grabbing the grabbable object. I have it wired to an interactable event on the grabbable but when I look at ActivateEvents args, I see I have a args.interactorObject but that's of type Interface IXRActivateInteractor. How do I just get the gameobject?
the only difference between the actual working code and this code however, is the fact that animator.SetBool("isJumping", true); is outside the second if statement
is your breakpoint getting hit?
ohhhh my god
i see now
i see the problem
yes my problem was the logic on that line
i feel so stupid, and i most likely am. Ive had visual studio, instead of visual code. im gonna die :/
visual studio is better than vs code
OH, WOO
but it dosent have a stupid unity integration that i can tell, so im getting code
!ide 👇
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
smexy
it still not work :(
regenerate project files and restart visual studio. if that doesn't work, check the solution explorer and if the project shows there but is unloaded then right click and reload with dependencies (though theoretically restarting should do this)
it shows that it is loaded, but it dosent autofill
like i typed some keywords and none of them autofilled
does it suggest anything or is it only not suggesting unity types?
it suggests stuff, not unity tho
screenshot the entire IDE window, preferably with the solution explorer visible
wait, something popped up
Miscellaneous files == not configured
shoot, one sec, something popped up to download, so im downloading that, but one second and it'll be mega restarted
ok, the donwload thingy worked, hurayy
Recreating chess.
I have a class ExplorationResult that has two public fields,
public List<Vector2Int> ExploredGridPositionList;
public List<Piece> HitPieceList;
-
ExploreDirections()creates anExplorationResultobject and returns it.
TheExploreDirections()is a general method and is potentially used for different usecases. -
Each chess piece needs to know where it can move, and where it can attack.
Pieceinternally usesExploreDirections()to determine this information.
Now,
I need to store this information, If i store it in an ExplorationResult variable inside Piece, I can simply look at ExploredGridPositionList to know where it can move, and look at HitPieceList to know where it can attack.
My question is,
Does it make sense to use the same type for both usecases? I feel like it is not very readable when using it for the second case, but also does not make sense (For example, class MoveSet) to create the same exact class with a different name to hold the same data.
What do i do?
I think this is a little over complicated. You probably just want a List<Vector2Int> legalMoves;
attacking and moving aren't really different things in chess
(yes pieces like Pawn can only move diagonally when attacking but that's ok)
basically - for each piece, calculate all the valid moves.
And if you're making an AI, then for all the valid moves for all the pieces, evaluate the board that would result, and pick the best position from those boards
that's the basic idea
I've thought of only using the gridPosList, but im using the Explore method to just look for pieces too, so tried to make it generalized
Although, you're probably right, i can still use that class for the explore method but store the legal moves in a simple list i suppose
you don't really need to "look for pieces"
as long as you recognize that a board location with an enemy piece on it is a valid place to move.
no no, thats for a different usecase of that method
in another usecase, i just needed to get a list of all the pieces hit by the exploration
I fail to notice what are the two distinct use case.
A piece have a list of valid move. Those moves are either landing on an other piece or an empty space.
You want to know what pieces could be possibly be captured ?
You want to know what are the legal move of the current piece ?
hello I'm something new, is there a way to imitate the grab, drop and throw objects from half life 2?
ah
So what im doing is, each turn, instead of calculating every single piece's possible moves, i only do it for pieces that are relevant.
-
To do this, I
ExploreDirections()(all directions) from the piece that just moved (Both from it's old pos and new pos) and calculate the moves for the pieces returned by this method. First usecase. -
But to calculate the actual moves, for each of the the pieces hit above, each piece explores appropriate directions (Eg. Bishop - diagonals) using the same method
ExploreDirections()to find where it can move/attack. Second usecase.
Why would you want to know the legal move of the piece that are being hit ?
because those piece's moveset could have been changed from the previous move
For example, consider this board
The bishop cannot move towards the bottom left direction because the pawn blocks
To be honest, I would recalculate the whole board to reduce the possibility of error.
Each time it is needed
But once the pawn moves, it can now move in that direction too, so its moves need to be recalculated
I don't see how it matters which piece most recently moved?
Event base approach are risky
@leaden ice This
In other words, I wouldnt cache the result. It does not seem to be that expensive to calculate.
My thought process is, at the start of the game, all piece moves are precalculated and stored.
Whenever a piece moves, a few pieces now have new moves available, so only those pieces are recalculated and stored, and the rest already know their precalculated moveset
You are trying to hard to optimize a game that does not need to be.
Start by recalculating everything.
When it is needed
It will reduce the probably of incorporating bugs.
Chess programming is extremely well described, there is no need to innovate
Thats fair, I will be trying to make this game multiplayer, so i'd like to have it optimized as much as i can, but not just that, i also see it as a personal exercise to try to write optimized code
If i ever encounter bugs with incorrect calculations, i can always switch to recalculating every piece's moves each turn or calculating when clicked on the piece or something, since i will only have to change when the calculation happens
- Make code that works
- Make code that is clean
- Make code that is optimize
(Keep those iteration relatively short)
Also, preemptively optimizing is most of the time a bad idea.
You want to be able to mesure the impact of your change.
That being, said, there is also a minimum to do.
By minimum, I mean, do not allocate 3G of data on the ram without having any other alternative.
In that case, we can even say that it does not work.
Yes don't disregard performance completely
Stuff like proper data structures should be taken into consideration at all times imo
I understand, i did start out with those three steps and ended up here. The only reason i optimized this is to challenge myself, with the assurance that if something goes wrong, reverting is extremely simple since only the when code needs to be changed, but all the calculation logic still remains the same
To some degree.
If you want to challenge yourself, you gotta first measure how well things are running.
Then, see how you can optimize it.
This way, you are "data oriented"
I completely understand your point, but i'd still like to have my original question answered incase i run into it under completely different circumstances,
In the case where a data structure with the same data needs to be used for multiple different purposes, what do you do?
You are asking if it is ok to use a function in two context. Yes, function are made for that.
I am asking about the ExplorationResult class, not the ExploreDirections() method
do you mean like have a game manager object that stores data that can be accessed by any other object in the game?
ExplorationResult is the result of ExploreDirections isnt ?
yes
Then, yes, it makes sense to use ExplorationResult in two context where you want to know about the result of the exploration.
@warm aspen Here is my initial question
I'd make a separate class that stores the state in a static variable
There's also the scriptableobject route
ScriptableObject wouldnt really fit here. We are talking about runtime data.
I use scriptableobject as data channel between classes a lot
Also, the result is per piece I imagine, not really something you keep in static.
Hm
That is different.
We are talking about stocking the result of the research of a piece after ExploreDirections
Okay i misunderstood then
I'm struggling to understand the issue
Whatever you proposed makes perfect sense to me, i don't know why you're considering making a new class
in the original question you ask if it makes sense to use the same method "in both cases". What both cases? In the question I only understand one case: the piece trying to determine which spaces it can move to and which pieces it can attack
Even if the cases are different i see no issue with reusing the same class
It still represents the same data. So maybe just name your class better to reflect what it is (though this is obviously hard to do)
Not using the method, using the same Class: I clarify the cases question here
So at the moment, each piece stores its moveset as an ExplorationResult variable, this is fine yes?
but wouldn't there be cases where the movement of a piece A affects the possible moves of a piece B even though B isn't hit by the exploration done by piece A?
I couldnt think of a situation where that's the case. The only possibility of that happening is knights, to counter that i'm just recalculating all knights every single move
I agree with @steady moat that I would just recalculate everything for every piece after every single move
but what if the knight is the one that moved last?
Yes, i will switch to that approach if i run into any bugs or incorrect calculations, it is a single method change.
then that wouldnt be different from any other piece moving
his exploration might not hit some pieces that would be affected by his new position
how?
Other pieces can only have new moves if
- The old position was blocking moves
- The new position now blocks moves
so if the piece that last moved frees a space for the other piece to move, how does the other piece know this unless it's hit by the first piece's exploration?
why try to optimize so much? A simple platforming game does more calculations than that every single frame, you would just do it once after every move
because im exploring from the old position in all directions
oh, you explore from the old position and then again from the new position?
yes, all the pieces hit from both those explorations are recalculated
Ok. Yeah, I see it. I still think it's overcomplicating something for almost no gain, but I understand now
I'm unsure why you are needing to calculate that. It would seem to me the only time a movement set matters, is when a piece is selected. So I'm unsure what the intent is myself...
I've already explained above, just as a personal exercise to see how well i can do, and if something goes wrong, it is a simple change to recalculate after every move
Unless it's for the AI maybe. Not judging just curious.
I was assuming it was for the AI
Agreed, Its just that when i started out i didnt know how expensive exploring everytime was, so simply cacheing the moves and referring to the cached value made 'logical' sense. (Not talking about if it makes practical sense)
It is always good to challenge yourself, and definitely learning about pathing systems and methods can be valuable
I probably wont be working on the ai, but since i already have all this optimized work done, i dont see how reverting would be better (unless there is a flaw in my design ofcourse), reverting to calculate ever time is simply just making it less optimized (however tiny the diffence is) for practically no benifit, i feel
I do agree it's over complicating it, however, you likely would cache all the available moves in a turn and then assess the best path for a possible strategy (for an AI). I'd probably recalculate every turn, but if you did only calculate the differences, it could be used to assess a risk to the AI strategy.
I.e. an AI could tell easier from incremental movements if a strategy is at risk. But if going down that path, I'd strongly recommend reading up on any existing methods for chess AI
For PvP, I'd only calculate available positions once a piece is selected, and maybe everyone once a piece is moved (although you probably dont need that data). And probably use Events and Delegates to create a message if a global refresh is needed. So it only runs the calculation when absolutely required.
But off the hop, I'd only calculate the movement options for a selected piece on selection, and leave it at that. You usually don't need to know any other pieces moves. Unless it is AI, I think.
You could even just calculate if the move is valid once the player selects a target space
or when he hovers over the space with the piece selected
Yeah absolutely. I'd only precalculate it for highlighting
although you could give some visual feedback to show which spaces are free to move or to attack
side note, it being multiplayer doesn't really have anything to do with the performance. The clients would be simulating the game entirely on their own, and only syncing simple commands like "opponent moved thing on a5 to b5" and they would do that move on their local machine to "sync"
but maybe you were referring to accessibility
Bit of a funky one but has anyone ever had issues with code running on a mac version of the editor but not windows?
My game runs completely different at home to on my work computer
I'm currently trying to detect which TMP_InputField was in focus after the user click on a button. The problem is clicking anything will reset all the input field's isFocused to false. What's the easiest way to work around this?
When I made apk for android, I set the aspect to 16:9, but my phone runs it at 20:9 since thats my aspect ratio.
But when testing with Unity Remote it uses 16:9 but the UI is squished.
My question is, how can I fix the issue so its not squished when resized to 16:9 and how can I force it to use 16:9 even if my phone is 20:9(like adding black bars maybe if needed or perhaps resize UI somehow to match.
Canvas scaler:
https://i.gyazo.com/2ac58139b85a437de04fc3239f02774f.png
yeah but I dont want apk to work only for 20:9
nor do I want to test it on all possible aspect ratios
is there a way to make it scale automatically without stretching
maybe aspect ratio fitter and parent all elements to that?
Tbh I assumed my phone is 16:9, not 20:9 😄
you can also experiement with the Match slider, i use 0 most often
Yes it was at 0 before.
canvas scaler is the issue I think
cuz it uses 1920x1080 which is 16:9
you do need the scaler though, otherwise your UI straight up won't work for different scren sizes
nice
Hi ! Since you can't directly put a ternary in a interpolated string ($"{condition ? resultA : resultB}") since : ends the interpolation, would having a first string that stores the ternary result then interpolate be lighter/better than having a string.Format ? Purely informational, I currently have a string.Format.
$"{(condition ? resultA : resultB)}
should work
It does, thanks.
Hi!
I'm trying to control the animation controller via script with a single blend tree that has all of the poses. Since I do everything via script, I'm using a direct blend tree with no transitions.
I noticed that values seem locked from 0 to 1 (both in the inspector and using animator.SetFloat()). Is there a way to set a negative value with direct blending (I'm using a generic rig, not a humanoid either)? The docs doesn't say anything about a limitation like this.
moving this to the animation thread*
What is the definition of Varyings ? Is it internal stuff ? It looks like it doesn't contain any uv field
that's what i've been trying to figure out actually, it's a package so i'm trying to hunt it down
i don't know much about hlsl so i wasn't sure if it was a language thing
#archived-shaders maybe..
You might have more help here https://discord.com/channels/489222168727519232/497874081329184799
right okay, ty
Hi, I'm using Invoke to call a function. It works on the Start void but not when it's inside my custom functions, is there any way to fix this?
Code? That's not really very much to go off.
void HitPrefect()
{
scoreManager.noteScore = "Perfect!";
Invoke("setNoteHitToZero", 1.0f);
}
void setNoteHitToZero()
{
scoreManager.noteScore = " ";
}
(HitPerfect is called when a key is pressed)
You need to show how you're calling HitPefect
Yeah, that and please use nameof
Also they're called functions, not voids
Are you actually sure HitPrefect is called?
Put a debug log in.
i did and it is being called
Can you use nameof, might fix it, might not
The other thing I can think of is the invoke is being interrupted somehow, like the script being disabled, gameobject being disabled, something stopping all invokes, etc.
Thank you!
is there an effective way to prevent elements of a vector3 from growing to a NAN
why it will become Nan?
im manually computing collision forces and im facing an issue where an object forced into collision accumulates infinite velocity
by sum(mv) before=sum(mv) after?
I used to use a float velocity, I just checked "IsNan" but now its a vector3
so do the same on each component of the vector3
Ah, okay, I was just wondering if there was a better way
clamp the x,y and z values to float.MaxValue
nah that doesnt work if the value going in is a Nan
AKA exceeding infinity
I presume because by definition of Nan it doesnt know whether its past positive infinity, negative infinity, or whatever
i just wonder why the velocity will becomes infinity, the mass is zero?
no, its because I base the depenetration force on a factor of the velocity, so it scales exponentially
(*((int*)&some float)&0x7f800000)==0x7f800000
Vector3 v3;
if (v3.x + someFloat == Single.Nan) v3.x = float.MaxValue;
or float.isnan
I did it a bit differently, I just used a temp variable and based the axis assignment on whether the result is an NaN
so if nan then keep the previous velocity on that axis
I need to deserialize json into a Dictionary<string, object>.
Googles MiniJSON can do this, but contains native code and can't be used in WebGL builds.
Unity.JSonUtility and Newtonsoft does not seem to be able to this.
Anyone know of a solution?
How did you serialize the json in the first place?
Using MiniJSON on a Desktop build. So yes I would like to solve the inverse case also, serialize a Dictionary. But is not as important
Pretty sure Newtonsoft can
I think I could use Newtonsoft JsonConvert.DeserializeObject<Dictionary<string, object>>(json); and the recursively go through the result and convert any JObjects and JArrays I find....
It's really just a question of looking at the json produced by miniJson and emulating it for another library
i mean json is json but you do need to understand it
I would prefer not to write my own json parser 🙂
no need to write you own parser. but you do need to understand the json strings produced
Nothing strange about the json. The problem is that the working deserializers are tailored towards targeting objects with fields directly, and not create a Dictionary
so you make it a 2 stage operation
public IEnumerator FadeOut()
{
var timer = 0f;
while (timer < 1f)
{
Debug.Log("fadeout");
vignette.intensity.value = Mathf.Lerp(0.322f, 1f, easeOutQuint(timer));
liftGammaGain.gamma.value = new Vector4(
liftGammaGain.gamma.value.x,
liftGammaGain.gamma.value.y,
liftGammaGain.gamma.value.z,
Mathf.Lerp(0f, -1f, easeOutQuint(timer)
));
timer += Time.deltaTime;
yield return null;
}
}```would anyone know why whenever i run this coroutine in one place, it works fine, but when i run it somewhere else it doesnt appear at all? the debug statements are being logged.
What should I do when my vector is "too small" to be normalized. Is there a mathematical formula to normalize it by myself? I'm asking because .normalize returns zero
How do I correctly get all the vertices of triangles in a mesh (for simplicity lets say a cube) that look in the same direction as transform.forward? Right now, I have this code:```cs
public void CalculateFrontBounds(){
Mesh mesh = GetComponent<MeshFilter>().mesh;
int[] triangles = mesh.triangles;
Vector3[] vertices = mesh.vertices;
for(int i = 0; i < triangles.Length/3; i++){ //Loop through every triangle
int triangleStart = i*3;
Vector3 p0 = vertices[triangles[triangleStart]];
Vector3 p1 = vertices[triangles[triangleStart+1]];
Vector3 p2 = vertices[triangles[triangleStart+2]];
Vector3 triangleNorm = (Vector3.Cross(p1-p0, p2-p0)).normalized; //Get the normal of the triangle
if(triangleNorm == transform.forward){ //If the triangle is on the same plane as the forward facing face(s) is
AddNewPoint(p0); //Adds a new point if another point doesnt exist with the same position
AddNewPoint(p1);
AddNewPoint(p2);
}
}
}
Which, to me seems like it should work, but the problem is that ``if(triangleNorm == transform.forward)`` seems give me wrong results, but instead ``if(triangleNorm == transform.up)`` gives me the vertices of triangles that look in the same direction as transform.forward, but even doing that doesn't work at all when I rotate the transform on the y or z axis.
Also, I noticed that mesh.vertices and mesh.triangles is 3x what they are supposed to be
Probably for like saving the uvs n stuff tho
I think you could multiply the vector by 1000 and then normalize it because that, I believe at least, should give the same answer
I looked into the strategy pattern, and I’m already using it. TileMonobehaviours are classes tied to my TileObjectBase SOs, which are listed in a big dictionary class which just holds a bunch of dictionaries to tie the different TileObjectBases to tiles. Once it gets to my ElectricalGridManager, it already has a reference to the TileObjectBase, which has a field corresponding to its TileMonobehaviour type. I just needed to make sure that the TileMonobehaviour implemented a function for the conductivity behaviour strategy IF the TileObject has a flag saying to expect it to have that function implemented.
This is why I was confused with your suggestion
thanks
Comparing float is never a good idea.
what? How could I use that to get the front face's vertices?
if((triangleNorm - transform.forward).sqrMagintude < 0.01f))
oh like that, k I'll try it
that unfortunately still didnt change the outcome
Not exactly sure what is the idea of the function
However, you are correctly itering the vertices
When I have a class or component which only needs one implementation, is it still a good idea to derive this class from an interface for the sake of programming to an interface instead of an implementation?
Actually, I think I have an idea how to solve my problem, but if I just compare which point is closer to another point, then couldn't I do ```cs
Vector3 posOffset1 = targetPoint - point1;
Vector3 posOffset2 = targetPoint - point2;
float distance1 = Mathf.abs(posOffset1.x)+Mathf.abs(posOffset1.y)+Mathf.abs(posOffset1.z);
float distance2 = Mathf.abs(posOffset2.x)+Mathf.abs(posOffset2.y)+Mathf.abs(posOffset2.z);
if(distance1 < distance2){
blah blah blah
}
instead of comparing the sqrMagnitudes in terms of speed?
Like would this work, or is there a problem with this?
And if it would work, then would it be faster than sqrMagnitude?
SqrMagnitude is the Sqr of the Distance
There is no need to actually do the sqrt here.
Also, your distance calculation is wrong.
distance = sqrt(posOffset1.xposOffset1.x + posOffset1.yposOffset1.y + posOffset1.z * posOffset1.z)
Also, there is no need for 3 points. Only 2
Is it not possible for VSC colors and highlight to work properly when editing files from inside Packages folder ?
nvm i think i need to add assembly
so I basically want to create a dungeon system for my 2d game with handcrafted rooms , can I use tilemaps to create each room prefab or would that be too inefficient
I'm asking this in the wrong chat aren't I 💀
Tilemaps are for tiles
You could use it if your rooms are static but i guess they aren't so you'll have to make your own system
Hey there, I'm having an issue with animations right now
I've tried to add a new property to my animation clip, which is the sprite renderer of the "sprite" child object.
I've used EditorCurveBinding.PPtrCurve() to bind the property to the animation clip, more specifically this was the line of code that was being run
EditorCurveBinding.PPtrCurve("neph/sprite", typeof(SpriteRenderer), "m_Sprite")```
And yet it marks it as missing! Should I change `"m_Sprite"` or something?
alr
ty
Welp, fixed this; the issue was that "neph/sprite" should be turned into just "sprite" only, because the path specified for the property starts from the first layer of children gameObjects. If it's left empty then you are referring to the parent object. Nvm
You use Strategy Pattern multiple times, its not a "one and done" sorta deal.
This is just another behavior/strategy if you will, "In what way does this electrify things" is yet another strategy to select.
Its quite common/normal to nest strategies in a tree, it forms a varient of a Behavior Tree effectively speaking.
Each time you hit a fork in the tree, that is strategy pattern, one is a subset of the other.
Its a good habit to be in professionally, I dont bother with interfaces on my data classes ("is a" models), but I always try and interface my services.
Makes mocking em up easier (btw, RIP moq D:)
Thanks, that sounds reasonable!
Hi I want to make the green line only active with selected skin, it's should look like this: (example image)
How can I make it?
void Start()
void for all buttons
active selected color = green outline
sth like this
!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.
Wth does UnityEngine.SceneManagement.Scene.GetRootGameObjects() want me to give it as input? (https://docs.unity3d.com/2021.3/Documentation/ScriptReference/SceneManagement.Scene.GetRootGameObjects.html)
nothing
for the first version
but everything is pretty well described there
Then hy do I get this error? error CS0120: An object reference is required for the non-static field, method, or property 'Scene.GetRootGameObjects()'
because you are trying to call it statically
when it is not a static function
you need a Scene instance to call it on
"An object reference is required"...
You're probably looking for https://docs.unity3d.com/2021.3/Documentation/ScriptReference/SceneManagement.SceneManager.GetActiveScene.html
Like the current scene I am in?
if that's what you want
whatever scene you want to get the root objects for
oh, I though that SceneManagement.Scene did that for me, but I guess not
What to do, to not snap to the standard position in the scrollview?
#📲┃ui-ux
I think you can select Movement type to unrestricted, or clamped.
forgot which
thx
- what are the things you include at the start of a C# script called? (the
using blablah.blah;) - how can I make custom ones that work like a C++ library (as in, any script in the unity project can have
using custom.name;and use functions from that like a C++ library)
Why rectmask doesnt work properly on dark blocks?
C# will not include all libraries for a single script, cuz u wont have few hundreds line of code that will use all the C# function possible
- using directives
- using directives only are for namespaces. They are not the same as libraries
by default, only minimal libraries are included
If you want a "library" you make a .NET assembly or a Unity UPM package
are there some tutorials for how to use them?
the only thing that using SomeNameSpace does is just let you write SomeNameSpace.SomeClass as SomeClass without the namespace
no, I just want it to act like one
normally i will just have few static classes to hold some custom extension functions for me to use lol
thats it, enough
it's very simple
they're more or less just part of the class name
I'm overthinking it
I want something like the raycast function, where you write physics.raycast(...) and the raycast does something in the scene, but something custom for my game like output.send(...) which a circuit in the game would use to output data.
I don't really understand this question but it sounds like you just want a static function
and every circuit component would have a using GameNamespace.Output in order to access the function
Sounds like you want some kind of messaging layer between different objects?
When object x does something, you want to inform object y without directly talking to it?
Idk if that's the proper name, but I think it's called something like Event Bus (Pattern) or just a simple Observer, depends on what exactly you're trying to do
no, no, the code for communication is in the function, what I want to do is have an arbitrary script (like an extra one from a mod for the game) to have access to that function
so the question is modding?
Ok, the things (arbitrary scripts) that want to access that function could subscribe to the output.send thing which will then inform them when it's called?
yes
in most cases where you want code mods support you use Harmony and expose some base class/interface for mods to extend from
modders will reference your game dlls in their project, access whatever they need, use harmony patches to modify code when needed
the only thing from you that is needed is some entry point, mod handling, and certain code style that simplifies modding
I don't know how to explain well what I want to do, and I don't know if what you're suggesting is what I want to do.
If you want (code) modding support for your game, that's probably the fastest way
I think what my ideal for this game would be is to have all of the circuits in the game be made the same way a modder would make them (like a json for definitions and a c# script for the functionality)
What do you consider to be a circuit, could you give a small example with pseudo code?
and then what the compiled game does is construct the parts at startup for example
example for a "rotation reader":
json:
- model
- rotation axis, attachment point
- output rotation and location
c#: - read axis angle
- sent that value to output
Ok, I begin to understand.
Why would you want to separate data and logic into separate file(format)s?
That's just making it harder I guess, most mods or add-ons may have a json or xml file coming with it, but those are mainly informational, things like the version and name.
Also, there are some different approaches to do this on your own, but I'd say they are not easy to execute
a json is easier to read/write, and expandable
But then, strip the C# File completely and have the C# logic live in your Game
And make the Json file store a function name and an execution Style
So your game reads those form the json and knows "ok, I should call X function with Y parameters in Z style"
Execution Style being for example Update, OneShot etc
I'm inspired by scrap mechanic, where the json file is used to define static "values" for a part (name, color, placement type, and script location), and a ||(lua)|| script that adds the functionality for a complex part in the game
and the lua script can use the scram mechanic api to interact with the game world
That's probably because Scrap Mechanic has a LUA Interpreter included in it's Runtime, but not sure, never played.
I once tried to create generic modding support and ended up tinkering with my own ScriptingLanguage for months, that's another possibility.
You could read into melon loader to make your game available for modding.
If you want to do it from scratch, this is gonna be hard
it uses a custom engine that isn't written in Lua, but that's off-topic
That Custom Engine could still include a LUA Interpreter/Compiler in it's Runtime, else it wouldn't understand LUA
still off topic for what I want to do
I think*
It's not off-topic, you could do the same, include some kind of LUA Interpreter/Compiler in your game.
I think you're underestimating the work you need to do for modding support 😄
Options so far:
- Use Harmony
- Use MoonSharp
- Create a SL from Scratch
- Use a JSON that holds data about which function to execute with which arguments which would be handled by your Game
The last one would be the easiest as of now, if you understand the concept, but also the most limited.
Example of how Cities: Skylines did it
https://skylines.paradoxwikis.com/Modding_API
The game ships with a C# compiler which allows for automatic script compiling at game start.
Including a Interpreter or Compiler is the way, if you use a pre-existing one or create your own is up to you.
Even the JSON Approach would basically need some kind of Interpreter
Hey there, does anyone know which IK solver does the Unity Two Bone IK use?
on that note, Logic World (also made in unity) uses C# scripts for modded parts.
I know some sort of interpreter or compiler is needed.
I've observed that I pretty much always get stuck at how "things" communicate with each other (script with script, json to script, ...lua interpreter with script)
For a simple scenario, they wouldn't communicate with each other, your game would read the mod and understand what it says.
The mods could be limited to using only the pre-existing building blocks that your game provides.
Each building block would just be an ID and a function call that takes a variable count of parameters.
I'd love to give you a concrete example, but I'm on my phone and typing code on it s.... hard.
I'd advise you to fiddle around with writing a simple interpreter and VM from scratch, that'll deeply improve your understanding of the process that happens behind the scenes when you write and compile a script, it'll definitely help with understanding how Code Mods work.
It's not too hard, don't become intimidated!
that's like writing visual scripting
Each building block would just be an ID and a function call that takes a variable count of parameters.
And? 1st, it's not, it's less flexible then Visual Scripting, but 2nd there are full blown good games out there that solely rely on Visual Scripting, so it's definitely good enough for modding..
Eventually you could start a thread to further talk about the modding "issue"
I'll give you an example for a pseudo JSON file
FunctionID: ModifyPlayerHealth
Parameters: 1
Execution: Update
or
FunctionID:
CreateEnemy
Parameters:
GetRandomEnemy
GetRandomPosition
Execution: WorldLoad
of course 90% would be strings, it's JSON, you gotta interpret those strings and find out if they are meant to be functions or whatever else, basically you need to Tokenize the JSON into your own format before Interpreting it
FunctionID: AddCustomEnemy
Parameters:
myEnemySpritePath
someAttackValue
someSpeedValue
etc...
Execution: GameInit
yeah, but then you have to add every function, and probably use all of them in the game.
In order to make something other people can use to create new stuff, you need to have some way to do extra computation, like math and control flow, so you would make a function for those, and then boom, you have a stupid json interpreter
Yeah, that's why it's called Modding SUPPORT, you gotta support it.. 😄
It's up to you what the user can and cannot do with their Mods, it's tedious but you have maximum control, also it's easy
If you don't want a stupid JSON interpreter, then utilize, as already stated, an existing solution like MoonSharp or Harmony, or create one from scratch.
I'm out, sorry, I've given enough information on the topic, not much more to say.
You'll get it done if you try, definitely, would be happy to see the results!
Yes, I know, I already stated I know that.
I'm gonna dig further into moonsharp
@floral coral Lua is popular for C++ games, I know that, as there's a lot of solid "ready to use" libraries out there that effectively let you define a C++ function but then expose it as callable from a Lua wrapper.
Another option you can do for C# are plugins dlls, where the user must create a .dll of their own that meets specific criteria (has a specific method exposed on a specific class or etc), and then they drag and drop it into a specific folder and your game scans there looking for "recognized" .dlls that match the requirements.
I have a game that allows player to create a levels and give them names. I save those levels into json file. What is the best way to call those json files? Just the name of the level that has to be unique, the name that is generated by custom ToJsonName method that deletes all spaces or int id?
Hello. I am using Addressables and it returns Asset as an "Object". Does boxing happens there since its a base class of Y?
public virtual Object Asset;
x.Asset as Y;
I would probably name the files with the name the player gave the level.
Another option is to just use a UUID as the filename and put the level name in the json itself, but it would make it harder for users to copy level files around manually if they wanted to
Do I have to parse those names?
anything that is an asset you can get with Addressables is going to be a reference type. There won't be any boxing, they're already reference types
parse what names
My nice level blabla => Mynicelevelblabla.json?
you would have to parse the json to get the level name in the scenario when the level name is part of the json.
if it's the filename then you just grab the filename
no, json will contain actual level name
I would probably also give them a .mygamelevel file extension for example too
why..?
well, they will be in specific folder
Oh! I read something like "Boxing is exists for only value types" i understand now that well. Thank you.
Assets/#Levels/MyLevel.json
Helps the user in avoiding drag-dropping completely random json files, if their extension is the same
when you download a game, do you have an access to all scripts??
alternatively when theyre sitting on some website or distributed through discord wouldn't it be nice if they have a custom file extension so you can identify them?
well, probably..
wait, no
it doesn't matter
they won't have an access to file itself
they will be able just to view a level in the game
with already instantiated items
so it doesn't really matter
you don't want your players to be able to share level files with each other? You know they'll go looking for them
if you're saving them as json files they will be able to do this
Yeah what's the point of a level editor and storing these in files if it's not possible to distribute them?
probably though the game?
like "share my level with foobar123"
sounds like a lot of work for you
you'll need a whole friend system, user login, authentication, etc
well, I have done the basics already
and then users will still complain "Why can't I just give a level file to someone"
yes, I have done authentication already, it is stored on another branch of my git
well, I think I will make them able to download levels from the link?
also I have created level system for the host for now
so no authentication rn
just levels that are created by host
But does it make sense to generate an id in format AvJ12SPfa3AN139SaP13Hy98 ?
well how do you want to generate the ID
it really should be some sort of checksum of the contnet
well, a for loop with e.g. 20 iterations first
and generate A-Z, a-z or 0-9
quite easy, right?
so it will be AvJ12SPfa3AN139SaP13Hy98.json
but why that instead of it being based on the real content
or using a established method of getting a globally unique id
for example?
like a SHA256 checksum or a GUID
depending on if you want it based on the content or just want a ID that will not clash with a other generated id
well, there can be several names with My nice level name probably
an id
i am talking about all the content
like the checksum would be for the entire contents of the file
I will probably just create a method that creates a unique id
then would use the built in GUID then
and the level should be found by its it..
but can I control what it generates?
if I want just A-Z, 0-9
why do you need to control that, dont you just need a ID that never clashes
if the players will find levels by id, then I want to control that
ok and what happens when the same ID is generated twice
new id is generated?
ok so your intent is to check the database every time a ID is generated
while (listOfAllIds.Contains(id))
GenerateSmth();
and hope its never done concurrently
it won't be done concurrectly I guess
also the chance for it to generate the same id among billions of combinations at the same second isn't that high
i am likly just thinking at the wrong scale, am used to dealing with databases that can get rather large
and where i would want to ensure the same thing is never stored more then needed
well, I will do that without a database first
also thank you all for your help 😄
also 10 letters (A-Z or 0-9) is 3,656,158,440,062,976 combinations
pretty reliable
it might end up with things ids larger then you want, but this would be a nice way to always get the same ID from the same input file
public string CheckSum(string filePath) {
using var sha256 = SHA256Managed.Create();
using var fileStream = File.OpenRead(filePath);
return Convert.ToBase64String(sha256.ComputeHash(fileStream));
}
so if 8 billion people play this game, the limit of levels each person can create is 457,019
obviosuly could format in otherways that are not base64
can I control string's length?
why i mentioned it might get longer then you want
yes, I see no problem in creating my own one then 😄
its main advtange is, its gives the same ouput for the same input file
and can be used after the download to verify the contents are what was infact requested
yes, but there can be a few levels with the same names
it would not compare the name, but the whole level
there can be 2 absolute identical levels
thats what GUID does :p
if you are storing in a DB though, with a server, your database should handle what ID is assigned
when a player saves the level, the server will tell them what ID they were assigned by the database after it has been saved
Hi, I have an object that has a script, and a trigger collider - and the script does not register callbacks. This is solved, when I add a kinematic rigidbody to the script. This is caused by the fact, that a parent object has a rigidbody, so all callbacks go to that object. Is there a way I can override this behaviour on a case-by-case basis without adding kinematic rigidbodies?
This is a work thing, and I'm forced to use a framework, and one of its features is that it turns all rigidbodies on certain objects into non-kinematic ones under certain conditions... it's more stupid than I can express with words, but I can't do much. It's how the system was made, it wasn't prepared for my usecase.
which is why I don't want to use rigidbodies
Trying this again, this time with a minimized project with only the integral details pertaining to my issue: I have a script which is triggering a cast filter on the incorrect object.
Player objects have a component called "TouchingDirections" which has three bools: IsGrounded, IsOnWall, and IsOnCeiling.
IsGrounded should be true when the player is touching the FloorColl layer.
IsOnWall and IsOnCeiling should only be when the player is touching the Collision layer.
Players touching other players should not be making any of the casts.
All objects colliding with the player are triggering all casts anyways.
what's your script?
and, assuming you're using unity collider collisions what's your layer collision matrix?
oh whoops didn't mean to send that yet. I'm prepping a small project to show off the problem, one sec.
Scene: CollisionDebug (if the player objects are invisible just pop the Square sprite onto their child sprite renderers)
The physics2D settings should only allow collisions between Players and FloorColl, and Players and Collision. Not Players and Players. Yet for some reason, it is.
the weird part is I have another project where a similar script is used but this problem isn't a thing. And I don't know why that is.
You'll need to move the "players" via the editor btw
I'm installing this unity version, but I read up on some documentation already
do you have proper layermask set up in your ContactFilter2D?
there's two contactfilter2ds. groundFilter should only be checking the FloorColl layer and wallFilter should only be checking the Collision layer
if it's not then something went wrong when zipping but that's how it's set up on my end, so that's not the issue.
Is there a way to blend the animations in a blendtree?
As you can see, its just changing direction instantly without smoothly transistioning
Yeah, they are called BlendTrees https://docs.unity3d.com/Manual/class-BlendTree.html just like you said.
That is also what I am using
I got the issue! Spot the difference:
So what is the question then?
it works with that change
@main shuttle It does not look smooth, it just cuts to the new direction
Of course it was something ridiculously simple as a checkbox flattens
thank you
no problem! Happens constantly to the best of us
is there a way to have a script-sided gameobejct? something that doesnt actually exist in the scene but I can assign components to?
I need to preserve transform axes of the object I have this script assigned to, so it would be helpful to be able to handle transforms in a nested object. I would prefer not to require an actual child gameobject for this script to function.
Don't think so - but many of the constituent members of a GameObject can be ... so if your just looking to deal with its Transforms you could have a private Transform as a member of a class that is not related to an instantiated game object
if I also have a private collider can I assign that collider the private transform?
Well you can certainly have a private Collider or Collider2d as a member of a class.
Having both private Transform and a private Collider would not be the same relationship as if they were attached to a gameobject though.
Usually you would do something like:
`
public class MyGreatClass : MonoBehavior
{
private Transform myTransform;
private Collider myCollider;
public GameObject myPrefab;
private void Start()
{
var go = Instantiate(myPrefab);
myTransform = go.GetComponent<Transform>();
myCollider = go.GetComponent<Collider>();
}
}
`
well I would like to orient a script collider with a script transform to use computePenetration on, I would have to add together the transform position and script transform though
i have few issues with my code, that i just dont understand how to fix. so one, the object that is tracing towards me needs to stop like 10 feet behind me, and im not sure how to do that, two, the object needs to start moving immediately, ive noticed it only starts moving whenever i stop moving, and three, i need a better way for the object to know im not looking at it. i was thinkin raycast but i havent seen any good way to do it online
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class CatController : MonoBehaviour
{
public Transform target;
[Range(0, 1f)]
public float Range = 0.5f;
[Range(0, 5f)]
public float Speed = 5f;
void Update()
{
transform.LookAt(new Vector3(target.position.x, transform.position.y, target.position.z));
float viewGap = Vector3.Dot(transform.forward, target.forward);
if (viewGap > Range)
{
transform.position = Vector3.MoveTowards(transform.position, target.position, Speed * Time.deltaTime);
};
}
}
Yeah .. sorry not really fully understanding your use case - but given best answers I can.
Its possible that Unity's way for you to do this is to really use the real gameobject in question - and you are going to be homebrewing something very custom.
Maybe change:
`
float viewGap = Vector3.Dot(transform.forward, target.forward);
`
to
`
float viewGap = Vector3.Distance(transform.positon, target.transform.position);
`
doing that makes him move when im looking at him, instead of the opposite
Sorry had to adjust my code sample, I didnt adjust the variables inside the Distance check at first
now he moves the entire time
Well your default value for the movegap is very small ... .5f
Depending on the size of the following object and the object that you are comparing it it might be that any movement at all easily falls in to your .5f range?
well, the object is a cat, and ill up the range, see what happens
so nothing happened, i up-ed the range, and the cat kept moving the whole time, and then i went back to the original script, and nothing changed
So reading your code .. the pseudo code I would write for it (exposing the intent) is:
1: Look at the target
2: Calculate a "viewgap" which is the distance between the object and the target
3: if the distance between the target and object is greater than the specifie drange then move forward.
With that being said it seems to make sense (if the above check outs)
The only other thing I'm seeing as note is you might be mis-using Vector3.MoveTowards.
https://docs.unity3d.com/ScriptReference/Mathf.MoveTowards.html
The docs here are very weird - they are assigning the output to a currentStrength float, whereas you are assigning it directly to a transform.position . I'm not sure what the intended behavior here really is.
I'm not by any means sure that is your issue - but call it out because I don't understand what it should really be doing - so its at least worth looking at a bit?
I say this is weird because a transform.position is a Vector3 - but this function outputs a float.
So your assigning a float to a vector3 somehow - not sure what that does for movement - but maybe it does weird things and keeps moving?? 😄
(you picked the wrong link - Mathf.MoveTowards does operate on floats, Vector3.MoveTowards on vectors, but they essentially do the same thing)
Thanks for catching that didnt see theres more than one type for that function.
Then I retract my statement 😄 not sure what is going on - possibly some other behavior affecting whats going on??
for the little nudge, i think it might be something to do with the model and physic stuff
but it should be fixed if i can get the follow to stop a bit behind me, but i got 0 clue on how to get it to stop at a certain distance behind the player model
Well theres manual control and physics systems.
It looks like you are manually controlling it otherwise you'd be doing something like rigidbody.AddForce or such.
So in the manually controlling area .. I would think just stop telling it to move and it stops
i know, i can set it to stop. i just dont know how to set it to stop when it gets to a certain distance, but at the same time, i dont want it to stop behind a wall im next to just because its close to me actually
Respected, is it possible to stop the particle system immediately when user don't touch the screen..
Anyone knows how to fix the validition failed prblbm
@turbid seal Don't spam code channels.
K
Btw i i tried but didnt work
run it as admin
This is a code channel, general Unity issues go in #💻┃unity-talk, thanks
Is there a way to display an array of strings as an enum-like dropdown selection list in the editor window?
To be exact, I need a single string variable, that is displayed as a selection of a few specific options from an array of strings.
I have a list of item names that I want to choose from in the editor (Specifically in a node in a dialogue system(the image), that redirects the conversation flow depending on if player has or doesn't a certain item in their inventory).
Normally I'd just make a simple enum and be done with it, however, my list of items is being loaded from a file, and it is, naturally, expected to change during the game's development. Keeping enum in sync with it would be a pain, and leaving the parameter in the node be a string field (as it is now currently) opens possibility of bugs and errors due to typos.
Write a custom inspector or use NaughtyAttributes or Odin
Is there a way in unity for me to add to what happens when prefabs are made?
Like if I create a prefab could I have it create an SO in the same place and populate it with the data of the prefab?
Not been able to find anything but I think I found a way to add my own "Create Item from prefab" button in the context menu, so I can right click the prefab and then make the SO from it.
I will work on this for now but if anyone knows of a way to automate this on prefab creation, please let me know! Thanks 
Does anyone know why when I put [SerializeField] and [Range()] on my privat variable, it doesn't keep the values after entering play mode? It seems like SerializeField doesn't work
are you sure you aren't reassigning the values in Start or Awake?
What's the code look like?
[SerializeField] [Range(3,6)] private float number
.
Bunch them together with a Comma
[SerializeField, Range(3, 6)] private float number;
Are you sure you're not assigning another value to this variable somewhere else in the code?
this is unecessary FWIW and wouldn't cause any bugs one way or the other
I was making some custom gravity modifiers to make the jump of my character feel nice. It works, however there is some funky stuff going on...
There are two gravity modifiers, one when the character is going up (jumpGravity) and another when the character is going down (fallGravity) If the character is standing still, there should be no gravity modifier (it would be set to 0)
But then, even when the character is not moving, the gravity modifier is set to fall gravity instead of 0 for some reason.
And then some funky stuff goes down when dragging the character while in play mode...
are you sure the debugs line up with what you labelled them to be? Id add some text to ensure this like $"Gravity modifier: {gravityModifier}"
(Although i shouldn't be doing this to begin with i guess)
Yes, but i'll do that just for sharing reasons.
your character is likely just adding a ton of speed over and over, since your velocity would rarely hit exactly 0
think about the case where you are falling. your speed is negative, and in SetPhysics you are constantly adding gravityModifier * Time.fixedDeltaTIme
Regardless if its not moving because its stuck against an object, its still gonna add
aight, thankyu brother!
It's calculated automatically based on the desired height of the jump, and the time it should take to reach that height.
I should put a vertical speed limit tho
How do I make an animation for a UI element that can be used by any other UI element irrespective of their position. Cuz right now, whenever I try to make an animation, it uses their global position so all of the elements with that animation get thrown to the same position
Or is it better to just code the animations?
I would suggest you use DOTween instead for UI animating, if possible. Sorry I don't know the answer for your direct question
Ah, yes. Code the animation!!
Ahh okayy thank youu, will try DOTween
The documentation has examples too, so it's pretty easy to pick up
I suggest you get the hang of DoTween sequences. Very useful
I just installed C# dev kit and Unity extensions to VS code and this error apppeared in my project. What can I do?
lol, an A: drive, haven't seen one of those for many a decade
doesn't matter
It probably does not matter in your case. I was just amused to see it
A: was the floppy drive iirc
Second answer could help you https://stackoverflow.com/questions/76534533/unity-intellisense-with-vscode-not-suggesting-autofilling
void BuildMesh()
{
Mesh mesh = new Mesh();
mesh.vertices = new Vector3[]
{
new Vector3(0, 0),
new Vector3(0, 1),
new Vector3(1, 1),
new Vector3(1, 0),
};
mesh.triangles = new int[] { 0, 1, 2, 0, 2, 3 };
GetComponent<MeshFilter>().mesh = mesh;
} ```
a square is supposed to appear but none appears help
did you set a material?
you need to add a component called meshrenderer which has a material
to what
to the gameobject which has you mesh creation script
still doesnt appear
https://www.youtube.com/watch?v=64NblGkAabk
Maybe this helps, he explains how to generate a mesh there, you don't need the procedural part if you want to do different things
Generate a landscape through code!
Check out Skillshare! http://skl.sh/brackeys11
This video is based on this greatwritten tutorial by Catlike Coding:
https://bit.ly/2Qd1o1d
● Perlin Noise: https://youtu.be/bG0uEXV6aHQ
● More on generating terrain: https://youtu.be/wbpMiKiSKm8
● Singleton: http://wiki.unity3d.com/index.php/Singleton
♥ ...
i literally tried this
Your code works fine. Where are you calling BuildMesh ?
What is better/More performant?
go to mesh generation thread
maybe delete that and write that R properly for ontrigger.
I also dont know what "where--" is but the one on the left only stores 1 list but accesses it through a reference (i assume). The one on the right stores a list per other class, and presumably uses an event to send that collider. If you're checking for performance in time, this is something you'll have to profile yourself or benchmark.
In terms of memory, its kinda obvious
oh those are brackets
Sorry. So, on the left you have a manager class that stores every collider it interacts with and the dependent classes each filter the colliders they need. On the right you have a manager class that just fires an event, and the dependent classes each have a list where they can add the colliders they need through if statements. I'm more so asking what is better to use in the situation where there are a few tens of "other class" objects and one manager class. I don't know how Linq .Where() works. Maybe it's fast enough to call it on every onTrigger event. Because without .Where(), I will have to handle the storage and removal of colliders in each dependend class, which is annoying
it'd be worth profiling still if thats a concern. 10s of classes really isnt much.
You are looking at a time-memory tradeoff basically, do you want 50 classes each storing a list, or 50 classes to filter through a list.
If accessing the list a LOT, I would go with the one on the right, where you filter if you should add a collider as you get them. If rarely accessing the list, id go with the one on the left
alright thanks. Imma do the left implementation because I'm lazy. If my potato laptop will lag, then I will have to do the right one
When I generate a script in c# it was able to figure out the return type.
Was it luck?
Now that I try it again it returns object
[SerializeField] private float mana;
[SerializeField] private float manaRegen;
[SerializeField] private int gold;
internal object GetGold()
{
return gold;
}
internal float GetMaxMana()
{
return maxMana;
}
public float GetCurrentMana()
{
return mana;
}
So i have a dilema where I want to be able to call this only 1 time but be able to "refresh" i guess would be a lack of a better word, the PASSIVE Abilities Buffs if say the level got changed.
I've been trying to think of how to not put it in Update, cause that will just call the passive buff to be added over and over again. Not really sure how to implement this without someone basically looking at all my code?? I would assume.
TLDR: I want to "use" the passive ability ONCE but keep the Buff rolling infinitely.
Snippit of what I was calling in update to test VVVVVVV
GetAbilitiesFromCurrentJob().Find(x => x is PassiveAbility && !x.BuffsBuffsCanStack).Buffs.ForEach(x => x.ApplyBuff(Character as Player));
What im currently also trying in Start to test VVVVVVVVV
private void Start()
{
foreach (var ability in GetAbilitiesFromCurrentJob().Where(ability => ability is PassiveAbility && !ability.BuffsBuffsCanStack))
{
((Player)Character).PlayerCombatSystem.UsePassiveAbility(ability as PassiveAbility);
}
}
Why does ur vector3 only have 2 coordinates
Because this is not Roblox
Well
Idk bro but a vector 3 seems to have 3 coordinates to me
A vector2 has 2 coordinates
A Vector3 with 2 coordinates sets Z to 0 as default...
Does InverseTransformPoint also take into consideration the transforms rotation?
Yes.
Position, rotation and scale.
Ight
If you use a Vector3 without explicitly defining a Z axis, you might aswell use a Vector2
I think that was the point being made
But this is not roblox
I dont want to
What does Roblox have to do with any of this
Roblox is trash because they force you to set all three parameters?
There's a whole lot wrong with what you just said but you do whatever you want to do. Just post in #💻┃code-beginner next time and perhaps look up how to make a basic mesh on 
If you want my suggestion, look up how to make a basic quad, or billboard plane, and then do that four times
Hi there. Let's say I have an Abstract Class Ennemy that inherits from monobehvior. I have several different script that inherits from Ennemy. How can I store the reference of an Ennemy Script on an object.
GetComponent<Ennemy>() does not work (because Ennemy is an abstract class) so what is the solution ?
foreach (Transform folder in folders)
is this as fast as array?
GetComponent<Ennemy>() will indeed work
not quite but almost
get abstarct class will work
is it possible to see the mechanism that makes it work? maybe in Tranform.cs ?
I get a NullReferenceExeption when I try to use the ref though :/
Why does getcompoment not work for you?
then your object doesn't have any Ennemy scripts on it
thank u
Debug.Log(BT.name);```
use tryget to check if some child class script exists
what is this supposed to show us
Sorry pressed enter too soon x) just a minute x)
how did u find it so fast?
I knew exactly where to look and what to look for
So I have this class:
public abstract class BehaviorTree : MonoBehaviour
And some class inheriting from it including this class:
public class SpikeBoiBT : BehaviorTree
I attach SpikeBoiBT to the root parent of the ennemy object.
On one of the child object of the ennemy object, i have another script with :
BehaviorTree BT;
private void Start()
{
if(!transform.root.gameObject.CompareTag("Player")) BT = transform.root.gameObject.GetComponent<BehaviorTree>();
Debug.Log(BT.name);
}
The Debug.Log return a NRE.
Is there something I missed ?
Oh nvm I am a idiot --'
thanks for the help though 🙂
the debug.log will always run
public void Categorize(int index)
when u press a button u can make it pass integer or string or something to an OnClick public method
is there a way to make it include itself ?
I don't know if this was the right channel to do this in, but I have this wierd issue with robot kyle where he is just not rendering any of his textures in. How do I fix this?
Image
looks like you're using a material that isn't supported by your render pipeline
e.g. you're using a BIRP material for URP or vice versa
(or perhaps no material at all)
I use android based type build. Also: it does have a texture on it. It has robot kyle's.
textures are not the problem
^reread this
android is also not relevant
The clue is in the channel name 😉
This is a code channel and your question isn't about code
oh that too lol
you need to answer calrifying questions
what render pipeline are you using
what RP are those materials from
Use a shader on the material that is supported by your selected renderer pipeline. To get further help take it out of this channel.
urp
wdym
Hello, i'm having a 3d game where i need to know when the collider has hit my camera's view edge, how can i do that?
Hello! How to raycast objects without collider?
For posterity - we handled this in the #archived-shaders channel
Physics.Raycast only works with colliders
what are you trying to accomplish
I solved my problem. Thanks
the moveVector has noe been normalized
Normalize the moveVector indeed.
moveVector = Vector3.ClampMagnitude(moveVector, 1); (between your last two lines)
is my preferred approach
normalizing loses all the values between 0 - 1 on a joystick
clamping will not
yes but necessary
I agree with ClampMagnitude, its better for when you have analog input
doesn't matter
mesh.vertices = new Vector3[]
{
vec1,
vec2,
vec3,
vec4,
};```
Can someone explain this? This Vector3 somehow accepts 4 vector 3's
this is an array
Vector3[] means "array of vector3s"
ohhh okay
arrays are basically a fixed-length list of things
How do i add something to an array
arrays cannot be added to - they are fixed in length. You must create a new, larger array, with the new elements in place as you wish
what i googled it it says .append
doesn't exist afaik
what
and if it did it would create a new array
it was literally aut orecommended
by who
Are you talking about https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.append?view=net-7.0 ?
This is a Linq method
it's not part of the array type
and it will not return an array, it will return a new IEnumerable
returns a new sequence that ends with element
not an array
what
try it and see
then is there something i can store variables in and add things to it
A List
Ok i changed it thanks
vertices.Add(vec1);
vec1 is Vector3(0,0) by the way
help pls
Initialize the List
looks like you never created your list
this is not creating a list
this is a variable that can reference a list
what how do i make it then
but it is not pointing at any actual list
List<Vector3> vertices = new List<Vector3>();
or the shorthand version:
List<Vector3> vertices = new();
Thats an array. It has a specific size by design, to change it would mean creating a new array.
Hence why it was said you can't append to the same array, as it is a fixed size.
still sometimes variables reset to their previous state
can someone help?
what is SceneView ?
I want to have sprites that act as billboards but only in sceneview
this is a editor only function
i want to use it only in the editor
do i have to declare my script somehow that its editor only?
this wont work in game export you know this yes?
yes
#if UNITY_EDITOR
and when i add the range it disables somehow serializefield
yes indeed. - #archived-code-general message
@rigid island I'm using this for invisible objects that have logic, for example an object that acts as a spawn position. Instead of using the unity label gizmo thing (which I find very ugly), I want to give these things Icons which I can see in the scene view, but ingame its not relevant
You're trying to access a non-static thing in a static context
You need to first get a reference to the current scene view like that
SceneView.currentDrawingSceneView
And then that will have a camera for you
But yes you need to wrap it in #if UNITY_EDITOR or your build will crap out
thanks guys
alrighty
you can assign custom icons to gizmos too iirc
I will do that instead 😅
I have a really stupid problem, I have a shotgun which fires multiple pellets. When the pellets hit an enemy, they call the "TakeDamage" function. Inside that function I checked if Health is below 0 and call the "Die" function. When the enemy has low hp, all pellets cause the if to be true and "Die" gets called multiple times, which is a problem... I can't think of a cool solution other than having a flag if "Die" was called already and just dont do anything if a "hasDied" flag is true... (does this even work?)
When all pellets call this function, do these run concurrently? Or does Unity have a call order internally?
only one line of code will be running at a time. using a bool to flag whether it has died or not is sufficient
in that case, how is this possible? I destroy the gameobject in the die funciton
i guess destroying happens on the next frame?
correct, calling Destroy just queues it up to be destroyed. it won't actually be destroyed until the end of the frame
why is a flag not sufficient?
I mean i dont like the solution anyway but i thought it would
oh
sorry
I misread your comment
alright, I guess I jsut do that for, maybe im stupid and thats the completely right solution anyway 🙂
i have met some simliar problem finally i realize thare maybe multipe callback from physics engine
so you need a flag to lock it
in your case i think you can lock it by if(hp<=0)early return;
true!
The code is meant to set a create a network object and set it as a child of the clients, but it only works on hosts, it spawns the object in fine for all clients but when it comes to making it a child the clients get an error of “only the server can reparent network objects” I’ve tried everything go get this working with rpcs to get the host to do this on clients behalf but all it does it make that client parented on the hosts side too(what I wanted but I also need it parented for the client) I’m completely out of ideas to fix this please help
It’s literally killing me, 3 days trying to fix it now and nowhere I look online I can find an answer that works anything I try makes it more broken than this ^
#archived-networking and mention which network framework you're working with
Sorry
hi so currently i have a car with wheel collider, whenever i try to change the cars location like reseting cars locations then it goes to the resetted location and comes back to the original location in a split second do anyone know why its happening
what other components are on it
rigidbody is there
what if you make the RB kinematic, then teleport it, then make it not kinematic again
📃 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.
input.gameObject.GetComponent<Rigidbody>().isKinematic = true;
yield return new WaitForSeconds(1);
input.gameObject.transform.position = spawnPoints[input.playerIndex].position;
input.gameObject.transform.rotation = spawnPoints[input.playerIndex].rotation;
input.gameObject.GetComponent<Rigidbody>().isKinematic = false;
this is what i am doing in courotine
it works in editor but not in build
i was searching how to simulate AI FOV and i found someone using these lines of code:
var toPlayer = (player.transform.position-transform.position);
var angle = Vector3.Angle(transform.forward.normalized, toPlayer);
if(angle<FOV/2)
{
//raycast to see the player, but thats irrelevant to my question
}
```could anyone explain to me why is the fov divided by 2 in this code?
how do you deal with the fact that people can load your game in dnspy and edit the sources
if its online
you ignore it because who cares
if you have an online competitive multiplayer game you use a combination of server-side validation of player actions and ever-more invasive client side anticheat software
people can fly just under any serverside anticheat while still gaining an advantage
i think when you divide the fov by 2 u basically get the ray in center of the current view
ive seen a unity plugin for an anticheat. it was really bad, i could just disable it lol
Cheating and cheat detection is a never ending arms race. What do you want to hear?
that's the reality
what
i want to see how you guys deal with it. i reversed a game recently where the guy paid for an anticheat plugin but the fact that c# compiles to bytecode ruins all security
find the mistake i tried this
cars[input.playerIndex].GetComponent<Rigidbody>().isKinematic = true;
cars[input.playerIndex].transform.position = spawnPoints[input.playerIndex].position;
cars[input.playerIndex].transform.rotation = spawnPoints[input.playerIndex].rotation;
yield return new WaitForSeconds(1);
cars[input.playerIndex].GetComponent<Rigidbody>().isKinematic = false;
and it worked
he is using a pathetic anticheat if it can't detect a simple attack like that.
I have a problem with addressable assets when building the project. It is completely OK in the editor.
There is a collection list with 90 elements. They are SOs. It is OK in the editor as I mentioned but in runtime, it logs 360!!! and then I get an exception exist same key because they are populated into a dictionary
if it worked wdym about finding a mistake
i guess a lot of it falls to proper integration of the anticheat plugin
does Collection is not fixed meaning it has to be a list?
it would be good if you guys could write all core anticheat stuff in c++ and properly compile it
what? Maybe share the code and the full error message you're seeing
cause in c# i can just modify event handlers for when a cheat is detected
basically the center of the screen so that you can measure the side angle and do stuff according to it
like if your fov is 120, half is 60 and then you can do like if angle < 60 do something and andle > 60 do something this is what i think not sure
clientside at least
opening vs 2022 wait
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEngine;
public class TestGenerator : MonoBehaviour
{
Mesh mesh;
List<Vector3> vertices = new List<Vector3>();
List<Vector3> triangles = new List<Vector3>();
public float chunkWidth;
public float chunkHeight;
public float Amplitude;
public float Scale;
private void Start()
{
CreateShape(new Vector3(0, 0), new Vector3(0, 1), new Vector3(1, 1), new Vector3(1, 0), new int[] { 0, 1, 2, 0, 2, 3 });
//CreateShape(new Vector3(0, 0), new Vector3(0, 1), new Vector3(0, 0, 1), new Vector3(0, 1, 1),new int[] { 0, 1, 2, 0, 2, 3 });
}
void CreateShape(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector4 vec4, int[] triangles)
{
Mesh mesh = new Mesh();
mesh.vertices = new Vector3[]
{
vec1,
vec2,
vec3,
vec4,
};
mesh.triangles = triangles;
GetComponent<MeshFilter>().mesh = mesh;
vertices.Add(vec1);
vertices.Add(vec2);
vertices.Add(vec3);
vertices.Add(vec4);
triangles.AddRange(triangles);
}
}
wait why is it addrange lol
basically switching the position and undo the kinemetic directly after changing the position is making my car to go back to the original position but adding the small delay after undoing the kinematic part gives it some time to reset the position that i think what is happening right now
why are you doing triangles.AddRange(triangles)?
i guess it was aut orecommended and i didnt notice it
int[] triangles < triangles is an array
as we told you before, arrays are fixed length
no
they cannot be added to
you have a local variable with the same name as your list field
triangles is a list
List<Vector3> triangles = new List<Vector3>();
with the same name
when i use vertices to make triangles
am i supposed to make the list a vector3 or int
can i add arrays to lists?
AddRange will let you add all the elements of any IEnumerable to a list
no i changed it to add
if that's what you mean
it was a accident
if it's still an array you can't use Add OR AddRange
if it's a list you can use either
no its a list
why when i try to add it like this
its saying that its a int[][]
when its supposed to be int[]
seems like triangles is now a List<int[]> considering you're adding an entire array to it
make sure it is a List<int> and use AddRange rather than Add to add all of the elements of the array to the list
it literally
doesnt let me to
prove it
exactly. the reason it didn't work before was because you were calling AddRange on the local variable that just happened to have the same name as your field
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEngine;
public class TestGenerator : MonoBehaviour
{
Mesh mesh;
List<Vector3> vertices = new List<Vector3>();
List<int> triangles = new List<int>();
public float chunkWidth;
public float chunkHeight;
public float Amplitude;
public float Scale;
private void Start()
{
CreateShape(new Vector3(0, 0), new Vector3(0, 1), new Vector3(1, 1), new Vector3(1, 0), new int[] { 0, 1, 2, 0, 2, 3 });
CreateShape(new Vector3(0, 0), new Vector3(0, 1), new Vector3(0, 0, 1), new Vector3(0, 1, 1),new int[] { 0, 1, 2, 0, 2, 3 });
}
void CreateShape(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector4 vec4, int[] trs)
{
Mesh mesh = new Mesh();
mesh.vertices = new Vector3[]
{
vec1,
vec2,
vec3,
vec4,
};
mesh.triangles = trs;
GetComponent<MeshFilter>().mesh = mesh;
vertices.Add(vec1);
vertices.Add(vec2);
vertices.Add(vec3);
vertices.Add(vec4);
triangles.AddRange(trs);
}
void UpdateMesh()
{
mesh.Clear();
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles.ToArray();
mesh.RecalculateNormals();
}
}
so im trying to make it so i can make 2 of these triangles
and so it saves both of them
because right now one of them dissapears
like its overriding the whole mesh
oh wait
i forgot to call the function
lmao
Why is Health false?
do you have a component called Health
i got a error
what is line 49
mesh.Clear();
this is line 49
then mesh is null
How I can fix it
what how
do you have a component called Health
how is it null
where do you assign it? hint: you don't
void CreateShape(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector4 vec4, int[] trs)
{
Mesh mesh = new Mesh();
again, local variable with the same name as your field
please learn about variable scope
No
it is because you redeclared it on the line you call new on
Mesh mesh = new Mesh(); has nothing to do with your field of the same name
then what component are you expecting to get with the GetComponent call?
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEngine;
public class TestGenerator : MonoBehaviour
{
Mesh mesh;
List<Vector3> vertices = new List<Vector3>();
List<int> triangles = new List<int>();
public float chunkWidth;
public float chunkHeight;
public float Amplitude;
public float Scale;
private void Start()
{
CreateShape(new Vector3(0, 0), new Vector3(0, 1), new Vector3(1, 1), new Vector3(1, 0), new int[] { 0, 1, 2, 0, 2, 3 });
CreateShape(new Vector3(0, 0), new Vector3(0, 1), new Vector3(0, 0, 1), new Vector3(0, 1, 1),new int[] { 0, 1, 2, 0, 2, 3 });
UpdateMesh();
}
void CreateShape(Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector4 vec4, int[] trs)
{
vertices.Add(vec1);
vertices.Add(vec2);
vertices.Add(vec3);
vertices.Add(vec4);
triangles.AddRange(trs);
}
private void Updating()
{
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles.ToArray();
mesh.RecalculateNormals();
}
void UpdateMesh()
{
if (mesh != null)
{
mesh.Clear();
}
else
{
mesh = new Mesh();
}
Updating();
}
}
Why does this not work
Its supposed to do the exact same thing as before
Make triangles then save it and make it 1 mesh
well, what if mesh is null?
it makes a new one
does it throw you the same error?
its suppose dto make triangles
as you can see in create shape function
then the vertices and triangles are stored in a list
then the mesh is created in the update mesh function
but the mesh is not visible
i dont even know if it exists
but all I know is that all the settings are correct cause the earlier code worked
what was the earlier code?
this
but this didnt update the mesh
so it only allowed for 1 shape creation
i need multiple of it
and how are you rendering this mesh?