#💻┃code-beginner
1 messages · Page 794 of 1
hi does onMouseEnter() and onPointerEnter() work properly for you ppl?
assuming any of you use it ofc
Im 95% sure I explained this already to you. The Monobehaviour OnMouseEnter and similar events do NOT WORK when using New Input System only
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
uhh ok but that's not really what I was asking

It kinda is
You are hoping they are magically broken so it explains your stuff not working
yes
where can I learn C#
can someone help pls? it keeps printing (0,0), no buttons work
@balmy vortex I've made an example project that showcases using the click pointer event and the drag pointer events. It has an example scene and scripts implementing this
https://github.com/rob5300/Unity-EventSystem-Events-Example
hey rob u were helping me yesterday
maybe wanna repeat this again? lol
I was but dont expect anything
alr
is "2D vector" type Value?
yeah
I mean the Move is
2d vector has no option as value
its digital normalized
but thats what people had in all guides
Ignore what i said before this should work. Let me show an example of one I know works...
ok
@warm iris
this is exactly the same as mine
bro ive been trying to make the new input system work since 3 days 😭
yeah I changed it to value
I was just testing pass through
to see if it will work
can u show the code?
maybe thats the problem
If you add the "Normalize Vector 2" processor it may make it print what you expect.
You have read the value correctly.
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
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
@grand snow so what can I possibly do to make this work
It really should already work. double double check the WASD keys are set up with the correct directions
perhaps you need to configure your rigidbody correctly such as disable gravity?
dont presume input is broken when something else is incorrect
it is exactly the same
is the new input system enabled in the project? (project settings, player, other)
@warm iris are you using OnEnable / OnDisable For your input action reference?
no
Try using them
but I just made another testing game
and it works...
why it doesnt work on the main one
Idk clearly you're doing something wrong. I remember when my input wasn't working when everything was set up what fixed it was using OnEnable and OnDisable.
IT WORKS
FINALLY
I just deleted everything and redone it
bro I spent 3 days on it 😭
gta VI devs are faster than me
I spent 2 days on that key 🔑 code
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 ?
if statements aren't loops. anyways, do some debugging, see which part of the condition isn't passing
Show more code
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
nvm it worked after using Color32
ah, everything was full yellow, wasn't it
Color goes from 0 to 1, if you read the docs
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
Ah perfect, exactly what I was looking for.
I had a feeling unity had a built in way to do this lol
check docs 
How do I Instantiate a object to a parent object?
Have you checked the documentation for Instantiate
I have and I see the parent area but I don't see where they use it in the code
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?
no
Then if don't mind, could you explain a little on it
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
Where i'm confused at is that it's says the transform parent. So it will place the object on the parents position but won't assign it to it? If it does, then how does it do with only the transform?
Transforms are what have the parent-child relation
The hierarchy view in the editor shows how the transforms are related
Ah, I see. Thank you
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
Does anyone know what this error means?
Show code
the return type of the function should be IEnumerator and not void (i presume this is a coroutine)
{
warning.SetActive(true);
startGame.SetActive(false);
yield return new WaitForSeconds(3);
startGame.SetActive(true);
}```
do what i said
Thanks
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
do you need to do smthg in the coroutine func for the wait time to kick in
Oh so to keep in simple terms, yield return can only run in coroutines and not public void?
Context?
Im tryna wait for a few seconds b4 the main stuff happens in my game
as like a grace period
NoobDev actually gives you an idea in their code ;p
Sure, but like, show your code etc, because idk what you're asking
This coroutine doesn't do anything
Coroutines don't delay other code
They delay themselves
yield return can only work to supply enumerators/enumerables
a method that returns "void" doesn't return anything - it doesn't give any values
ye and since you are returning a yield instruction, if the method was void then the return wouldn't work
Coroutines cleverly use the iterator functionality of c# which is why this works as it does
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
haha lazy evaluation go brrr
Async would have been the natural choice and is my preference now
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)
You are probably going in the wrong direction to even ask this question
why
Sounds like you want to hard code specific logic per direction.
Anyway you can compare the input to Vector2.up and such
if you have analog/continuous values, you could probably find the direction with eg Atan2 and separate out the specific cases
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
pretty much all languages have a version of switch/case, yes
is it switch or case in c#?
(the primary feature is the switch aspect, not the case)
oh yeah sorry lol
...this is the case in most languages, with some variance in specific keywords
the language feature is match, which includes the case keyword
but thanks
why do people name something like this?
with _ first
what is the use case for it
what does it represent
this feels reminiscent of an xyproblem to be honest
https://xyproblem.info
Some like to indicate a variable is private by doing this
oh ok thanks
Some do m_foo which I hate
I definitely wont be doing that lol
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)
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
depends on how you check
i called it lmao
I will use switch case and Vector2.up down etc
with equality checks?
based on the docs it will do nothing
yh
is (0.71, 0.71) equivalent to (0, 1)
yeah its not
Be warned this is usually unreliable but if you have your input normalised it should work in this case
go give this a read. what are you trying to achieve here
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
so how would I do it
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
your snake can go diagonally?
no
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
so how would I do it
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)
how would I do that? Im a very beginner
this is literally my first game after copying 1 simple game from tutorials
which part specifically?
enum value
is there a specific term there you don't understand or something
and the rest I didnt really understand so idk lol
what would be the "specific conditions"
checking for perpendicular inputs
do you know what an enum is
not in unity
this isn't a unity thing
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?
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
k so how to do that
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
do I need if statements or is there a method for this?
no enum, no string etc
it's math
no conditionals
might just be one assignment depending on how it's set up
how to do that
well, how do you plan to rotate the snake head?
idk tranform.rotation = ...
if it's a gameobject you could set the transform's up direction
or right depending on how the sprite is set up
ok what to set the up direction to?
the direction vector your snake is moving in
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
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
i mean.. i just said it...
btw, you can just write !(a == b) as a != b
oh bruh I did that but something was wrong
and on yt someone did the !()
k so just another function to check that right?
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
is switch case fine?
for this example
cuz I will get rid of 0,0 and holding multiple buttons fast
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
yeah ok thanks
but Ive got to go
so Ig I will finish it later lol
thanks for the help tho I appreciate it
sooooo im new to this and i dont know how to solve the issue it wont run
hi, this is a unity server. for general csharp help, try the csharp server
!csharp
There's no command called
csharp.
!cs
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
okay
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
is the rb dynamic or kinematic
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?
yep it as the linear dampening @ 100 instead of 1
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)?
Animation via code or animator to perform the "jump"
may need to move a child so the navmesh agent wont fuck it up
and then snap the agent to the destination?
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?
can you elaborate?
hello
do you guys use state machines for movement in character?
or just use if-else instead
i am losing my MIND. I've been programming a healthbar all day and I eventually crapped out this code:
I think the animator system already has that covered?
then created code for the player which tests if the slider actually works
what is your goal
!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.
Do you need help?
i managed to fix it and it's working as intended now (thank god)
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
Glad I'm not the only one
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.
This is the model in case you were wondering:
https://sketchfab.com/3d-models/animated-rifle-1cfaabe4c0bd4db189d4768ead272e8a
-Take
-Shoot
-Reload
-Idle
You can change prototype rifle model to your own
Low-Poly Rifle from - https://sketchfab.com/notcplkerry - Animated Rifle - Download Free 3D model by JUST (@teenjust500)
The preview issue could be due to funky model scale. Try adjusting the import scale to make it normal size.
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
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.
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
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.
I really don't know what to do. Maybe you can try it yourself or something if you have time. I would be grateful
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; }
c# has properties, this isn't java lol
can you still serialize them for the editor if they have getter and setter properties?
getters and setters aren't properties, they're part of properties
regardless
your question is ambiguous because of that
like [SerializeField] private float speed { get; set;}
unity can't serialize properties, but properties with automatic backing fields have, well, backing fields
right, this wouldn't work, because that isn't a field
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
haha i didn't know how much there was to fields, i'll need to read up on it
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
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?
No because monobehaviour is not meant to be used in any other way. (it may actually serialize but you would need to still copy data out to a real mono instance)
sounds like you need a plain class to store data that you can use in both places
I thought about storing like polymorphic data objects but i dont know if thats applicable here
i also thought of just straight up moving the serialized fields into the scriptable object but im also using abstract classes
and i guess unity cannot serialize abstract SO fields directly
so thats also out of the window
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
How do I get the transform component of an object in a script attached to said object>
hint: look at the documentation for Component (or MonoBehaviour)
or, in a configured IDE type this. and look at the available properties
Hello
if it's red it will tell you in the console in unity
also your input vecotr
it wont return up down left right
I mean I get this
That's a transform's thing
your cases must be constants or patterns, those properties are not constant
That worked, but how do I do it for classes from other files, I don't want to have to drag the transform component every time. I tried using static ... but that doesn't work
you cant use up down left right, you have to use the x and y
how is (0,1) not constant
its literally short for (0,1) why wouldnt this work
if you are referring to dragging a component reference, then you just use the type of component you are trying to get. otherwise, again, look at the documentation for relevant methods
because it's literally returning new Vector2(0,1)
there is no possible way to make that constant in the first place
just because you can write (0,1) doesn't mean it can be treated as a compile time constant
so I have to use ifs here?
you can do case input.y > 0.1 etc..
yes, but also what is the actual point of this? you're just returning what you expect the input to be?
literally "moveDir = input;" accomplishes the exact same thing here
its to not get 0,0 or 0.71, 0.71 if 2 buttons are down
its a snake game
I only want to get up down left right
then you can do checks for greater/less than
The image above shows dumb logic anyway so why bother with this switch?
then check each axis and only move it along the strongest axis instead of attempting to check each of the possible values
You read input and you already have a direction to move on a 2d grid
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
we already talked about this topic yesterday but that part hasnt gotten through yet 😆
Also your logic isnt good, what if someone wants to move up AND left
so like math.abs and then check the greatest value?
math.abs so -1 will be greater than 0.71
they explained it's Snake. there is no diagonal movement
Then you can just adjust the input value to say clear Y if X is non zero
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
yes but it wouldnt matter
his code is for if 2 are pressed in the same frame
it should just disregard it and keep whatever was done before
tha'ts what im talking about
that's bad user experience
it should not disregard new inputs
if the user goes from going up, to going down and right the next frame which direction does it go
it should go whichever was pressed most recently
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.
it's unlikely that a usser can press 2 buttons in the exact frame
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.
both are in the same frame
that would be incredibly rare unless the user was macroing
im not replying to you
low/capped framerate
or if hes using the current inputs and not the GetDown variant
even still its very possible even on high fps
no i know i just dont get why u said that (respectfully)
that a user presses two buttons in the exact frame is rare?
With low framerate its very easy for many keys to begin their press on a frame
low framerate is true though
How can I access special fields of gameObjects in other scripts (like movingSpeed n stuff)?
thanks
and all components have a gameObject property to get the gameobject the comp is on
also based on his function name, his code is to handle any and all inputs, not edge cases
@grand snow @prime goblet this good?
does it work?
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
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
if 2 axis of inputs are being entered it will move only horizontally
not good design
yes?
I just mean effective solutions which are easy too read and works well
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.
have you tried the code yet
does it work?
if it does then it's good
im trying it rn wait
theres no diagonal movement since its a snake game no?
yeah exactly
it is snake
open a thread in #1390346827005431951
i did 😭 But i gotta get it done asap
ya forgot the preamble
for some reason holding s and a is the same as s and d
why?
it is always 0, -0.71
shouldnt it be positive 0.71 for one of them?
what did i say bro
right
oh ok
how to check if theres 2 axis?
is there a quick property for it?
or do I have to check taht
if (abs(x) > 0.4 && abs(y) > 0.4) // diagonal movement so ignore it
return new Vector2(0, 0)
or actually
why 0.4?
return the snakes current movement before
its just a value
you could do 0.5
as long as its above 0.001 and under 0.7
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
are you sure I can use that to for example get the speed field?
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
[Header("Player Component References")]
public Rigidbody2D rb;
[Header("Player Settings")]
[SerializeField]
float speed;
[SerializeField]
float jumpingPower;
...
if speed was public then yes
rob does this look good and clean?
now you can do GetComponent<PlayerController>().speed = 20f;
gameobjectThatHasTheComponent.GetComponent<PlayerController>().speed
thanks
Learn about c# access modifiers: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers
since you're accessing the class variables from outside the class they need to be public
guys @grand snow @lethal meadow does this look clean now? may I go to sleep lol
if there is no good reason plz dont ping me
its always user choice to participate
unless it was a thread where only a few users were active
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
Can somebody tell me, when variable gets referenced or set. Sometimes write code and reference without knowing. I fix by using .clone() as type
I hardly get what you are asking but sounds like you need to learn about reference types and value types in c#
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types
@elfin pike ^
Yes, I have to learn them or is there tool to see if it's value or reference?
You can tell by looking at the variable type; that's all, really . . .
your IDE should colour code type names based on them being a class or struct
if you navigate to the type you can then confirm (or you can check the unity docs/whatever docs to also confirm)
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.
You learn over time too. Vector2 and Vector3 are structs so are Value types
structs are value types; classes are reference types . . .
yea thanks for saying the same thing
Check the docs..? 🤔
The unity manual just explains what code to use but not what namespace to import
the name spaces are in the scripting api part of it
Unity.PlatfromToolkit
If still not recognized, you're likely using assembly definitions and need to configure them to use the package assembly.
or if the error only appears in your IDE you need to regenerate the project files
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
oof
whats the oof
its telling you exactly what it requires you do in that error
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
await can only be used in async methods
yeah I thought it was complaining about GetAchievementSystem
Sorry I'm being distracted lol
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
Damn. getAchievementSystem does not exist.
does anyone know how to work with vfx like particle systems to make a muzzle flash type effect
i imagine the people who hang out in #✨┃vfx-and-particles might know
Easily to Google as well, plus look on the asset store if you want to just get something:
https://www.google.com/search?q=unity+muzzle+flash+particles&oq=unity+muzzle+flash+particles
they kinda either do or dont reply
well if your entire question boils down to "how to make it" then you need to put more effort into research
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)
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.
https://assetstore.unity.com/packages/vfx/particles/war-fx-5669
There are even free ones 🤷♂️
each tutorial just made the same thing so i think im doing the wrong ones or something
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
Perhaps apply some smoothing to the RB.MoveRotation part,
There’s nothing smooth about MoveTowardsAngle as far as I know. It just has a maximum delta per frame.
how could i make it smooth tho cause it has to be an angle and doesnt it use turn speed to make it smooth
It also may be a result of not having Interpolation on, or not using it correctly / the camera not being set up correctly.
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;
Are you familiar with Quaternion.Slerp
kinda but does it have the same angle thing as MoveTowardsAngle
And, the camera should be in Update mode so the interpolation is visible, not FixedUpdate, I think. But that’s likely not the issue
i move and rotate the cam in late upadate
and i rotate the character in fixed
Okay, so the jitter is just from that code itself, which doesn’t smooth it out
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
Well you could smooth out the TargetYaw, maybe that will work?
maybe a bit less tho
hmm lemme try that rq
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
so i kinda dont know how to smooth out the target yaw any ideas
been trying for over 15 hours and its 1 am I have a college interview tmrw i gotta show this 😭
Yeah it’s tricky. Takes time.
Well “newYaw” is a float, so maybe pull it out of the function and just use Mathf.SmoothDamp
Make sure to not WrongLerp, you can find that whole thing on UnityHowHuh website.
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));
You took too many steps forward in one shot. Have to delete the other attempts before trying this new one
ye i js a got a lil confused on what i should smooth out
I tried smooth damp on new yaw firstly it didnt work and secondly it broke the rotation cause its not angle based
My confusion is the turn speed is supposed to be the smoother but idk
And smoothing out the rigidbody didnt work either
neither did the targetyaw
so ig nothing work 😄
There’s a lot at play here,
I do recommend Quaternion.Slerp the most if you can figure out how to use it in your context
Isnt this how i use it tho
RB.MoveRotation(Quaternion.Slerp(RB.rotation, Quaternion.Euler(0f, newYaw, 0f),TurnSpeed * Time.deltaTime));
That seems fine, but a bunch of other things could be wrong in your setup/code 
That’s not how the Unity docs use MoveRotation, so I’d start there
well i js asked chat gpt and even hes saying i shouldnt use slerp on the rigidibody since im already using movetowardsangle on the new yaw
Yeah, I know. They’re completely different approaches that cant be combined, that’s why I said if you can figure out how to use Slerp in your context
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
Did you check out the Unity docs for MoveRotation? They compute some “deltaRotation” and multiply it
i did
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
😭 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
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
i was looking at the wrong thing
i find it rlly cool
like the motion matching
its rlly realistic but u gotta work on it a bit to perfect it
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
i have a quick turn mechanic that turns the cam by 180 degress and that has no jitter when turning
The cam or the player? I thought the player is the rotating Rigidbody in question.
it rotates the cam
no the cam rotates the player and the rigidbody is the player
… 
is that bad 😭
So the player is supposed to follow the rotation of the camera?
What about WASD and such?
thats based on forward of the player rotation

movement works fine trust me
its js the damn jitter
if i could fix the jitter i can get onto do so much
Putting stuff into Debug.Log can help, OnGUI even better for some cases
It’s your project, how would I know 😪
Keep troubleshooting different things until you pinpoint the issue,
Or ask ChatGPT maybe it knows more
chatgpt is the stupidest mf ever it keeps saying random things
ive been finding out the cause of my issues this whole time
Your RB is kinematic right? I think interpolation for MovePosition and MoveRotation only works on kinematic RB
I EVEN MADE IT READ THE UNITY DOGS
nah its not
oh shit
so ig i do this? RB.rotation = Quaternion.Euler(0f, newYaw, 0f);
Awesome so dynamic RB are only supposed to use AddForce and AddTorque to maintain interpolation
well that seems the same even with rotation =
wait so for rotation dont i do rotation =
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.
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
This is how it looks with the values do u see anything odd SUS
That’s not how Slerp works, nor Springs,
Properly used they are supposed to adapt well to new inputs as they change
You’re still using MoveTowards right? That has no smoothness within it
but im using lerp on turnspeed
TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);
Maybe dlich sees the issue better.
I feel like you have multiple issues already with the approach that will make smoothness difficult to achieve 
This looks like your character is rotated in fixed update without interpolation.
its in fixed update
Well, then it's broken for whatever reason. Probably because you're not rotating in a physically compatible way.
Not supposed to use MoveRotation on Dynamic RB… interpolation doesn’t work in that pairing AFAIK
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
i stoped using moverot tho
Manually assigning is like the same.
Dynamic RB only interpolate properly with AddForce and AddTorque. Those are harder to use, too.
First, setting rb.rotation would break interpolation.
well how do i change rot then
should i use addtorque
Forces/torque, or setting velocity. Not entirely sure about MoveRotation. 50:50.
im not gonna get any sleep am i 😭 I hate unity so much but its too late to quit now
MoveRotation should work according to the docs
alr ima test torque ig
ye thats what i was thinking too
Then there probably was something else that was breaking it.
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.
I remember movePosition and MoveRotation working properly in the past. Though it was a long time ago.
chat gpt said
Yes — but only visually.
MoveRotation does NOT interpolate by itself.
With a Dynamic Rigidbody, interpolation happens only if Rigidbody.interpolation = Interpolate, and it’s just visual smoothing between physics steps, not real rotation smoothing.If the target rotation changes every frame → jitter still happens.
That’s cap.
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 💀
Please avoid posting AI answers here. This is against the server rules and an easy way to invoke the server wrath on you.
oh mb 😭
I'd also add that you both confuse and get confused by the AI since you don't really understand the topic.
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
It's reply is a jumble of unrelated info in this case.
alr gimme a sec
I posted a Unity discussions link. But ok whatever.
ai has destroyed my mind lol
damn it worked
I see that, but that thread is quite sus.
Yeah of course. Now suffer with AddTorque (hint Vazgriz PID controllers video)
I'd suggest trying velocity before torque
ah alr ima test that first then
it says i gotta give it a turn speed but then how will i get the actual target rot set
idk if my minds fried at 2am or what
dude it’s called delta lol
Compute the difference between current and target
You check how far you are from the target rotation. If not reached yet, set the velocity. If reached, don't(or reset to 0).
RB.angularVelocity = new Vector3(0, TurnSpeed, 0);
i cant look around at all now
like my body doesnt turn
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
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
You need to debug instead of making random changes.
What I mean is, “Winging it” is not recommended when working with Dynamic RB 
No it doesn't. Not mass.
ik but i just want to fix this and sleep bro ive not slept in 24 hours
well not 24 but i woke up at 5 yesterday and now its 2 am
and yesterday i slpet at 2 am
im cooked 😄
Well, it would be way faster if you debug and understand the issue first, then trying numerous solutions randomly.
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
Im trying to understand it as i go but my brain is js a pancake rn so im focusing more on js fixing it which i know is wrong but im stupid 😄
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)
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);
You can't fix what you don't understand, can you?
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
Jumps? Like the character itself, into the air?
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
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
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
@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.
well, isn't moverotation specifically for kinematics
Yes. And MovePosition
Yeah, the docs fail to mention this though
Yep exactly. I remember suffering through this before and only could find that info in Unity Discussions
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
Whatever that means. I wonder if there's a channel here to suggest Unity Docs improvements.
You can click on the report button again to add a comment.
I don't see anything like that. Do you mean that "Something else" button
After I clicked "information is missing", then clicking on the button again revealed a comment ui.
Ohh omg I didn't notice the 'provide more information' button. Thanks, good eye
yall should go through each doc and tell unity how to make em all peak 😄
it will only take afew days 😄
Yeah literally. Well maybe more than a few days I’ve only even read prob 20-30% of the Docs.
is the docs that long 😭
Combined effort of multiple people though, yeah maybe.
imagine the person writing it
unity is a really big project
it's not gonna be one person, it's entire teams (plural)
yikes
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
Try restarting Unity.
thanks, fixed it
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?
man, the people here aren't gonna know. #↕️┃editor-extensions
the editor part is just variable/class names though?
the main question was about type conversion
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
edited the code to be more general-case
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
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)
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
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)
check before casting
so essentially, it's just casting
there are also as and is with pattern matching checks
I don't know the whole context, but you typically don't need to access subclass fields from a base class. This is a code smell. You'd typically use polymorphism.
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?
What makes yoou think that the class is in the Unity.Entities assembly?
Are you using entities v 6.5?
So unity editor 6.5?
ok I see now the package manager says 1.4.4
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
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
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.
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
I'd suggest looking at some open source/free(maybe paid too if they provide source code) asset solutions to learn different ways to tackle such problems.
i need help about my Skin not following camera corretly.
i cant do this with parenting since then some networking issues i use occur.
how do i make the skin follow my head?
i got a script that should do the job but it doesnt work well.
https://paste.mod.gg/twaezrvqbbgm/0
A tool for sharing your source code with the world!
You could probably use a parent constraint component rather than setting position and rotation.
This would allow you to freeze particular constraints if you aren't wanting the parent to effect those particular values.
https://docs.unity3d.com/6000.3/Documentation/Manual/class-ParentConstraint.html
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.
Ok thanks im Looking onto it later
Is this a code question? If not, try #💻┃unity-talk
fixed, yes wrong chat. chunk culling auto is terrible
is there an API to greate an array from a piece of existing array?
like from elements 4-10
fyi this would be referred to as a slice or a range or a sub[sequence/array/string/list/graph/set], for ease of searching in the future
i got a dialogueManager that can receive any LocalizedString[]
thats it really
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;
}
}
}
you can add an extra check other.compareTag("Player") && isInsideBuilding
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;
}
}
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?
but why the enter wont trigger on the other box collider? is the playercontroller moving too fast?
that too
OnTriggerEnter is usually a thin collider
otherwise you'll have OnTriggerStay
The enter triggers before the other collider's exit
Ohh actually i never tought of that, so i just should put a thin collider between the doors? Otherwise no any reason to cover the whole inside part
Like this
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
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.
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
oww, i try that. hold on. 🙂
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
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.
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)
transform. searches for children
gameobject.find search all the gameobject from the hirearchy from top to bottom, transform.find only searches childs on the given gameobject
(Also both are awful)
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
Which method would be preferable to either of these? Using the Unity editor and storing the reference instantly?
But they should theoretically return the same transform if the gameobject that the transform is on is neither a duplicate or inactive right? I'm just a bit confused why one works and the other doesnt
it's better relative to GameObject.Find, but it's still not good.
is there any video explaining the multiplayer system for unity in detail
yes, direct serialized reference are the recommended way
you're gonna have to be more specific - how exactly is one of them not working?
do not crosspost
My rule of thumb is to use the Find methods for quick prototyping only, if anything
When using the GameObject.Find I'm getting completely wrong information about the objects transform. As soon as I change it to the transform.Find and recompile it fixes the issue
Direct reference is usually possible
depends, if you can, you should make the reference and drag it from the editor (the less code you run the more optimalized it is), if you make a reference runtime then the second.
Did you confirm that they find the same object?
this channel is for code help that why i asked here to
Oh I'm fairly new and I'd read that its okay to do it a bit as long as its not in an Update method. Is it really that much of a concern
I'm using Debug.Log() to print the objects name and there are only a handful in the scene and only one with the that exact name
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)
there's a lot of aspects to "okay".
that one definitely isn't true though.
there's 2 main issues with find, the fragility of indirect references through a magic string, and the performance to find retrieve the target
the performance is not too much of a concern if it's not being done constantly - like in Update, but also in any other cyclic contexts
but the fragility is always there
I'd learn to do it properly from the beginning (avoid Find)
pick one channel to post in, don't crosspost.
okay
imo, don't worry about perf for now. worry about having sensible, safe, maintainable code, and perf will follow (at least at this stage in learning)
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.
ok, and did you get the same name
Yeah it's the exact same
what's the issue then exactly?
have you tried just logging Find(...) == transform.Find(...).gameObject?
this is why i said if you can you should drag the reference from the editor instead of flooding awake or start.
What wrong info?
Its not always possible unfortunately
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.
No errors at all
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?
yes, when you runtime instantiating something, then you should store that reference immidiatly when you make it.
Getting the transform.forward is yielding different results between the two references. The game object reference doesn't seem to be updating at all and staying static
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
well Transform is a reference type, so that shouldn't be happening
you weren't caching the forward vector, right?
Maybe showing the actual code would help, might be an obvious mistake
if you still have the code that you encountered this issue with that'd be very significant/useful context
can I like
create a new basic materal from code
new Material()?
did you try googling "unity create material code" at all
research is the expected first step here
sorry I will try to be more thoughtful
!code
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
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
there'll be tutorials for that
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
just in general, try to find existing resources first, especially for general questions. chances are it'll be faster and more in-depth. spaces like these work for more specific questions or issues
might need it down the road
pace yourself and rest, burnout is a bitch and brainfog does not help
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
Is anyone here interested in indie game development?
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)
!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**
even in more casual spaces, trying to research a bit is expected imo
you d be surprised
Okay let's talk about it
no, let's not
sometimes I feel like that my question is cohesive and makes sense is above the mark
i do hang out and help in other casual spaces, there is a limit to how "casual" it can go imo. these spaces aren't google proxies
Are you interested?
no, read the bot message
just saw this are interfaces serializable now or only IAudioGenerator?
@deep heron #🔀┃art-asset-workflow
@limpid skiff
#1390346776804069396
Neither of these are coding questions.
ops sory
My bad. The other channel was not in my list.
Unity's been able to serialize interfaces for a while now (with SerializeReference), it just never had a built-in way to display it in the inspector
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...
SerializeReference works for concrete implementations only it cant serialize UnityEngine.Objects
!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**
Also cant help but notice the lack of experience in unity
Oh yeah true. I couldnt find anything about new interface serialization though, so maybe it's just custom editor code for audiosource. You could test it out though?
I can see it being very useful especially for ScriptableObjects
why things gets hidden in the editor when I get to a specific distance? it was normal yesterday
Not a code question, but select any object in the scene and press F
I didn't know where to ask 😅 .
but thank you. it got fixed. Can you tell me what happened exactly and how?
The scene view camera's clip planes were wrong and focusing on an object reset them
#💻┃unity-talk for questions that don't fit any other channel
thank you
Hey guys
Zoom out
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.
I guess it was because I was focused on doing the UI on the canvas. since the canvas is very large. Thank you for the help 👍
Alright I will try that out! If you know any open source ones it will be very helpful
Mhm that's convenient, but I mean if there are so many scriptable objects or variables that you have to keep tweaking again n again, I thought there will be a better way to do it, like a dialogue graph system or something so visually it's more debugable which thing goes where
Heya, isn't OnEnable supposed to run every time a GO/Script is enabled, after being disabled?
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
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
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
The button got enabled and I was thinking the !'s script would run, but the ! was still disabled during that time 😄
OnEnable fires when a behaviour becomes enabled on an active gameobject
either it's already enabled and the GO becomes active, or the GO is already active and the behaviour becomes enabled
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 😛
also to be pedantic - GOs don't get enabled/disabled, they get activated/deactivated. sometimes that distinction can help with clarity
yeah, enable is just quicker to type lol
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
Yeah lol, just dumbing it down but I can see how those specific words could 100% mean something else 😛
Make the icon in a container that gets hidden / shown and not script (then have the script be a part of the parent object (which shouldn't get deactivated)
Oh it's cool, I just made my menu find the ! and run it's code manually when needed 😛
I mean guess that works...
just needed for 4 objects, I was just being lazy lol
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...
Better start learning then
Then learn with something like unity pathways
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!