#💻┃code-beginner

1 messages · Page 738 of 1

rich adder
#

you have a reference to it

edgy sinew
#

That's fantastic. Thank you

feral sapphire
#

the objects which is spawned upon a Instantiate which is clones, which is not a object within the scene or anything like that by standard, it appears once started the game, so i cant refer to those

naive pawn
polar acorn
#

Also yes they are in the scene

#

that's why you can see them

feral sapphire
naive pawn
#

they're still in the scene

polar acorn
#

so what's the problem

feral sapphire
#

they "spawn in" they are non existent in the scene while editing

naive pawn
#

i think this is getting off track

#

who/what is detecting the click?

feral sapphire
polar acorn
feral sapphire
#

I have. it disables the reference one in the scene, but more keeps spawning, even tho its disabled

naive pawn
#

what is SBA there

#

please just share full code properly

#

!code

radiant voidBOT
feral sapphire
#

its the reference one

polar acorn
naive pawn
feral sapphire
#

thats what u were refering to with setactive lol

polar acorn
#

You've disabled an instance of a prefab, which is what you want to do. Why are we now talking about spawning?

naive pawn
#

you're getting ahead of yourself

#

you're bringing up links that either are not there, or are very weird links that need context, and you have not given context

polar acorn
naive pawn
feral sapphire
edgy sinew
#

So turn off the spawning???

polar acorn
naive pawn
#

yall are talking past each other

polar acorn
#

The thing doing the spawning and the thing you spawn are different things

#

If they were the same thing, it'd replicate itself until the game crashed

#

So are you saying you want to turn off the spawner when you click on an instance of a prefab?

feral sapphire
# naive pawn answer this please <@451277028940054529>

the scriptmanager (where the script is attached to) which is an empty object itself. the SBA (reference object in the scene) has the "onclick" actions. and the prefab is from it. its refering to that one when spawning. the spawning works fine, but I want to disable it upon reaching 1 click (hitting one bread) so they dont stay active. but the thing is ive no idea how to do that per say.

polar acorn
naive pawn
#

and it sounds like it is not the SBA, no

#

it kinda seems like you're overwriting SBA each time you spawn, so you lose references to previous spawns

#

again - you're getting way ahead of yourself in your descriptions

edgy sinew
#

I have an interesting question.

I read in the UnityHowHuh - "larger values approach the target faster"
The main problem of WrongLerp is the last parameter not having any consideration of that right? Usually it's something like myRotateSpeed * Time.deltaTime

What if it does have consideration of the "desired delta"? Hence, larger delta values result in higher maximum allowed movement. Then it's not WrongLerp anymore is it?

feral sapphire
naive pawn
#

it's.. not that complicated

polar acorn
#

Disabling that won't do anything

#

But I also still don't know what you're actually trying to disable

naive pawn
feral sapphire
#

trying to disable the already spawned in "breads" that has been placed there

edgy sinew
feral sapphire
#

or simply remove them from the scene

polar acorn
feral sapphire
polar acorn
#

Right now you put them in the spawnedObjects variable and then do nothing with it

#

So, actually keep that reference around, and disable that

patent wedge
#

why doesn't this work?

char Character = TargetText[Rand];

bool isLetter = Character.IsLetter();

seemingly char.IsLetter(); is a thing, so why doesn't Character.IsLetter(); work?

feral sapphire
#

I tried it with "breadlimit" as they are a float that should be counting them, if there is more than 1 bread on the scene i want it to be disabled

polar acorn
#

You call char.IsLetter(Character)

polar acorn
feral sapphire
polar acorn
#

which ones

#

Presumably, you want one of them to not be disabled

#

which one

#

If you just want the first one to exist and not have any others, why not simply not spawn extras if there's still one?

edgy sinew
#

Sorry guys if it's dumb question -
Does anyone understand the math of this UnityHowHuh about WrongLerp?
They say to use 1 - Mathf.Exp(-decay * deltaTime) as the t value with decay = 10
I'm really unclear on what this is doing or how it affects the Lerp. Thank you blushie

hardy wing
feral sapphire
#

so if you look at the code, 1 of them is spawning, the other ones doesnt until xx amount of time. (its set to short now) but Its alright if there is more on at the same time. the problem is that they dont ever go away. so if I dont make em dissapear, the whole screen will be filled, and you can click on them infinitely

polar acorn
feral sapphire
#

like, they are supposed to be like in cookie clicker where 1 golden cookie spawns

edgy sinew
polar acorn
feral sapphire
#

how do I do that?

polar acorn
#

Whatever code you're doing to detect when the bread is clicked on

#

also disables itself

hardy wing
#

Yeah it's neither an Ease-in nor an Ease-out whereas a = Lerp(a, b, dt) would be more similar to an Ease-out.

edgy sinew
#

As I understand it the basic idea of smoothness is "large delta, move more. small delta, move less"

naive pawn
feral sapphire
polar acorn
edgy sinew
hardy wing
feral sapphire
naive pawn
polar acorn
#

There's no click detection in this code at all

edgy sinew
#

Mostly I never have myMagicValue * Time.deltaTime there's always some "higher delta yields higher allowed change this frame"

hardy wing
edgy sinew
#

Pretty sure the behaviours are identical in this case. Or is there more to it.

naive pawn
feral sapphire
polar acorn
#

and add in one

#

that disables the object

hardy wing
polar acorn
#

You're doing something to call these functions.

#

Add a disable there

naive pawn
hardy wing
#

that's why i asked how you do it properly

naive pawn
#

i mean, depends on what you mean by "proper", i guess?

naive pawn
#

if you just mean making it consistent, that would be the exponential decay thing

hardy wing
feral sapphire
polar acorn
naive pawn
polar acorn
#

and you know how to disable an object because I've told you

edgy sinew
#

Yes. What is the way to handle that?
For some of my functionalities, I've literally just implemented a "minimum approach velocity" because, well, yeah the

#

SNAP? I KNEW IT!

polar acorn
#

So, just, do that

edgy sinew
#

HAHAHA!

feral sapphire
polar acorn
hardy wing
naive pawn
feral sapphire
#

its a button on the reference (SBA) and the script for the button is the one I showed earlier

edgy sinew
#

One Lerp away, from AAA! stonks

polar acorn
#

what is the name

#

of the thing you do

#

to set a function

#

what is that called in the inspector

#

so add a function

hardy wing
feral sapphire
polar acorn
#

that disables the object

naive pawn
#

it'll just be fps-dependant

polar acorn
feral sapphire
polar acorn
#

So add a function to the on click

#

that disables the object

#

You know what function it is

#

I've told you it before

#

You can put the pieces together

#

I believe in you

hardy wing
naive pawn
#

ok, and what is p

edgy sinew
#

myMagicNumber * dt - no good

eternal needle
#

thats pretty much the whole reason its wrong

edgy sinew
#

Normalized time? Sorry, what is that

naive pawn
polar acorn
feral sapphire
polar acorn
#

0 means none done
1 means full done

edgy sinew
#

Oh okay

#

Yes of course

hardy wing
naive pawn
polar acorn
#

Call that function

#

from the button's on click

naive pawn
edgy sinew
#

So guys again... If the "t" value is dynamic, NOT just magicNumber * dt - we're actually totally cool right.

hardy wing
#

but the percentage concept is inherently flawed because a is not constant

naive pawn
eternal needle
polar acorn
#

So, if you want to make sure it reaches b, make sure you do something that involves t being 1 or more

edgy sinew
#

What if the t value is lower or higher based on the delta?

eternal needle
edgy sinew
#

It's not a WrongLerp then or?

naive pawn
hardy wing
edgy sinew
hardy wing
#

but the problem is that there is no predictable start and end

#

so you cant normalize it

naive pawn
#

i wonder why it's called wronglerp

#

maybe because it has all these issues

hardy wing
#

petition for unity to rename lerp to wronglerp

naive pawn
#

no, the usage is wrong, not the function

#

lerp stands for linear interpolation. if you aren't using it for linear interpolation, you're technically using it wrong

polar acorn
naive pawn
#

the issue is on you, not unity

polar acorn
#

The problem is assuming "Lerp" means "Do this thing over time"

edgy sinew
#

yeah i use Lerp correctly sometimes too. for like, "happens over 0.5 seconds" things that have a start and end

polar acorn
#

It has nothing to do with time

#

It's a mathematical function

eternal needle
naive pawn
#

lerp is just a * (1 - t) + b * t

hardy wing
naive pawn
#

yes, that's why we're talking about wrong usage

edgy sinew
#

Basically. Our whole issue is, to go from currentValue to desiredValue - and how much to approach it the current frame.

naive pawn
#

what are you going on about

eternal needle
polar acorn
#

If you want to move a value towards a destination and the destination is amorphous, you'd want to use MoveTowards

hardy wing
naive pawn
#

we don't know what you want

hardy wing
naive pawn
#

also, no-one is saying it's bad

#

it's objectively a wrong usage of the lerp function. but if the output is desired, then it's a correct application of wronglerp

polar acorn
#

It's not "bad" it's just "not a linear interpolation"

hardy wing
zenith cypress
#

There is also SmoothDamp

eternal needle
eternal needle
naive pawn
polar acorn
#

Lerp can be part of a greater mathematical function that achieves something that is not a lerp.

eternal needle
#

I can explain things in different ways if you don't understand it. I can't read things for you
My message specifically said if you dont know the end value

hardy wing
#

and i probably still didnt process the talk and am still confused and overwhelmed by it

naive pawn
edgy sinew
hardy wing
polar acorn
zenith cypress
hardy wing
#

but ultimately the solution i have rn is "use fancy freya formula that i dont understand nor comprehend"

#

and that is what is frustrating

edgy sinew
#

The only way I can make it feel decent, is by basically making it like SmoothDamp with curve.Evaluate()

polar acorn
eternal needle
hardy wing
#

how am i supposed to break down a completely uncomprehendable exp(x * dt) factor? but as you said, maybe i'll take time to watch the talk but for now it'll just be "not understand"

edgy sinew
#

Maybe graph it?

#

Let me see if i can do that it's graphed on the UnityHowHuh

hardy wing
zenith cypress
#

no

supple phoenix
#

hello im starting programing in unity. Im making 2d game what extensions in visual studio code can help me with that?

radiant voidBOT
polar acorn
eternal needle
#

(missing a 0 in that 0.0166)

polar acorn
#

So shift the whole thing down a bunch

edgy sinew
#

So.. basically, it's some kind of smooth curve

polar acorn
eternal needle
#

either way yea thats how exponential functions look

edgy sinew
#

IRL everything moves in curves eh? Just how things work physically

naive pawn
#

lerp stands for linear interpolation. the "correct" usage to get a linear interpolation is y = lerp(a, b, t) where a and b are constant and t is a normalized value that either increases or decreases over time.
if a or b aren't constant, or t does not increase/decrease over time, then it is, in regards to "linear interpolation", an incorrect usage of lerp.

a = lerp(a, b, dt) is a common usage of lerp that can be useful to emulate ease-in smoothing, but ultimately is not linear interpolation. since it's a common pattern, it has the name "wronglerp".
since it's using a function that isn't designed for smoothing, it comes with a few hidden issues, mainly time inconsistency and asymtotic behavior.

time inconsistency: dt does not have reasonable "percentage over time" units as one might assume, and multiplying in factors just have a vague "quickness" effect. different values of dt will make wronglerp approach b at different rates.
this is solved by sampling an exponential function instead, yielding consistent results with different values of dt, due to some math regarding euler's number.

asymtotic behavior: lerp will yield b once t reaches 1. since this usually will not happen with wronglerp, b won't be reached.
this is solved by setting an epsilon, where b is yielded once the distance between a and b is less than the epsilon.

@hardy wing

#

oh shoot, it's not exponential decay is it, it's just exponential

#

and TIL euler's constant and euler's number are not the same thing
thanks, euler

patent wedge
#

how can i find the point at where two different strings change.

naive pawn
#

iterate through them until you reach the end of one or you find a different character

edgy sinew
#

@naive pawn the epsilon snapping thing is just a hacky bandaid fix for WrongLerp right?
Or when doing things correctly is it also required?

#

I'm wondering if there's a way to have the smoothness but also reach the final value.

naive pawn
#

(asymtotic just means it approaches some value but never reaches it)

edgy sinew
#

Copy that. I'll keep that in mind

edgy sinew
naive pawn
#

freya's video also has a plot with the "better" wrong lerp i think? and that was asymtotic too

edgy sinew
#

It says it solves frame rate dependency, but it doesn't say if it's still bad practice to do this

eternal needle
naive pawn
#

i think SmoothDamp also does the epsilon thing inside but i can't confirm that because i cannot wrap my head around its code lmao

naive pawn
slender nymph
brave robin
#

The lerp info there also linked to this, which has a lot of useful stuff for making your own animation curves for easing in and out
https://easings.net/

#

Like if you want only an ease in with a sine curve

function easeInSine(x: number): number {
  return 1 - Math.cos((x * Math.PI) / 2);
}```
#

That's not C# code syntax, but easy to figure it out from that formula

feral sapphire
polar acorn
brave robin
feral sapphire
polar acorn
#

Both affect the object that is running the code. Is this script on the object you want to destroy.

feral sapphire
#

and now it just magically works

#

I had the Destroy Gameobject on the manager as well (removed it from there, and added to only the object and it works)

hardy wing
vital otter
#

how do I change the triggers using code in a button component?

#

specifically the Normal Trigger

vital otter
#

oh i figured it out myself right before finding yours

#

thats lucky lol

#

why did all my animator controllers clear?

astral flame
#

Hi everyone, could you please help me with this error in my code? Please watch this video first so you can understand exactly what's happening when it shouldn't.

slender nymph
#

instead of spending more than a minute wiggling your mouse around and waiting for loading bars, you should have just recorded just the last bit so we can point out that it seems to be an issue with either your animation or the placement of relevant objects

astral flame
slender nymph
#

so your issue is not that the player is floating above the seat? because if that isn't the case then your video was not clear at all

astral flame
#

!code

radiant voidBOT
slender nymph
#

now actually describe your issue in detail

static terrace
#

is UI Bugged and confusing or is it normal for it to make the objects and sprites disappear?

winged ridge
static terrace
#

When I select on my sprite, everything appears, but when I go to my text everything disappears

winged ridge
static terrace
#

it only disappears in the editor

#

not the whole game

#

so when I run it, or preview it, the text is there, and everything is there

slender nymph
#

show relevant code. otherwise #📲┃ui-ux (you'll also need to provide relevant details about your UI setup)

static terrace
#

There is no code, it's just Legacy Text with Canvas

slender nymph
#

this is a code channel

static terrace
#

Oh sorry

dense lantern
#

hi, since machine learning and LLM AI has been all the rage for a while now i'm wondering if someone's made some sort of "game" or tech demo that lets u make an NPC with any type of skeleton (i want it to use my custom Ark raptor model) make any movement, sound, or activate any particle effect or script u want on command, either through talking to it through your mic or text? i know these types of experiments have been going on for a while but i'm wondering if any have been somewhat successful

eternal needle
dense lantern
eternal needle
grand snow
#

Don't be dumb and use some api in the client because people will just steal the api key and fuck you

#

if it must be some llm then you need a local model or a server you create that then uses some third party llm rest api

dense lantern
grand snow
#

I have no idea if anything exists that is compact enough for viable use with a game but you can do some research on this

dense lantern
dense lantern
grand snow
#

you can just dont directly use it in the client/build

eternal needle
#

Even generating text/speech at runtime is just a gimmick thats already quickly faded out. I doubt AI companies are rushing to push AI animations (at runtime) considering it'll likely just bug out and get boring after the first 10 mins if it works

winged ridge
teal viper
# dense lantern hi, since machine learning and LLM AI has been all the rage for a while now i'm ...

You're mixing up several unrelated concepts. Or at least concepts that would require many different AI models(speech recognition, llm, tts, animation generation model, etc...). While some of it is possible given enough effort and costs, other(like animation generation) is probably not gonna be good enough for a real time app, even if you're using a cloud service via an api.

If you're looking for a simpler example(TTS + LLM + peach recognition), could look at a game called AI2U.

thorn kiln
#

The animation for running seems to keep playing even after I stop. Anyone know how to fix it? This is the code I'm using for the triggers.

        if (Math.Abs(Input.GetAxis("Vertical")) > 0 && uIManager.isGameActive)
        {
            anim.SetTrigger("Move");
        }

        if (Math.Abs(Input.GetAxis("Vertical")) == 0 && uIManager.isGameActive)
        {
            anim.SetTrigger("Idle");
        }```
teal viper
polar acorn
grand snow
#

that any to locomotion transition seems bad too

#

disable transition to self for a start

thorn kiln
#

I know it's bad, but I'm jury rigging a more involved animation that the pathway gives to you

#

Thats why there's all that unconnected stuff to the right

thorn kiln
grand snow
#

I think that is an option for any state transitions

#

you can see it keeps transitioning into itself

#

dis guy

thorn kiln
#

Doesn't fix it

grand snow
#

you need to do more like correct the other transitions to not have exit time + a long duration

tall agate
#

ah lame they changed a bunch of channels to be forum-style so it's less efficient to just bounce ideas off of people

timber tide
#

the channels still there, but hidden at the top of the forum channel

dense goblet
#

looking for some help here real quick, I wanted to change how I do my Raycasts (to turn it into a CircleCast so it can see a little below the line)

so I wanted to turn it into a seperate bool because the way I have it done now kinda sucks. but now it constantly sets off.

https://paste.mod.gg/uyacorvwjivt/0

main note is that

``` is constantly true, regardless of player distance*
zenith cypress
#

The classic pitfall of distance before layermask LUL

dense goblet
#

so distance has to be after layermask?

zenith cypress
#

Yeah

dense goblet
#

okok let me try that

zenith cypress
#

no

dense goblet
#

oh

zenith cypress
#

I misread that since it is late lol, distance is before

#

Yours doesn't have "distance"

#

So the mask is acting like it

dense goblet
#

tysm

#

Im gonna say it just in case its simple, but all I need now is to find a way to the number positive/negetive depending on direction, but its prolly a transform thing

#

(trying transform.rotation.x + 1)

naive pawn
#

please do not spam here

river seal
#

67777 😂

cosmic dagger
#

No reaction gifs . . .

naive pawn
#

that isn't even a reaction gif

winged ridge
#

I mean in general... Don't be annoying

fast tusk
#

can somebody help me with a weird issue with the inspector breaking?

#

I don't want to dump all the error messages here but I haven't touched anything editor related and I'm getting strange unity UIElements issues

winged ridge
#

Is it things vanishing like text on the right hand side?

fast tusk
#

yup

#

and error spam

winged ridge
#

What unity version are you using

fast tusk
#

most recent lts

#

6.000.0.58f1

#

windows

#

I started with 6.000.2.5f1 and had the same issue so downgraded to lts and the issue kept happening

#

I can give specific error messages if it would be helpful

winged ridge
#

First step is restart your application, see if that fixes, if not since it's an editor bug you'll have to file a proper error report with screenshots

fast tusk
#

restarted, reinstalled, recreated

#

done it all

#

how do I file error report?

winged ridge
fast tusk
#

oh officially through unity

#

got it ty

winged ridge
#

If it's your code, here, if it's Unity itself, their proper channels. 1st step for all issues is restart as you did etc, 2nd can it be repeated.. in this instance it has been just not by you.. 3rd report it

fast tusk
#

do you think it would be worth it to keep downpatching until I find a release where it isn't an issue?

#

i've been working with unity for 4 years ish and i've never run into this issue before

winged ridge
#

I'll tell you the version I'm on, so far I've not had issues

#

6000.1.2f1

fast tusk
#

thank you, i'll try that

umbral hound
#

I read over it and I just saw one reference to CharacterController.Move

wintry panther
#

Hey I'm having large spikes in my game right now. Looks like its under "other" category. i have like 6-10 objects in the 2d scene

#

not sure why thats happening

#

looks like the rendering is super slow? not sure since im new

#

could be my pc as well, but my pc is pretty good. i have had problems with my GPU in the past though

winged ridge
#

I mean.. I thought my pc was good then blue screened it 4 times in a row... There should be some tests you can perform online to see if it's any failing components

teal viper
#

Pro tip: don't use the timeline view unless you know what you're doing. The hierarchy view is way easier to understand for a beginner.

#

Also, it seems like the player loop is just 13 ms, which is more than enough to run at 60fps.
Around 2/3 of the frame time seems to be coming from the editor loop.

If you don't care about editor performance, test and profile an actual build.
If you do, then you'll need to switch the profiler to editor mode to see what's going on.

wintry panther
wintry panther
#

if i have a composite collider for my ground objects and i move a ground object from the left to the right side of ground plane would the composite collider update? and would that impact performance?

#

im making a 2d endless runner and i have like 10 ground objects

#

that i move to the front after the player runs past them

#

i should probably make each ground object long, so i dont have to move them too often

limber turtle
#

is there a way to use FindGameObjectsWithTag() on a list rather than an array? i need to find active objects with a specific value in one of their components and my way of doing that is to find all objects with the right tag, get the component and remove all of those with the wrong value from the list but i'm getting a conversion error

teal viper
#

You can add the desired element to a separate list that you reuse.

limber turtle
#

because i can't remove the values from an array, from what i know. i may be stupid

teal viper
#

Why do you need to remove them?

limber turtle
#

how the Fuck did i not think of that

limber turtle
teal viper
limber turtle
#

thank you

#

i can't find much on the unity docs about lists so i may need to ask a few silly questions

eternal needle
winged ridge
#

foreach(Itemtype item in listname)
{ if(item.GetComponent<component name>.variable)
itemlist.Remove(item);
}
else continue; a quick example may need tidying

eternal needle
limber turtle
#

yeah i prefer knowing what to do myself

eternal needle
limber turtle
rose atlas
#

It completely removes the critical thinking aspect of problem solving

winged ridge
#

Oh I meant the wrong bit

limber turtle
#

thank you guys, i'll get back to it

eternal needle
# winged ridge Expand on why

Well first off it just wouldn't compile. Your else is in the wrong spot. It also does the opposite of what's needed, adding to a new list

#

Its also particularly a hassle to go into a lesson correcting someone providing wrong information, in the middle of helping someone else. Generally this happens when people try to spoonfeed

winged ridge
#

I did say it needed cleaning up, formatting on phone is not the best.
And the adding to a new list is needed if he needs the data of the components he doesn't want in the new list

naive pawn
#

protip: if you're on mobile and not confident with writing accurate code, just write in pseudocode

winged ridge
#

If you already have one singular list, and don't need certain aspects of that list, just remove them

winged ridge
sharp bloom
#
transform.rotation = new Quaternion(0, playerCam.transform.rotation.y, 0, playerCam.transform.rotation.w);

I did a little "hack" to rotate in third perspective based on a Cinemachine orbit look camera, is there a good reason not to do this?

eternal needle
winged ridge
#
foreach (GameObject saveData in objectsToSave)
        {
            state = new();
            nSaveable = saveData.GetComponent<ISaveable>();

            if (saveData == null)
            {
                continue;
            }

            if (data.sStates.Contains(state))
            {
                data.sStates.Remove(state);
                Debug.Log("Data Changed");
            }

            // HandleInventory(state);
            // state.itemsInInventory = nSaveable.SendData().inventory.SendItemFromInventory();
            // state.itemQuantities = nSaveable.SendData().inventory.GetItemQuantities();
            state.id = saveData.GetComponent<DataHandler>().objectID;

            //Iterates through the entire list of states in the List<SavedData> and for each one, checks its ID against the objects raw ID
            for (int x = 0; x < data.sStates.Count; x++)
            {
                int sDataID = saveData.GetComponent<DataHandler>().objectID;
                //If the ID matches, saves the data below but first, deletes the data from file to replace it fresh, this happens to prevent duplicates
                if (data.sStates[x].id == sDataID)
                {
                    data.sStates.RemoveAt(x);
                    HandleChangeableData(nSaveable);
                    HandlePermanentData(nSaveable);
                    data.sStates.Add(state);
                }
            }

Ignoring the end aspect, you are telling me this code would not work?

sharp bloom
#

Well it's just a quick prototype and it does what I want

north kiln
#

well it's nonsense code that doesn't even maintain quaternion normalization

eternal needle
winged ridge
#

well, its not a code question since I know it works, and it does implement the feature i mentioned, albeit far tidier. The original question asked if it was possible to do in an list and not an array, hence the foreach loop mentioned, yes the code wouldnt work due to several issues, but was enough for someone to look into ie what is a foreach loop

sharp bloom
north kiln
#

it's unclear what you're even trying to do because the code makes no sense

naive pawn
#

if you want to suggest foreach, then do so

eternal needle
north kiln
sharp bloom
north kiln
sharp bloom
#

Yes it's very much a "hack"

north kiln
#

No you're not, you're constructing a non-normalized quaternion

#

use Euler angles

sharp bloom
#

Here I don't need anything precise but yeah I should

patent wedge
#

ok so i have a typewriter effect and i'm using maxVisibleCharacters but i also want that movement of the text when typing how can i achieve that?

grand snow
# patent wedge ok so i have a typewriter effect and i'm using maxVisibleCharacters but i also w...

With tmp you can modify the mesh produced via an event (or you can modify the whole mesh and replace it if you prefer). This can be used to animate the text. There are also free packages that offer many different pre made animations for tmp text.
https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/api/TMPro.TMP_Text.html#TMPro_TMP_Text_OnPreRenderText
https://github.com/Luca3317/TMPEffects

patent wedge
grand snow
#

Center alignment? Do characters that are not visible still affect alignment then?

grand snow
#

if you just want the text to appear over time then you can just update the text with more characters.
Otherwise alignment wont act as you wish

regal fractal
#

Hello, I am new to the channel.

#

I want to share data between multiple mono-behaviour script files of game objects. Anyone interested?

teal viper
#

Not interested, thanks.

teal viper
#

Other than that, go learn C# basics.

regal fractal
teal viper
#

You can have a public property though.

stoic flare
#

can you create a game like whiteout survival using unity?

regal fractal
silver fern
winged ridge
regal fractal
#

yes, that is obvious if one is sharing the data between several classes

stoic flare
silver fern
winged ridge
stoic flare
#

cool , thanks

teal viper
stoic flare
#

Whiteout survival works?

#

like this game

regal fractal
teal viper
#

That would be sharing a reference to an object in the memory. Not a file...

winged ridge
stoic flare
#

it's online game

winged ridge
#

To start with if you know little to nothing, unity learn.
Else 2d, importing the multiplayer packages

stoic flare
#

2d universal?

#

where is unity learn

winged ridge
#

!learn

radiant voidBOT
silver fern
#

!learn

radiant voidBOT
stoic flare
#

thanks

past ivy
#

hlo , we wade some levels of a game, initially they're doing well and now after 7 8 levels when pressing the play button, it immediately stops playing and there are no errors showing in any case like on console, script is the same for every level with only some changes but 1 or 2 levels works sometimes

hollow light
#

ill be frank this isnt really scripting but it is very simple and i dont know how im messing it up, imported a bird library and the textures are all fucked up, the sextures are set in the material but alas, its still pink? tried swapping the textures and playing with some value to no avail

slender nymph
#

and please use the correct channels next time instead of intentionally using an incorrect one

hollow light
#

unity.huh.how is an incrediibly funny url

slender nymph
#

ill be frank this isnt really scripting

#

you knew you were posting in an unrelated channel, that is literally the definition of intentionally using an incorrect one

hollow light
#

to my knowldge other channels were more discussion not for help, most servers for other engines have like, help_0 help_1 etc

slender nymph
#

everything except for the showcase channels are help channels

hollow light
#

alright

#

thanks my apologies

#

meant no harm

cedar peak
#

is anyone able to help over vc my codes not well written and i cant figure out the problem im trying to put a score text over my game when its running and a gameover screen wich also shows the final score

slender nymph
#

there are no voice chats here. if you need help then you need to actually provide details about your issue here

#

!ask

radiant voidBOT
# slender nymph !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

slender nymph
#

!code

radiant voidBOT
cedar peak
weary finch
#

How can I create a Texture2DArray that only lives inside the GPU?

silk night
polar acorn
# cedar peak

Look at the lines that are underlined in red, and start to fix them from top to bottom

cedar peak
#

i tried but its like really bad

weary finch
weary finch
brave compass
weary finch
weary finch
#

Now, separate but similar, can I somehow move NativeArray data into a RenderTexture? Basically write directly to the render texture, without going through a Texture2D copy. I understand I can create a texture2d, get a writeable native array, write, and then move it into the GPU, but then I still would have the CPU version

#

Apply, once again, only makes it unreadable, but it still exists on memory

pallid forum
pallid forum
rich adder
#

if you want to share code use the appropriate paste bin sites

radiant voidBOT
pallid forum
# radiant void

Am I suppose to place my code inside the website? (Tbh I should ask before paste and save it)
The code isn't finished by the way. I just feel like I wrote it in a bad way, So I just came to ask for someone to review.

rich adder
weary finch
rich adder
weary finch
rich adder
#

codeblocks are good for like 5-6 lines of code

pallid forum
weary finch
#

Well, first thing, you shouldn't manage turns via a string

rich adder
#

Coroutine will delay code inside the method not outside

#

eg

 IEnumerator DelayCoroutine(float delay)
    {
        yield return new WaitForSeconds(delay);
        //some code to run after delay
    }```
#

so that for loop is not delaying

#

every iteration you start a new coroutine that does nothing for 0.1 basically

pallid forum
#

okay so.. what's the correct way here?
Do I just use yield return new WaitForSeconds(delay); inside of other medthod that is suppose to be delay?

rich adder
#

what you could do is also pass a specific method as Action to run if need be .

#

currentPlayerTurn could probably be turned into an enum for a slight efficiency , clarity , consisentcy.. like not having to worry about any string mistakes (spelling, capitalization etc.)

midnight plover
#

you better remove that

rich adder
#

<@&502884371011731486> spam

frosty hound
#

!ban 1412567089360928779 span

radiant voidBOT
midnight plover
#

bye bye 😄 thx

rich adder
#

@pallid forum I see you used enum for DicePhase, why not also use it for playerTurn / team for player

#

other than that, I think you should be okay

pallid forum
rich adder
#

yeah strings are finnicky. they are not type-safe and generally a pain to work with, you can mitigate some issues with const but with enum is basically a const numeral with human-readable labels

midnight plover
rich adder
#

by default they already are integers too

midnight plover
#

Wow, sorry for that bad description, but I hope you get what I mean 😄

rich adder
#

I get what you mean, in certain cases I guess that could be useful if you add additonal entries but here its only two teams anyway
(black, white)

brave compass
# weary finch Now, separate but similar, can I somehow move NativeArray data into a RenderText...

One option is to create a Texture2D, write to it on the CPU, Apply, then use Graphics.CopyTexture to copy from it to the RenderTexture, then Destroy(tex2D) to release all the memory from that texture, on CPU and GPU.

Another option would be to create a GraphicsBuffer, which you can write to with a NativeArray, and copy the data from that to the RenderTexture in a compute shader. I don't really know if there's much benefit to that, though.

pallid forum
#

Hey uhh, I think I am a little bit confusing in this part.
if I want to delay the medthod OnRollDiceButtonClick() do I have to put in IEnumerator too?
But that cause a red line.
how do I delay it?

#
public void OnRollDiceButtonClick() 
    {
        if (rollDiceAvailable)
        {
            int diceNumber = 0;
            for (int i = 0; i < 8; i++)
            {
                diceNumber = Random.Range(1, 7);
                rollDiceText.text = diceNumber.ToString();
                yield return new WaitForSeconds(0.1f);
            }```
slender nymph
#

yes, if you want to yield within the method it must be a coroutine

rich adder
pallid forum
rich adder
#

buit yeah basically aside from wrong return time thats how you delay between each iteration

rich adder
pallid forum
#

What's the solution here?

rich adder
#

put the code you just showed in a IEnumerator you call from OnRollDiceButtonClick

#

private void OnRollDiceButtonClick() => StartCoroutine(DiceRollWithDelay()); // lambda for brevity but you can put it in braces (actually called expression body )

private IEnumerator DiceRollWithDelay()  {
        if (rollDiceAvailable){
            int diceNumber = 0;
            for (int i = 0; i < 8; i++)
            {
                diceNumber = Random.Range(1, 7);
                rollDiceText.text = diceNumber.ToString();
                yield return new WaitForSeconds(0.1f);
            }```
edgy sinew
sharp abyss
#

How can I make the head bead get past without problems.I want it to look like head bead is moving and other follow it.

rocky canyon
#

Snake layer -> snake disabled
Snake layer -> everything else enabled

normal copper
#

Hello! I'm running into some problems with Unity 6.2 and Tilemaps. My project consists only of a scene, a grid with a script, and a tilemap. If i declare a public Tile array member, then i get all these errors above when i click my grid GameObject in the Hierarchy, even without running the game. What am I missing? Any help greatly appreciated.

winged ridge
normal copper
#

Thanks! Is 6.2 not considered stable?

rocky canyon
#

do a little search around here.. 6.2 be notorious for bugs RN

#

stick to LTS unless ur actively help Beta and bug test the engine

normal copper
#

F*** me i just read "supported" and figured i'd give it a go

rocky canyon
#

ya, apparently that Tag is "misleading"

normal copper
#

THANK YOU though!

rocky canyon
#

ive had pretty luck with this version

#

any LTS tho should be pretty solid

normal copper
#

I couldn't find that one but gonna try this one

grand snow
#

you always want the latest patch for the editor version

#

as you can see its marked LTS

charred monolith
#

Is there a way to make other Delay than coroutine

grand snow
#

async as well as MonoBehaviour.Invoke()

shell sorrel
#

or just keeping track of time in a float

#

or keeping track of the target time to reach

rocky canyon
# charred monolith Is there a way to make other Delay than coroutine
 void Update()
    {
        timer += Time.deltaTime;

        if (timer >= limit)
        {
            CallFunction();   // Do the thing
            timer = 0f;       // reset for repeat
        }
    }
   void Update()
    {
        if (triggered) return;

        timer += Time.deltaTime;

        if (timer >= limit)
        {
            CallFunction();   // One-time call
            triggered = true; // stops repeating
        }
    }```

as a beginner my timers usually consisted of just counting in update
like Passerby mentioned above ^

you can count up, you can count down, you can reset it to count again, or stop it for a single thing
shell sorrel
#

can also just do something like nextTrigger = Time.time + duration;

#

then in update check if (Time.time > nextTrigger)

supple phoenix
#

does someone know how to disable this reference?

slender nymph
#

it's part of Code Lens. and it's typically better to leave useful debugging tools like that on

supple phoenix
#

Hym.. u got a point

echo sandal
sharp abyss
gloomy bison
#

Bearing in mind i dont change my visual studio because i’m a very boring person

#

Shit im a bit late

zenith cypress
sharp abyss
#

How can I make movement look better I mean how can I prevent the build up of limbs in one place. I tried freezing the head rotation but build up stayed the same.

thorn kiln
#

So, I'm trying to use OnMouseDown(), but it's not working, and googling it shows a lot of people saying the same thing, but they're all from like, a decade ago. Is there something I'm missing?

polar acorn
#

Is the object you're trying to use OnMouseDown on a world-space object with a collider?

thorn kiln
#

It is... a sphere? With a collider and rigidbody, if that answers your question

polar acorn
#

So, it's not in UI, and has a 3D Collider?

thorn kiln
#

Oh, wait, it's working now, but my debug.log still isnt posting anything

#

Weird

#

Hmm, it doesn't seem to wanna work once it hits the "ground"

polar acorn
#

Could be that when it's close to the ground your mouse click is detecting the ground instead

thorn kiln
#

Oh wait, this project comes with a box collider

#

Would that be interfering?

#

Yeah, it seems to stop responding once it enters that zone

polar acorn
#

Probably

#

It detects the closest collider to the camera

thorn kiln
#

Doesn't explain why debug.log isn't working when I click it

thorn kiln
polar acorn
#

More work, but you can actually customize what you hit

grand snow
#

New input system fully breaks those mono mouse messages

willow iron
#

im using renderer.isVisible to debug.log true when this cube is in sight of the camera. for some reason, this renders as true even though it is out of sight from the camera. yes i made sure that the scene camera is not triggering it

grand snow
#

A better way is to get its bounds, figure out its screen/viewport space bounds and then see if the min or max is within the screen
needs extra steps if the mesh covers the entire screen but the general idea works

#

oh also needs handling to know if its in front of the camera of behind too

normal copper
rocky canyon
#

im still not a pro.. but i typically use coroutines now

normal copper
grand snow
#

async is where its at 😎

rocky canyon
#

see thats pro level ^

#

i use some async stuff like loading levels and stuff

grand snow
#

I would not recommend async for beginners though

#

especially in unity. elsewhere well its the only choice probably

normal copper
#

How often do you guys use async? Ive only ever really used it when handling HTTP stuff so im trying to think of use cases in game dev

rocky canyon
#

my loading screen uses it to load in and out scenes

grand snow
#

I only use it and stopped using coroutines almost entirely

#

makes integration with anything else async much better and also fixes the problem where coroutines require a mono instance to be started (and be executed)

rich adder
rocky canyon
#

as a beginner/novice the only time i need async is to load scenes that way i can animate a progress bar and not have the display frozen while it loads up
else its just .... hung loading screen ... pow game

#

really any other time a coroutine is just fine

normal copper
rich adder
rocky canyon
#

async in general (i dont think unity raises the complexity) altho i couldbe wrong

grand snow
#

but async doesnt give a shit, its up to your logic to make it stop when you want it to

rocky canyon
#

unity offers alternatives b/c its such a great game-engine 💪

grand snow
#

well unity took too long to implement their own task alternative so UniTask is better

winged ridge
rocky canyon
#

ya, i can tell im still a beginner b/c looking thru UniTask stuff and async stuff just feels outside my realm of understanding.. trying to think of a use-case I ,myself, would run-into is impossible it seems lol.. overkill in otherwords

winged ridge
rocky canyon
#

"generalist" lol.. jack of many trades, master of none

#

one day i might start caring about how the threads are working in my projects.. but not anytime soon i would imagine lol

winged ridge
#

I like the term "Research capable" lol what I don't know I know how to learn and find resources to help me on my way. I can't make 3D art to save my life, but I know how to follow tutorials and replicate that.
Code is same, get the code down, look at why it works, play with it, see what works and what doesn't work, best way to be

cloud fox
#

Whenever I make a script it makes some other misc files that cause unity to throw this error and enter safe mode. How do I fix this? I googled online and I've found conflicting answers and am now just confused.
PLEASE PING ME WHEN YOU REPLY

winged ridge
#

What are the files? And have you ensured your Using statements are outside of the class

cloud fox
#

these are just some files that get created whenever I make a script

#

and this is what unity automatically puts in them

winged ridge
#

There are .meta files which is normal

cloud fox
#

yes my issue is that the second they're created they immediately start throwing these errors

#

it says I'm using C# 9 over 10 but documentation about switching to 10 seems unreliable

winged ridge
#

Unity is on C9 i believe anyway, I'm using c9...I can't say I've seen that bug generated outside of my own file I made

cloud fox
#

'm not sure why unity does this by default if it immediately decides to do this??

#

do you think that editor version would matter here?

brave compass
#

I think it's probably the IDE that is making those files.

cloud fox
grand snow
#

!ide

radiant voidBOT
cloud fox
#

I've done this already

#

I ended up finding a kinda dumb fix, I just deleted the first global in every line and it stopped throwing errors

winged ridge
#

The first? There's more?

cloud fox
#

I just deleted the first global and unity was magically happy again

winged ridge
#

There's probably a duplication or something... Otherwise it would throw other bugs

cloud fox
#

this was a consistent issue across multiple created scripts

#

It's not that awful though ig

grand snow
#

this obj folder shouldnt exist so delete it

cloud fox
#

I also just got this warning what does this mean?
The project currently uses the compatibility mode where the Render Graph API is disabled. Support for this mode will be removed in future Unity versions. Migrate existing ScriptableRenderPasses to the new RenderGraph API. After the migration, disable the compatibility mode in Edit > Projects Settings > Graphics > Render Graph.
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadMethodAttributes ()

rich adder
#

you have some type of fullscreen effect that is using the old API so your project was switched to compatibility mode , its telling you in the future it will be removed so its best to merge to new api

cloud fox
#

ok I did that but when I go to save it prompts me to choose a new location for my project. . . why??

#

e is my repo name(I was lazy I'll fix it eventually) and changle later is the current project name until I get around to making a better name for it

half notch
#

Hey, i want to create some rooms in my game, which i can go through with my player. I thought the solution was to have one scene with every room of my game, but each room is one gameobject who has children of what it's in the room in particular. Each room can be disable/enable depending on the player's position.
I want to know if this is a good solution or maybe I should have one scene per room, which can cause some problems with the enemies in the rooms.
I ask this because i don't really know if go.SetActive(boolean) with a lot of children costs a lot of performance or not.

thorn kiln
eternal needle
half notch
rich adder
cloud fox
teal viper
cloud fox
teal viper
cloud fox
#

ty!!

median rune
#

hey bois how much of the intro to c# do I do before jumping into junor pathway ? Is doing the Getting Started section and the Fundamentals good enough?

timber tide
#

Learn up to classes and objects

median rune
#

oh ok thanks friend

median rune
astral flame
#

Hi everyone, I need help with this animation issue. As you can see in the video, the animation doesn't work correctly when in play mode, but it works fine when not in play mode. During gameplay, you can see the animation of the character getting in and out of the car, but when testing it, it behaves as shown in the video. Please take a look.

radiant voidBOT
simple granite
#

I need help. Can someone teach me unity events? I understand the basics but I am stuck at a place.

#

The problem will need a lot of explaining.

frosty hound
#

So start explaining?

teal viper
#

In a thread preferably

charred monolith
eternal needle
simple granite
#

Okay. This is the whole situation. To test what I have been learning, I am making a first person game. For moving the character, I did these steps:-

  1. Added a script on the player.
  2. In the script, made an OnMove function and got InputAction.CallbackContext context.
  3. Got the player input there and saved in a variable.
  4. In the FixedUpdate, used the variable to move the character with some speed.
  5. In the editor, added a Player Input component on the player.
  6. Expanded the event and used the Move event which I had defined in the new input system.
  7. Dragged the player object into the Move Event and selected the OnMove function from the dropdown. Doing all this made the character move.
#

The camera is a separate game object from the player so, in the camera script, I am moving it with the player by using LateUpdate. Now, I want to use mouse to look around. This is what I want to do:-

  1. In the player script, I have an OnLook function.
  2. I want to get the mouse delta values in that function.
  3. When the user moves the mouse right and left, the player will turn right and left and the camera will turn right and left too.
  4. When the user moves the mouse up and down, only the camera will rotate up and down.

Turning the character is simple, I can do it exactly the same way I did the movement. I will just get the X value of the mouse delta and use it to rotate the character along the Y axis. The problem is with camera. I know I can just take reference or get the player input in the camera script and then get the mouse input values there. But I want to learn how to decouple scripts. I don't want to get any references. I want to learn events or something like that. Youtube tutorials are confusing me even more. I don't understand what I should use, Unity Events or C# events and why? Then I read another term everywhere called Scriptable Objects. What are those? How do I use them?

#

I want a centralized place where I can declare all the events for now and fire the events from anywhere and listen for the events anywhere.

#

I'll give you the codes.

winged ridge
#

!code

radiant voidBOT
simple granite
turbid plover
#

hi im very very frustrated with this error because well im obviously a beginner

I have set the variable at the Components

i do not know how tf GetComponent work, neither did the tutorial im following did say, I am just following himm with this, BUT im getting an error with it and He is not, error is

Object reference not set to an instance of an object

Imm well aware that textMeshPro Variable is being set to another object, but does not know what is, I have 3 different buttons working on it so I need it, and the tutorial apparently said it is so communicate scripts with a variable

eternal needle
# simple granite https://paste.ofcode.org/SuuC5ki2JGPWs6wS7jQAG6 Here are the codes.

you should just consider using cinemachine for camera functionality. it has pretty much everything you'll ever need. Your current code for it isnt logically correct. you're reading quaternion values and plugging them into a function expecting euler values. Your controller script is also a little bit confusing, you have playerControls which I assumed is the generated c# class from the input asset but then you also use OnMove and OnLook which should come from the PlayerInput component. That component could also just send inputs to a script controlling the camera though still cinemachine has this behaviour by default.
as for your actual concern above "I don't want to get any references", this isnt something to always strive for and doesn't make sense in a ton of cases. All you'll be doing is hiding dependencies and making it harder to debug if you needlessly "decouple". The furthest id go here at the moment is having a separate component purely for input and you can choose to either pass values to the movement component, have the movement component directly read values, or use events (which i dont see a major reason for). Separating these out would let you use an interface and have different types of input if needed like npcs.
as for events, "Unity Events or C# events and why", unity events are just serialized events. you can assign them in inspector and thats about all. It has its uses but I tend to avoid it because I find it's quite annoying when trying to follow a chain of logic and then suddenly theres a unity event so I can't find everything referencing an event in my IDE. Scriptable objects is mainly just a data container and you dont need it for this case. Theres a lot more to it that I just dont want to get into right now. It'll be best if you just experiment around with it

eternal needle
pastel iron
#

Calling GetComponent in Update is not recommended. It is better to call it in Awake or Start.

turbid plover
# eternal needle if you are assigning the value in inspector, you don't need to get the component...

I wanna clarify something, so first of all,,

there's 3 different buttons that im working on with only one script, Im trying to know or detect the type of functionality of that button with enum, so it is in the component, if it Heals or Damage, and then use switch function on which is working when the button is pressed.. The reason im doing this is because I think that the 3 different scripts are independent to each other, and when I tried not having a getComponent, the variables simply cant communicate to each other because the scripts have its own variable I wanna give an example:

when I pressed the damage button, the public variable on it changed, good, but the public variable on the other scripts doesnt, that's how I got the idea of script independency or simply all of the script imported aren't the technically the same

Now I tried searching how to get it communicated, and so far that's the thing I got, GetComponent

eternal needle
turbid plover
#

lemme send the script and see if you could review it

eternal needle
#

either way, your code is calling GetComponent so it doesnt matter what you assign to textMeshPro

#

its being overwritten

turbid plover
sick plover
#

After connecting to Unity MCP, I can create objects and do everything, but script creation is limited, so Claude keeps recommending only generating code and inserting it directly into Unity, but I don't get why. Does anyone have a similar experience?

turbid plover
#

I know the code is messy but im just experimenting in the mean time

using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Linq.Expressions;
using UnityEngine;
using TMPro;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

public enum CurrentUse
{
    MaxHealth,
    TakeHealth,
    Heal,
}

public class HealthUpdate : MonoBehaviour
{
    private const int maxHealth = 100;
    public CurrentUse usage;
    
    public int currHealth = 100;

    public TextMeshProUGUI TextMeshPro;

    void Update()
    {
        TextMeshPro = GetComponent<TextMeshProUGUI>();
        TextMeshPro.text = $"Health: {currHealth}";

    }
    public void onClick()
    {
        switch (usage)
        {
            case CurrentUse.Heal:
                currHealth += 10;

                break;
            case CurrentUse.MaxHealth:
                currHealth = maxHealth;

                break;
            case CurrentUse.TakeHealth:
                currHealth -= 10;

                break;
        }
    }
}

eternal needle
turbid plover
#

alr alr thanks for help and you're welcome for the frustration talking to me :D

turbid plover
#

how...

eternal needle
echo ruin
#

@turbid plover you said you followed a tutorial? Check if the tutorial put things inside Start() or Update(). Start runs once, and Update runs every frame

Also yeah, GetComponent can be confusing if you’re a beginner.
If you create a reference by starting off typing ‘public’, you can click and drag the component you need into the field in the editor.
If you set it to ‘private’, you have to tell the script which reference you’re refering to. So GetComponent is the script way of saying “Just give me the component that is attached to me”
A bit like if I had a script on me with a “ShootGun” function, and the script needs to know what gun I want to shoot, I use GetComponent to “Just shoot whatever gun I’m holding”

worn hemlock
#

public class Stare : MonoBehaviour
{
    [Header("Target Settings")]
    public Transform target;
    public Vector3 upVector = Vector3.up;

    [Header("Axis Locks")]
    public bool LockX = false;
    public bool LockY = false;
    public bool LockZ = false;

    [Header("Rotation Settings")]
    [Range(0.1f, 50f)] public float rotationSpeed = 10f;

    private Transform _t;

    void Awake() => _t = transform;

    void LateUpdate()
    {
        if (!target) return;

        Vector3 direction = target.position - _t.position;
        if (LockX) direction.x = 0f;
        if (LockY) direction.y = 0f;
        if (LockZ) direction.z = 0f;

        if (direction.sqrMagnitude < 0.0001f) return;

        Quaternion targetRotation = Quaternion.LookRotation(direction, upVector);
        float t = 1f - Mathf.Exp(-rotationSpeed * Time.deltaTime);
        _t.rotation = Quaternion.Slerp(_t.rotation, targetRotation, t);
    }

    void OnDrawGizmosSelected()
    {
        if (target)
        {
            Gizmos.color = Color.yellow;
            Gizmos.DrawLine(transform.position, target.position);
            Gizmos.DrawSphere(target.position, 0.05f);
        }
    }
}
naive pawn
#

we arent psychic, we won't know what you need unless you tell us

teal viper
#

I think they're just showing off their code😬

echo ruin
#

Of all the code I’ve ever seen, that is some of it

upper mist
#

Hi, could you tell me if it's better to create a UI document for each menu I want to create or do everything in a single panel and manage the visual elements on the script side?

timber tide
#

However you want to do it. More documents means more referencing

lunar coral
#

hi guys, could you tell me what's wrong with this, I'm trying to teleport my player to the otherLadder position

#
void TeleportPlayer()
    {
        if (player != null && otherLadder != null)
        {
            Vector3 newPosition = otherLadder.position;
            newPosition.y += 0.1f; 
            player.position = newPosition;
            Debug.Log("teleported");
        }
    }
```csharp
#

teleported gets logged in the console so the problem is with the logic itself but I can't figure out what's the issue

hexed terrace
#

you haven't said what's wrong, what happens other than the logging out..

lunar coral
grand snow
#

or something else overrides the change

lunar coral
lunar coral
grand snow
#

a badly written character controller or an animator.
Its unlikely though.

#

Are you sure otherLadder is positioned correctly too?

lunar coral
#

It's an empty gameobject which is the child of the "ladder" gameObject

hexed terrace
#

log out all the various positions so you can confirm

lunar coral
grand snow
#

Well we know that something is incorrect here. Add extra logging or use a debugger to verify things further

lunar coral
#

the player just doesn't move and the ladderPosition neither does

grand snow
#

i need a bot command for this damn link

hexed terrace
#

how is your player moved? CharacterController or rigibdbody?

lunar coral
hexed terrace
#

afaik - that's teleporting to move the transform. And IIRC someone else had this issue the other day, it conflicts with your teleportation, and sets it back to where it was expecting to be.

lunar coral
#

before, I was also changing the player's rotation and it worked, player.rotation = otherLadder.rotation;

hexed terrace
#

Cant remember the fix, disabling the CC for the teleport (re-enable after).. I think

lunar coral
#

I just removed it because the rotation was inversed

grand snow
#

is character controller really that weird that it has some old pos internally?

lunar coral
#

and he's really good

#

so I don't think the problem comes from this but yea there's a problem somewhere

hexed terrace
#

oh, so not the Unity one.. so what Ive said may not be valid

grand snow
#

Yea its worth a shot still to disable it and see if it works

lunar coral
#

it uses the character controller component from unity

#

but the script controlling it I mean

#

is from an asset

lunar coral
#

okayyy, thank you much guys @grand snow @hexed terrace , it's working now

#

I just disabled the cc while teleporting

#

thank you so much

grand snow
#

nice nice

hexed terrace
#

The Unity CC just seems.. lacking of basic features. No graivty, no teleport method

vale blade
#

Hola, is there a linter available for the Unity style guide?
I want to add a GH action to one of my repos that ensures the style guide is adhered to on merge.

signal vine
#

hello, I'm extremely new and wanted to start with a platforming style of game, I've followed a tutorial and made a C# script for character movement (simple left and right) and I thought I understood it, but when applied to the character it still won't do anything, can I upload the script here? I don't want to look like I'm spamming or anything

#

2D platformer btw ^

#

oh wait

#

public class PlayerMovement : MonoBehaviour
{
    private Rigidbody2D body;

    private void Awake()
    (
        body = GetComponent<Rigidbody2D>();
    )

    private void Update()
    (
        body.velocity = new Vector2(Input.GetAxis("Horizontal"), body.velocity.y);
    )
}```
#

that's what I've got

hexed terrace
#

If it works in the tutorial and not for you - you've either missed a step or done something wrong. Go back over the tutorial and see what you've got different

keen dew
#

also check the Unity console for errors or warnings while playing

signal vine
#

there is one

keen dew
#

About using the wrong input system?

signal vine
#

vector2 does not contain a definition for Z

keen dew
#

dang

signal vine
#

but it should only be X Y anyway no?

hexed terrace
#

is it pointing to this class though?

keen dew
#

Yes, and that's why it's an error to try to use Z

signal vine
signal vine
#

I'll follow it again rq it's understandable so I can redo the project quickly

hexed terrace
#

is the error in this class.

signal vine
#

then I'll import that script and see

signal vine
#

originally they put vector3 with z then fixed that

keen dew
#

Save the file

signal vine
#

I'll make a new project and use the script in that and see how that goes maybe

signal vine
hexed terrace
#

Just watch the tutorial and compare to what you have

keen dew
#

If you've saved the file, close VS and Unity and reopen them. No need to redo everything

signal vine
#

alright I'll give it a go

#

I've compared a few times so other than the placement of the floor which isn't related to movement there shouldn't be a difference

polar acorn
#

How about you show the code you have, and link the tutorial

signal vine
#

one sec

keen dew
#

If it's still not working, screenshot the error in Unity and screenshot the full VS window with the script open

signal vine
#

alright I'll find the tutorial rq then do that

#

I can't test it now something about compiler error

polar acorn
signal vine
signal vine
polar acorn
signal vine
#

I'll get the VS ones too

polar acorn
# signal vine

Okay so it's the player movement script all right. Look at the lines underlined in red in your IDE and then compare them to the tutorial. You should see the problem

signal vine
#

okay I'll give it another go

polar acorn
signal vine
#

is it to do with the speed part of it?

polar acorn
#

The first error makes no sense, it doesn't seem to recognize that's a function and thinks it's a normal line?

signal vine
#

cause he had that stuff working before implementing speed

signal vine
polar acorn
#

I think I'm missing something, some weird stray character somewhere

#

Like your original code that you posted had an extra ) on the last line

signal vine
#

I mean the colours in his one look different idk how much that changes

keen dew
polar acorn
#

I had a feeling it was something like that

signal vine
#

I don't see it

polar acorn
signal vine
#

oh my holy fuck

polar acorn
#
signal vine
#

that was my problem after like 7 hours lmao

#

spec?

#

like what the brackets do and all that?

#

ah

polar acorn
#

Yes, how the syntax works

signal vine
#

okay so that's what I need to really dig into then

#

I think I remade the project 4 times tryna find the problem lmao

#

thank you for your help

keen dew
signal vine
#

gotta reset for the input handling but hopefully it works this time

#

yeah that worked thank god

#

thanks for the help and patience

naive pawn
# signal vine spec?

specification, a description of how the language is structured and what it provides (though technically what digi linked isn't a spec, a spec is a pretty technical document)

slow blaze
signal vine
signal vine
polar acorn
signal vine
#

I noticed that in the tutorial video there are a lot more "commands" and such that pop up in the suggested thing as he's typing, is that something I can add?

radiant voidBOT
signal vine
#

ah

#

thank you

heavy ruin
#

Help..... im stuck to how to make that when u click a button new scene loads , i searched a bit of tutorials but none work

hazy dagger
#

i´ve been stuck on this for a long while now, the boulders don´t work like they are supposed to, and for some fricking reason they are directional. I tried everything i could think of. They are supposed to work like when the snake hits them, or the way slowed down turtle. Them also being pushed while the turtle appears staying still also is as intended, it´s when you input movement while right next to it.

#

when it´s a single boulder it works also as intended, being pushed normally and making the turtle stop

hazy dagger
#

managed to fix it

polar acorn
#

the clicking or the loading

heavy ruin
heavy ruin
#

i made the script by AI cause i didn't have the last script saved cause i tried other things anyways here tell me if u find anything wrong

slender nymph
#

the AI forgot to tell you that "No Function" means nothing will happen when the event is invoked.
instead of relying on bullshit generators to generate bullshit for you, consider going through the pathways on the unity learn site

#

!learn

radiant voidBOT
naive pawn
#

you haven't actually set the listener

heavy ruin
slender nymph
#

way to completely ignore what was said!

hazy dagger
#

i have a question, how do i make it that clicking a button makes the code go for a single instance instead of it going constantly as long as it´s hold down?

naive pawn
hazy dagger
#

movement

grand snow
hazy dagger
#

my player moves in a straigh line until it hits something

slender nymph
# hazy dagger movement

why don't you show the code so we don't have to play 20 questions to get a little bit of info from you

hazy dagger
#

it would also help removing the click cooldown code, it was a workaround but it´s not working with an interaction

slender nymph
#

!code and show all of it, not just a small snippet of it

radiant voidBOT
hazy dagger
#

i don´t remember why i have the "moveEast();", only this part of the script calls it, i could just put it back there

grand snow
#

Ideally you handle movement with a vector2 instead of if else

#

as you can see you repeat yourself

naive pawn
#

setting the rb constraints is also.. questionable
along with moving the transform

hazy dagger
polar acorn
heavy ruin
polar acorn
hazy dagger
#

without it it cause unwanted interactions

#

like getting stuck on walls

#

or touching something with the side and triggering it

grand snow
#

Ive done grid based movement before and I did it by movement triggering a linear move in the direction. Once done we can read input again and repeat the process.
I deny the move it the player would move into a tile on some layer.

#

I did not use physics because that isnt really needed if we have tiles

hazy dagger
#

the player and enemies can hit boulders. and when they do the boulders get pushed around

heavy ruin
naive pawn
hazy dagger
grand snow
hazy dagger
#

the boulder moves until itself hits another boulder or a wall

naive pawn
#

you can just make the grid do that
or use raycasts

grand snow
#

if everything is using tile movement only then physics has no place

naive pawn
#

you don't need physics if they don't make sense for the thing you're trying to make

hazy dagger
#

is the video playing on your end?

grand snow
#

Yea this could all be done without physics because grids and tiles are easy to query and modify and move things around in

hazy dagger
#

ah, noticed some more unused code

#

how would you suggest doing it then? i found collision detection necessary. At least for as much as i know about programming

grand snow
#

If we have a 2d position in the grid, e.g. 2,2. We can look at other positions to figure out things.
e.g. check 3,2 to see if its empty, if yes we allow a move from 2,2 to 3,2.

#

no physics needed

#

Vector2Int would be the ideal type to use for such positions

hazy dagger
#

if i click left, the turtle constantly goes left until it hits something

#

it´s not one step at a time like in pokemon

#

it´s like the ice puzzles in pokemon

grand snow
#

Very possible and certainly does not need physics to work

hazy dagger
#

does physics handle onCollision?

#

i guess both can be used together

naive pawn
#

it can, but you don't need collision to do this

grand snow
#

Well you can trust us or not

hazy dagger
#

i´m not saying that i don´t 😓

grand snow
#

unity tilemap makes it easy to do tile based stuff and the components can be used to handle positions too

hazy dagger
#

i´ll look into it, thanks

grand snow
#

Or you can go with your own system

hazy dagger
#

i´m still curious if there is a way to only have an input he used once per click

grand snow
#

using axis values no

#

using keys directly yes but then you want to use new input system if you care about input rebinding

hazy dagger
#

i can change it to key directly

grand snow
#

But if you know some "movement" is active then you know not to accept input right?

hazy dagger
#

"Input.GetKeyDown" right?

grand snow
#
if(!moving)
{
  Vector2Int input = move.ReadValue<Vector2Int>();
  Vector2Int nextPos = currentPos + input;
  if(CanMove(nextPos))
  {
    Move(nextPos);
  }
}

made up example

#

anyway if this is just some beginner short term project you can read keys directly

fast helm
#

Why does my character floats when crouching, and despite being small enough, i still cant enter the small opening?

hazy dagger
grand snow
# hazy dagger i only followed tutorials before, they all ended up not working later down the l...

Tbh lots of tutorials dont do things well because they are also beginners or are outdated.
Its usually a bad idea to read keys directly because it makes things harder to change in future and it means you will do movement logic in a funny way too.

My example sticks with vectors (we let input system handle key/controller binding for the action) and thus greatly simplifies reading input and the logic to check + perform character movement.

sharp abyss
#

*I posted this yesterday but posting one more time so I can reach more thoughts

How can I make movement look better? I mean how can I prevent the build up of limbs in one place. I tried freezing the head rotation but build up stayed the same.

rocky canyon
#

maybe a weighted tail piece?

sharp abyss
#

or only the last

#

thankss that workedUnityChanThumbsUp

ivory bobcat
thorn kiln
#
using UnityEngine;

public class Bouncy : MonoBehaviour
{

    private string playerTag = "Player";
    private float bounceForce = 1000;

    void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.tag == playerTag)
        {
            Rigidbody otherRb = collision.rigidbody;
            otherRb.AddExplosionForce(bounceForce, collision.contacts[0].point,5);
        }
    }
}```This does not seem like the best way to get the Player tag? (Stole the code from a youtube video, which didn't even originally set the string to "Player")
rocky canyon
#

if(collision.transform.CompareTag(playerTag)

thorn kiln
#

For my purpose, it's not actually the player. I'm trying to make a plinko game and I just need the balls to bounce off the pegs and side walls

rocky canyon
#

well w/e the tag is CompareTag is better than a string comparison like u have now

thorn kiln
#

Yep, that works. Thanks.

polar acorn
thorn kiln
#

I was more bringing it up because I thought the context might mean different code would be needed, since a player is usually a single consistent entity, not 30 plinko balls

austere plover
#

why does my unity 2d character randomly bump into invisible barriers during movement, even though i'm using overlapcircle for ground detection and have a composite collider on the tilemap? how can i get around this problem

austere plover
wintry quarry
fast helm
#

anyone knows what seems to be the problem?

  • Crouching/Sliding works but capsule seems to float
  • It cant enter the small opening and seems to have a specific limit before it can fit/enter properly.
wintry quarry
#

so you can see the CC capsule

fast helm
wintry quarry
#

there ya go

#

don't forget about the skin width

#

it will add an additional 0.16 height here

fast helm
#

eh? im quite still stupid enough to know correctly the problem is, the green line (i assume the collider CC) fits enough for the hole, so why cant I?

wintry quarry
fast helm
#

oh aight thanks that fixed it

thorn kiln
#

A problem I'm having is that it's possible to drop a ball in a way that it bounces out of the plinko machine. I'm wondering that the best way to solve this will be. Ideally, my idea for this game is to put a cup next to the cast full of balls you can drag and drop into it, so just putting an invisible wall at the side would cause issues. I thought I might be able to make a one way wall, but that seems easier for a single character than 30 balls.

austere plover
wintry quarry
#

this needs to be set to "Merge"

#

I also recommend Geometry Type on the composite collider to be set to "Polygons"

austere plover
#

i think the bug is solved now thx for the help

rocky canyon
thorn kiln
#

I might just change it to instantiate a ball where I click and make the game about getting the highest score within a set number of balls

#

Seems easier

hybrid tapir
#

!code

radiant voidBOT
gentle bone
# thorn kiln Seems easier

or just make the colliders of the walls on the side longer ... i dont think it matters if thecolliders go more up or down...

rocky canyon
#

model it after a real plinko machine.. im pretty sure the top portion is inclosed as well

thorn kiln
#

Inclosed? I don't think so? 🤔

rocky canyon
#

the sides are yes.. almost every version i see the side rails come up above the top pegs

thorn kiln
#

Oh, the sides. Yeah, so is the one I made

#

I could make it higher, i just think it'd look weird

wintry quarry
#

also you generally don't drop it from above the board

#

that's the bigger thing

rocky canyon
#

u shuld be able to tune the values and things u alrady have

thorn kiln
#

Yeah yeah, I was in the middle of doing thar before I had to leave

rocky canyon
slender nymph
#

you can also adjust the bounciness on your physics material to be less bouncy so there's less likelihood of it bouncing up and over the sides