#💻┃code-beginner

1 messages · Page 794 of 1

shell sorrel
#

if that does not work go to the top right where it says layout

#

and set it to default

dusky beacon
#

I FIXED IT

#

ty all of u and sorry for my cretincy

balmy vortex
#

hi does onMouseEnter() and onPointerEnter() work properly for you ppl?

#

assuming any of you use it ofc

grand snow
#

The doc pages for these functions state this fact if you dont believe me.
If you have issues still with the event system IPointerxx events then state what you have done since last time

balmy vortex
grand snow
#

It kinda is

#

You are hoping they are magically broken so it explains your stuff not working

grand snow
#

I have told you when it doesnt work and how the event system ones DO work

queen adder
#

where can I learn C#

warm iris
#

can someone help pls? it keeps printing (0,0), no buttons work

grand snow
warm iris
#

maybe wanna repeat this again? lol

grand snow
#

I was but dont expect anything

warm iris
#

alr

grand snow
warm iris
#

I mean the Move is

#

2d vector has no option as value

#

its digital normalized

#

but thats what people had in all guides

grand snow
warm iris
#

ok

grand snow
warm iris
#

this is exactly the same as mine

grand snow
#

No its not

#

action type should be "Value"

warm iris
#

bro ive been trying to make the new input system work since 3 days 😭

warm iris
#

I was just testing pass through

#

to see if it will work

#

can u show the code?

#

maybe thats the problem

grand snow
warm iris
#

this is my current code

#

I copied it 1:1 from some guide

sinful zinc
#

does deleting the library folder auto update some packages

#

i noticed my steamworks.net was updated to the latest version, but im not sure if it is from something else

grand snow
#

it shouldnt but may do that for git packages

#

I forget if that stores the commit it uses or not

#

check your packages.json file

warm iris
#

@grand snow so what can I possibly do to make this work

grand snow
warm iris
#

yeah they are

#

but nothing happens

grand snow
#

perhaps you need to configure your rigidbody correctly such as disable gravity?

#

dont presume input is broken when something else is incorrect

warm iris
#

it is exactly the same

grand snow
warm iris
#

yeah

#

else I wouldnt be able to create input controls right?

red igloo
#

@warm iris are you using OnEnable / OnDisable For your input action reference?

warm iris
#

no

red igloo
#

Try using them

warm iris
#

but I just made another testing game

#

and it works...

#

why it doesnt work on the main one

red igloo
warm iris
#

IT WORKS

#

FINALLY

#

I just deleted everything and redone it

#

bro I spent 3 days on it 😭

#

gta VI devs are faster than me

solemn crypt
#

I spent 2 days on that key 🔑 code

rocky whale
#

Im trying to make a ship sprite change colours when it takes more damage.the first colour change works but the second doesnt, but it still goes into the if loop. Can you only change colour once or smthg ?

naive pawn
radiant voidBOT
rocky whale
naive pawn
#

ah, everything was full yellow, wasn't it

rocky whale
#

do uk the reason ?

naive pawn
#

Color goes from 0 to 1, if you read the docs

red rover
#

Is there a convenient way to check if a gameobject is eventually a child to another gameobject (like, if its a child, grandchild, and so on)

#

Or should I just climb the parent tree and check manually

red rover
#

Ah perfect, exactly what I was looking for.

#

I had a feeling unity had a built in way to do this lol

naive pawn
#

check docs think

safe root
#

How do I Instantiate a object to a parent object?

keen dew
#

Have you checked the documentation for Instantiate

safe root
keen dew
safe root
# keen dew

But the transform, I need to actually assign it to the object as a parent

#

Wouldn't it just set in at it's current position and that's it?

keen dew
#

no

safe root
keen dew
#

What's the confusion? If you want to set the instantiated object's parent you pass it as a parameter. There's nothing else to it

safe root
keen dew
#

Transforms are what have the parent-child relation

#

The hierarchy view in the editor shows how the transforms are related

safe root
#

Ah, I see. Thank you

ivory bobcat
# safe root Where i'm confused at is that it's says the transform parent. So it will place t...

The second and third overload for the Instantiate method is expecting a second parameter of type Transform. The name listed for the parameter is parent but in actuality, it could be named anything. As good naming conventions go, this hints that the Transform parameter may have something to do with parenting. Where the docs explain that the field parent is the

Parent that will be assigned to the new object
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Object.Instantiate.html

glass summit
#

Does anyone know what this error means?

timber tide
#

Show code

grand snow
glass summit
# timber tide Show code
{
    warning.SetActive(true);
    startGame.SetActive(false);
    yield return new WaitForSeconds(3);
    startGame.SetActive(true);

}```
grand snow
#

do what i said

glass summit
#

It works now, but for educational purposes, may I know what caused the issue?

grand snow
# glass summit It works now, but for educational purposes, may I know what caused the issue?

Exactly as the error states. The method return type needs to be an iterable interface (which is usually IEnumerable) as this is how coroutines work behind the scenes.

You can click the CS1624 in VS and it will take you to the doc page for this compile error
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/iterator-yield#structure-of-an-iterator-method

#

Just google "unity coroutines" next time, check the example and compare

rocky whale
#

do you need to do smthg in the coroutine func for the wait time to kick in

glass summit
rocky whale
#

as like a grace period

timber tide
#

NoobDev actually gives you an idea in their code ;p

wintry quarry
wintry quarry
#

Coroutines don't delay other code

#

They delay themselves

rocky whale
#

ohhhhhhhhhhhhh

#

ty

naive pawn
#

a method that returns "void" doesn't return anything - it doesn't give any values

timber tide
#

ye and since you are returning a yield instruction, if the method was void then the return wouldn't work

grand snow
#

Coroutines cleverly use the iterator functionality of c# which is why this works as it does

timber tide
#

unity coroutines just a little hacky cause it is somewhat confusing that you're using these interfaces as you might have previously used them on a custom collection you've made

naive pawn
#

haha lazy evaluation go brrr

grand snow
#

Async would have been the natural choice and is my preference now

warm iris
#

Hey guys just asking cuz I feel like something like this might exist, is there a vector2 function that says for example up or north if the vector 2 points to up?

#

like if its (0, 1)

grand snow
warm iris
#

why

grand snow
#

Sounds like you want to hard code specific logic per direction.
Anyway you can compare the input to Vector2.up and such

warm iris
#

oh yeah thanks

#

that is kind of what I was asking for lol

naive pawn
#

if you have analog/continuous values, you could probably find the direction with eg Atan2 and separate out the specific cases

warm iris
#

I could easily do this without it but I was just curious

#

is there a case thing in c#?

naive pawn
#

if you're doing something like assigning Vector2.up directly, you could also just assign "Up" in the same place instead of using the vector as an intermediate for that

naive pawn
warm iris
#

is it switch or case in c#?

naive pawn
#

(the primary feature is the switch aspect, not the case)

naive pawn
#

case is a part of switch syntax

warm iris
#

oh yeah sorry lol

naive pawn
#

...this is the case in most languages, with some variance in specific keywords

warm iris
#

I got it confused with python

#

cuz there its match

naive pawn
#

python has match/case

#

it's the same thing

warm iris
#

yeah yeah ik

#

and I confused match with switch lol

naive pawn
#

the language feature is match, which includes the case keyword

warm iris
#

but thanks

#

why do people name something like this?

#

with _ first

#

what is the use case for it

#

what does it represent

naive pawn
grand snow
grand snow
#

Some do m_foo which I hate

warm iris
#

I definitely wont be doing that lol

naive pawn
# warm iris what does it represent

it's a private field, rather than a local variable
it's a relic from before ide integration was really extensive, it made code easier to read. some people still use it out of familiarity or because they don't want to hover the variable to figure out where it's from every time

#

in the same vein as hungarian notation (including the type in the identifier)

warm iris
#

btw what will happen

#

if vector 2 has .71,.71

#

like just if player holds 2 keys

#

will this count as both right and down?

#

or up and left idk

naive pawn
#

depends on how you check

warm iris
#

I will use switch case and Vector2.up down etc

naive pawn
#

with equality checks?

warm iris
#

based on the docs it will do nothing

warm iris
naive pawn
#

is (0.71, 0.71) equivalent to (0, 1)

warm iris
#

yeah its not

grand snow
naive pawn
#

given it's player input you would not want to use equality checks here, they'd immediately break if you consider using analog inputs lmao

warm iris
#

so how would I do it

naive pawn
#

what are you trying to achieve here

#

i don't know what "it" is here

warm iris
#

a snake game, currently trying to get what direction the snake should be looking at

#

so if its vector2.up he will look up

#

for .right he will look right

#

etc

naive pawn
#

your snake can go diagonally?

warm iris
#

no

naive pawn
#

then you don't need to consider this at all

#

you don't need to check the vector at all

#

you wouldn't be using a vector

warm iris
#

so how would I do it

naive pawn
#

you would store which direction the snake moves as its own thing, detached from player input

#

probably an enum in this case

#

you'd set the enum value based on specific conditions, only checking perpendicular inputs

#

(with analog inputs you might use the dot product to see if it's close enough to perpendicular for example)

warm iris
#

this is literally my first game after copying 1 simple game from tutorials

naive pawn
warm iris
#

enum value

naive pawn
#

is there a specific term there you don't understand or something

warm iris
#

and the rest I didnt really understand so idk lol

#

what would be the "specific conditions"

naive pawn
#

checking for perpendicular inputs

naive pawn
warm iris
naive pawn
#

this isn't a unity thing

warm iris
#

but like a data type you create

#

right?

naive pawn
#

there's a bit more nuance to it, but sure

#

to make sure we're on the same page - you want a string output of the direction somewhere?

warm iris
#

tbh I dont have it all figured out lol

#

but yeah prob store this in a variable

#

and then rotate the snake's head

#

and make him move in that direction

naive pawn
#

what is it that you want here

#

that wouldn't require a string

warm iris
#

k so how to do that

naive pawn
#

man x/y problem is such a pain

#

ok, so you would probably just use a vector then

#

just point the head in the direction of the vector

#

no need for intermediate data

warm iris
naive pawn
#

no enum, no string etc

naive pawn
#

no conditionals

#

might just be one assignment depending on how it's set up

warm iris
naive pawn
#

well, how do you plan to rotate the snake head?

warm iris
#

idk tranform.rotation = ...

naive pawn
#

if it's a gameobject you could set the transform's up direction

#

or right depending on how the sprite is set up

warm iris
#

ok what to set the up direction to?

naive pawn
#

the direction vector your snake is moving in

warm iris
#

oh yeah it works but after I release the button it goes back to pointing up

naive pawn
#

you wouldn't receive the direction vector directly from input, as mentioned before

#

you would store the direction separately, and modify it based on input

#

otherwise you'd be able to go diagonally or backwards into yourself

#

(these constraints are specifically from the game of snake)

#

but hey, this is half the task

warm iris
#

so what is wrong?

#

I did this and it works almost as I want it to

#

I just need to add so it wont work for diagonals too

naive pawn
#

i mean.. i just said it...

warm iris
#

oh sorry

#

I missed that lol

naive pawn
#

btw, you can just write !(a == b) as a != b

warm iris
#

oh bruh I did that but something was wrong

#

and on yt someone did the !()

#

k so just another function to check that right?

naive pawn
#

could be, sure

#

might want to try writing out the logic for what actions are allowed first, and then how to check for them, and then implement it in code

warm iris
#

is switch case fine?

#

for this example

#

cuz I will get rid of 0,0 and holding multiple buttons fast

naive pawn
#

probably, yeah

#

it'd make code pretty repetitive. you could make it less repetitive by using dot products like i mentioned before, but that might be a bit much lol

#

make it work before making it good

warm iris
#

yeah ok thanks

#

but Ive got to go

#

so Ig I will finish it later lol

#

thanks for the help tho I appreciate it

patent plaza
#

sooooo im new to this and i dont know how to solve the issue it wont run

naive pawn
#

!csharp

radiant voidBOT
naive pawn
#

!cs

radiant voidBOT
plucky sage
#

I need help my player's rigidbody has completely stopped moving, I've disabled the animator and only left the movement funciton working. I even still get a rigidbody.linearVelocity value from it. No other script acceses the thing too

plucky sage
naive pawn
#

wth, 3d rigidbodies don't have an info dropdown?

#

anyways, have you tried reducing the linear drag, and is the position of the transform changing?

plucky sage
stone oar
#

hey guys, question - how would a jumping enemy work (like how the jump would be performed), if the enemy uses navmesh and character controller (no rigidbody)?

grand snow
stone oar
tame juniper
#

hello, im trying to make a face to put on these blocks in my game, and want to have a random face from a couple face assets i have, how do i do this?

grizzled crag
#

can you elaborate?

vagrant lynx
#

hello

#

do you guys use state machines for movement in character?

#

or just use if-else instead

void geyser
#

i am losing my MIND. I've been programming a healthbar all day and I eventually crapped out this code:

grizzled crag
#

I think the animator system already has that covered?

void geyser
#

then created code for the player which tests if the slider actually works

void geyser
#

attached it to the player

#

pressed play

#

and i got this

grand snow
#

!input

radiant voidBOT
# grand snow !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

void geyser
#

i've been coding for a solid like

#

2 days now

grand snow
#

READ the error

#

Input class is for old input system

#

@void geyser ^

void geyser
#

thank you

#

i see what's wrong now

#

i'm following a 5 year old tutorial lmao

void geyser
silent elk
#

Ok, it shouldn’t be too hard, all you have to do is copy values over

#

Should be a single line of code if I’m thinking correctly

crystal shell
#

Glad I'm not the only one

deep heron
#

Yoo guys. I am really new to Unity. I might need some help. So I imported this animated Pistol Gun Model from sketchfab. I already did this before with an Mp5 and it worked fine. The Problem now is, it won't show the model in the animations anymore. The preview is basically missing and the animations therefore are not working inGame.

grand snow
deep heron
#

How exactly am I adjusting it?

grand snow
# deep heron How exactly am I adjusting it?

99% of fbx models I have imported need a scale of 0.01 to be normal sized
You can try also dragging in a different mesh to the preview window but otherwise it should be based on the skinned mesh renderer the animator is on

deep heron
#

Well, I tried it, It doesn't seem to help. On top of that If I drag the model into the scene now its way too small. Before it was normal size already.

grand snow
#

When you drag the model into a scene does it have scale 100,100,100? If so then the import scale should be adjusted to 0.01

deep heron
#

No. If I drag it into the scene the scale is 1, 1, 1

#

I don't know if this helps but I did find something in the animation clip preview. It looks like some pipes, I don't really know.

deep heron
mild lake
#

I have private, serialize fields i want to get, and set later. But, i'm ending up with piles of these methods. Is there a better way?

public float GetSpeed() { return _speed; } public void SetSpeed(float speed) { _speed = speed; } public float GetDashSpeed() { return _dashSpeed; } public void SetDashSpeed(float speed) { _dashSpeed = speed; }

naive pawn
mild lake
naive pawn
#

getters and setters aren't properties, they're part of properties

mild lake
#

regardless

naive pawn
#

your question is ambiguous because of that

mild lake
#

like [SerializeField] private float speed { get; set;}

naive pawn
#

unity can't serialize properties, but properties with automatic backing fields have, well, backing fields

naive pawn
#

but, with this { get; set; } case, that's an autoproperty with a hidden backing field

#

you can target the backing field to serialize it by marking the property [field: SerializeField], that makes the attribute target the backing field

mild lake
#

haha i didn't know how much there was to fields, i'll need to read up on it

naive pawn
#
Type name; // field
Type name { /* ... */ } // property
Type name { get; set; } // property with auto-generated backing field
#

getters and setters are collectively called accessors in most languages

#

sometimes setters are called mutators

solar hill
#

is it possible to store monobehavior components inside a SO and then edit their serialized inspector fields inline as if they were attached to a game object?

grand snow
solar hill
solar hill
#

and i guess unity cannot serialize abstract SO fields directly

#

so thats also out of the window

grand snow
#

Id expect abstract classes to work if using SerializeReference

#

As long as you have a valid class reference assigned to be serialized it should work
You may need editor code to assist with assigning a value to begin with so it shows in the inspector

solar hill
#

actually i think i get how im going to do it now

#

thanks!

gilded badge
#

How do I get the transform component of an object in a script attached to said object>

slender nymph
#

hint: look at the documentation for Component (or MonoBehaviour)

#

or, in a configured IDE type this. and look at the available properties

nocturne palm
#

Hello

warm iris
#

can someone tell me why do I keep getting error?

#

whats wrong here, why is it red

prime goblet
#

also your input vecotr

#

it wont return up down left right

warm iris
#

I mean I get this

prime goblet
#

That's a transform's thing

slender nymph
gilded badge
prime goblet
warm iris
slender nymph
slender nymph
#

just because you can write (0,1) doesn't mean it can be treated as a compile time constant

warm iris
#

so I have to use ifs here?

prime goblet
#

you can do case input.y > 0.1 etc..

slender nymph
#

literally "moveDir = input;" accomplishes the exact same thing here

warm iris
#

its a snake game

#

I only want to get up down left right

prime goblet
#

then you can do checks for greater/less than

grand snow
#

The image above shows dumb logic anyway so why bother with this switch?

slender nymph
grand snow
#

You read input and you already have a direction to move on a 2d grid

prime goblet
#

an input Vector2 is equivalent to -x being left, x being right, -y being down and y being up, so you dont need to use these

grand snow
#

we already talked about this topic yesterday but that part hasnt gotten through yet 😆

prime goblet
#

Also your logic isnt good, what if someone wants to move up AND left

warm iris
#

math.abs so -1 will be greater than 0.71

slender nymph
prime goblet
#

ah

#

i must have missed that part

grand snow
#

Then you can just adjust the input value to say clear Y if X is non zero

prime goblet
#

if 2 buttons are down it should instead be so that it chooses the input of the most recent button press
i.e. if the user presses up, keeps holding, and presses right, it goes right, instead of just going to whatever one has priority in the case

#

the case is really not a good solution

lethal meadow
#

his code is for if 2 are pressed in the same frame

#

it should just disregard it and keep whatever was done before

prime goblet
#

tha'ts what im talking about

#

that's bad user experience

#

it should not disregard new inputs

solar hill
#

theres an actual name for it

#

i cant remember but its a pretty important qol

lethal meadow
#

if the user goes from going up, to going down and right the next frame which direction does it go

prime goblet
#

it should go whichever was pressed most recently

copper jasper
#
    private void RotateBody()
    {
        if (!IsBodyTurning) return;

        float BodyYaw = RB.rotation.eulerAngles.y;

        if (CurrentDrift > ActiveStart * SlicesTotal ) CurrentTurnSpeed = SlicesTotal * SliceSpeed;

        float NewYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetYaw, CurrentTurnSpeed * Time.fixedDeltaTime);

        RB.MoveRotation(Quaternion.Euler(0f, NewYaw, 0f));
    }

    private void HandleBodyRot()
    {
        float BodyYaw = RB.rotation.eulerAngles.y;
        float CamYaw = CamHolder.eulerAngles.y;

        CurrentDrift = Mathf.Abs(Mathf.DeltaAngle(BodyYaw, CamYaw));

        ActiveStart = MovementHandler.MoveDirection != Vector3.zero ? MovingStartTurnAngle : StartTurnAngle;
        float ActiveStop = MovementHandler.MoveDirection != Vector3.zero ? MovingStopTurnAngle : StopTurnAngle;

        if (CurrentDrift > ActiveStart)
        {
            TurnTotal = Mathf.Abs(Mathf.DeltaAngle(BodyYaw, CamYaw));
            IsBodyTurning = true;
            SlicesTotal = Mathf.RoundToInt(TurnTotal / ActiveStart);
            if (LastSlicesTotal != SlicesTotal) { TargetYaw = CamYaw; }
            LastSlicesTotal = SlicesTotal;
        }

        if (CurrentDrift < ActiveStop && IsBodyTurning)
        {
            IsBodyTurning = false;
            IsInPanicTurn = false;
        }
    }

I’m trying to recreate an Unreal-style first-person camera in Unity where the camera is free but the body turns in fixed 35° slices with increasing speed to catch up. The issue is heavy jitter and stuttering during continuous camera rotation because the body’s rotation target and speed keep changing mid-turn, causing it to slow near the end and repeatedly restart. I’m stuck on how to restructure the yaw logic to stop this and would really appreciate help.

prime goblet
#

it's unlikely that a usser can press 2 buttons in the exact frame

full bane
#

Linux . Ive noticed unity versions older than 2022 are more probable to get stuck at Initial Asset Database Refresh, I recommend using versions higher than 2021, most of 2021 have failed in my os (cachyOS) this is my case if anybody is experiencing this, try what ive said.

lethal meadow
prime goblet
#

that would be incredibly rare unless the user was macroing

prime goblet
#

im not replying to you

lethal meadow
#

low/capped framerate

#

or if hes using the current inputs and not the GetDown variant

#

even still its very possible even on high fps

full bane
prime goblet
#

that a user presses two buttons in the exact frame is rare?

grand snow
#

With low framerate its very easy for many keys to begin their press on a frame

full bane
#

in the same frame bro??

#

thats kinda hard

prime goblet
#

low framerate is true though

gilded badge
#

How can I access special fields of gameObjects in other scripts (like movingSpeed n stuff)?

grand snow
#

GetComponent

#

you learn that on day 0

gilded badge
#

thanks

grand snow
prime goblet
warm iris
#

@grand snow @prime goblet this good?

prime goblet
#

does it work?

warm iris
#

lemme chekc

#

I just meant code quality for now

#

im trying to learn effective and clean code right away

#

since im only new to unity, not coding in general

prime goblet
#

making clean code is a hard thing and it's subjective what might look good

#

the best way to do it is just format it in a way where it's not a mess to look at and understand what it does

lethal meadow
#

if 2 axis of inputs are being entered it will move only horizontally

#

not good design

prime goblet
#

yes?

warm iris
#

I just mean effective solutions which are easy too read and works well

copper jasper
#

I’m trying to recreate an Unreal-style first-person camera in Unity where the camera is free but the body turns in fixed 35° slices with increasing speed to catch up. The issue is heavy jitter and stuttering during continuous camera rotation because the body’s rotation target and speed keep changing mid-turn, causing it to slow near the end and repeatedly restart. I’m stuck on how to restructure the yaw logic to stop this and would really appreciate help.

prime goblet
#

does it work?

#

if it does then it's good

warm iris
#

im trying it rn wait

lethal meadow
prime goblet
#

it is snake

lethal meadow
#

if the user enters 2 axis then just ignore the inputs

#

vec2(0, 0)

copper jasper
grand snow
#

ya forgot the preamble

warm iris
#

why?

#

it is always 0, -0.71

#

shouldnt it be positive 0.71 for one of them?

lethal meadow
#

what did i say bro

warm iris
#

right

#

oh ok

#

how to check if theres 2 axis?

#

is there a quick property for it?

#

or do I have to check taht

lethal meadow
#

or actually

warm iris
#

why 0.4?

lethal meadow
#

return the snakes current movement before

lethal meadow
#

you could do 0.5

#

as long as its above 0.001 and under 0.7

warm iris
#

yeah ok I get it

#

but Im gonna do the same for the 0,0

#

cuz I dont want too'

#

yeah I think it works thanks

grand snow
#

Id check if the abs value is above float epsilon

gilded badge
gilded badge
#

how

#

im losing m,y mind

grand snow
#

Change it to public float speed;

#

if you dont specify anything its private

gilded badge
#

okay and then?

#

bad example

#

sorry

warm iris
#

rob does this look good and clean?

grand snow
#

now you can do GetComponent<PlayerController>().speed = 20f;

lethal meadow
gilded badge
#

thanks

grand snow
lethal meadow
#

since you're accessing the class variables from outside the class they need to be public

warm iris
grand snow
#

if there is no good reason plz dont ping me

warm iris
#

ok sorry ill try to remember that

#

mb

grand snow
#

its always user choice to participate

#

unless it was a thread where only a few users were active

warm iris
#

yeah ik its just that its getting late and idk if u read this message and ignored it or did u miss it cuz u were responding to the other guy

#

but mb

#

thanks for the help

#

gn

elfin pike
#

Can somebody tell me, when variable gets referenced or set. Sometimes write code and reference without knowing. I fix by using .clone() as type

grand snow
#

@elfin pike ^

elfin pike
#

Yes, I have to learn them or is there tool to see if it's value or reference?

cosmic dagger
grand snow
stone narwhal
#

guys quick question, for playfab is there not a way to make it so you can add an exisiting guest account (created with a custom ID) to a username and a password without requiring an emal.

grand snow
#

You learn over time too. Vector2 and Vector3 are structs so are Value types

stone narwhal
#

Because I tried Addusernameandpassword

#

and it still asks me for an email input?

cosmic dagger
#

structs are value types; classes are reference types . . .

grand snow
#

yea thanks for saying the same thing

pallid heron
#

what do I using to use PlatformToolkit stuff?

#

I have the package imported

teal viper
pallid heron
#

The unity manual just explains what code to use but not what namespace to import

teal viper
#

If still not recognized, you're likely using assembly definitions and need to configure them to use the package assembly.

slender nymph
#

or if the error only appears in your IDE you need to regenerate the project files

pallid heron
#

Oh, hrm. I was including Unity.PlatformToolkit and it wasn't working but now it does.

#

I guess yeah it needed to regenerate proj files or something

shell sorrel
#

its telling you exactly what it requires you do in that error

pallid heron
#

yeah I know but that's the code the manual told me to use so I have to do some deeper digging into what's going on

#

oh wait

#

within an async

#

sorry I'm dumb

shell sorrel
#

await can only be used in async methods

pallid heron
#

yeah I thought it was complaining about GetAchievementSystem

#

Sorry I'm being distracted lol

shell sorrel
#

simple way would just make it async void assuming SaveWithTimestamp is a fire and forget type function and the timing of what you call after it does not care of its done yet

pallid heron
#

Damn. getAchievementSystem does not exist.

shell sorrel
#

yes it does,

#

you have to get a account first

pallid heron
#

ah I forgot to Establish

#

thank you 🙏

silent elk
#

does anyone know how to work with vfx like particle systems to make a muzzle flash type effect

slender nymph
frosty hound
silent elk
#

they kinda either do or dont reply

slender nymph
#

well if your entire question boils down to "how to make it" then you need to put more effort into research

silent elk
#

ive grasped making bursts and how to kinda make the shape

#

but i dont know how to make it look like muzzle flash

#

ive tried pretty much all recent tutorials and none has worked (when i say most ive spent 4+ hours trying)

frosty hound
#

That's an impossibility, and we often have people claiming that tutorials are somehow all not useable.

#

But if you're convinced of that fact, just get something off the asset store.

#

Regardless, this isn't a coding question, so #✨┃vfx-and-particles if you want to try seeing if anyone will essentially regurgitate whatever a tutorial would show you.

silent elk
copper jasper
#
    private void HandleIdleBodyRot()
    {
        BodyYaw = RB.rotation.eulerAngles.y;
        CamYaw = CamHolder.eulerAngles.y;

        YawDrift = Mathf.DeltaAngle(BodyYaw, CamYaw);
        float ABSDrift = Mathf.Abs(YawDrift);

        if (!IsBodyTurning && ABSDrift > TurnThreshold)
        {
            IsBodyTurning = true;
            Debug.DrawRay(Player.position, CamHolder.forward, Color.red, 10, false);
        }

        if (IsBodyTurning)
        {
            // track camera while turning (kills the hard-stop jitter)
            TargetBodyYaw = CamYaw;

            TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
            float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);
            Debug.DrawRay(Player.position, Quaternion.Euler(0f, newYaw, 0f) * Vector3.forward, Color.blue, 10, false);

            RB.MoveRotation(Quaternion.Euler(0f, newYaw, 0f));

            // stop only when drift is actually small
            if (ABSDrift < StopThreshold) IsBodyTurning = false;
        }
    }

How do i fix this jitter

edgy sinew
copper jasper
edgy sinew
#

It also may be a result of not having Interpolation on, or not using it correctly / the camera not being set up correctly.

copper jasper
#

let's say, I turn instantly at 180 degrees, it's perfectly smooth, everything's perfect. But if I try to use my mouse to consistently turn at 180 degrees, since my mouse's mouse speed is inconsistent, it jitters. But what part of the script is causing that?

#

basically for the cam i js do this

    CamHolder.rotation = Quaternion.Euler(VerticalLook,HorizontalLook,0);
    CamHolder.position = CamTarget.position;
edgy sinew
copper jasper
#

kinda but does it have the same angle thing as MoveTowardsAngle

edgy sinew
#

And, the camera should be in Update mode so the interpolation is visible, not FixedUpdate, I think. But that’s likely not the issue

copper jasper
#

and i rotate the character in fixed

edgy sinew
#

Okay, so the jitter is just from that code itself, which doesn’t smooth it out

copper jasper
#

should i do it like this

TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);
RB.MoveRotation(Quaternion.Lerp(RB.rotation, Quaternion.Euler(0f, newYaw, 0f), TurnSpeed * Time.fixedDeltaTime));

#

ig not its still jittering

#

oh shit i used lerp oops

#

nvm still jitterting

edgy sinew
#

Well you could smooth out the TargetYaw, maybe that will work?

copper jasper
#

maybe a bit less tho

copper jasper
edgy sinew
#

Achieving smoothness is tricky, especially with Rigidbodies, so it’s quite a process.
You must experiment & pinpoint the exact part of code that is causing the issue. I can only provide suggestions based on my experiences with Rigidbodies

copper jasper
#

so i kinda dont know how to smooth out the target yaw any ideas

copper jasper
edgy sinew
#

Make sure to not WrongLerp, you can find that whole thing on UnityHowHuh website.

copper jasper
#

am i smoothing too much 😭

#

TargetBodyYaw = Mathf.Lerp(TargetBodyYaw,CamYaw,15 * Time.fixedDeltaTime);

        TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
        float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);
        Debug.DrawRay(Player.position, Quaternion.Euler(0f, newYaw, 0f) * Vector3.forward, Color.blue, 10, false);

        RB.MoveRotation(Quaternion.Slerp(RB.rotation, Quaternion.Euler(0f, newYaw, 0f), TurnSpeed * Time.fixedDeltaTime));
edgy sinew
#

You took too many steps forward in one shot. Have to delete the other attempts before trying this new one

copper jasper
#

ye i js a got a lil confused on what i should smooth out

copper jasper
#

And smoothing out the rigidbody didnt work either

#

neither did the targetyaw

#

so ig nothing work 😄

edgy sinew
copper jasper
edgy sinew
#

That’s not how the Unity docs use MoveRotation, so I’d start there

copper jasper
edgy sinew
copper jasper
#

the issue isnt with smoothing tho ive seen it myself its cause each time the targetyaw changes the new yaw lerping or whatever has to reset

#

so it stops then starts again

edgy sinew
#

Did you check out the Unity docs for MoveRotation? They compute some “deltaRotation” and multiply it

edgy sinew
#

I’m sure you will figure it out. But troubleshooting here is not valuable, literally 5 or more things could be causing the jitter. It’s tricky for real

copper jasper
#

😭 I wish i was a unreal engine dev

#

they has gasp

#

they get everything for free

#

meanwhile i gotta work my ass off js to deal with some camera

#

should i move the cam in update or late update

#

acc nvm

edgy sinew
# copper jasper they has gasp

Try out GASP, it feels whack lol.
Not saying it should feel good right out of the box, but, I was very unimpressed & uninstalled right after

copper jasper
#

i was looking at the wrong thing

copper jasper
#

like the motion matching

#

its rlly realistic but u gotta work on it a bit to perfect it

edgy sinew
#

It shouldn’t matter with interpolation on.
If I were you I would try to just get rotation working without user input,
Make it work smoothly like that. Then you will learn more about which part of the code causes the issue

#

When you try to do too much in one shot, you have to step back & achieve a more basic accomplishment first

copper jasper
edgy sinew
copper jasper
edgy sinew
#

kekwait

copper jasper
#

is that bad 😭

edgy sinew
#

So the player is supposed to follow the rotation of the camera?

copper jasper
#

ye

#

like in unreal engine

edgy sinew
#

What about WASD and such?

copper jasper
#

thats based on forward of the player rotation

edgy sinew
copper jasper
#

movement works fine trust me

#

its js the damn jitter

#

if i could fix the jitter i can get onto do so much

edgy sinew
#

Putting stuff into Debug.Log can help, OnGUI even better for some cases

copper jasper
#

what should i put tho

#

i can already see my variables in the inspector

edgy sinew
#

It’s your project, how would I know 😪

copper jasper
edgy sinew
#

Keep troubleshooting different things until you pinpoint the issue,
Or ask ChatGPT maybe it knows more

copper jasper
#

chatgpt is the stupidest mf ever it keeps saying random things

#

ive been finding out the cause of my issues this whole time

edgy sinew
#

Your RB is kinematic right? I think interpolation for MovePosition and MoveRotation only works on kinematic RB

copper jasper
#

I EVEN MADE IT READ THE UNITY DOGS

copper jasper
#

oh shit

#

so ig i do this? RB.rotation = Quaternion.Euler(0f, newYaw, 0f);

edgy sinew
copper jasper
#

well that seems the same even with rotation =

copper jasper
edgy sinew
#

Yeah probably is, interpolation isn’t going to work in either case with those functions

#

But you said you are able to rotate the player smoothly, just not when you add the whole user input stuff? Strange.

copper jasper
#

it doesnt work well with mouse movement cause its inconsistent

#

so it keeps reseting the rotation smoothness

#

idk how the whole lerping stuff work so ye

#

but it restarts them

#

so then it gets that small pause and bang jitter

#

well atleast thats what i think is happening

edgy sinew
#

You’re still using MoveTowards right? That has no smoothness within it

copper jasper
#

TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);

edgy sinew
#

Maybe dlich sees the issue better.
I feel like you have multiple issues already with the approach that will make smoothness difficult to achieve notlikethis

teal viper
teal viper
#

Well, then it's broken for whatever reason. Probably because you're not rotating in a physically compatible way.

edgy sinew
#

Not supposed to use MoveRotation on Dynamic RB… interpolation doesn’t work in that pairing AFAIK

copper jasper
# teal viper Well, then it's broken for whatever reason. Probably because you're not rotating...
    private void HandleIdleBodyRot()
    {
        BodyYaw = RB.rotation.eulerAngles.y;
        CamYaw = CamHolder.eulerAngles.y;

        YawDrift = Mathf.DeltaAngle(BodyYaw, CamYaw);
        float ABSDrift = Mathf.Abs(YawDrift);

        if (!IsBodyTurning && ABSDrift > TurnThreshold)
        {
            IsBodyTurning = true;
            TargetBodyYaw = CamYaw;
            Debug.DrawRay(Player.position, CamHolder.forward, Color.red, 10, false);
        }

        if (IsBodyTurning)
        {
            // track camera while turning (kills the hard-stop jitter)
            TargetBodyYaw = CamYaw;

            TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
            float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);
            Debug.DrawRay(Player.position, Quaternion.Euler(0f, newYaw, 0f) * Vector3.forward, Color.blue, 10, false);

            RB.rotation = Quaternion.Euler(0f, newYaw, 0f);

            // stop only when drift is actually small
            if (ABSDrift < StopThreshold)
            {
                IsBodyTurning = false;
            }
        }
    }

All it should do is every 35 degrees the cam is away from the bodys forward it should rotate

edgy sinew
#

Manually assigning is like the same.
Dynamic RB only interpolate properly with AddForce and AddTorque. Those are harder to use, too.

teal viper
copper jasper
teal viper
copper jasper
#

im not gonna get any sleep am i 😭 I hate unity so much but its too late to quit now

teal viper
#

MoveRotation should work according to the docs

copper jasper
#

alr ima test torque ig

copper jasper
teal viper
edgy sinew
#

Google it or ChatGPT it 🤷‍♂️
“Unity 6 does MoveRotation interpolate when using Dynamic Rigidbody”

#

I don’t have time to dig through where I found that stuff but, I’m like 90% sure.

teal viper
#

I remember movePosition and MoveRotation working properly in the past. Though it was a long time ago.

copper jasper
copper jasper
#

hmm thats weird

#

oh boy

#

Short answer: NO.

This does not have proper interpolation logic — it only has visual interpolation if the Rigidbody is set to Interpolate.

Why ❌ (very direct):

RB.MoveRotation(...) teleports the body each FixedUpdate

Mathf.MoveTowardsAngle is fine only if the target is stable

You are changing TargetBodyYaw = CamYaw every physics step

That means the target keeps moving → the step size keeps changing → micro jitter

Rigidbody interpolation cannot fix a moving target feedback loop

What is working ✔️

Physics-safe rotation (non-kinematic ✔️)

FixedUpdate timing ✔️

Visual smoothing ✔️

What is not working ❌

Logical interpolation toward a locked target

Stable angular progression

Deterministic turn completion

One-line verdict:

This code is chasing the camera, not interpolating toward a fixed goal — so jitter is expected.

#

btw half of the things there chat gpt told me to do

#

just fyi 💀

teal viper
teal viper
#

I'd also add that you both confuse and get confused by the AI since you don't really understand the topic.

edgy sinew
# copper jasper alr ima test torque ig

Try making your RB kinematic for a sec! Maybe MoveRotation will be interpolated then.
Then accept that for Dynamic RB you will have to suffer through learning AddTorque

teal viper
edgy sinew
copper jasper
#

damn it worked

teal viper
copper jasper
#

😭

#

is kinematic fixed the jitter

#

but i dont want kinematic

#

kinematic suckssss

edgy sinew
#

Yeah of course. Now suffer with AddTorque (hint Vazgriz PID controllers video)

copper jasper
#

oh boi

#

well ima get to it

#

lets see how this goes 😭

teal viper
#

I'd suggest trying velocity before torque

copper jasper
#

wdym

#

like add force?

copper jasper
#

ah alr ima test that first then

copper jasper
#

idk if my minds fried at 2am or what

edgy sinew
teal viper
copper jasper
#

so is it my new yaw

#

my brains defo fried

teal viper
#

it's y rotation

#

because it's around the y axis

copper jasper
#

RB.angularVelocity = new Vector3(0, TurnSpeed, 0);

#

i cant look around at all now

#

like my body doesnt turn

teal viper
#

Then there is an issue with your logic. Debug it.

#

Or the rb is kinematic

copper jasper
#

rb is not kinematic ima check the variables

#

this should work ig

            float yawError = Mathf.DeltaAngle(BodyYaw, TargetBodyYaw);
            float absError = Mathf.Abs(yawError);

            float turnSpeedDeg = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, absError / PanicAngle);

            // angular velocity expects radians per second
            float angularVelY = Mathf.Sign(yawError) * turnSpeedDeg * Mathf.Deg2Rad;

            RB.angularVelocity = new Vector3(0f, angularVelY, 0f);

            // stop only when drift is actually small
            if (ABSDrift < StopThreshold)
            {
                RB.angularVelocity = Vector3.zero;
                IsBodyTurning = false;
            }
#

ig not...

#

ughhhhhhhh

edgy sinew
#

Dude… You probably have to multiply the value a bunch,
Angular velocity may factor in and angular drag value

#

You’re supposed to know a lot of stuff before you try doing Rigidbody related stuff especially kinematic

teal viper
edgy sinew
#

What I mean is, “Winging it” is not recommended when working with Dynamic RB notlikethis

copper jasper
#

well not 24 but i woke up at 5 yesterday and now its 2 am

#

and yesterday i slpet at 2 am

#

im cooked 😄

teal viper
edgy sinew
#

Try multiplying the angular velocity Y value by some multiples,
Or try lowering angular drag on the Rigidbody component. Might be called something else they change the name a lot

copper jasper
edgy sinew
#

Yeah that seems fine. Try multiplying the angular velocity so it reaches like 100 total value or something

#

(The Y value not the entire Vector3)

copper jasper
#

thats weird its saying its 0

        float yawError = Mathf.DeltaAngle(BodyYaw, TargetBodyYaw);
        float absError = Mathf.Abs(yawError);

        float turnSpeedDeg = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, absError / PanicAngle);

        // angular velocity expects radians per second
        float angularVelY = Mathf.Sign(yawError) * turnSpeedDeg * Mathf.Deg2Rad;

        RB.angularVelocity = new Vector3(0f, angularVelY, 0f);
        print(RB.angularVelocity);
#

time to use my final idea to debug this method 😭

        print(yawError);
        print(absError);
        print(turnSpeedDeg);
        print(RB.angularVelocity);
teal viper
copper jasper
#

im so dumb 😄

#

it works decently

#

but it kinda has some lag

#

not rlly

#

like hmm

#

nah it has the same jitter as before

#

acc no

#

im getting confused XD

#

ah alr each time i turn and reach the target point it jumps a lil

edgy sinew
#

Jumps? Like the character itself, into the air?

copper jasper
#

no lemme send a vid 1 sec

#

well ig not rlly a jump but a hard stop that feels like a jump or a speed bump hard to see but easy to feel

#

ig i gotta find out how to smoothly stop the rotation

edgy sinew
#

PID controllers… Vazgriz has a useful video on it. Not particularly easy stuff

#

Maybe there’s an easier way since you’re not using AddTorque. But I’m not sure

copper jasper
#

i wrote a note to watch the vid tmrw so i can finish this first then improve it

Cause if i dont finish this then i wont be able to sleep it will be stuck on my mind and i will prob spend hours planning

#

@edgy sinew and @teal viper Thank you so much for spending ur time to help me it means alot youve both saved me from not sleeping at all and not being able to show off my game to my college interviewer

teal viper
#

@edgy sinew @copper jasper
Made a small test scene and it does indeed seem like interpolation doesn't work with MoveRotation on a dynamic rb... The moment it's switched to kinematic it starts working.

naive pawn
#

well, isn't moverotation specifically for kinematics

edgy sinew
#

Yes. And MovePosition

teal viper
#

Yeah, the docs fail to mention this though

edgy sinew
#

Yep exactly. I remember suffering through this before and only could find that info in Unity Discussions

naive pawn
#

wait this is 3d right?

#

oh wait i just misread docs, yeah ok

edgy sinew
#

Use Rigidbody.MoveRotation to rotate a Rigidbody, complying with the Rigidbody's interpolation setting.
It says this, which is quite misleading 🥺
I used the "Report a problem on this page" feature at the bottom,
But there was nowhere for me to specify what information is incorrect. But it says "they" will review it UnityChanHuh

#

Whatever that means. I wonder if there's a channel here to suggest Unity Docs improvements.

teal viper
edgy sinew
teal viper
#

After I clicked "information is missing", then clicking on the button again revealed a comment ui.

edgy sinew
copper jasper
#

yall should go through each doc and tell unity how to make em all peak 😄

#

it will only take afew days 😄

edgy sinew
#

Yeah literally. Well maybe more than a few days I’ve only even read prob 20-30% of the Docs.

copper jasper
#

is the docs that long 😭

edgy sinew
#

Combined effort of multiple people though, yeah maybe.

copper jasper
#

imagine the person writing it

naive pawn
naive pawn
copper jasper
#

yikes

sinful zinc
#

what do these errors mean ?

#

They are coming from post processing scripts such as bloom editor, volume component editor and tone mapping editor

#

I deleted global volume from scene yet still get these erros

#

and turned off post processing on camera

ivory bobcat
sinful zinc
undone wave
#
        ClassA instanceOfA;
        switch(thing)
        {
            case "case1":
                instanceOfA = Instantiate(prefabOfSubclassOfA);
                SubclassOfA instanceOfSubclassOfA = (SubclassOfA)instanceOfA; //SubclassOfA is a subclass of ClassA
                instanceOfSubclassOfA.propertyB = someValue; //propertyB only exists for SubclassOfA
                instanceOfA = instanceOfSubclassOfA; // instanceOfA is returned after the end of the switch block
                break;
            ...

Is this how you're supposed to do this kind of type conversion?

naive pawn
undone wave
#

the editor part is just variable/class names though?

#

the main question was about type conversion

naive pawn
#

there's probably some convention to make editor stuff safe/easy tbh

#

i understood the question as being about the flow for editor stuff tbh

undone wave
#

edited the code to be more general-case

naive pawn
#

i mean, if you're asking about the general case, no you would not be casting without checking

#

the editor field type being in the switch is kinda significant there

undone wave
#

but is that how you normally apply values to an instance of a subclass,

#

when you have a variable in the parent class?

#

(assuming all casts are valid)

naive pawn
#

if you have a variable in the parent class, you wouldn't need to cast to the child..?

#

that assumption is significant

#

you would not normally make that assumption

#

the people in #↕️┃editor-extensions would know whether it makes sense to use that assumption in that editor-specific context, and whether it's appropriate to cast directly because of that assumption

undone wave
#

alright, but i'm just asking for the preferred method to access subclass-specific fields, from an instance of its parent class,

#

not specifically about that method or this context, just the generally preferred method

#

(or if one exists, if it doesn't)

naive pawn
#

check before casting

undone wave
#

so essentially, it's just casting

naive pawn
#

there are also as and is with pattern matching checks

teal viper
molten otter
#

hey guys I got a really weird one in my DOTS project. I'm trying to put my code in different assembly definitions, but when I did that and referenced all the needed assemblies, Unity stopped recognizing the Baker class

#

Baker should be in Unity.Entities, which I'm referencing here

#

when I put that script back outside an assembly definition, everything is back to normal

#

is this a bug or what?

teal viper
teal viper
#

Are you using entities v 6.5?

molten otter
#

yep

#

let me double check the package actually

teal viper
#

So unity editor 6.5?

teal viper
#

Not the assembly

molten otter
teal viper
#

The assembly in 6.5 is Assembly: Unity.Entities.Hybrid.dll
In earlier versions: Assembly: solution.dll, which I'd assume is included in the core

molten otter
#

oh interesting

#

oh wait I see where it says that now

#

oh yeah everything works now :)
so not only was I looking at the docs for the wrong version but I was looking at the namespace instead of the assembly name

unreal basin
#

Hellow there kind fellow devs,
So I was trying to make a dialogue system thinking it won't be that hard, but system wise I realized (as always) how hectic it can be to manage so many assets.
Currently am using scriptable objects to store data for the dialogues and then using another separate ones specifically for logic only,
So one for logic flow one which will have all the events and choices there can be, while the data for languages which is stored separately
I know people always say to not reinvent the wheel so I want to ask where can I find the wheel to learn or observe about how can I create a scalable system and easy for designers to use for dialogues with the options for different languages built into it?
Thank you for reading.

stray fog
#

Hm anyone built like a crafting system for placing prefab building parts eg floor wall roof? Just wondering how you did it, was it just ”grid” based or you also did a snapping where you add snap points on prefab that other prefabs could snap onto?

#

I think I’ve answered my own question, best bet is to create gameobjects on prefab mark then as a snap layer and have the game object on each side and look for that. Unless anyone know a better way

teal viper
charred monolith
ivory bobcat
#

The last four would seem to be related to what you're doing in Update

#

Note that the component doesn't make the object parent-child one another but instead provides a similar behavior without requiring parenting.

charred monolith
ivory bobcat
elfin pike
real thunder
#

is there an API to greate an array from a piece of existing array?
like from elements 4-10

midnight plover
real thunder
#

thanks, somehow missed

#

I mean the calls with indexes

keen dew
naive pawn
median hatch
#

thats it really

tawdry rock
#

Im not sure if this is a code or design problem but how do you solve this problem? What i want to achive is when the player enters the house it should trigger the "isInside" bool and basiclly reduce the ambient sound (like wind, bird noise etc.) The image shows the layout of the house and the yellow squares are the inside part (top down view). I did a ontrigger enter and exit which works if you enter any of the section of the house but if you go to the next section it sets back the bool to false due to ontrigger exit and doesnt register the next ontriggerenter. Im curious how this could be resolved since collider shapes are limited it just a problem when the interior has a L shape.

using UnityEngine;

public class InsideOutside : MonoBehaviour
{
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag.Equals("Player"))
        {
            randomBirdSound.i.ambientSound.volume = 0.1f;
            Reference.i.isInsideBuilding = true;
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.tag.Equals("Player"))
        {
            randomBirdSound.i.ambientSound.volume = 0.7f;
            Reference.i.isInsideBuilding = false;
        }
    }
}
median hatch
tawdry rock
#

So like this?
edit: thats the same result

 private void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals("Player") && !Reference.i.isInsideBuilding)
     {
         randomBirdSound.i.ambientSound.volume = 0.1f;
         Reference.i.isInsideBuilding = true;
     }
 }
median hatch
#

yea like that

#

give it a shot

#

if it doesnt work then check your colliders

keen dew
#

That won't work because the exit event still triggers

#

Is there a reason why the colliders cover the entire house and not just the entrances?

tawdry rock
#

but why the enter wont trigger on the other box collider? is the playercontroller moving too fast?

median hatch
#

OnTriggerEnter is usually a thin collider

#

otherwise you'll have OnTriggerStay

keen dew
tawdry rock
#

Like this

keen dew
#

Usually you have a collider on the inside that sets the "is inside" state and one on the outside for the "is outside" state

#

Red collider enter: player is going inside, green collider enter: player is going outside

tawdry rock
#

ahh yeah, i see i give it a try and both collider just have ontrigger enter event right? and set the bool for the state

#

erm, something is off. by default isinside is false and when i touch the first trigger (green) it set to true, and when i touch the second (red) it sets back to false but then im inside the building by that point.

keen dew
#

You need different scripts for both collider types

#

the inside collider always sets isinside to true and the outside collider always sets it to false

tawdry rock
#

oww, i try that. hold on. 🙂

keen dew
#

also it probably works better if you use the exit event instead to avoid issues when the player moves back and forth near the door

tawdry rock
#

Sorry got carried away. I dont want to say it too early but i think its working now properly. Thank you for your time and help.

hard hollow
#

I'm getting different results when caching the reference returned by the following lines:

GameObject.Find("objectName").GetComponent<Transform>();

transform.Find("objectName");

I'm aware that the former is inefficient but surely these do the same thing (The objectName that it's trying to find is neither disabled or has a duplicate in the scene)

midnight plover
tawdry rock
#

gameobject.find search all the gameobject from the hirearchy from top to bottom, transform.find only searches childs on the given gameobject

sour fulcrum
#

(Also both are awful)

tawdry rock
#

for performance wise, transform.find is good, for searching based on a string, yup. if its a const then i would use the second if i must

hard hollow
hard hollow
naive pawn
queen adder
#

is there any video explaining the multiplayer system for unity in detail

naive pawn
naive pawn
verbal dome
hard hollow
verbal dome
#

Direct reference is usually possible

tawdry rock
verbal dome
queen adder
hard hollow
hard hollow
verbal dome
#

Not a huge concern for beginner, but its good to know that can be very slow. These methods get slower when your scene grows in object count (GameObject.Find) or if the transform has more children (Transform.Find)

naive pawn
verbal dome
#

I'd learn to do it properly from the beginning (avoid Find)

naive pawn
queen adder
naive pawn
verbal dome
#

I did have a project with a huge scene and doing a few Find/FindObjectOfType calls in awake/start actually made it noticeably slower to enter playmode etc.

naive pawn
hard hollow
#

Yeah it's the exact same

naive pawn
#

what's the issue then exactly?

#

have you tried just logging Find(...) == transform.Find(...).gameObject?

tawdry rock
solar hill
hard hollow
#

I'm plugging the transform into a player controller and I'm getting completely different movement when using the two methods of getting the reference. I've got it working with the transform.Find but I'm just wondering how they would be different.

verbal dome
#

Any runtime errors in the console?

#

When using either

hard hollow
#

No errors at all

naive pawn
#

ok to be blunt, you just aren't giving any info that would let us answer your question
what exactly was the issue you had, what wrong info?

tawdry rock
hard hollow
#

Apologies for not being super helpful, I'm not entirely certain what the problem is to begin with. Which is mainly why I'm asking so I can learn

naive pawn
#

well Transform is a reference type, so that shouldn't be happening

#

you weren't caching the forward vector, right?

verbal dome
#

Maybe showing the actual code would help, might be an obvious mistake

naive pawn
#

if you still have the code that you encountered this issue with that'd be very significant/useful context

real thunder
#

can I like
create a new basic materal from code

naive pawn
#

new Material()?

#

did you try googling "unity create material code" at all

#

research is the expected first step here

real thunder
#

sorry I will try to be more thoughtful

naive pawn
#

!code

finite sable
#

so im like NEW new to game development, (no shame please) but uh how do i make a 2d sprite move and collide with the sprite of the floor

radiant voidBOT
naive pawn
#

!learn

radiant voidBOT
finite sable
#

aight thanks man owe ya

#

got any general tips for a newbie junior lil cousin

naive pawn
finite sable
#

might need it down the road

naive pawn
#

pace yourself and rest, burnout is a bitch and brainfog does not help

finite sable
#

ay thanks okay okay

#

keep that in mind

naive pawn
#

oh also, no such thing as 100%-ing a skill. you never stop learning and there's always space to improve. don't set your goal to perfection, you'll always come up short

ripe oracle
#

Is anyone here interested in indie game development?

real thunder
# naive pawn just in general, try to find existing resources first, especially for general qu...

A moment when I asked I thought it's borderline impossible (idk why)
Albeit a bright idea to search followed quickly and I found an answer about a moment I got an answer and got surprised it's simple
I feel like I am bad at thinking today

Also I thought that channel is... more casual but I guess it's not
I got used to use quick question channels elsewhere as a faster form of google because people hang out there and it's like symbiotic I get an answer bit faster than doing research and they got some kicks out of helping and explaining (I know that because I am one of those)

radiant voidBOT
# naive pawn !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

naive pawn
real thunder
#

you d be surprised

ripe oracle
naive pawn
#

no, let's not

real thunder
#

sometimes I feel like that my question is cohesive and makes sense is above the mark

naive pawn
ripe oracle
naive pawn
#

no, read the bot message

remote lynx
#

just saw this are interfaces serializable now or only IAudioGenerator?

frosty hound
limpid skiff
#

ops sory

deep heron
#

My bad. The other channel was not in my list.

verbal dome
#

This field is likely being drawn manually from the audiosource editor

#

You can use packages/custom drawers to draw fields for serialized interfaces. Would be neat if unity had that natively though...

remote lynx
twin pivot
#

!collab

radiant voidBOT
# twin pivot !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

twin pivot
#

Also cant help but notice the lack of experience in unity

verbal dome
#

I can see it being very useful especially for ScriptableObjects

mystic hemlock
#

why things gets hidden in the editor when I get to a specific distance? it was normal yesterday

keen dew
#

Not a code question, but select any object in the scene and press F

mystic hemlock
keen dew
#

The scene view camera's clip planes were wrong and focusing on an object reset them

mystic hemlock
#

thank you

zenith musk
#

Hey guys

polar acorn
# mystic hemlock I didn't know where to ask 😅 . but thank you. it got fixed. Can you tell me wha...

More detailed version: Unity will try to dynamically set clipping planes based on the size of the last object that was "focused". Various things can cause an object you're editing to come into focus, so if that thing was something very large like a terrain object or a big mesh, it'll set some pretty generous clipping planes to make sure you can see all of it. If you then zoom in and try to look at something very small that needs to render things up very close, it's not going to be set. You can manually focus an object at the size you want to look at like Nitku suggested, which is usually the best way. There's also a camera icon near the top-right of the scene view window to manually dial in settings if you want precise control over them.

mystic hemlock
polar acorn
#

Yep, that'd do it

#

the canvas is big

unreal basin
unreal basin
slim solar
#

Heya, isn't OnEnable supposed to run every time a GO/Script is enabled, after being disabled?

slim solar
# naive pawn only if the GO is active

Ohhhhh. So I have a little ! (new item icon) on my menu buttons that is disabled, and I want it to enabled itself when the button appears if something is new

#

But I guess because the ! is already disabled, when the button enabled itself, the !'s script doesn't run

#

Yeah that makes sense, thanks

naive pawn
#

i'm not sure what the situation is there

#

but uh, ok

slim solar
#

My ! had it's own script on OnEnable to enable itself if there is something new

#

but the ! itself is disabled, so obviously it's OnEnable doesn't run lol

naive pawn
#

oh sorry, shouldve been more specific - i was referring to how the hierarchy was set up (or what your question was exactly) but i think i figured it out after a few rereads lol

slim solar
#

The button got enabled and I was thinking the !'s script would run, but the ! was still disabled during that time 😄

naive pawn
slim solar
#

Yeah your msg made me realize my goof lol 😛

#

That's what I mean, the button got enabled, but the ! was still disabled, so it's OnEnable didn't run 😛

naive pawn
#

also to be pedantic - GOs don't get enabled/disabled, they get activated/deactivated. sometimes that distinction can help with clarity

slim solar
#

yeah, enable is just quicker to type lol

naive pawn
#

there's also a component called button so "button got enabled" just sounds like the component getting enabled, but i'm not sure if you mean that or if you have a gameobject named button that got activated

#

those would be very different situations

slim solar
#

Yeah lol, just dumbing it down but I can see how those specific words could 100% mean something else 😛

rough granite
slim solar
#

Oh it's cool, I just made my menu find the ! and run it's code manually when needed 😛

rough granite
#

I mean guess that works...

slim solar
#

just needed for 4 objects, I was just being lazy lol

kind charm
#

I wanna make something like this, but I cant really code…

https://www.crazygames.com/game/escape-from-prison-multiplayer

Escape From Prison Multiplayer is a thrilling multiplayer platformer game where your mission is to make a daring escape from prison! Customize your brave little mouse and race against time to break out. Each room you conquer brings you closer to freedom, but watch out for the dangerous traps and obstacles in your way! Can you outsmart the prison...

keen dew
#

Better start learning then

rough granite
#

!learn

radiant voidBOT