#archived-code-general

1 messages · Page 72 of 1

leaden ice
#

Your life will become much easier

kindred sparrow
#

And the script also is being used for multiple cubes

leaden ice
#

So?

buoyant crane
#

change the type of owo from string to Transform. then you can set owo to collider.transform

leaden ice
#

You're getting the reference on OnTriggerEnter aren't you?

buoyant crane
kindred sparrow
#

So then that’d work

leaden ice
kindred sparrow
#

Because I need it to happen repeatedly

leaden ice
#

Same question

buoyant crane
leaden ice
#

The name is not what you want here

kindred sparrow
leaden ice
#

?

kindred sparrow
#

I need the name to be stored so then I can move that data into the update function

leaden ice
#

No

kindred sparrow
#

So then the movement of cubes can happen repeatedly

leaden ice
#

You need the reference to be stored

#

Not the name

kindred sparrow
#

That is my plan in my code

#

So I still need stuff to be stored, so same issue

leaden ice
#

The name is not useful

kindred sparrow
#

I’m going to say this as respectfully as possible. Fuck off

#

Please and thank you

leaden ice
#

The Transform reference is useful

kindred sparrow
#

You are being rude

#

I’m going to leave it at that

leaden ice
#

/shrug some people prefer ignorance

kindred sparrow
#

Ohhh noooo, how shall I code without your oh so important advice on code that already works

#

D,:

void basalt
#

good luck getting help beyond that

#

I would've told you exactly the same thing praetor did, for your problem.

#

You can store the name in a string variable, if it's really that important right now.

kindred sparrow
#

When I stored it in a string Unity was giving a incorrect storage error

void basalt
#

what is an incorrect storage error

kindred sparrow
#

But pumpkin let me know that Unity has special storage type called transform

#

The top box on this

void basalt
#

Praetor also told you that

#

but alright

void basalt
#

and it told you that

kindred sparrow
#

Ohh

void basalt
#

Generally this is why you listen to seniors

#

instead of giving up and calling them an asshole

kindred sparrow
#

I did not actually, I specifically said they were being rude

#

Do not exaggerate the situation

#

I was also trying to follow along with someone else who was giving proper explanations and not just short answers without context

#

Whom they were talking over

void basalt
#

There's a reason why he was telling you to do that.

#

You are wasting space storing individual names as strings

#

they are already stored in the transform

#

and can be directly accessed from the transform's reference. The reference is the size of a pointer.

kindred sparrow
#

How could it be directly accessed from the transform’s reference?

void basalt
kindred sparrow
#

So I need the objects name?

void basalt
#

You need a reference to the object.

#

Generally you learn this stuff before you dive into unity

kindred sparrow
#

This is how I’m learning

#

So

#

:)

kindred sparrow
void basalt
#

No. Just store the transform

#

then you can access everything attached to it.

kindred sparrow
#

That’s what I mean

#

Meant

void basalt
#

no

#

First of all your owo is a string type

#

and that's not a transform

kindred sparrow
#

Yeah, I’d change that of course

void basalt
#

second of all .name is not a transform

kindred sparrow
#

So are you referring to something like .position?

#

Or a sprite

void basalt
#

I'm saying get the reference of the GameObject you want to store, get the transform from that, and set the transform to the reference

kindred sparrow
#

By reference are you referring to the name of? Or information of

void basalt
#

I'm referring to the reference of the object in memory

#

Since you're posting in general I assume you already know how to get a gameobject

kindred sparrow
#

The information or name

void basalt
#

the pointer

#

to the object

#

in memory

#

Again, this is why we learn C# instead of just trying to do random stuff inside unity

#

if you need help doing that, let me know

kindred sparrow
#

Boi, if I wanna practice c# in Unity I can do so, and if you don’t want to help me you can also do so

void basalt
#

I assume that you would at least read over some documentation and understand how it works

#

Since you don't know what a reference is

kindred sparrow
#

I did so

void basalt
#

GameObject myGameObject = GameObject.Find("ObjectName");

#

Transform myTransform = myGameObject.transform;

kindred sparrow
#

THAYS HOW YOU DO THAT?

#

Yas, thank you

#

Trust me, I do have the documentation open, it’s just difficult to sort through

#

Where do you recommend I practice C# if not Unity?

void basalt
#

I mean it doesn't matter since you already have unity open

#

It's good to understand what an object is, how stuff gets stored in memory, rather than "update loop go brrrr"

kindred sparrow
#

I understand how it generally gets stored

#

I just didn’t know how to store transformation information, because that’s a Unity thing

void basalt
#

It's just a regular class

#

made by unity

kindred sparrow
#

Yup

#

One that I didn’t know about :)

#

“Update loop go brrrr”

#

You don’t have to help people if you don’t want to

#

Good lord

void basalt
#

Keep in mind that there's only one object in memory, per GameObject.

If you reference "GameObject1" in one script, change the name, and then access the name in a different script with another reference to "GameObject1" you'll see the updated name

#

and with the transform reference, you can access literally anything gameobject related

kindred sparrow
#

Alright

#

Unfortunately my pc is already off so I can’t fix the thingy today 😮‍💨

spiral geyser
#

https://hastebin.com/share/mapicizoje.csharp

Essentially what is going on is that I am moving the gameObject that the script is attached to back and forth between a undefined set loop of transforms using a horizontal input,

when going forward through the transforms, it will select the next one in line as the one to go to, however when going backwards for some reason, it doesn't select the one before it as the one it should be heading towards? (When it should)
Any ideas of why this could be happening? (2D URP)

night harness
#

This is probably just something small I'm missing, I'm setting my NPC SetDestination to the selected object and due to the door in the way its setting the path to the front of the door which is the closest it can get. Is there a way I can force it to set the destination to the selected object (im aware the npc will get stuck at the door)

The door is a NavMeshObstacle right now

wicked scroll
#

the nav mesh doesn't extend into that room because there's an obstacle in the way which exactly how it should be

#

you could try unchecking 'carve' so that the mesh does extend past the door

#

oh actually it looks like you do have some nav mesh in there, maybe you just need to set up a link between those meshes?

#

but it sounds like you want to generate your nav mesh based on anything that could be accessible, and then block parts at runtime

night harness
#

the doors gonna open for my little buddy i just need him to believe it's going to. right now he has no faith in the orange slab and takes the half measure of waiting out front

#

ill try messing with carve

wicked scroll
night harness
#

yeah just killing carve is probably exactly the right setup for me

#

tyty

#

Now that my blue boy gets stuck at the door, does NavMeshAgent have anything nice like a bool that lets me know if he's stuck?

void basalt
#

Why don't you just detect he's infront of the door

#

then open the door?

#

wouldn't that be the most logical solution?

night harness
#

Thats the goal! But he won't be infront of the door unless he goes to it and his destination isn't what I want it to be things break

void basalt
wicked scroll
wicked scroll
#

'why don't you just...?' yeah totally, which is why i would say to avoid them

void basalt
#

stop

#

talking

night harness
void basalt
#

to

#

me

night harness
#

oh your being an ass

#

nevermind

void basalt
#

no

wicked scroll
#

yeh

void basalt
#

was talking to the other guy

#

prakkus

night harness
#

Yes i'm aware

#

thanks for your time!

void basalt
#

I mean, I'm going to help you

#

if thats what you're looking for

night harness
#

No thanks!

wicked scroll
#

everyone would be better off without the kind of help you are offering

void basalt
#

please shut up 🙂

#

and stop telling me what to do

wicked scroll
night harness
#

tyty

void basalt
#

@night harnessyo sorry for hurting your feelings earlier. Gonna be the bigger person and apologize. It's now obvious that my tone of voice can scare people or hurt people's feelings. I'm sorry.

#

I won't be responding after this

chilly prawn
#

Hello everyone, I was just wondering what is the best way around coding 4 raycasts pointing out from all 4 directions of a enemy. Similar to this:

#

would really appreciate some help, thank you.

somber nacelle
#

is there a reason you prefer four separate raycasts only in the cardinal directions and not like an overlapbox or something instead?

chilly prawn
void basalt
#

@chilly prawnDepends what you're doing

somber nacelle
chilly prawn
#

the map i am adding the enemy into is a very cramped location just like a maze

void basalt
#

that doesn't answer the question

#

are you trying to do AI?

chilly prawn
#

oh yeah ai movement

void basalt
#

DIY pathfinding?

#

You need to look at navmesh

#

shooting raycast isn't the way to do it

#

I mean, you could

chilly prawn
#

ok ill take a look thanks

void basalt
#

Then if you want to detect if a player is infront of the enemy, and you want the enemy to "see" him, I think the best route would be to first use dot product, and then shoot a linecast

#

since you don't want your player getting detected behind the AI

chilly prawn
#

@void basalt came across an issue. My project I am now trying to add ai pathfinding to is completely procedurally generated. Can navmesh be compatible with levels created at runtime or no?

void basalt
#

but it should be

#

rust does pathfinding on their procedural terrain

deep fable
#

Is there a way to draw the Enable checkbox of a MB (like in Physics Body) from a custom inspector? (Basically I would like to make the Balancer Authoring script be disabled/enabled but without actually disabling the MonoBehaviour but writing the enabled state in another variable)

thin aurora
uncut plank
deep fable
void basalt
#

transform.forward will tell you a direction

thin aurora
#

That's the whole point of that button

uncut plank
thin aurora
#

Oh you edited the message

void basalt
somber nacelle
deep fable
uncut plank
#

transform.y is the downward vector

uncut plank
thin aurora
void basalt
#

transform.position.x is a position on the X axis

#

@uncut plank

uncut plank
#

oh wait nvm

#

youre right, i though this was godot discord

void basalt
#

no you're right position isn't a position

#

its a direction

uncut plank
#

my bad, I keep messing them up

thin aurora
chilly prawn
#

bruh you guys are confusing me

uncut plank
#

yeah, transform.forward it is

#

transform.left and .right and so on

thin aurora
# deep fable Yeah this

Riiiight. I honestly don't know if you can add a checkbox there manually using custom scripts. You can add it as a boolean variable, though?

uncut plank
#

disregard what I said before

somber nacelle
uncut plank
deep fable
uncut plank
#

alright then

uncut plank
#

then the directions would be
transform.up
transform.right
-transform.up
-transform.right

thin aurora
void basalt
chilly prawn
void basalt
#

@chilly prawnDunno man, I've never used Unity's navmesh before

chilly prawn
#

thanks for the help anyways think i am getting somewhere

void basalt
#

likely something like this

chilly prawn
worthy tiger
#

Hello. I need some help with TMP Regex. I need to validate code like "xxxx-xxxx" where can be set symbols count to 4 for left and right parts and validate that has an "-" between them. I tried to use something like this "^[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}$" but i doesn't work

swift falcon
#

So I have heard of Array.Max

But this is a little different. I have an Array of classes and each class has a value, lets call the value 'B'. I want to find the class that has the highest B value out of all other classes.

How can I do that? Its a lil confusing (Still googling but not finding anything)

cedar egret
#

Why does BoundInt size not extend from the centre?

#

And how would I fix it?

#

I set my my position to the origin and it's extending like it's at the bottom left

swift falcon
thin aurora
worthy tiger
eager cliff
#

I would like to ask how to achieve localization (multiple language) on some text that will change or not static (eg. a weapon description, item description). All tutorial I saw is some text that is unchanged (eg. starting button, setting button). Is there any tutorial about changing text?

gleaming sparrow
#

Or overwrite

sullen loom
#

hey guys super quick question, i want my character with a circle collider and rigidbody2d to somewhat "fall" off the map, by making it's layer above everything else's. i've tried setting it's order in layer to 1 on the sprite renderer, but that's only its render and it's collider still stops it from falling. how do i make it's whole layer above everything else so it falls off the map, kinda like mario when he dies

solid heron
solid heron
#

you go wo where i said Project Settings > Physics

sullen loom
# solid heron you dont?

nah i mean i need it to be in c# so on my death function the layer gets set to above everything else so it falls over everything off the screen

solid heron
sullen loom
#

on death() layer = above all

#

ohhh i need to make a new layer ok

#

where do i make the new layer

#

in circle collider?

#

or project settings

solid heron
sullen loom
#

ok

#

where about in circle collider all i see is this

solid heron
#

not here

#

at the top

#

of the entire game object

sullen loom
#

oh yeah i already have it's own layer

#

but its third out of 6 layers

#

so do i need to make it the 6th one?

solid heron
# sullen loom

you can probably actually set what this collides with right there

#

on "Exclude Layers", change that when you die maybe

sullen loom
#

ok

#

oh yeah

#

its doing something now

#

the character doesnt collide but instead goes behind

#

does that mean if i used the include layers instead then it will go over them?

solid heron
#

exclude, you wont collide with them

sullen loom
#

oh yeah

solid heron
#

you can check the docs probably and see

sullen loom
#

i already collide with them anyway

#

ok

#

oh i did it

#

i did the thing with exclude layers, but then i just also made the character's sprite renderer in the top layer

#

and now it doesnt collide and also goes above them as it falls off the map

#

do you know how i'd activate the exclude layers in c#

#

so like in my death function i'll have spriteRenderer.sortingOrder = 1; aaand also change the exclude layers to the targeted layer in the collider component?

#

how'd i do that

solid heron
cedar egret
#

Does BoundsInt size scale up from bottom left?

long ibex
#

what's the simplest way to access the manual for a given package? google rarely gets me there and there doesn't seem to be a list/search function for all the packages

knotty sun
long ibex
#

ah, that'll work, a little annoying to have to open the editor and a project just to get a link to some docs but that helps if I'm already in editor

trim schooner
#

google -> unity <package name> package manaul

sullen loom
#

hey guys how'd i access and change the value of a circle collider's exclude layers section? i've tried this but it doesn't work. i want to change the exclude layer value to the pipe layer which has an index of 6 in the layers at the top of the inspector.

#

the .excludeLayers is the correct definition by the way

solid heron
#

i said use LayerMask

#

public LayerMask mask1; - nothing
public LayerMask mask2; - layers you want to collide with, so probably everything

#

set the excludeLayers to one of these variables

sullen loom
#

ohh

#

so what does the layermask type do

solid heron
#

same thing

sullen loom
#

ok

#

so a layermask is basically just a variable for a layer inside code

#

is how im thinking it

solid heron
#

try it and see what it is

#

you will know what it is better then

sullen loom
#

oh yeah its looking good so far

#

so i can basically set the .excludeLayers to the layer mask variable

#

alright this is good

solid heron
#

i think so at least

sullen loom
#

yeah

#

yesss dude it works

#

now when i die my character falls through the world aaaand it's sprite renders infront

solid heron
sullen loom
#

thanks so much i wouldnt have done it without you i coudlnt find anything online

sullen loom
#

hey guys this is hard to explain to docs so im gonna ask here but how do you find the child of a GameObject without having to like make a public gameObject for the script and then drag the gameobject from the hierachy into it? so i've heard about a FindChild() or GetChild() how does that work

#

so for example in this prefab i have i want to be able to select the top pipe or bottom pipe and then setactive=0 it

solid heron
#

1 is Bottom Pipe

#

2 is Middle

sullen loom
#

oh alright

#

so how would i refer getChild to the gameobject

solid heron
sullen loom
#

how would i use the getchild function

#

how do i actually do it

solid heron
#

that is how you do it

sullen loom
#

yeah i know that

#

but i cant just go in update() and put GetChild(0) and then i will get the top pipe

sullen loom
#

oh wait

#

when you type GetChild() in a script, will it get the child of the gameObject that the script is in?

sullen loom
#

thats it?

solid heron
sullen loom
#

oh ok

solid heron
#

you want to get a child

#

thats what that method does

sullen loom
#

so how would i get the child of a gameobject that doesnt have the script as it's component

solid heron
#

and it can get the children

sullen loom
#

so for example i have an empty gameobject which has the current script in it, and i am using this gameobject to spawn pipes that then lead to moving from the gameobject's position

#

but the pipes that start spawning from the empty gameobjects position are prefabs

#

so they arent in the game yet until start

#

so i have the parent of the prefab saved as a public gameobject in the script thats in the empty gameobject that then spawns the prefabs

#

and im trying to get the children of the prefab that gets spawned by the script in the empty game object

#

so how would i do that

solid heron
#

i dont understand, just do GetChild(indexOfChild);

sullen loom
#

yes but im trying to get the child of another gameobject to the one the script is in

solid heron
sullen loom
#

ohhh thats what i was looking for

#

finally lmao

#

it dont ork

#

work

solid heron
#

what doesnt work, how does it not work

sullen loom
#

it says the transform doesnt have a definition for getchild

#

pretty sure because transform is just the info about the state of a gameobject

sullen loom
#

ok get ready because it might be really confusing for you because you dont know what the code is intended to di

#

pipe is a public gameobject of the prefab i have

solid heron
sullen loom
#

oh shit

#

i need capital C

#

oh now its saying it dont have def for setactive

#

its worked before tho

solid heron
sullen loom
solid heron
#

more because it doesnt have a value, its a method

sullen loom
#

then how come this works

#

oh my god

#

yeah

solid heron
sullen loom
#

im so dumb

#

i forgot it takes a parameter

#

my bad

#

ive only been doing unity for a bit

solid heron
sullen loom
#

i used to do it years ago and i was absolutely brilliant but then i stopped doing it and ive only been back on unity for like 3 days

#

im using a Game Makers Toolkit video on youtube to refresh my mind

#

its a 40 min tutorial on how to make flappy bird and i've finished it but now i'm adding my own stuff to the game for practice

sullen loom
#

oh yeah the reason i made it take the bool value instead of parameter is from when i made somethings component disabled by doing .enabled = false and i mixed it up with setactive because they are similar

honest meteor
#

Hii

sullen loom
#

hi

honest meteor
#

Hello bro how are you

#

@sullen loom

sullen loom
#

fine

#

just adding my own features to a flappy bird game i made off a yt tutorial

#

lol

sleek bough
#

@honest meteor !collab

tawny elkBOT
coral kettle
#

when I do Formatting.Indented with JsonConvert.SerializeObject, but then I later do string json = File.ReadAllText(files[randomIndex].FullName); this comes out empty var description = Serializer.DeserializeDict(json);

is there a way to make Formatting.Indented that I might not know of? I just like how it looks really, and I do want to make modding these easy

#

if I remove Formatting.Indented it works fine

sullen loom
#

this is still saying an error

#

@solid heron

quartz folio
#

!ide

tawny elkBOT
#
💡 IDE Configuration

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.

quartz folio
#

Your IDE should underline errors in red and give you proper autocomplete

steel vortex
#

How do I code PlayFab to save "public void AudioApply()"? because in the tutorial video it has "Data = new Dictionary<string, string>" and when I change the void to string in "public void AudioApply" I get errors, how do I make the PlayFab script save my public void AudioApply?

sullen loom
#

and im on microsoft visual studio

quartz folio
#

!ide

sullen loom
#

does anyone know whats wrong with this code its giving an error

#

!ide

tawny elkBOT
#
💡 IDE Configuration

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.

sullen loom
#

how transform doesnt have a definition for the setactive method

quartz folio
#

Configure Visual studio using the instructions I keep linking

sullen loom
#

how do i configure it though

quartz folio
#

So you can actually type code without guessing

#

Click the link associated with your IDE.

#

Follow the steps listed.

sullen loom
#

where is the link

solid heron
sullen loom
#

oh

#

ohh im on it]

coral kettle
sullen loom
#

lmao how did chatgpt do that

coral kettle
#

I pretty much pasted the same thing I asked here

#

minus the part about modding

#

chatgpt is great if you know how/what to ask. it did take me telling it that I had already debugged and was sure it was blank, since the first thing it wanted me to do was confirm it

sullen loom
#

@quartz folio ive instally unity onto my visual studio now but it hasnt changed

#

it still looks the same in visual studio

quartz folio
sullen loom
#

i restarted everything

#

and just now ive clicked the regenerate button like you said and visual studio is closed

#

and now ive opened visual studio and nothing looks different

quartz folio
#

If it doesn't start working in a minute then you must have missed a step, it you installed VS manually then you mustn't have added the Unity module

sullen loom
#

oh wait do you mean this

#

is that the autocorrect thing

#

or is it something else

quartz folio
#

No

#

It will stop staying Miscellaneous files in the top left when it's functioning

sullen loom
#

then how will i switch between files

#

wait do i just need to use visual studio code instead of visual studio?

quartz folio
#

No, VS Code is much harder to configure

sullen loom
#

now i have this error

#

is this linked to the installage that im doing?

quartz folio
#

Can you screenshot the two steps you configured just to confirm they're done?

sullen loom
#

ok

#

i clicked modify

#

unity is installed

#

the correct visual studio is selectred

quartz folio
# sullen loom

Is this 2022 VS? It looks old, but I'm not familiar with it

sullen loom
#

yeah im using 22

#

because its most recent

sleek bough
#

Try opening the script from inside Unity

sullen loom
#

oh yeah ok

solid heron
sleek bough
#

Also check that plugin in Package manager is updated

sullen loom
sleek bough
#

and open Help>About and check the version

sullen loom
#

there is no plugin package

quartz folio
#

It's the last one, no?

sleek bough
#

About of the VS

quartz folio
#

You can open the package manager window to confirm, and update it if there is any updates

sleek bough
#

And package manager is here. Find VS plugin and update.

sullen loom
#

im in package manager

#

there is nothing called plugin

quartz folio
#

If it's still not working, comment out that line of code and once Unity complies again that may fix it?

sullen loom
#

and the only available update is for version control

quartz folio
sleek bough
sullen loom
#

exactly the same as that

sleek bough
#

Did you confirm in VS About that it is the 2022?

sullen loom
#

i cant find the about section in vs

sleek bough
#

open Help>About and check the version

sullen loom
#

theres no about in help

sleek bough
#

About Microsoft Visual Studio

sullen loom
#

oh crap my bad

fresh cosmos
#

why does Material.GetTexturePropertyNames() return names i dont have declared in my shader?

sullen loom
sullen loom
#

idk

#

im not that good at unity

fresh cosmos
#

the documentation says "Names of all texture properties exposed on this material." and as far as i know only the ones i declare i the shader should be exposed

quartz folio
fresh cosmos
#

so technically all materials will have those properties then?

quartz folio
# fresh cosmos so technically all materials will have those properties then?

No, materials accrue the properties of all previous shaders they have ever used with the inspector. They'll get stripped in the end so it's generally not a concern. I'd have to do some testing to confirm myself that that's what the method is returning, but I'm on my phone. You can see the data structure with debug mode in the inspector

fresh cosmos
#

hm ok ill have a look

sullen loom
#

i got this error and it wont let me do anything with it here

sleek bough
# sullen loom

Close Unity and VS, reopen project and create a new script in the Assets folder inside Unity, then open it from there and see if it is properly in the project.

sullen loom
#

ok

sullen loom
#

but nothing changed

quartz folio
ruby fulcrum
#

how do i decrease the timescale of only certain gameobjects

sullen loom
fresh cosmos
sullen loom
sleek bough
ruby fulcrum
#

but that will only slow down the movements though

sleek bough
#

It depends how you move, if it's not physics based you should be using deltaTime already and just add multiplier than

sullen loom
#

make a new multiplier

quartz folio
# sullen loom but now ive still got this and only this which was never here before

At this point I have no idea why it's bugged, but these things sadly happen in the world of development. You will have to close Unity, and delete the Library/ScriptAssemblies folder in your project and hope once it regenerates everything starts working. Because even if you get rid of the new error you can't go on without a functioning IDE!

ruby fulcrum
#

ok ill try

fresh cosmos
ruby fulcrum
#

im basically trying to implement time deceleration, similar to superhot

sleek bough
#

@sullen loom Previous IDE might be conflicting with a new one, it could be cached by the project settings. You should remove it just to be save. If that fails reinstall cleanly both.

sleek bough
#

Uninstall

sullen loom
#

you mean the editor?

#

or visual studios?

sleek bough
#

The VS 2019 remove it

sullen loom
#

ok

sleek bough
#

And if persists remove everything and reinstall

fresh cosmos
#

i have not, that seems like it should work better

#

thank you

ruby fulcrum
sullen loom
sleek bough
ocean river
#

hey, i have a question...
how do i press a button from code?
i used "EventSystem.current.SetSelectedGameObject(buttonOpt);" to select it, can i click it in a similar way?

#

the button does have a onclick event, i just want to add controler support

sleek bough
#

There's an event you can send that presses a button, don't remember from the top of my head, research it.

ocean river
#

this is part of that "research" here...

sullen loom
#

maybe just used the onclick event in code

ocean river
#

well, its a gameobject, not a "button"

sullen loom
#

like maybe get the button gameobject and do button.OnClick()

ocean river
#

and i get countless errors trying to convert it

sullen loom
#

public GameObject button

#

button.OnClick()

#

try that

#

and set the button to the gameobject

ocean river
#

Type `UnityEngine.GameObject' does not contain a definition for `OnClick' and no extension method `OnClick' of type `UnityEngine.GameObject' could be found. Are you missing an assembly reference?

#

here you have that detailed answer

sullen loom
#

yeah idk just use that doc

normal arch
#

is there a way to make certain colliders not interact with other certain colliders without using the layer system?

normal arch
vast wigeon
#

Very good

vast wigeon
gray mural
#

who knows how to fix it?

vast wigeon
#

for Example if im holding something then my hands dont collide with it

dusk apex
#

Why would you need an if statement?

normal arch
#

ok ty i think this saved me

#

ill try it out first

dusk apex
#

It's a regular statement to set colliders to ignore one another..

vast wigeon
#

not a constant not collide

dusk apex
#

Look at the code example from the docs for more information

normal arch
#

is there a way to atop all ignore collisions from being ignored or would i have to do that manually

dusk apex
vast wigeon
#

Sorry im not following

vast wigeon
dusk apex
#

Look at the docs and read it.

vast wigeon
#

so i dont know what a Third Paramater is

vast wigeon
dusk apex
vast wigeon
#

Thanks

#

If you look in code-beginner

#

and scroll up

#

I caused some problems

thin aurora
tawny elkBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

buoyant crane
languid hound
#

Basically my first time using the new input system properly and was wondering why this isn't working?

#

Actually

#

I never tried doing &&

#

Nope still nothing

thin aurora
languid hound
#

Alr

#

Those if statements should be working fine though

#

If I remove the requirement for 0 or the alt key it works fine

#

Yeah

languid hound
thin aurora
languid hound
#

Oh right. That's a bit irritating. How should I go around doing this? Some bool trickery?

thin aurora
#

Well, a messy solution, 1 sec

#

What is the method for when the key is pressed in general, not just the exact frame?

#

Assuming it's wasPressed, what you probably want is this:

var keyboard = Keyboard.current;
var pressed = (keyboard.altKey.wasPressedThisFrame && keyboard.digit0Key.wasPressed) ||
  (keyboard.altKey.wasPressed && keyboard.digit0Key.wasPressedThisFrame);

if (pressed) {
  ...
}
#

The reason why it checks twice is because either one needs a check if it's pressed "this frame". If you don't add the second two for example, the code won't run if you press digit0 first, then alt.

languid hound
#

I see. Thanks. I'll give it a shot now

gleaming sparrow
languid hound
thin aurora
languid hound
#

Yeah it just doesn't happen

#

WAIT

#

I implemented it wrong sorry

#

It works fine now. Thank you!

thin aurora
#

Nice

wise dirge
#

Hello I am trying to upload my project to github using the unity desktop app, I do have a gitignore for unity, however, every time I open unity it says i have 800 changes that are made even if I never edited anything. Is this an error with the gitignore?

gleaming sparrow
#

Is your current repo empty or already has everything in it

wise dirge
#

already has everything i think?

gleaming sparrow
#

Then its likely gitignore

#

Just google the default one and download that, should be fine

#

Have u placed it in the right folder?

wise dirge
#

what folder is it supposed to be in?

#

this is how its setup rn

strong cloud
#

If you go to that directory and run git status are you seeing it saying things are mostly added? Or modified?

gleaming sparrow
#

Should be in the right one then iirc

#

Are the changes mostly deleted files?

wise dirge
gleaming sparrow
#

Bcs maybe u uploaded the full project without gitignore, and now that u have gitignore its removing the files? Idk

strong cloud
#

I think gitignore just ignores changes to already tracked files

gleaming sparrow
#

Ok then my last message doesnt make sense

winged mortar
#

Send an image of your git client?

#

gitignore doesnt delete files

strong cloud
#

Maybe the files were moved? They'd show up as missing (I forget the label git uses) and there'd be a bunch of new, untracked files

wise dirge
#

this is what it says on most files

strong cloud
#

Ahhh

#

I would assume binaries aren't tracked

#

Oh hang on

winged mortar
#

they shouldnt be

#

what is the name of this file?

wise dirge
winged mortar
strong cloud
#

Oh hang on. Try git fetch --dry-run from that folder on your local machine

wise dirge
strong cloud
#

Maybe the gitignore is only containing the right stuff in the pushed repo

winged mortar
#

11 changed files

#

thats fine right?

wise dirge
strong cloud
#

Ah yeah, everything seems normal in the client.

#

Did you change anything in the editor?

winged mortar
#

probs an editor script or smth that ran

strong cloud
#

Even just clicking and dragging something?

wise dirge
#

nope

winged mortar
#

Asset rebuild can sometimes trigger a bunch of changes

thin aurora
#

So either your gitignore is wrong, or you already committed these before, meaning they're not ignored anymore

thin aurora
wise dirge
#

i committed before adding the gitignore

#

thats what happened

thin aurora
#

Manually delete and commit the delete changes

#

Then your gitignore should work, if you ignore them

#

Unity will regenerate the library folder for you

wise dirge
#

so delete "library" and "logs" folder?

thin aurora
#

Yes

wise dirge
#

alright

thin aurora
#

It is possible the changes are not tracked, because your gitignore is partially working

#

In that case remove the gitignore, make sure to only commit the right changes, and then make a new commit to readd it (preferably the one I linked)

winged mortar
#

ignore stops tracking from the moment that you added it

wise dirge
#

deleting logs and lib worked tysm

#

WAIT what about usersettings bc that is also being updated

#

i changed nothing in usersettings i dont think

south tinsel
#

Hey guys. Is it possible to support different Steering Wheels with the InputSystem? I'm finding it impossible to generalize wheels button like we do with gamepads 'Example: Button South'

wise dirge
#

wait now its creating a usersettings change every time i close unity

strong cloud
#

If you look at the diff, what is it changing?

thin aurora
swift falcon
#

Has someone tried Roslyn C# - Runtime C# compiler with dotnow intepreter? Do you know any more examples apart from the one in the dotnow interpreter github?

tawny elkBOT
thin aurora
#

This channel is for general coding questions regarding Unity. For basic questions like these: google

wise dirge
thin aurora
#

It's supposed to

#

I'm not sure, but I think later versions don't change it when you close it (then again, I'm probably wrong)

polar marten
polar marten
#

there are lots of ways to "redo everything"

#

without losing a single file

thin aurora
#

You are responding to a problem that was already fixed

polar marten
#

okay

thin aurora
#

😄

stuck forum
#

Is it possible to in someway use a variable as a type? (specifically talking about casting) or is there an alternative solution to this?

I have a method that takes in a FieldInfo parameter and in the method I need to do GetValue. I know that I'm taking in an array (specifically int so therefore i could cast it as int[]) but I am unsure if I'll only use int arrays (maybe I'd use float arrays too? Basically, how do I dynamically cast a variable?

polar marten
polar marten
#

can you show the real snippet where this would be used?

languid hound
polar marten
#

it depends on your platform

polar marten
#

you might have to check them separately

thin aurora
#

Your use case sounds weird

#

Reflection like that

polar marten
#

are you trying to express, "alt+0"?

#

@languid hound so my suggestion is to explicitly check left and right alt

#

your keyboard might also not have "alt". it could be "meta". depends on the platform

#

you should use an input action for this

#

then you can press the keys on your keyboard and find out what they are

#

using the input map window in editor

languid hound
#

Oh this was just like a quick 5 minute thing to test AssetBundles not a fully blown thing lol

#

I appreciate you putting so much thought into your response though it'd be super helpful

polar marten
#

@stuck forum before you say anything more

can you show the real snippet where this would be used?

stuck forum
#

thats what i am trying to explain

polar marten
#

because you're going to write something so ambiguous

stuck forum
#

wait a sec

polar marten
#

focus on the snippet

stuck forum
#
    private void SetupUI()
    {
        FieldInfo[] fields = _gameMode.GetType().GetFields();

        foreach (FieldInfo field in fields)
        {
            if (field.FieldType == typeof(bool))
                CreateConfigFieldBool(field, "Enabled", "Disabled");

            else if (field.FieldType.IsArray || field.FieldType.IsEnum)
                CreateConfigFieldMultipleSelection(field);

            else
                Debug.LogWarning("Invalid type has been used for game stats. It has to be either of type bool, array or enum");
        }
    }
#

thats literally all atm

polar marten
#

okay

stuck forum
#

and in the function in the ElseIf statement im trying to do the casting thing

polar marten
#

is this a UI at runtime?

stuck forum
#

yes but it will only be called once

polar marten
#

is _gameMode the only object you will want to "inspect" at runtime?

stuck forum
#

yes

polar marten
#

how about in the future?

stuck forum
#

hmm got no plans for changing anything

polar marten
#

okay can i make a recommendation?

stuck forum
#

not use reflection?

polar marten
#

that's correct it's unnecessary

stuck forum
#

when tf does one use reflection then xD

polar marten
#

when you don't know the types ahead of time

stuck forum
#

but in my case, i used this to that if i were to change something in the class, i wouldn't have to change the UI separately, i'd let the code do it for me

polar marten
#

since you control your own code and see all the source, you know all the types ahead of time

polar marten
#

you think you are using reflection

#

you are calling .GetType() and touching things in the Reflection namespace

#

but actually, you know the types ahead of time, so you are not using reflection

#

you are using something, to write a macro

#

it's not worth it

stuck forum
#

welp...

polar marten
#

in my opinion this is a very challenging thing to wrap your mind around because the namespace literally says Reflection in it

#

99% of the effort will be in creating the different UI widgets. it will take you 5s to add or remove fields that you want to visaulize

winged mortar
#

For usages on reflection: you could find implementations of an interface at runtime, and then do something with that. I personally use to build a dictionary which maps enums to specific implementations, to minimize the number of places I have to change stuff when I add something

polar marten
#

don't do that stuff either

#

if you know the types ahead of time, you are not actually doing reflection

#

you might be using Reflection namespace and such

#

but it's not reflection

#

it's just macros

stuck forum
#

could you name one good situation where reflection is actually useable?

polar marten
#

yes, for serialization for example

#

if you are writing a serialization library

#

you do not know the types it will be used on ahead of time

#

however, many modern serialization approaches, for example Unity's JsonUtility and protobufs, do try to find out the types ahead of time

#

so that they do not have to use reflection

#

a common pattern for typed ui inspection is something like

GameMode gameMode = ...
CreateCheckbox("X", getter: (GameMode edited) => edited.x, setter: (GameMode edited, bool newValue) => edited.x = newValue);
#

of course all of this would be a lot more abbreviated

#

i am showing you the labels and type names so that you can nunderstand

#

in your code it would look like

CreateCheckbox(nameof(GameMode.x), edited => edited.x, (edited, newValue) => edited.x = newValue);
#

@stuck forum does that make sense?

#

UIToolkit already has this

stuck forum
#

hmm im trying to understand this

polar marten
#

the signature of createcheckbox is

stuck forum
#

so it does what i want it to do, but just more... better?

polar marten
#
GameObject CreateCheckbox<T>(string label, Func<T, bool> getter, Action<T, bool> setter) { ... }
polar marten
stuck forum
#

I am so confused... I'm struggling to understand what exactly your snippet is doing

#

sorry

polar marten
#

okay

#

well i think you do things the way you need to do them

#

your game mode object has what, like 10 fields

#

i think create the checkbox

#

it's too much new syntax for you

stuck forum
#

actually some will be checkboxes, but some will be multiple selections

polar marten
#

sure

winged mortar
#

@tropic relic just post in here instead of sendin me a DM request

mint estuary
#

Hey people, how are you doing? Let me ask you this, i'm trying to create an inventory system for my survival game, i'm trying to create with Scriptable Objects, the problem is, i'll also have a party of npcs that will have an inventory too...if i use scriptable objects i will have to create an scriptable object file for each npc, and if i want an enemy to have it too, i will have to create for each enemy, the solution that i found was to create a deep copy of a single scriptable object file into the Monobehavior property Ex: SOInventory inventory = DeepCopy(inventoryScriptableObject), but deep copy doesn't seem a good efficient solution, can someone give me a btter way to create an inventory system?

rose fulcrum
#

So, I want to make a way for my player to be able to have a "lock on" feature as part of my combat system. Something similar Bully or Assassin's Creed where you lock on by holding the left shoulder. I'm not sure what the best approach to something like that would be. I initially was going to try and use sphere collider that, whenever an NPC enters, that NPC would be "targetable and when the player presses the left shoulder, it would lock on to the nearest valid target. But then I read something about using raycasts instead.

So I guess I'm asking, are either of the solutions better than the other, or is there another solution that is better overall?

rose fulcrum
#

Its a bit more complex than that but I don't wanna bore you with the details lol

mint estuary
#

Got it Mayo, thanks 🙂

tropic relic
#

the object don't teleport

leaden ice
tropic relic
#

yes

#

should i teleport that?

leaden ice
thin aurora
#

There is also method you can call that updates the CC

hard sparrow
#

Is this not how you do this?

hard sparrow
leaden ice
#

If you're trying to pass it as a delegate you should not be providing a parameter list

#

It should just be ButtonBind(PromotUnitTo);

#

When you provide the () with parameters you're invoking the function

hard sparrow
#

So what's the syntax for passing the parameters?

thin aurora
rose fulcrum
#

Does OnTriggerEnter() work with a character controller as a colider? Cause I don't have another collider on my object and its executing anyway? If it DOES work with a character controller, how can I make it not do that, and make it so I can just have it work with a sphere controller?

#

Or do I just do that with the passed argument?

potent sleet
potent sleet
tropic relic
#

yep

rose fulcrum
hard sparrow
#

I guess this is how you have to do this?

mystic ferry
#

does anyone have any good resources on learning about cancellation tokens?

potent sleet
rose fulcrum
potent sleet
potent sleet
rose fulcrum
#
public void OnTriggerEnter(UnityEngine.Collider other)
    {
        Debug.Log("Hit: " + other.name);
        validTargets.Add(other.gameObject);
    }

potent sleet
tropic relic
rose fulcrum
rose fulcrum
#

So I have a characterController, sphereCollider, and my script on the same object. I need the OnTriggerEnter to only work if the collider is the sphereCollider and not the characterController

stuck forum
potent sleet
tropic relic
potent sleet
potent sleet
#

did you try the first option?

tropic relic
rose fulcrum
tropic relic
potent sleet
potent sleet
#

eg if(other.TryGetComponent(out MyScriptOnThisSphereCol _)) // do stuff

tropic relic
potent sleet
tropic relic
#

since it always printed position to the console i guess yes

potent sleet
#

maybe it's hitting an error

#

is controller assigned ? check console for any errors

#

Debug.Log(spawnPosition) Debug.Log(control.transform.position)
before doing move and after move

tropic relic
sullen loom
#

hey guys i know this is probably super easy to ressolve, but how would i set a bool in one script to whatever the bool is in the other script? cuz i want to detect whenever it's gameover, which does all of that work in my playerscript but i want that same bool to be updated in my logic script so i can detect if whenever i try to pause the game it will let me or not depending on if its game over or not, and all of that pause stuff is in my logic script which is a different script to where the bool gameover is being done

tropic relic
rustic ember
#

Can I make an Update loop like this that I start whenever I need it?

    public IEnumerator SelectiveUpdate()
    {
        while (true)
        {
            // This is a normal Update() loop until we use return;
            yield return new WaitForEndOfFrame();
        }
    }```
tropic relic
#

since debug after move printed the location that i specified as a target location

rose fulcrum
#

Turns my problem was that I just shouldn't have had my script attached to the same gameobject the characterController was on and just create an empty with the script and the sphere collider by themselves.

#

No extra code needed 💪

potent sleet
rose fulcrum
#

i was so confused lol. Thank you for your help tho

rustic ember
potent sleet
tropic relic
rose fulcrum
potent sleet
potent sleet
rose fulcrum
hushed topaz
#

How do i make my projectiles have no collision with eachother? Like how do i stop them from bumping each other away lmao

rustic ember
tropic relic
potent sleet
mystic ferry
#

what is the point of UnityEvents? They just seem like regular delegates

fading yew
#

They are but they are serliazed in the inspector making for easy drag&drops

#

Guys I'm going nuts 🥜
I'm trying to do something so simple. I'm trying to have a "frosted background" look for behind my popups.
My setup is as followed right now:
I have a camera that renders all my UI (excluding my popup)
I have a copy of my main camera only this time it renders to a texture instead
I have a canvas set to screenspace camera (with my main UI camera linked)
I have a "blur popup" canvas with screenspace camera (with my frosted camera linked). In side this canvas is the popup and a rawimage with my RT in the backgound

With this setup the result is I simply don't see the frosted canvas at all and the RT displays the content of my frosted canvas instead of the main UI

But this isn't working at all for some reason and I've tried every combination of depth, sorting layer and settings I can think of 😢

chilly girder
#

Hey everyone! So I'm working on a game jam, and i've ran into a weird issue--Everything about my code is working pretty well for this implementation of sound from FMOD. I am getting the Debug.Log of the "Moving" and "Not Moving"

And! I am getting the debug.log for the start of the InvokeRepeating function.

The only thing is that the InvokeRepeating function isn't calling my CallFootsteps, as im not getting any ping from the debug.log to "PlayFootsteps"

Does anyone have any ideas as to why that might be?

fading yew
#

Are you sure "playerismoving" is true there?

chilly girder
#

I mean, it should be, when debug.log is spitting out "MOVING" the value should be true. Right?

fading yew
#

(also use nameof(CallFoosteps) instead of the string directly, you'll avoid hard to find typos that would lead to no errors like this)

fading yew
#

try a breakpoint at the if there and check if it ever reaches this if

chilly girder
#

Okay! thank you for the help!!

fading yew
#

from what I can see, it can only be playerismoving is reset to false imiedtly after set to true, or walkingspeed is more than the default 5 you have there (check the inspector is also saying 5)
invoke repeating is in seconds by the way, a foot step every 5 second is normal? your boy must big a really big boy haha 🙂

chilly girder
#

Hahahahah

#

Okay good to know haha

#

I didn't realize invokerepeating was in seconds XD

potent sleet
#

also UnityEvents can be serialized, which means that they can be exposed in the Unity editor.

chilly girder
#

Ahh, unfortunately I don’t know much about working with the unity UI stuff 😅 I wish I could help!

swift falcon
#

Are there any downsides to making my classes sealed in unity ? Or making most of my fields static if i know im not turning them into objects.

#

I just dont see this alot and im wondering if there are any downsides to this approach

eager yacht
#

I make all of my classes sealed by default, as I despise class inheritance. If I end up needing it, I can remove it. I do this for myself so that I don't somehow end up creating a chain of 8 inherited things when it only needs to be none or 1 + an interface.

swift falcon
#

Ok so im not crazy

#

I just dont see it anywhere else and it feels like im doing something wrong

magic harness
#

Hey guys. Im working on designing a system to handle enemy spawn in my 2D game.
Im going to have a lot of enemies, so i'll be object pooling. I only want objects to appear at the edge of a collider I have on my character. But I also need to update the position of my enemies through the map. Any ideas on how i should approach it?

#

Right now I have a grid system that gets Points of interest and then activates the enemies on all the adjacent cells of said Points of interest

#

Problem is, that is highly inneficient :/

swift falcon
#

I didnt read ur whole post sorry

eager yacht
# swift falcon I just dont see it anywhere else and it feels like im doing something wrong

Common use-cases tend to be the easiest and most viewed. So take that for what you will 😄 I very much like composition and explicit data-flow, so I make the most that I can without inheritance wherever possible. And that explicitness turns into making sure there is no guesswork in the types or the data. sealed on nearly everything, no virtual, prioritize interfaces without properties or local state changes, etc. There are some exceptions, like needing to inherit for various GraphView things, or other specific APIs ofc but for the most part that's what I do.

swift falcon
#

thank u nomnom

#

Just needed reassurance

#

I am also i very big of being explicit and trying to avoid inheritance hence why i try and make everything static as much as possible. No Idea why sealed isnt the default state of all classes. Besides just the small performance boost. Interfaces are a fucking amazing tool as u mentioned. But seeing as how DOTS is becoming the standard unity is looking forward to pushing. Im thinking about dabbling with the ECS

chilly girder
# fading yew Are you sure "playerismoving" is true there?

So you're right, something about how the code is working right now it's not actually updating the bool at all.

So i think it's starting false then its not being updated too true when I move the player.

If i comment out the entire Update section then set the bool too true it does work - it just plays the audio file at the start.

I guess I'm just unsure how to make sure that the bool value is being updated when I do move.

dusk apex
#

Looks like aspect ratio issues where some pixels aren't drawn due to floating point imprecision or simply not able to draw said pixels scrunched up.

#

You'll need to provide more specific details with what you're doing or have done. Ask the folks in #💻┃unity-talk (they'll figure it out for you)

sage latch
#

When I use MovePosition on a dynamic rigidbody every frame, velocity is ignored. Is this intended?

dusk apex
#

Move position was meant for kinematic rigid bodies

sage latch
#

ah

#

Is there an alternative? I have top down movement but want to use velocity for things like knockback as well

dusk apex
#

To Rigidbody physics or not to Rigidbody physics UnityChanThink (Want some "physics" functionality but overbearingly difficult to undo)

sage latch
#

So you're saying I should code it myself?

dusk apex
#

Kinematic or Character Controller with your own implementation of non real physics is the normal approach.

potent sleet
sage latch
#

If I set the velocity every frame won't the knockback be overriden?

potent sleet
#

not if you make a condition for movement while knockback

#

like a bool

dusk apex
#

It would. You'd have to work around it with edge cases, constraints and whatnot.

sage latch
#

Yeah, but then you lose control completely while knocked back

potent sleet
#

you have to work around that like Dalphat said

sage latch
#

I think I'll go with a kinematic rigidbody

#

And some custom "physics"

dusk apex
#

Wouldn't be surprised if there are half-baked non-realistic but semi-realistic physics assets on the asset store. This is a pretty common issue UnityChanThink

west lotus
rustic ember
#

I have two scripts: PlayerCharacter, and EnemyCharacter. They both derive from UniversalCharacter. I get the component using GetComponent<UniversalCharacter>(). This is then stored in a variable characterComponent. How do I check if my characterComponent is a PlayerCharacter or an EnemyCharacter?

sage latch
potent sleet
#

if(characterComponent is PlayerCharacter) // do stuff

simple egret
#

But you shouldn't

#

The whole point of having a base class is to not know the "real" type behind it

#

You should be able to call a method or get/set a property, and C# handles the action of selecting the right method/property on the "real" type

potent sleet
#

yeah def a quick dirty way

#

polymorphism ftw

#

xD

rustic ember
#

Thank you both 🙏

#

That's smart

rustic ember
simple egret
#

Can UniversalCharacter be used on its own?

rustic ember
#

It just has basic unity events

simple egret
#

So make that class abstract, and declare an abstract method in it. It'll force the deriving classes to override that method

rustic ember
#

Exactly what I needed

#
        public class AStarAlgorithm
        {
            public class PathFindResult
            {
                /// <summary>
                /// Whether or not the algorithm found a path.
                /// </summary>
                public bool foundPath;
                /// <summary>
                /// The optimal path found by the algorithm (Is empty if foundPath is false).
                /// </summary>
                public List<Vector2Int> pathFound;
            }```

This is inside a namespace. I use `using MyNamespace.Pathfinding`, but how can I access `PathfindResult` without having to write `AStarAlgorithm.PathfindResult`? Like I can access `RigidBody` from the `UnityEngine` namespace
#

I don't know if I explained it well

#

Wait is it because it's a class within a class?

simple egret
#

Take the PathFindResult out of the enclosing class

rustic ember
#

Alright

#

Thanks

#

What about public PathfindResult FindPath(Vector2Int[,] _map, Vector2Int _startPos, Vector2Int _target) This has to be inside a class right?

simple egret
#

Yes, as that's a method

rustic ember
#

Okay. Thank you

nova roost
#
int temp = GetOtherValue();
if (temp < currentLowestValue) currentLowesValue = temp```

Is there a short version for this? It feels like there would be. Overwrite value if its smaller, otherwise keep current value?
eager yacht
#
currentLowestValue = Mathf.Min(currentLowestValue, temp);
nova roost
#

perfect, thanks!

severe saddle
#

I assure its advanced

ionic path
#

ah

unreal zinc
#

Is it good architecture practice in Unity to keep the Assembly-CSharp project just for thin wrappers around functionality implemented in a main class library project?

#

or is it more typical to basically write all the code for the game in Assembly-CSharp project?

urban stream
#

Hello! Is there a way to make 3 random bools turn true in an array?

lavish mist
#

hi everyone. Does overlapcircle2d works with triggers?

potent sleet
stable rivet
lavish mist
stable rivet
#

then repeat X amount of times - in your case, 3

potent sleet
#

specific as in trigger / nontrigger or you mean filter it by specific objects?

#

use layermasks

granite mantle
#

I have a text box that I am going to use to display health as a number, but when i define it as a public GameObject, it doesn't let me use getcomponent to define it as text, and when i use public text, it has an error saying cannot convert float to string. im pretty new so this is probably an easy fix. i also tried a health.ToString() method but it won't let me drag my text into the script.

#

im a bit lost rn ngl

stable rivet
#

!code

granite mantle
#

alr one sec

tawny elkBOT
#
Posting code

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

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

lavish mist
# potent sleet sure

i mean something like make it work only with colliders of Gameobjects with specific tags

granite mantle
potent sleet
granite mantle
#

this is just what i have atm

#

but this code doesn't let me drag my text object into the script

stable rivet
# granite mantle alr one sec

typically, you would have a class variable that is the actual text component of the thing you want to update, rather than a GameObject
public TextMeshProUGUI textBox
(this might not be TextMeshProUGUI depending on the type of text you're using)
then you would just textBox.text to change the text

stable rivet
stable rivet
#

it's not a Text box. show your inspector for the GO you're trying to assign

granite mantle
#

it let me drag it on

#

let me see if it works

#

ok yeah it works

potent sleet
granite mantle
#

so what is textmeshprougui

#

is that like some sort of command for text boxes?

#

anyways thanks!

stable rivet
granite mantle
#

oh!

#

that is why i have a canvas linked to all my ui

#

i just assumed it was a "folder"

#

when i made my ui

stable rivet
serene lake
#

How do I send strings through network variables?

potent sleet
serene lake
#

yes

somber nacelle
light jay
#

Hey all i got a quick question i have this line :

{

    public AudioSource CreakSound;```

But in the inspector i cannot put my .mp3 file in it ?

What am i doing wrong here?
#

i can see it in the inspector

somber nacelle
#

AudioSource is a component that plays an AudioClip

light jay
#

so you say i can better make my sound effect a .wav ?

potent sleet
somber nacelle
#

no, i'm saying you are using the wrong variable type

light jay
#

ok Ty!]

#

Maybe i stupid question but CreakSound.Play(); does not work with a Audioclip, So how do i play the Audioclip ?

somber nacelle
#

assign the audioclip to the AudioSource's clip property