#💻┃code-beginner
1 messages · Page 648 of 1
@rocky wyvern
those special characters in the directory path seem likely to cause issues
really?
just our language xd
but we will try
And this is just for your friend or both of you?
just for him
Have him try to update .net
what is that mean
.net is a software framework for Microsoft
It’s what unity projects use
The error you’re getting failed to resolve assembly is an error from .net
It could be caused by something in your project, or it could be something in his .net installation
Just look up update .net and there should be a official Microsoft document for it
maybe the other guy is right?
this sone
one
I mean, maybe, but i feel like that would be something that would have been fixed fairly rapidly
Just have him reimport the project to somewhere on c drive not under his user
If you think that might be an issue
I would recommend never having non-ascii characters in your directories anyway
I even had problems with whitespaces in the past
I mean if it’s bros name it’s kind of understandable
just wanted to confirm something is going to behave as expected
if I have an object like indicatorLight
and I give it the property
public static CommsManager commsManager
the static keyword means that if I give one indicator light the commsManager in inspector, all will be able to read it?
they need to be able to run, essentially,
if (commsManager.messageQueue[0].address == this.address)
then turnSelfOn()```
Operative question is, will the static keyword mean I can have many indicator lights without having to manually assign the comms manager to all of them to get them to listen for whether they should turn on
ok I just fixed it by replacing the entire if statement with a single equation and it works... its a cosine function that drops to 0 when close to 0 and 1
it works perfectly now
Still very confused why you had to do it this way but gratz
The ‘better’ way to do this is to have the commsmanager hold a static variable of itself
Lookup a ‘singleton’
oh, duh, I forgot I did that exact thing to check story flags for something else it's even already set up for that
thank you lol!
man u saved it
i fucking love u
What's the easiest way to accurately bounce an object off of a wall? I have this but it obviously isn't giving the desired effect
private void OnTriggerEnter(Collider other)
{
changeAngle = transform.eulerAngles;
transform.Rotate(changeAngle);
}
All 3 walls have a collider
Alternatively look into event channels, if I understand what you’re trying to create then it’s fitting for their usecase
static means it belongs to the class, not an(y) instance. Any instance (or any class that has access to the class) can assign it . . .
(I would argue better but it’s a new can of worms if you have no idea)
in essence it's like a telephone operator's wireboard with input and output wires, need a visual indicator of whether a port will have a message waiting when the player connects the plug
ah
static means it belongs to the class, not an(y) instance. Any instance (or any class that has access to the class) can assign it . . .
Sorry, chat kept moving and I tapped the wrong person . . .
Use Vector2.Reflect . . .
oh
I would consider looking into event channels if you have many things that need to be done when something occurs
And a singleton when you need to access data or functions from many scripts
I think your use case fits here
When message received, turn on light x
When message read turn off light x
The issue with your implementation is that every light has to check if it’s meant to be on every frame
Which unless you need to you’d rather not do
I was actually going to have that line of code run in a function like
onMessageQueueChange()
triggered in CommsManager
but an event system sounds like something build for that
so I'll look into it thank you
Yeah that’s basically the entire point of event channels
Purpose built for conveying when things happen to many instances of scripts that need it
yes..?
gist of my usecase from my rough GDD is here
CommsManager will store all conversations with active incoming messages in a list of conversations called QueueIncoming
CommsManager will store a list of conversations that can be responded to in a list of conversations called QueueOutgoing
playerActiveDevice will keep track of whether the player has the radio or wireboard plugged in
playerActiveAddress will keep track of what address is selected, either which switchboard plug or what radio coordinates
playerActiveDirection will keep track of whether the player is in sending or receiving mode
if the method and address match an incoming message and the active direction is receiving, set the comms equipment to decode mode to begin displaying the data
if the method and address match a conversation with a reply available and the active direction is sending, display the player’s dialogue options and allow them to key a response
if the method and address do not match anything in either queue, or the wrong PlayerActiveDirection is set, comms devices should remain dormant
Every address with a matching conversation in QueueIncoming should have some form of indicator, either an indicator light for the switchboard or radio distortion minigame for radio
why does ui appear in my scene
not a code question, but that is how the screen space overlay canvas works
So you can see it while editing it?
How else would you position things on a canvas
use imagination
If it’s on overlay mode it won’t be rendered while in game
well it will, just - overlaid on the screen not like this.
It has to be displayed for you to see and edit it. Each pixel represents a Unity unit, that's why it's huge . . .
Well yes i meant you won’t see this huge canvas when looking about
Honestly struggling to understand how to use this
All the examples I see online for getting the normal off the other object say to use thing.contacts.normal; but that doesn't seem to exist
contacts is a property of the Collision class.
You only get one of those in OnCollisionEnter
You don't get that in OnTriggerEnter
The other way generally to get a normal is from a raycast (or similar things like boxcast etc)
the RaycastHit will have a normal
for OnTriggerEnter - a common approach is to do a raycast from where your object used to be last frame to where it is now for example, and get a normal from that
Or just do the raycast/boxcast/etc in FixedUpdate before a collision actually happens
I think I'm almost there, doesn't actually effect the object upon collision yet
private void OnCollisionEnter(Collision other)
{
Rigidbody rb = GetComponent<Rigidbody>();
Debug.Log(rb);
Vector3 v3Velocity = rb.linearVelocity;
Debug.Log(v3Velocity);
transform.Rotate(Vector3.Reflect(v3Velocity, other.contacts[0].normal));
Debug.Log("Rotated");
}
Cache the rb btw don’t want to get component when you don’t have to
so i got a small problem with my sound , sometimes when i slam and then jump afterwards , when i land , the slam sound plays again for some reason and im not sure what causes it
is it possible to have images and stuff in a input box?
Just add an image to it
Won’t break anything
like will it be inline with the text?
Depends where you put it
What do you mean by have images in an input box you just want to display an image there right?
i'll keep working and see if i have a better question
actually i have one, how do i clip a sibling, like for a scrollable container?
How are you setting movementstate
If I understand what you want then the component you want is called a Mask
i fixed it 
Use mask for ur raycast btw if you don’t want to slam on random anything
Well, calculate the slam strength on anything
If it’s closer than the floor
Okay, now at least the balls react to the collision, but they keep trying to go the same direction
private void OnCollisionEnter(Collision other)
{
Debug.Log("tforward" + transform.forward);
transform.Rotate(Vector3.Reflect(transform.forward, other.contacts[0].normal));
Debug.Log("normal: " + other.contacts[0].normal);
//Debug.Log("Rotated");
}
You're trying to use a direction vector as a parameter to Rotate
Rotate takes an euler angles vector
And it's also additive
Perhaps you want transform.forward = Vector3.Reflect(....)
Okay THAT works
Thanks a bunch
Literally all that I found on google was like 20 lines long
It’s normally something you’d probably just use physics for so
im trying to make the slam knockback objects with a rigidbody but for some reason , it doesnt knock back anything which is weird i guess
how can i make an audiosource play a sound on collision without it playing the sound a lot of times due to collisions triggering multiple times
You can first check if the audio source is currently playing
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/AudioSource-isPlaying.html
you have to add some type of 'gate', there are many ways to do it, but a bool probably be the easiest if you need it to play once and only once
eg.
bool hasPlayedSound = false;
void OnCollision() {
if(hasPlayedSound == false) {
sound.Play();
hasPlayedSound = true;
}
}
or a timer
float waitTime = 5f;
float counter = 0;
void Update() {
counter -= Time.deltaTime;
}
void OnCollision() {
if(counter <= 0) {
sound.Play();
counter = waitTime;
}
}
I think there is Collider.attachedRigidbody btw
But your last raycast is weird
Is it meant to be a not?
I assume you’re trying to check for los?
looks like it's for detecting walls and stuff. so the force doesn't trigger through a 'blocking' object
Ah I got it the wrong way round
have you tried setting a breakpoint or adding some logs? might just be the HitLayer that's setup wrong, so it's not finding any colliders
If this doesn’t exist but I think it does I would also try hits[i].gameobject.getcomponent
or since you are using OverlapSphereNonAlloc maybe you forgot to init the Hits[]? that will always give you an empty list
He has maxhits field so
yeah ik, but it's easy to forget to add Hits = new[maxhits] in Start or something afterward. god knows I've made that mistake a few times 😅
No. They often bounce off(depending on the hit angle and the surface material). The only case where they might stop immediately is if they break the surface and get stuck somewhere inside.
The latter is not a common feature in game engines, so all you have is bouncing.
to address the question, seem like you just have to increase the linear and angular damping on the bullet rigidbody.
okay yeah , that was the problem xd
i forgot
i randomly started getting this error
UnityEngine.Input.get_mousePosition () (at <0b0249d5e61a446b913cd2910a5a40f5>:0)
UnityEngine.UI.MultipleDisplayUtilities.GetMousePositionRelativeToMainDisplayResolution () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/MultipleDisplayUtilities.cs:40)
UnityEngine.EventSystems.BaseInput.get_mousePosition () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/BaseInput.cs:75)
UnityEngine.EventSystems.StandaloneInputModule.UpdateModule () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:183)
UnityEngine.EventSystems.EventSystem.TickModules () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:331)
UnityEngine.EventSystems.EventSystem.Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:344)
Probably because you are trying to read Input using the UnityEngine.Input class, but you have switched Active Input Handling to Input System Package in the Player Settings
i mean i have a UnityEngine.InputSystem but i don't know where this issue is happening at
Looks like the EventSystem
oh
ok so when i made the 2d Canvas it made an EventSystem object
do i delete it or something?
Are you intending to ever interact with anything on that canvas or is it purely visual
intend to interact
Then deleting the thing that lets you interact with the canvases would probably be a bad idea. If you select it there should be a button that lets you add the Input System module to it
i see it now
thanks
is it possible for canvas mode to snap to a grid?
i can't set the text anymore of any of my input components
i can set the placeholder though
Is the variable of type Text or TMP_Text, and are you trying to drag in a TextMeshPro object or a Legacy Text object
Text, and no
Text is Legacy Text. What object are you trying to drag in
not dragging anything in i just used the input ui object
and it was working and now it's not
no errors
Ah, so when you say "can't set the text" you mean you can't change it in-game?
i can't change it in the editor
Is it just frozen at a specific value or is it getting reset when you hit play?
it just doesn't do anything, when i defocus from the field in the inspector, the text just vanishes, and it never shows on the scene editor
Show a screenshot of the inspector of the object you're editing
Are you sure ur editing the placeholder text and not the text that’s meant to change when the user types in it
im trying to edit the text text
Show the object you're trying to edit
Yeah don't change that one. That's going to get set by the input field
Change the text on the input field
Yeah you are editing the one that the player is meant to type in
Btw do yourself a favour and just import tmpro
what's that?
TextMeshPro - the thing you should be using whenever you're doing anything with UI
Text mesh pro package
there is no reason to use Legacy Text any more
this one?
Yes, use that one
aight
Use the TextMeshPro versions of everything when it's an option
including images?
Do you see an Image - TextMeshPro option?
oh
now it's happening with those
one time it worked
and now it just refuses to allow me to manually change the "Text" area
Because you don't do that
Edit the text value on the input component
not the text object
is there a way i can mask out the inner portion of a panel so it is transparent and have rounded borders?
Use a sprite that looks like that
i think i found a bug
emojis do not show up at all (not even the black outlined emojis for regular text style) in a text area in the inspector
they do show in the editor though
Your chosen font might not support them (?)
the font of the Unity editor itself?
Hey how could I get ui elements tied to locations in the world working with splitscreen? Normally I just use world to screen but that doesn't really work with there being two smaller render textures.
legacy UI is meh , if i ever have textmeshpro i would ensure its tmp
only solution i can think of is to add a collider and instantiate the ui whenever the collider is triggered
but also i am still a beginner so theres probably a better solution
Get the world to screen POS normally. This is the screen space position for the specific camera/half or the screen. Do some simple math to convert it to full screen space position.
Ok I may be dumb but what math? Like it makes sense on the surface for it to be like dividing it by the size of the render texture and then offsetting it by the distance of the render texture from the center of the screen but the screen itself isn't the same size as the splitscreen areas
If it's the bottom screen, then add the top screen hight to the position. And that should basically work🤔
The top screen should work as is
Unless I'm missing something. Need to test and see the numbers. Debugging
The screen itself, at least in this example, is 3440 x 1440 but the splitscreen segments are actually a slightly different ratio since they're 2000 x 700 so I think the resolution ratio wouldn't translate right to the UI.
You need to test and see.
The render textures should have the full screen resolution in sum.
Otherwise you're gonna get blurry image.
Or other artefacts, like aliasing.
I had them at that resolution but it absolutely killed the framerate. Probably since there's 3 cameras in total all rendering at once. 
Then, when you use world to screen, it should return the position in that render texture space. The x should align with the full screen. The only difference is the y.
Hmm ok.
Yeah, you'll need to optimize your rendering so that each renders at 1/x of the budget.
What you're doing now is basically a primitive version of "upscaling" and there are various techniques for that, like FSR or DLSS. I think unity implements some of them.
Hey y'all, still learning C#. Found my way to Microsoft's modules.
I have a simple script here that isn't making sense to me.
int fahrenheit = 94;
fahrenheit = fahrenheit - 32;
decimal result = fahrenheit * (5 / 9);
Console.WriteLine("The temperature is " + result);
The console is reading 0, any advice?
Ah duh, I'm missing the m. lol
what is "m" ?
what does "m" mean?
but f - is float
what is m?
decimal.
ah got it, thanks
It's more precise double, not usually talked about it seems
since this is the first time ive heard of it through the MOS modules
Yeah, and it can't express a decimal because I'm trying to divide integers
Just an oversight haha
In this article, we will have a look at data type suffixes in C#.In C#, data type suffixes are used to explicitly specify the data type of a numeric literal when it might otherwise be ambiguous or to indicate a specific data type for a literal. Suffixes are appended to numeric literals to indicate whether the literal should be treated as an int,...
in C# or C++ , adding an alphabet behind numbers have meanings
Yes, ik, it was just an oversight that I forgot to add and I was scratching my head wondering why console was giving 0
like a missed semicolon xd
but i dont think u need decimal level of accuracy lol
thats even stronger than float
or double
No, but for this particular module it asks for the end result of the script to be: 34.444444444444444444444444447
and instead of counting the repeating decimal, I just played it safe so it was satisfactory

never understand when someone uses non-monospaced font in code snippets 🙂
the only font i will use is arial lol
if it involves chinese i will use notosans, cuz arial cant process that well
why?
do you use non-monospaced font in your code editor / IDE too?
jetbrains mono
i just use it as it is bruh
hm, getcomponent<> is fine because it's retrieving a component on the object right
but gameobject.find() is searching through all (sibling?) objects for one with that exact name right? isn't that resource intensive
Yes, find searches through all loaded gameObjects. You should avoid it if you can.
Can I define a constructor for an enum or will I need a little base class to wrap around it
normally by using singleton manager, reference when instantiate , inspector on editor mode can help u avoid 90% of situations of using .Find
hooyea i'm just surprised the tutorials are saying to use .find() so frequently and without disclaimer
glad my intuition is good
using .Find is just easy and lazy
tutorial expects u to follow every steps, so if u named ur objects the same way .Find will work and tutorial itself will work
so no object.direction_to(object) function or anything like that huh
hehe i'm gonna be launching projectiles backwards so often
transform.LookAt() ?
lookat
so coroutines are declared like a function, but with IEnumerator instead of private/public void
i assume yield tells it to wait for the WaitForSeconds to finish, but what is the return doing?
IEnumerator is the return type for the method and return just returns a new instance of WaitForSeconds
what does returning a new instance of waitforseconds do here?
i assume the purpose of this coroutine is just to delay the toggle of hasPowerup by 7 seconds, is returning a waitforseconds necessary to achieve this?
An enum is just a simple numeric value(usually int). So there's nothing to construct.
or could you just like call start on
void powerupCountdownRoutine(){
new WaitForSeconds(7):
X = false;}```
if u dont declare accessor(public/private) on functions
by default it will be private, so its okay to not declare that with only datatype
void Awake is private void Awake
how would you guys insert a simple like 7second delay into something?
The logic that requires the delay must be implemented with it in mind, i.e. it either needs to be a coroutine or async method. Or you could break the logic into 2 parts, execute 1 part normally, and delegate calling the second part with a delay to some system that can do that, like a coroutine, async, invoke
You can also use timers in update to implement the logic
so i guess how i'd want to do it, declare a new timer, and have that timer call a function once it's done
Great. All you need is just to implement such a timer(system).
hehe seems like i cant do what i did in godot, i had a dozen tiny await's that let me fine tune the timings of attacks for the best gamefeel
intrinsic functions like invoke/coroutine is easier to setup, u can also do custom timer function
which was bad practice admittedly
and yeah, unity uses C#
You can do that fine in a coroutine.
Or in an async method
okay so the yield return is just standard practice for coroutines i suppose
yes
still dont entirely wrap my brain around it but it doesnt matter to me immediately, and hopefully once it becomes relevant i'll figure it out
torque is rotational force
it wouldn't
ah they updated it two lessons later
is OnMouseDown() a special unity function that detects when mousedown is pressed while hovering over the gameobject?
you know google exists, right?
hom fair point, i think i started figuring it out mid ask
i was thinking of onInputDown and thinking that this would just trigger on every mouse press
but it's a function
hm, i went to the unity docs and saw that it's a special event that's added to any gameobject with a collider
but when i went to the collider page on the docs, i didnt see it mention OnMouseDown()
because it is not a method on the Collider class, it is a method on MonoBehaviour
ah okay time to go search for useful events and methods yay
What is the typical method for doing auto-stepping with 2d kinematic rigidbodies?
I've been trying an algorithm that fires a raycast ahead of the player and if it detects an obstacle, it'll fire a raycast above, if it detects an obstacle again, the cycle repeat. If it doesn't find an obstacle then it places the player there.
The issue is that this always feels very staggered and janky, and also suffers from the problem of the player getting stuck on miniscule heights as the initial detection raycast has to be judt above the ground or else it'll keep detecting the ground, so I was wondering if there was a standard way of implementing this.
Hello, I'm a beginner on unity and I wanted to know if velocity and linearVelocity are the same thing? For example, when I write rb.velocity, the software modifies it directly to rb.linearVelocity (whereas on the tutorials I'm looking at it's rb.velocity).
linearVelocity is the new name yea
ok ty
hey there, a cousin of mine wants to start learning game making in unity and I am not really the best teacher, so will any of you guys gimme good recommendations for him?
Thanks Again!
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I mean like for a child who has the attention the span of a reel☠️
I personally believe that he wont have the dedication and will to do so:)
consider suggesting something simpler then
ik you do
Not sure if this is the right channel but how do you get the transform of the camera
Wait i can just use tmp nvm
(°-°)👍
Use layermask on your raycast
maybe not what youre looking for but the Character controller component has auto step

If you want to implement yourself I would recommend just raycast forward to find obstacle
Than raycast down to find height
Don’t really need to recur
If by staggered and janky you mean the teleporting is bad then just use ramps
So many games use it for a reason
The world geometry functions as both walls and floors so I don't see that working, assuming that's what you meant
How does this work? What if the obstacle is lower than the raycast?
Then your raycast is too high
Unless you mean cast forward, and then downwards and then check for the obstacle?
If its too low then it'd touch the ground and give false flags, if its any higher then tiny lip steps will go undetected
Kinematic
Honestly I think this will work
You raycast a tiny bit above foot level
If it hits something
Anything
Doesn’t matter if it’s the floor
Your char is MEANT to autostep
raycast in the direction youre moving,
set its height via a variable
set its length to the step length
if the raycast detects nothing then youre good, otherwise move up
What do you mean false flag
I meant if the raycast is aligned exactly with the ground then it'd just detect the ground, but if it's any higher then it won't pick up the tiniest of bumps
Is it really important to your game that your character move up 0.01 units when he walks on a grain of sand?
The issue is that they won't move up at all and will get stuck
hii on line 55, i have an error where it says i need a } but i have one already, i have another issue where my Destroy(gameObject) does not work as it says theres no reference and was wondering how i could fix this
Is there a reason you aren’t using physics
I wasn't a fan of the skin width lol
if isnt closed
It was unsightly since its on a small scale
You miss a curly bracket on line 42
I know you can change it but it stopped working properly
Configure your !ide so you can see basic issues like these
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
I think casting a ray forward from the max step height and then casting down to detect an obstacle will work, right
Sounds like it would
Would but you don’t want to raycast if you don’t have to
Is it really that expensive
I made this mistake before
Trust me it isn’t worth it
If it bothers you you can increase the visual size of your char by the skin width
Not sure what you mean but I'm having (decent) success with kinematic as of now except this smoothstep lol
The biggest issue tight now is that the players velocity keeps getting zeroed when autostepping since they technically collide with a wall and slow down as a result so the movement on steps is very staggered
It’s not that expensive
Just make sure to use nonalloc
Walls and floors are tricky
Colliding with the side of a floor or the top of a wall is your worst nightmare
If you will have any sharp edged verticality
tysmm
tyy
a configured IDE will never have that messy issue on update()
and do configure it
by the look of it , seems like rider
leftClick is not changing for some reason
https://paste.mod.gg/ebdstizexviy/0
A tool for sharing your source code with the world!
ignore the fact that leftClick is y
how come you're not using https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Input.GetMouseButtonDown.html ?
great question, lemme go do that thx for the help
Does anyone know why this line always returns 0 on Android build?
It works as expected in simulator and Unity remote
Is it ok to not use player controller script and use transform.translate(yk the horizontal and vertical after )
If you don't need collisions then it's fine
Depends. I wouldn't use transform.translate with physics
Thanks
Thanks too 🙏
I would probably learn the player controller cuz yk unity learn make only transform.translate for some reason
In the pathway
Physics based movement probably comes later
I don't think so cuz there gameideas doesn't require much physics
Hence why they don't cover it.
I can be wrong but till now and after searching in the future units they don't cover it
To be more precise - I believe they intentionally picked projects that don't require physics so that they don't have to introduce physics based movement too early
But there is a good tut that learnt me AI and stuff (roll the ball )
Ik but I searched every single unit and didn't find any physics movement
Like tbh roll the ball tut made me learn alot on how to build and how to use nav map and how to make a count system and using TxPro smth like that
Okay so can you share me some ideas if you don't mind
#📖┃code-of-conduct read the rules
I want to have a tile smoothly rotate 90° around the z-axis over a set duration (0.5 seconds) when clicked. How do I do that? (I know it has to be a Coroutine, but I can't wrap my head around Quaternions and Euler angles.)
One option is to use a tween library
Otherwise you would use Slerp or RotateTowards in a loop in a coroutine
or just set a target rotation and rotate towards it in update
for example:
float rotateSpeed;
Quaternion targetRotation;
// You need to call this somehow when it's clicked
public void WhenClicked() {
float amountToRotate = 90;
float duration = 0.5f;
targetRotation = transform.rotation * Quaternion.Euler(0, 0, amountToRotate);
float rotateSpeed = amountToRotate / duration;
}
void Update() {
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotateSpeed * Time.deltaTime);
}```
There are ultimately many ways to do it
the exact right thing to use depends on your project and your existing code
looks good to me bar the rotation being applied always in update even if done
It's also not clear exactly what a "tile" is in this context
A square-shaped 2D sprite.
if it's a GameObject, this is fine.
If it's a tile in a TileMap, things are a little different
A GameObject.
If there are a huge number of these things, it indeed might be better to go with a coroutine rather than using Update.
or a tweener
There's a 2-digit amount, but only one can be clicked and rotate at the same time.
It's for a puzzle game of correctly aligning pipe pieces.
Has anyone worked with the quest 2 that can help me?
a coroutine version would look something like:
void DoRotation() {
StartCoroutine(RotateOverTime(90, 0.5f));
}
IEnumerator RotateOverTime(float amountToRotate, float duration) {
Quaternion targetRot = transform.rotation * Quaternion.Euler(0, 0, amountToRotate);
Quaternion startRot = transform.rotation;
float timer = 0;
while (timer < duration) {
timer += Time.deltaTime;
float t = timer / duration;
transform.rotation = Quaternion.Slerp(startRot, targetRot, t);
yield return null;
}
}```
I see, thanks.
guys i need help with the movement code
im following unity learn programming
and when i paste the script for movement it actually moves
but not in straight line mine is jumping lol
You would have to show your code and maybe a video - and explain how things are set up
here is the code
https://learn.unity.com/pathway/unity-essentials/unit/programming-essentials/tutorial/add-a-movement-script?version=6 and the video is here
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
oh lemme screen record then wait a sec
here it is
and this is the video
like before unity learn i tried multiple tuto for movement but i couldnt manage to make them walk
How come you added an extra collider to the player?
Did the tutorial ask you to do that?
I would guess it has a collider already
As you can see - the collider you added is clipping through the ground
so that explains why your object jumps into the air at the start of the game
Yeah you can see the green framework looking stuff around the actual cylinder - that's probably the existing MeshCollider that the object already had
well i redo the tutorial and it worked idk what i did different but worked thanks
you presumably didn't add a random box collider this time
could someone give me an example of how the InstantiateParameters parameters work
i dont really understand what that means
yes and i still dont understand what the last parameter is supposed to represent
you can just click on it
The docs describe it
is it just any parameter?
no, it's that specific type
The exact description of the type is right here #💻┃code-beginner message
ive read it 3 times now but i still dont quite get it
The docs are pretty straightforward. You can see it's a struct defined in the UnityEngine namespace, and it has 3 properties:
parentsceneworldSpace
you can even click on each property to see what it does
no i know what the properties are
it's a combination of those 3 values, into a single parameter
i just dont know how one would use it
So I'm having trouble understanding where your confusion comes from
Look at your screenshot here
you would use it as a parameter to Instantiate just like it shows
It's a type used to hold some data, making it easier to re-use the same values without having to keep typing the same 3 things
Maybe you're confused about how structs, classes, and parameters work in general?
Instantiate(obj, new InstantiateParameters() { parent = parentTransform });
oh i see
it's no different from the Vector3 position parameter, for example
hold on lemme see if my understanding is correct
just a struct holding some data
does anyone here know tf is going on? im returning to the original MR template but it doesnt work anymore???? i need it because apparently you cant use building blocks to: have a cube with physics and have it use the room scan - also the room scan block sometimes displays sideways room scans so i need this template
where would said prefab be so i can get it from the template and fix it.
this is a code channel, and that is not a code question. Please delete from here and try asking in #🤯┃augmented-reality
it was not
You don't need it, you can instantiate without it (I didn't know this type existed until now). You could just ignore it and carry on - return to trying to understand it when you've got more experience
You would use it to set:
- The desired parent
- The desired scene
- Choose between local and world space
to the values you want them to be
im trying to use it to set the desired parent
So you would create an InstantiateParameters instance with the parent set to what you want, and use that for Instantiate
Well there's an easier overload to use for that
well i tried using this Instantiate(_pointerParent, gameObject.transform.position, gameObject.transform.rotation, gameObject.transform);
but _pointerParent and its child kept taking on the size of the gameObject
pay attention to which thing you're putting in which place
gameObject.transform is the same as just transform.. and they're both THIS gameobject/transform (where this component is attached)
this way would clone _pointerParent and make the new clone a child of the object this script is attached to, i.e. transform
which object are you trying to clone and which object do you want the clone to be a child of?
this is what im trying to do
but avoiding that
if you don't want things to be scaled that way, you need to fix your hierarchy so your parent object(s) are not scaled.
oh my god i thought the gameObject was at (1,1,1) scale the entire time
thanks for the help
in cases where I have number of variables like this, my general process is to take a screenshot so I can remember what they're called when I'm working on a function ~100 lines down in a long file. Winkey/shift/s is just the fastest way I know to put the information on screen and keep it there.
is there a way to pin them or something in VS?
Googling mostly gives results about how to keep an eye on their values for debugging, that's not what I need
you could open a separate window/tab with the same file
I would recommend giving them some sort of shared prefix that explains what they're for, then you can just do .whatever and see all of the options
Like, if these were named ConvoQueueIncoming, ConvoQueueOutgoing, and ConvoArchive, you could just do .Conv and see them all in suggestions
Thanks for the tip!
why is spacesArray null?
Where do you assign it a value?
hm, well i was thinking i should declare the array, then have a function assign values to it
but i cant assign values to it because it is null
You can't assign values to null
You can assign values to an array, but you haven't created one
so i declared the array incorrectly?
You've declared it fine. But you haven't put anything in the variable
you would create an array with the size you want it to be
you have a perfectly declared variable that can hold an array of transforms.
you just haven't actually put an array of transforms into it
if you don't know what size you want it to be (which seems to be so since you're doing i++ in Start) you should use a list instead (and you still have to initialize that
also why are they static
that's not how they should be, and not how singletons work
yeah i realized static variables are more what i want here than a singleton, i just didnt rename the script
i figured i'd make it globally accessible so i dont have to get a reference to it since this is just a small practice project
ah i see, when i declare a variable, that remains as null, i have to immediately or later create a new value to assign to it
Yes, declaring and assigning are two different things.
Until you assign a value to a variable, it will remain default, which is null for anything that can be null
is there an equivalent to .Length but for lists?
i tried to find list on the unity docs but i couldnt seem to find it
Count
List isn't a Unity thing, it's a C# thing
ahh so if i cant find it on the unity docs, check the C# docs, thaat explains a bit
how do i use a script to retrieve a child gameobject?
it looks like i can only retrieve components on child gameobjects
transform.Find, GetChild
though do you need to? consider using serialized references instead
i was just thinking that
well transform is a component of the gameobject right?
do i have to find the transform then use that to retrieve the gameobject that owns that transform?
ah okay so like this
you could theoretically find "child with component X" by doing GetComponentInChildren<X>().gameObject
(but really you should probably just use serialized references)
getting children by component rather than by name does sound better
doing it statically in the inspector would generally be even better
mhm but i know how to do that, gotta try new things to learn
thank you~!
what is this warning me about?
what does DiceButton do ?
is this on rider? dont think ive seen this on VS. but it seems clear that its telling you DiceButton is doing something expensive and you're doing it in update
mhm it's rider
I usually get this when methods use Debug.Log. It’s not smart enough to know when it's rarely used.
okay so it's just a random warning and it's up to me whether it's founded
i put in the _buttonCooldown for a reason so i'm good
its not a warning, its just rider information
this ide sure is nervous
they had to add extra bells to make it worth the $
thats something id probably turn off lol
so many bells and whistles of questionable usefulness
hm, are tweens difficult to do in unity? i tried looking up a tutorial on how to make a tween, and didnt really see one, and like 3 websites providing services (plugins?) to simplify tweening did pop up
oh and all the video guides are using one of those services heh (DoTween)
Making your own tween(s) is a bit of work, but you can use free plugins. If you need smth simple, use Lerp with the update loop or with coroutines . . .
DOTween is probably the easiest and most robust library for tweening various values. For a long time, Unity had no tweening library, and what they have now, Timelines, is significantly more complex and less useful than DOTween
ohh lerps are probably what i'm thinking of when i think tween
yupyup
i guess the difference is tweens can have an arc
question: is there a way to get the unity 2022 ui in unity 6? i had to use unity 6 for the MR template but now the ui changed :(
the editor UI ? no.
:( i guess i have to use this ui just because i want MR multiplayer :/
the editor UI would be the last thing I'd worry about..
idk if this is the correct channel but how could i test multiplayer if i have 2 devices?
i got 2 people too
Have you made your game multiplayer?
yeah i used the MR multiplayer template (im assuming this isnt ar talk)
because uh this is really multiplayer in general
Have a read through this?
https://docs.unity3d.com/Packages/com.unity.template.mr-multiplayer@1.0/manual/test-multiplayer.html
yeah uhh i can build it
ok -
can i use unity 2022 android build tools with unity 6
cz i dont have 5 gb to blow on stuff i already have
If you only need a smooth ease in and out, that's also possible with lerp. The t just needs to be a Mathf.SmoothStep
how do i cancel a selection in a selection event function <Input Field>?
Attempting to select while already selecting an object.
i got the same device so i shouldnt need a new compiler of the same thing how do i set the paths - ive also tried asking AI for help but it doesnt help either because last i checked it aint working
yeah don't use genai for help lol
if you aren't using unity 2022 you could uninstall that
you should be able to share it between i expect, ive done it all though android studio custom before and that was mostly stable
yeah but
i need to use unity 2022 android compiler
welp it might be time to get my 20th usb in a year soon
or buy 1 decently sized drive?
So uninstall the Oblivion Remake, give yourself back 125 gigs
well idk how to use waittillendofframe to bypass the error, it still doesn't work. I need to deselect when someone selects the item, but if used in the same frame, i get an error
adding the eventdata parameter makes the function not even show up in the inspector
like this doesn't even show up anymore in the inspector when trying to add it
{
if (!mainChatFadeScript.currentlyVisible)
{
Debug.Log("Selected Item");
eventData.selectedObject = null;
//eventSystem.SetSelectedGameObject(null);
}
}```
Is anyone interested in a virtual chemistry set?
it has to be void apparetly with no parameters
you trying to peddle something?
Not sure I understand? Are you real or some sort of bot?
if you want to wait 1 frame, that would be yield return null;, not WaitUntilEndOfFrame
are you trying to sell something
that isn't allowed here
this channel is for help with code
ArgumentException: method return type is incompatible
is this not a coroutine
No. Why all the agression? I have produced a 3d version of the periodic table. Am happy to share, if anyone wants to play.
what aggression lol
this server isn't for advertisement, this channel isn't for sharing finished projects, that would be #1180170818983051344
please do read channel topics before posting
i see you're new to discord, so; most servers have rules that you have to read and agree to before interacting in the server. did you actually read the rules? #📖┃code-of-conduct
WaitForEndOfFrame or yield return null would have to be in a coroutine. Im not sure exactly what you're doing here, didnt see full context, but you could start a coroutine from this method
I have an event that triggers when the player selects an input control, and when a certain condition is met, i want them to not be able to select the control (meaning immediately deselecting) however I can't seem to get it to work no matter what I do.
what did i do wrong with my lerps?
You're not using the return value, which is probably what it's telling you if you hover
Look. I am new to this. I am not selling anything. I have spent a long time trying to use the Unity game engine to create a virtual universe. If you are not interested, let it go. If you are, tell me what you need and I'll pass it on.
i see no variables being defined so it's doing work for the void
This is a programming channel, if you want to share your work use #1180170818983051344
Your t is an unchanging value of 14. It's supposed to be a float that changes from 0 to 1 over time, where 0 is at A and 1 is at B
Daisy is definitely a Bot!
What?
beep boop
What are you waffling about
14 is also a silly value to use in Lerp, as Mathf.Lerp is clamped.
oh weird
so the value of t should be decreased from 1 to 0 over 14 seconds, and each call returns the value at the current t value, okay
Contrivance is some sort of AI. Are there any real people out there?
Are you ok?
If you don't have anything on topic to say in this channel please just stop.
So if you want your lerp to function over 14 seconds, you'll either need to set it up in update to keep track of a float value and increment it every frame with the time spent that frame, or do it in a coroutine or async method
Ok. Had enough. If you're not interested, I'll try some other group. BYE!
Because we're ignoring you? This a channel for getting help with coding in Unity.
If I post my progress like get a feature done here and there, is that proper use of devlog or do i need to wait until it's fully complete?
All progress reports go to #1180170818983051344 currently. In-progress, released, everything.
You have literally been told multiple times which channel to post your project in
This is a help channel
Yep i think that's one of the purposes for devlog
unless you have a question, you should not be posting in this channel
I havent done this specifically so im unsure what error you're talking about with deselecting immediately. Though making a coroutine should be fine here, and starting it from the method you've shown.
You're logging your progress yknow
ahh
but what if i use a lerp to decrease 1 to 0 over 14 seconds 
Lerps can work in either direction too
mhm they seem pretty flexible
All it takes is a starting place and a stopping place, the order doesn't matter
All the lerp does is figure out where something should be between A and B, if it is at T. So if T = 0.5, it will be halfway between A and B. 0.1 = 10% of the way from A to B. And so on
does unity essentials tutorial enough for making simulator game with presets...
no, unity essentials are essentials
you'd need to learn a lot more to make a full game
No tutorial is going to be tutorial enough to make a game without additional research and unstructured learning
they get you started, not finished
i love unstructured learning
well what do i need to learn for making smtn like supermarket tutorial
i mean ofc i will add some stuff with searching im jst saying can i do it ?
break it down to simple pieces and learn each piece
then link them all together
it variest from person to person, i myself learn best from just leaping right in and researching how to do things as the need arises
but you might be different
As in "Is it possible to make this specific kind of game in Unity?" Yes. The answer is yes no matter what kind of game you're thinking of
regardless you'll want to start by learning the fundamentals, in my case i did iit by following a tutorial series on how to make a 2d topdown rpg
then i just built off of that
well i just mean basic supermarket game just selling and stocking items just for now
"basic" supermarket game
We really can't tell you what you need to learm
start with basics of c#
and also i dont plan doing 2d stuff rn should i watch them
There's so much out there to learn that it will quite literally take them hours to list off all possible things you'd need to learn
make a console app that manages some product items. Simple buy / sale logic
Also yes learning 2D is very useful
okay thanks guys
I understand what you're trying to ask, and people her do want to help. but the question is a bit wrong, because what you need to learn to make a "basic supermarket", is the same as what you need for a "basic shooter game" or a "basic rpg", "basic pong", etc, etc. it's a broad field. what you really need to ask is "how do I get started making games?"
the skills will transfer 🙂
so im just following all unity tutorials
hmm, i want to modify the width of a UI gameobject with a rectransform component
how should declare it in serialize field so i can access the recttransform property and edit it?
oh wait should i declare it as a gameobject and like getcomponent recttransform on it
There is basically no reason to ever make a field of type GameObject
use the component you actually want
.gameObject from a component is basically free.
.GetComponent() from a GameObject is slow as balls
Only reason to declare a field of GameObject is if you only ever want to set it active or inactive
Or if its a prefab you're instantiating and don't need anything else
( might be more reasons, but not many )
hm okay so my thought process is right
why is it a 'temporary value' then?
It's a struct, so if you want to modify it in this case you'll need to declare a new one with the values you want and then assign it to circleShrink's rect
oh weiird i guess that works though
In this case, the struct it's giving you is a copy of the real one. So its warning you that modifying the copy will do nothing.
so i have to make a new recttransform, copy over the properties of circleshrink, then change the width property, then assign that as the new value for circleshrink
circleShribk.rect returns a copy of the rect. Modifying the width of the copy doesn't actually affect circleShrink
You'd need to store the rect, modify it, then set circleShrink.rect to the new one
Not a RectTransform. A Rect
not sure if you're being facetious. but my point is that: moving a character is moving a character, looking with the mouse is looking with the mouse, selling an item is selling an item. regardless of the game / genre. so there is no answer to the question "how do I make a supermarket simulator". what you need to do is break the game down in to small tangible mechanics (like looking with a mouse, clicking a button) than start to learn those things in small incremental steps as you slowly start building your project.
wait a minute
if circleShrink is only a copy of the actual rectTransform variable of the gameobject
how do i set the actual gameobject's rect?
circleShrink is not the copy, the rect of circleShrink is a copy
Make a new rect with the values you need, and set circleShrink's rect to it
how do i set circleShrink's rect?
circleShrink.rect = new Rect( .. values you want go here.. );
if you're only changing its width, you can copy the values from the existing rect for the other aspects
rect transforms are annoying
oo wait circleShrink.rect.set() seems interesting
No
fair enough
Use .sizeDelta
ah, yes, it was sizeDelta. I forgot that rect is just a read only
.rect is a property and Rect is a struct. Structs are copied by value, so any time you retrieve from the property a copy is made
so .Set would modify that copy and throw it away
and yes, rect transform is annoying. I always need a refresher every time I dive back into them
So it has a Set() method, but no property setter?
Rect defines Set
okay so basically do what i did but instead of rect use sizedelta
RectTransform defines rect and it only has a get
Pretty much. It has a lot of caveats though depending on how the rect transform is set up
It depends how the recttransform is anchored
Ah, looked up Set(), yeah that would do nothing useful in this case, since again it's just modifying the copy from the property
Note there's a Vector2.Lerp that could simplify this to practically one line
i don't think that would make it very readable
circleShrinkTime should decrease from 1 to 0 over 14 seconds right?
truue
i think most direct (to logic) would be something like
float r = Mathf.Lerp(...);
circleShrink.sizeDelta = new Vector2(r, r) + circleShrink.sizeDelta;
how do you if a float like that?
oh nvm im blind
approximately, yeah?
hmmm, then why is it doing it over half a second
i feel like adding such small deltas could encounter floating-point issues, but probably not...
and i increased it to /140 and it was about 1 second
what does circleShrinkTime start as?
Found this picture online, figured it would be useful for beginners
eh well that worked
it's not entirely true though (fixed update is an extra loop to the update cycle)
Start circleShrinkTime at 14, subtract Time.deltaTime every frame, and use circleShrinkTime / 14 as your Lerp t parameter
it gets called at a predetermined point during the update cycle correct?
no, fixed update is independent of the update loop
Oh, well thats a much better summary LOL
does color.a have a range of 0-255 or a range of 0-1?
0-1
it can get called multiple times
depending on your Time settings and cpu right?
and the diagram you showed doesn't indicate any sort of loop, so that kinda misses out
okay well im never using that website for unity help again
oh no, is this another sizedelta vs rect situation
how do i set color
I dont even remember where I got it from
its the general idea..
but leaves out lots of detail about the FixedUpdate and stuf
I c'
depends on the tickrate, which is configured, and framerate, which depends on target framerate, vsync, cpu, gpu, etc
this is an extension method that I use
extract the color into a variable
change the a value
assign it back onto the property
moddedColor.a = desiredValue;
img.color = moddedColor;```
col is for collider! (╯°□°)╯︵ ┻━┻
lol
col is for column 
lol also acceptable!
-# col is for colander
col is for collisseum! Get that Dizana's Quiver!
kk
hi
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Ink.Runtime;
public class DialogueManager : MonoBehaviour
{
[Header("Dialogue UI")]
[SerializeField] private GameObject dialoguePanel;
[SerializeField] private TextMeshProUGUI dialogueText;
private Story currentStory;
public bool dialogueIsPlaying { get; private set; }
private static DialogueManager instance;
void Awake()
{
if (instance != null)
{
Debug.Log("no");
}
instance = this;
}
public static DialogueManager GetInstance()
{
return instance;
}
private void Start()
{
dialogueIsPlaying = false;
dialoguePanel.SetActive(false);
}
void Update()
{
if (!dialogueIsPlaying)
{
return;
}
if (Input.GetKeyDown(KeyCode.E))
{
ContinueStory();
}
}
public void EnterDialogueMode(TextAsset inkJSON)
{
currentStory = new Story(inkJSON.text);
dialogueIsPlaying = true;
dialoguePanel.SetActive(true);
ContinueStory();
}
private void ExitDialogueMode()
{
Debug.Log("imate pravo");
dialoguePanel.SetActive(false);
dialogueIsPlaying = false;
dialogueText.text = "";
}
private void ContinueStory()
{
if (currentStory.canContinue)
{
dialogueText.text = currentStory.Continue();
}
else if (currentStory.canContinue)
{
ExitDialogueMode();
Debug.Log("imate pravo jos jednom");
}
}
}
sorry idk how to send script files
but anyway
!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/, https://scriptbin.xyz/
📃 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.
im using ink and does anyone know why it only says one line
and wont end the dialogue and continue to next line
i think i made the code pretty obvious
hm, why is playerObject.Transform destroyed?
on game startup it works fine, but when i transition to another scene and then back, it says it has been destroyed
maybe you create it on start?
nope the playerobject is just part of the scene, and is never deleted
tbf you shouldnt be using Find in the first place
Whenever you change scenes, everything in the old scene is destroyed
i know, but i'm just doing it for debug reasons in this case
Considering the usage of Singleton in this snippet, you probably have something DontDestroyOnLoad, so it's referencing an object in a scene that no longer exists
ah you're right maybe it's talking about that space's transform
can i make that variable accessible by other functions without making it static?
(so it gets re-initialized on scene load)
You could just get a reference to the object normally instead of it being a singleton
heh it's not even a singleton i just called it that, yeah that should work
inputText = GameObject.Find("Chat Input (TMP)").GetComponent<TextMeshPro>(); is returning null, I have deugged and checked that GameObject.Find("Chat Input (TMP)") is correct and not null. What is going on here?
thats not TextMeshPro..
also you should not be searching for components like this (GameObject.Find)
TMP_InputText
most textmesh pro you should use is TMP_ prefixed
text is just TMP_Text that works for UI and mesh version
thanks, i didn't know that
so i'm supposed to have it as a public variable at the top and assign it in the inspector?
ideally
aight
is there a way to hide a public variable from the inspector?
[HideInInspector]
easily googleable
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/HideInInspector.html
it is STILL SERIALIZED EVEN WHEN HIDDEN
[NonSerialized] will hide AND not serialize it
i shout cus its easy to forget and get fucked by it later 😆
its rare you should use public though. Use properties for public gets and private vars
inspector for private is[SerializeField] private to avoid using public as default for inspector
So I'm following Unity's own tutorials right now, and I am in Unit 3. The lesson is making a jumping minigame using the AddForce method, and my code and the settings in the inspector are EXACTLY the same from what I see, but when I play the game the character flies way off into the sky, meanwhile the video's character does a normal jump.
First image is my code, second is the video's.
In Section 5 of this lesson
https://learn.unity.com/tutorial/lesson-3-1-jump-force-2
code 👇 #💻┃code-beginner message
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
public class PlayerController : MonoBehaviour
{
private Rigidbody playerRb;
public float jumpForce = 10f;
public float gravityModifier;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
playerRb = GetComponent<Rigidbody>();
Physics.gravity *= gravityModifier;
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.Space))
{
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}
}
whats gravity modifier set in inspector
ahh..
look at the input getting method 😉

its basically jumping every frame you press/hold it, as opposed to GetKeyDown which only runs in 1 frame
Thank you
{
if (currentlyVisible)
{
fading = true;
deltaTime = Time.time;
if (fadeChildrenWithScript)
{
foreach (SimpleFadeScript fader in GetComponentsInChildren<SimpleFadeScript>())
{
Debug.Log("why are you stack overflowing?" + gameObject.name);
fader.closeWindow();
}
}
}
}```
`fader.closeWindow();` is causig a stack overflow, and it seems that GetComponentsInChildren gets the root object as well, how do i avoid that?
if you use a for loop you can skip the first element
recursive calls are pretty dangerous if there isn't a way to exit gracefully
can anybody recommend an example 3d project i can download so i can look through it and see how things like meshes, materials, and scripts are incorporated?
in what way ? every project is very different..
each person / team does their own system, its all very specific
just any publicly available one, i'm aware that there's alot of self expression in script but seeing how they did things provides a helpful perspective regardless
idk the usual places like github, unity asset store, blog sites etc
unity also has https://github.com/unity-technologies
mmkay i'll have a looksee
there are no version 6 is it a problem ? can i do it
aside a few minor api changes, and editor UI nothing has changed
at least i know now next time i want to loop children for a class that the root also contains.
In fairness the GetComponentsInChildren() function name is a little misleading with how it includes the parent
yes yes
in an ideal situation you could store them in an array on the parent then just access the parent's array through a public property
hmm i could do that yes and then i might not need to put those fade scripts everywhere
Hmmm... i'd need to store more data for each one, the targetAlpha numbers will be different for each item
already doing that tbh, just had to make new fade scripts for each one
thats fine for the component to be there, its just easier to have a "mediator" you access to do further things instead of accessing children directly
so like two scripts? one for main logic and one for crutial settings per object?
so like you would call closeWindow() on a the parent, then that script handles the SimpleFadeScript() on its own from there, like closing or whatver else
unless the closeWindow is already on the parent then nvm , just use Serialized array instead of GetComponentInChildren
[SerializeField] private SimpleFadeScript[] simpleFades
yeah i'm working on that atm
i might still need the fader scripts on all the objects since i am calling .closeWindow() on all of them
yeah thats fine
just get into the habit of trying to avoid acknowleding any parent/child relationships when it comes to code
its worth remembering that c# was designed for itself and Unity is just something that uses it, so a lot of the ideal logic and workflow is designed for class to class conversations without all the gameobject shenanigans
Having 1 class control/manage a given group of """worker""" classes is really common too, not just in this example
very similar to how a business or store might have a manager in a department with many employees
how do i change this to the one with the add button?
Array is fixed size, List is dynamic
what type is AdditionalFaders ?
wha no an array can be any size when editied in the inspector
somehow the drawer is broken?
List<GameObject>
my b
do you have some custom inspector gui for this mono?
i dont understand for some reason either my code got cursed or i made a grave mistake somewhere please help
public void SettingOpen(string Name, string Description, string ExtensionName)
{
SettingNameText.text = Name;
SettingDescription.text = Description;
UpscalingFilter.gameObject.SetActive(false);
MinMaxFPSAndPing.gameObject.SetActive(false);
AutoColorFpsAndPing.gameObject.SetActive(false);
BackroomsAutomaticRenderDistance.gameObject.SetActive(false);
switch (ExtensionName)
{
case "UpscalingFilter":
UpscalingFilter.gameObject.SetActive(true);
break;
case "MinMaxFPSAndPing&AutoColorFpsAndPing":
MinMaxFPSAndPing.gameObject.SetActive(true);
AutoColorFpsAndPing.gameObject.SetActive(true);
break;
case "BackroomsAutomaticRenderDistance":
BackroomsAutomaticRenderDistance.gameObject.SetActive(true);
break;
}
}
BackroomsAutomaticRenderDistance does neither become On or Off, why? like when this void gets called and lets say its case UpscalingFilter then UpscalingFilter gets on, and when its something else, the upscaling filter with everything else goes off too?
!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/, https://scriptbin.xyz/
📃 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.
i mean yeah the code is kinda big but i can simplify it to remove the things that arent important so its easier to understand
also it gets called by other script, but the fact that it gets called, everything is working, but that object just doesnt set off or on is weird
Its easier to read
because it is assigned in editor
okay give me one sec
A tool for sharing your source code with the world!
Add logs right after the lines where your you activate/deactivate it and see if they print.
if ExtensionName doesn't match a case it will just disable everything. Best to add a default: case to inform you when this happens.
yeah thats the point, it doesnt disable at all
the last object
but the other objects get disabled
AutoColorFpsAndPing gets disabled for example
BackroomsAutomaticRenderDistance doesnt
Also log the name of the object with the object passed as a second parameter:
DebugLog("BARD deactivated", BackroomsAutomaticBlabla);
Then click the log message to see what it select.
why, thats so weird
How do you know that?
A breakpoint?
because i deleted that line and it now sets off
thats really weird honestly
Use logs or breakpoints as I suggested to see where this is called from.
okay i am not joking i just put this at the end (the e case) just to check things and now its gone, and there is no debug log at all
What's gone?
this is really weird honestly
the BackroomsAutomaticRenderDistance now sets on when needed
only on that case
and e never goes off. never prints
how do i get a list to show up with this in the inspector?
Could be some issue with code compilation. Maybe it was using a way older version of the code.
Does the issue reappear if you erase the e case?
should i just switch to if statements? because this is just random to me honestly
don't think if statements would help here
Add elements to it in the inspector.
No. There's nothing wrong with a switch. It's like doubting that 2x2=4
what the hell...
when i deleted the "e" case it just went away
so im on the same code when i encountered the problem, but no more problem
thats so weird..
Yeah, so it was likely an issue with code compilation and ide interaction. Happens sometimes.
Make sure your !ide is configured correctly. That would make it less likely to happen.
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
i think imma backtrack and use te get element children
idk, it's already difficult to assign multiple things
editor button to auto fill list is the way (e.g. using [ContextMenu] or naughty attributes button)
You probably need to assign the additionalFaders variable of the SimpleFadeScript script in the inspector.
UnityEngine.GameObject.GetComponent[T] () (at <028e4d71153d4ed5ac6bee0dfc08aa3b>:0)
SimpleFadeScript.closeWindow () (at Assets/SimpleFadeScript.cs:78)
SimpleFadeScript.closeWindow () (at Assets/SimpleFadeScript.cs:78)
UIChatBoxHandler.Start () (at Assets/Scripts/User Interface/UIChatBoxHandler.cs:42)```
But it IS in the inspector, and it IS assigned as a new entity, why is this doing this?
it only seems to happen on one of the scripts
Check every script of that type in the scene by searching it
Don't double click it. Click it once. It should highlight the relevant objects in the scene.
yeah it looks like the main one
Is this SimpleFadeScript?
yes
additionalFaders is an array?
I didn't expect it to report the error you're seeing
what is this syntax? what are ? and : doing
ah i see so it returns the first one if the first rand is 0, else it returns the second one
it was a list and now it's an array and it is still giving me that error
Can you link to the script?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
it only complains when it's not empty
tried both List<GameObject> and GameObject[]
I suspect you're still just not looking at the actual script with the unassigned value, and you should search the scene. But the error honestly makes very little sense to see on a serialised array, nor coming from getComponent()[]
how do i even search the scene for components?
there's only one SimpleFadeScript in my assets
Also, that looks like an infinite loop to me, as GetComponentsInChildren<SimpleFadeScript>() will also return itself.
You never use otherfaders so it's not (it's pointless instead). But if you did!
oh, it didn't do anythign until i typed th ewhole name in
that's why i thought it didn't work
ok so that's done, but one of my things won't fade now
ok it works now
so i guess it is a bug, as it directed me to the main skript instead of where the issue actually was
using UnityEditor.Animations;
using UnityEngine;
public class PipeGenerate : MonoBehaviour
{ [SerializeField] private Transform trigger;
private float Distance;
private bool HasCloned = false;
private Vector2 childpos;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
Distance = Vector2.Distance(transform.position,trigger.position);
if(Distance < 2f && !HasCloned){
PipePosi();
Debug.Log("worked");
HasCloned = true;
}
if(Distance > 3){
HasCloned = false;
}
}
private void PipePosi(){
foreach(Transform child in trigger){
childpos = child.position = new Vector2(Random.Range(-2,2), Random.Range(-7,7));
}
Instantiate(trigger,childpos, Quaternion.identity);
}
}
``` is there any better way to randomize the position in the PipePosi function? no matter how much i change the values i cant seem to get it right it either goes inside of each other or too close to the other pipes
does it have to be an inputbox to be able to select the text?
the issue seems to be fixed but i have another issue, it clones once only ```using Unity.VisualScripting;
using UnityEditor.Animations;
using UnityEngine;
public class PipeGenerate : MonoBehaviour
{ [SerializeField] private Transform trigger;
private float Distance;
private bool HasCloned = false;
private Vector2 childpos;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
Distance = Vector2.Distance(transform.position,trigger.position);
if(Distance < 0.1f && !HasCloned){
PipePosi();
Debug.Log("worked");
HasCloned = true;
}
if(Distance > 1){
HasCloned = false;
Debug.Log("false");
}
}
private void PipePosi(){
childpos = new Vector2(Random.Range(-5,6),Random.Range(-4,4));
Instantiate(trigger,childpos, Quaternion.identity);
}
}
The expression within the if statement would need to be true for Pipe Position to be called.
I'm going to assume that has-clone was false as initialized (not modified from the editor inspector) but the distance was not less than 0.1f
is there a way to allow scrolling even if hovering over an input field?
UIChatBoxHandler.updateTime () (at Assets/Scripts/User Interface/UIChatBoxHandler.cs:111)```
but it still sets the value, idk if it's because it's an invokerepeating or not
if code after the line the error occurs on is running then you have more than one copy of that component in the scene where the error is occurring on a copy of the component you aren't looking at
show the relevant code
but it does seem to run twice
{
//...
InvokeRepeating("updateTime", 1f, 1f);
}
public void updateTime()
{
Debug.Log(localCharacter);
localCharacter.text = "Localhoster" + "\n" + System.DateTime.Now.ToString("HH:mm:ss");
}
literally only this
then the only possible explanation if it is being set correctly is that you do have another copy of the component in the scene. search t:UIChatBoxHandler in the hierarchy during play mode when you see this error
That's what you should always check. If you have an error for a variable that is not assigned but you check and it is, then there is a duplicate script somewhere . . .
aight thanks
code does not exist in a quantum state where it is simultaneously working but throwing an exception too
maybe in a quantum computer
Thankfully you can't run games on a quantum computer yet
when it says limit of one line that's what it means... i was thinking limit of one line break.
A quantum computer running synchronous code still cannot be both errored and not
just learned about content size fitter but it doesn't seem to taks bottom alignment
ok so i added a vertical layout group and content size fitter and now my script is buggy, when it scrolls to bottom it is always one item behind.
and i can't get the scrollbar to show up again
ok i got the scrollbar to show up again
Hey I'm trying to make a 2D rotating platfrom that rotates clockwise or counterclockwise based on bullets falling on it on the left or right side Rightnow I'm stuck figuring out where how to invert the rotation , Should I post the code and the stuff I tried or is that a different channel? Absolute begineer
Or should I post it in the physics Channel?
might be easier to use animations for that and trigger those animations when the bullets hit a collider
just one suggestion tho
I'm a completer begineer, Can you share a reference of what you mean? Is it like, there's an if statement that triggers an preset animation of the platform when it passes a certain threshold?
is there a reason why a camera's FOV would change at runtime ? It kept happening to my main camera so I just added another one and I added no scripts or has any references, and when I run the scene that camera's FOV also switches from 60 to 111.something. I was trying to do some animation sequencing with Timeline, and no cinemachine installed
Shouldn't happen unless you have some component that's doing it, no.
interesting, I changed it to physical camera and it stays at 60 
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
we can't help you without knowing what you need help with
da
....is the bot down again
idk
ah there we go
for some reason when i have 2 nav agents only one moves
nvm i found th issue
i was baking every object instead of just only baking the floor
hii on line 41, it says the object is not set to an instance, what can i do to fix this?
eh i cant figure it out either
you need to post code as code and also all of the script so we can see what "EnemyManager" is
!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/, https://scriptbin.xyz/
📃 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.
why i cant get started on this i click on get started but it doesnt direct me to another website
Guys does anyone knows why my IDE isnt auto compleating? And Yes I #854851968446365696 read it but Idk why it still wont work
I even have it installed
is it set as the default external editor in the unity project?
no this
!ide 👇 this is a good embed.. has pretty much every solution
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
kk I pressed it Ill restart my PC
also make sure u dont have any errors in the IDE console