#💻┃code-beginner
1 messages · Page 533 of 1
You can get the y position at any point along the parabola like that:
y = a(x - h)^2 + k
What's a x h k sorry 😞
Where (h, k) is the peak point.
Ok so the original position
(x,y) is the position along the curve.
So x,y varries?
Yes, x is the x position where you want to find the height of the curve(y)
Ok but how can impliment this in script by having the final position and the initial?
Just replace the known variables and calculate the unknowns.
Presumably, you know the peak point and the x positions between the start and end points, so just input them into the formula to get the y.
Okok ty
Is there an equivalent for "onMouseHover" for raycasts?
I'm trying to check if my VR controller's in front of something, and just wondered if there's a more elegant solution than just check on update
Nah raycast away. That or use triggers
What do you think onMouseHover does under the hood?
Honestly? i don't know
i'm not great at programming
but i've grown used enough to it to realize that most stuff doesn't work how i think it works
Pretty much the same as raycasting each frame and seeing what it hits
You can make it more "elegant" by offloading it to your own Raycaster(maybe think of a better name) class that you would just need to initialize and update. That would be just 2 lines in your script that want to use it.
how can i make a script what has text that grows score. game what i am making is an endless runner
private void GrowScore()
{
this._score++;
}
Have fun
ty
Hello i am trying to make a building system does anyone have any idea on how to align the objects perfectly without a grid (like dragging them near each other and transforming their position to be perfectly aligned) i don t have any idea
like some anchor points
Yeah define anchor points in a script
is there any tutorial/ script on how to do this?
Each anchor point should have a position and a rotation (or direction) and maybe the compatible types if you need
ok imma try it
You would check near objects anchor points and check which one best aligns to the anchors in the block you are building
Position + angle checks most likely
the get component lags a lot
it runs it every frame the cursor is over a object
is there a way around this? or does the GetComponent<> normally not lag the computer?
asking the second question because my computer is quite laggy sometimes...
GetComponent<T>() is an expensive call, and shouldn't be used every frame - especially avoid it in (where possible) Update()
maybe at the very least cache the existing object and check if it's the same one
Avoid repeat calls too ☝️ - cache so you do it as few times as possible
maybe use TryGetComponent instead
I'd be doing this with IPointerEnter/ Exit handlers though, not Update
ah
ok thanks
When I searched this on the unity documentation, it says its no longer supported, and it seems the IPointerEnter is not working.
is there a unity 6 equivalent of this?
ah, alr
I assume that means it was part of the old input system, maybe. Try googling for something similar with the new input system
IPointerEnter works fine on 6. What you write?
`public class SelectionManager : MonoBehaviour, IPointerEnterHandler
{
public GameObject textObject;
TMP_Text textData;
void Start()
{
textData = textObject.GetComponent<TMP_Text>();
}
public void OnPointerEnter(PointerEventData pointerEventData)
{
if(TryGetComponent<InteractableObject>(out InteractableObject pointedObject))
{
textData.text = pointedObject.GetItemName();
textObject.SetActive(true); // Show the text object if it's not already active
}
else
{
textObject.SetActive(false);
}
}
}`
what the-
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
oh thank you
ok. Do you have an Event System in the scene? where is this script placed ? (it needs t be on the actual UI element)
put log inside the OnPointer enter.
I do have a event system in the scene, the script is placed in a seperate selection manager gameobject
by UI element do you mean the canvas?
it needs to be on the UI item that is part of the canvas, idk if it will work on the canvas, it typically goes on the gameobject to recieve these events
It seems like the OnPointerEnter is not triggering
I do have my cursor hidden, as it is 1st person game, I dont know if that will affect it
It seems the unity scripting API last included OnPointerEnter in 2020.1
Should I just try to make a manual pointer enter by using raycast or is there another method for this?
again OnPointerEnter works fine. Of course it will not work if the cursor isn't there.
You have to explain the usecase for others to be able to make a suggestion that will work well for this
ok, my apologies
I thought if its just visually hidden it wont effect its raycast Cursor.visible
also
https://docs.unity3d.com/Packages/com.unity.ugui@3.0/manual/SupportedEvents.html
this is why you dont see it in the manual anymore,its part of the UI a seperate package
it shouldn't unless you have the cursor locked
yea, I have it locked too...
so in this case I assume it wont work as long as I have it locked?
It can with a custom InputModule. Again you have to explain what the usecase is exactly? what are you making ?
ok
im making a 3d sandbox game and I want a textbox to show an object's name when the cursor hovers over it.
something like this
huh why did you need the UI raycast on the text then ?
you should just use a raycast then
hold on let me scroll to the original code
what you had here was fine just needs a few fixing
ok
I assume I just need a few varibles and optimizations so it doesnt GetComponent as often?
this is only doing a GetComponent when raycast hits something its fine
all you need is to make that if statement as the TryGet you did
is it ok to erase my question from this channel and ask in code general?
if it suits better there sure
isnt this going to run every frame it hits something though?
^ should probably not keep doing getcomponent if you're hovering the same object though
soif(hit.collider.TryGetComponent(out InteractableObject interactable)){ myText = interactable.displayName
honestly I wouldn't worry about runnig this if statement on the same collider, its not a big deal
the difference is negligible
ok i might need to fix my computer then....
right now whenever I hover over a tree it lagspikes 😔
assumptions don't get you much. You'd have to profile to verify that is legitamte concern.
on the surface, nothing in that code would cause lag spikes
chanced are is something coincidental to something else
Profile it, could be all sorts of reasons why it is lagging - might also be rendering. If this GetComponent is truly the root cause, build a Dictionary<Collider, Interactable> at startup or editortime and then use that lookup table. But this sounds like too much optimization for a problem that might not actually exist, so try to identify it first 🙂
Guys is it possible to change the speed of a specific animator state via script?
yep
Does anybody actually find work after completing just the junior programmer pathway on Unity Learn? I’m gonna do more pathways but I was just curious if it’s even worth putting myself out there until I’ve gotten more practice and maybe even a few projects of my own for the portfolio? Sorry if this is the wrong channel for this but the industry channel didn’t seem very active or on topic.
No, any of the pathways alone won't be enough to get a job
I didn’t figure as much. Thanks.
Heya everybody! I am fairly new to Unity. I have a game object of waypoints whose transforms I am using to create a path for a game object to travel to. I would like to take my game object and store the data into a ScriptableObject or some other way so I don't have to keep the entire GameObject around. Can somebody point me in the direction of how I would go about that? Preferably without manually entering the Vector3 data.
You cannot store scene objects in a scriptable object
I know. I don't want the scene objects, I want their position vectors.
you could store their v3 positions, in a list sure
Exactly. What I am trying to do is get a list of transforms from a game object, take their positions, and store them in a scriptable object's list of Vector3s
alr so whats the issue you're having with that?
My issue is that once I have the list of transforms and put them into Vector3's, in the game, they get dumped from memory.
well everything at runtime gets wiped ofc.
you would store those positions elsewhere if you're doing it runtime and expect it to last in the next run
Yup. Preferably, I wouldn't have to enter runtime
You don't have to
I would like to take the positions in the transforms, press a button, and have the vectors written to a scriptable object.
so do it just like that.
the button would have to be a context button or custom button,
since you would not be able to run canvas UI button in editormode, I don't think
Sorry, maybe I am not making myself clear.
What steps do I take to do that?
I know how to put the transforms in a list.
I know how to make a scriptable object and put it in a asset menu
run a foreach loop or for loop and add them to a list of vector3 after you access their .position during iteration
context menu and asset menu are two different things btw
there are many ways, in this case you probably just need a single function.
In that case basically use the ContextMenu attribute above the function that you want to run in the editor
so this goes in the same script that reads all positions and stores them in a L<v3> for the SO
egcs [SerializeField] private Transform[] locations;//adjust in inspector [SerializeField] private MySO storageSO; [ContextMenu("Store Positions")] private void RunFunction{ List<Vector3> positions = new(); for (int i = 0; i < locations.Length; i++){ positions.Add(locations[i].position); } storageSO.Locations = positions; }
yeah, that's a lot like what I went with
nice. might need to add the locations directly to the list in SO via function instead of assigning the reference, I think.. Im having a brain fart this morn
Pathwinder.cs
public class Pathwinder{
List<Transform> waypoints;
...
[ContextMenu("Save Waypoints to Scriptable object")]
private void SaveWaypoints()
{
Path path = new Path();
for(int i = 0; i < waypoints.Count; i++)
{
path.waypoints.Add(waypoints[i].position);
}
}
}
Path.cs
public class Path : ScriptableObject
{
public List<Vector3> waypoints;
}
Hi i'm new in the server and i'm new dev and i don't know how i can debug my problems :
my character is always flying and the animations doesn't really work and i don't know to how i can debug this.
CharacterController InputTrigger cannot trigger values for exemple Input.GetAxis("Vertical") return 0 when i move or not.
Sry for my english i'm not english
good enuf
show the entire !code , send it through the links below 👇
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
also the first step into debugging is to start with one little piece at a time
you cannot new a ScriptableObject, use CreateInstance
just store the SO reference directly, or use Create Instance but you need to save it explicitly to the AssetDatabase
just can you help me in a vocal in discord please because i don't really understand all. And show you the bug
not really, plus I cant anyway even if I wanted to. I'm at work lol
oh ok sorry
You can record videos or screenshot, show those if you want it to be visual
ok and send it to you
Like I said, one of the steps is also to send the code so we get an idea of whats going on there
ok
Create Instance
You can also create a gist. https://gist.github.com
idk
nahh thats more work and unecessary , use the linked sites
copy the class, paste it on the site, hit save and send the link
post the code properly as I already instructed
this
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
first I would not use triggers for moving animations, I would use Blend Tree.
second, You should debug your values to see what they are
its very easy to link Idle and Walking state with BlendTree if you use a float and grab it from the cc.velocity's magnitude for example or just the moveinput
just how i should debug my values
well you do have 1 log, the concept is the same
yeah just i don't know because i'm new
instead of Debug.Log(cc.isGrounded); for example, use Debug.Log($"horizontalInput value: {inputHorizontal }" );etc
(btw the $ symbol is for <string interpolation>)
ok
well Instantiate could be one of the main reasons, depends how many times this is called or whats inside those butt50
and it was just that
how to fix it?
pardon?
the bug
I need to instantiate this amount of gameObject
first before fixing a problem is to identify the exact cause
what bug?
its not necessarily a bug when its not what you expect it to be
mainly it could be that shitty script, no offense
also why are you setting the position of the gameobject after you Instantiate? Just do it whilst you Instantiate
https://docs.unity3d.com/ScriptReference/Object.Instantiate.html
ok but its not mine its a plug
thats why we put logs to whats the current values are compared to expected values?
As for your issue, it depends on how many you spawn, how frequently you spawn them, and what they contain. You would need to debug and use critical thinking to find which one is your problem
can you send me a better script for this ?
write one from scratch, its not that difficult . Unity also has premade ones you can use
all you do is replace the model with yours and adjust values.
but its better writing a basic one from scratch so you at least have an idea of whats going on incase you need to add changes / modify things
@rich adder i'm always in the ground
but is the animation who do that i think and the script
is your player in the ground or is your model in the ground as those are 2 different things.
How do i pause execution until a coroutine finishes? All the answers online just say not to do it, but the non-async unload scene function is deprecated, and I can't figure out how to await an AsyncOperation >.>
you can convert an async operation to awaitable so you can use await
Oooooh!!
Is there any way to access this value of Cinemachine Camera through code?
I'd like to change the mode from Position Composer to None
anything you see can most likely be accessed , if you see it in the inspector anyway
...how do i do that? >.>
Oh, was that added in Unity 6?
indeed
Curses xD
You don't have unity6?
either that, or just stick to using coroutine
or use a bool you can await on from the coroutine for async function
upgrade first after a backup/git commit ofc. See if anything is a miss and go from there
On it o7
Is there like a good tutorial to make a character movement?
good is subjective
If you need a kinematic CC, it's probably best to use an asset (like ECM2) and then read through their documentation. Implementing your own kinematic CC from the ground up takes a lot of time. If you got that time, its a good exercise though
Good as in easy to follow and the codes are clean
What's ECM2?
it's an asset, easy character movement 2. There are lots of character controller assets on the asset store, this is one of them. Choose one with enough and good reviews, that can be extended to fit your specific needs. You can learn a lot from them
Best you learn each part individually instead of an "all in one" video, this way its easier to construct it how you need it
Ooh yeah, I didn't thought of that, though I do have the 3rd person starter pack
personally i really enjoyed working with the KCC addon for Photon Fusion, which is their version of a networked kinematic character controller. It uses a processor-based and data driven approach for controlling the character. This allows you to fully abstract away your custom movement logic by writing your own processors that modify data (like desired speed, gravity, direction...). Processors can suppress each other, have priorities and such... After processors have modified the data the KCC takes care of registering collisions, depenetrating the character and actually moving it. Really allows you to build very complex movement without having to alter anything within the underlying movement code
probably worth a look 🙂
Ooh nice, I'll take a look
Guys anyone else having trouble setting up vscode with unity they are linked and all. I have one problem on vscode the unity suggestions aren’t popping up like when putting debug.______ no options pop up to fill it in
Hey guys, I'm trying to code an animal npc movement system. I want to animal to roam around endlessly as the default state, and then based on an OnTriggerEnter event, stop roaming exactly wher it is and do a different behavior. All I have been able to figure out so far is the roam mechanic, but what would be a good way to manage the states? https://hatebin.com/wwmzsqwvwf
implement a finite state machine in your code
just found this, might be helpful (haven't used this implementation) https://learn.unity.com/project/finite-state-machines-1
hey! im trying to code a 1st person movement script for 3d with headbopping, running, and walking, but i have absolutely no clue where to start. ive searched tutorial after tutorial
does it support standing on moving platforms by default?
!ide
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
thank you, ill take a look and get back to you
yes. But it is for Photon Fusion projects only. You could probably rewrite it that it doesn't rely on NetworkBehaviour and other Fusion-related base classes, but at that point you'd be far better off using a different character controller asset. The design patterns it uses are amazing though, worth a look just for studying it
code the movement first, then add details like headbobbing (Primary first, secondary second)
You should get familiar with unity and C# to do so#💻┃unity-talk message
im familiar with the unity editor and know some basics of C#. im trying to get better at C# as of right now lol
not just the unity editor, you need to get used to its components and API. For beginners it is generally recommended to use rigidbodies as it uses the physics system and you do not need to code any physics unto it (unless you use kinematic rigidbodies or character controllers)
I have done all the steps but still not suggestions
did you regenerate project files, and do you have the correct extensions installed
Is there a way to shrink this into a single custom window decorator-type toolbar, kinda like Rider?
Yes all of that has been done from installing the .net thing to the c# by unity and all
I see some options but not a lot of them and they arent in alphabetical order which I believe its supposed to be like
Doubt it ..thats something you'd have to speak to their UI/UX team
where are singletons stored?
if its not attached to a gameobject where is the script actually located?
Why do you ask? Singletons aren't really a 'real thing' so you can implement them a number of ways and a useful answer will depend on knowing that. Ultimately everything is 'stored' in memory.
just wondering. usually scripts have to be attached to gameobjects so
unity offers a model of programming where you have a 'scene' full of 'gameobjects' and can attach 'components' to them, but that is just a way they have set things up to make it easy to flexibly make a lot of kinds of games
those things all exist as a subset of, like, C# itself
you could have a bunch of code which doesn't interact with your scene at all
so if you just wrote some C# code and made some variables and objects, where are those stored? it's all just objects in memory, so the answer isn't super useful directly
it is useful to understand that a lot of your game could, and potentially should, exist independent of the unity scene view
no, but if you're interested there is a free unity asset called unity editor dark mode and it will make the toolbar, window border, and context menus dark mode. But you can change the colors as well. So even if you use light mode on your PC you can change the defaults and have context menus and such stay as white but make the toolbar the same color as the rest of the editor
installing the extensions won't regenerate project files automatically, you need to do so manually
I did that however I think its because I dont have this extension I cant find it on vs code extensions
I don’t specifically see a c# powered by omnisharp extension
Yes I have that installed but I dont get the code suggestions for unity
You must install the "Unity" extension. Do not install any other extensions.
The Unity extension will install several other dependencies
Do not take any creative liberties with the install instructions. Follow them exactly.
!vscode
you need do need code snippets though
if you do not have it, some of the update functions will not show
That gives you suggestions for Unity messages, yeah
But if you aren't getting any completions at all, then VSCode does not understand the project files being spat out by Unity
you do need the Visual studio package in unity as well
as that includes the VS and VSC stuff (for unity)
indeed
So do I just install Vscode again but straight from the unity site would it affect my old vscode configurations that I use for other things
do you have the visual studio editor package installed in unity, if not then install it
And did you set the external script editor to VScode?
literally just follow this guide
there is no "VScode from the Unity site"..
Yes
Not exactly sure how do I know if I have it
I followed it step by step and still have this problem
With the old packge it used to be a pain to get VSC working with Unity, I thought it was supposed to be straight forward now..
follow the guide -> relaunch both unity/ vsc -> regen proj files if needed
check the package manager
is there a reason you're using VSC and not VS?
it is, it actually is very easy
They may be using it as it is more light weight than VS, all it is, is a glorified text editor anyway
I’m on mac I use visual studio code
Do I just try this out
Get rid of "Visual Studio Code Editor"
remove visual studio code editor, isn't that deprecated?
you may need to remove the "Engineering" feature
since that installs a bunch of random packages
its deprecated yes
Visual Studio Editor now includes the support for VSCode too
well yes I know it was combined into the Visual Studio package but Isn't the old package deleted from package manager?
I removed the engineering feature which removed and installed Visual studio editor and reloaded project file thing it still does not work
Honestly is there another ide where I don’t have to go through this lol
well Rider would be another one but I do not know how to configure it as I do not use it 
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
anyone know of a fun way to learn to coe
code
cuz sitting thru the tutorials be rlly boring not finna cap
code.org/khan academy? those are gameified for kids
aight ill try that
but it's probably gonna be like, the opposite end of the spectrum
yuh
hi y'all thanks again for helping, I managed to make the scene work, with display of a text object in HUD. I would like the text object to dynamically update to show me my coordinates (x,y,z) (the x,y,z coordinates of the camera), is there some example code on how to do this ?
in update, set the text to the position
I am very new to all this, but to make a script, do you have to attach it to an object? for example I have to make a script that I attach to the text object of the hud ?
sure
i mean you don't have to to just, make a script, but you do have to put that script on something in the scene to make it work
are there some examples of that process? I never did this before. I have been programming in matlab but never this
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Depends on what kind of tutorials your sitting through, but I would suggest w3schools, they have a bit more "sandyboxy" tutorials, then you can look up challenges with the topics you learn about, which could be a fun way of getting familiar with what you learn
i don't think it's supposed to be fun (C# and Unity), but you can look at scratch tutorials. it's not Unity, but i think it's meant to be fun/cool for beginners . . .
is anyone able to check this video out and see why when i hit new game after leaving the game scene then hitting new game again, my scene doesnt load properly? https://imgur.com/a/kC43Dkx
It's hard to tell considering there is not much code/details. Are you using some lifecycle for this? Looks like when you second load your scene, there is some data left from first run and it causes an issue.
my current issue is in the image but i fear the true problem may lie deeper within. The code is for simple first person melee combat, and for that i did copy from a tutorial but had to make some slight alterations for it to fit in my project, which happened to fully brick it. can provide more sc if needed + full code
not anytype of life cycle, im hit tab, to go back to the main menu, then hit new game and it gives me that error
Is there any conditions that enable your behaviour in scene? May it be possible that this NPE causes an issue?
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class attack : MonoBehaviour
{
Animator animator;
AudioSource audioSource;
PlayerInput playerInput;
PlayerInput.MainActions input;
public Camera cam;
[Header("Attacking")]
public float attackDistance = 3f;
public float longAttackDistance = 4f;
public float attackDelay = 0.4f;
public float attackSpeed = 1f;
public float longAttackSpeed = 0.4f;
public int attackDamage = 1;
public int longAttackDamage = 2;
public LayerMask attackLayer;
public GameObject hitEffect;
public AudioClip thinSwordSwing;
public AudioClip hitSound;
bool attacking = false;
bool readyToAttack = true;
int attackCount;
public const string IDLE = "Idle";
public const string ATTACK1 = "Attack 1";
public const string ATTACK2 = "Attack 2";
string currentAnimationState;
public void Attack()
{
if (!readyToAttack || attacking) return;
readyToAttack = false;
attacking = true;
Invoke(nameof(ResetAttack), attackSpeed);
Invoke(nameof(AttackRaycast), attackDelay);
audioSource.pitch = Random.Range(0.9f, 1.1f);
audioSource.PlayOneShot(thinSwordSwing);
if (attackCount == 0)
{
ChangeAnimationState(ATTACK1);
attackCount++;
}
else
{
ChangeAnimationState(ATTACK2);
attackCount = 0;
}
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
animator = GetComponentInChildren<Animator>();
audioSource = GetComponent<AudioSource>();
playerInput = new PlayerInput();
input = playerInput.Main;
AssignInputs();
}
// Update is called once per frame
void Update()
{
if (input.Attack.IsPressed())
{ Attack(); }
SetAnimations();
}
void ResetAttack()
{
attacking = false;
readyToAttack = true;
}
void AttackRaycast()
{
if(Physics.Raycast(cam.transform.position, cam.transform.forward, out RaycastHit hit, attackDistance, attackLayer))
{
HitTarget(hit.point);
}
}
void HitTarget(Vector3 pos)
{
audioSource.pitch = 1;
audioSource.PlayOneShot(hitSound);
GameObject GO = Instantiate(hitEffect, pos, Quaternion.identity);
Destroy(GO, 20);
}
public void ChangeAnimationState(string newState)
{
if (currentAnimationState == newState) return;
currentAnimationState = newState;
animator.CrossFadeInFixedTime(currentAnimationState, 0.2f);
}
void SetAnimations()
{
if(!attacking)
{
{ ChangeAnimationState(IDLE); }
}
}
void AssignInputs()
{
input.Attack.started += ctx => Attack();
}
}
Truth to be told not sure why it's not working. How do you restart scene? It's a bit unclear from video
Also considering you're getting npe, I assume you'r missing animator on your game object. can you check?
seems like animator is null, so there's no Animator component in the object's children
hmm alright
animator component is on the sword object
under the cameraHolder
and is that a child of this object
then thats' pretty straightforward then
is there a way i can connect them
it's not in a child so it's not being found
make it a child
probably make cameraholder a child of player. the camera should follow the player anyways, no?
i had it like that originally but there were some odd problems with the camera script so i seperated them and made a script to have the camera follow the player better
which the camera bobbing script relies on
if you don't want to modify the camera bobbing to handle inherited position, you'll have to access the component differently, since it's not a child
would that be difficult
no
um
how
- make it public and set it by reference instead of getcomponent, like how you're doing the camera
- make it access the camera holder, then get the component from a child of that
- make it access the sword directly, then get the component there
- find components in the scene
etc
i actually forget the reason
i swear there was one
I think it was so that i could get that orientation object connected to the player at the top here
you don't need a separate object for that
Make the animator field public or a serialized field and then drag/drop the scene object into that field via inspector.
alright i did that yet the error persists
did you remove the animator = GetComponentInChildren... line in Start
Alright, so, i'm finally trying to get a tweening library into my project
Someone suggested primeTween but at this point i'm not sure that was serious or not
are there any suggestions? leanTween seems, well, abandoned, and the documentation is whack
PrimeTween is fantastic, I use it in everything.
LitMotion is our gonto tween lib now https://github.com/AnnulusGames/LitMotion
there's also apparently dotween that's decent
ive heard about it here, haven't used it
I'm giving dotween a shot right now
DoTween and LeanTween are grandpa at this point. Slow and produce allocations
Why do you feel your leg is being pulled ?
when i look up tweening library in the server, it feels like every six months there's one new hot tween library, that feels like mostly a joke sometimes
it's just something i'm not knoweldgable on so, i don't know how serious these comments are
We have used LitMotion in like 5 commercial projects and are using it in our big game atm so I would say it is definitely not a joke
What exactly are you trying to do? Sometimes if it's just a simple tween along path a tween package is overkill
I'm just trying to make the experience of my project a bit better, most usecases would be tweening a float here and there with specific easefunctions
seeing as there's a gajillion tweening libraries out there it feels like it would be a waste of time to write my own
hot tween
Fair enough
I'll give the documentation a shot
One really handy piece of code I use a lot is this:
float yourValue;
float valueMin = 0;
float valueMax = 1;
float duration = 5f;
float smooth = 0f;
private bool doinTheThing;
public void DoTheThing()
{
StartCoroutine(DoTheThingRoutine());
}
IEnumerator DoTheThingRoutine()
{
if(doinTheThing) { yield return null; }
else
{
doinTheThing = true;
float t = 0;
float dur = duration;
smooth = 0f;
while (t < dur)
{
t += Time.deltaTime;
smooth = Mathf.SmoothStep(0, 1, t / dur);
yourValue = Mathf.Lerp(valueMin, valueMax, smooth);
yield return null;
}
yourValue = valueMax;
doinTheThing = false;
}
}```
where the Mathf.Smoothstep is you can replace with any type of easing func you want
and the value is normalized usually so you can just plug in anything
i had to double check.
Recently I have taken to purging coroutines from our code base
Using Await instead? "Coroutines Hot Sister" Reference
wouldn't that if (doinTheThing) check just wait a single frame and then do it anyways?
It essentially makes it only able to run if it's not "doin the thing"
OH, you're right, sorry, it's late lol
I'm not asking to be spoonfed here but i'm kiiiiinda asking to be spoonfed here:
How much of a pain in the ass would it be to update an external component value in litmotion?
Like Palmer Luckey (god damn it man) said, it's late, my brain's toast
(you could just yield break; in the if to make it a guard clause, no? or check if (!doinTheThing))
i tend to check before starting the coroutine 
public void DoTheThing() {
if (!doinTheThing) {
StartCoroutine(DoTheThingRoutine());
}
}
```wonder if anyone else does that, i tend to see the check inside the coroutine
(didn't read far enough in the thread lmao, it was not return)
That's much cleaner, I don't remember why but I had some weird race condition in an old project I inhereted and I think it stuck with me
don't you love necroposting in forums
Point being tho tween packages are cool as hell, but a lot of time for MOST stuff you can just grab a simple method and wrap it in a static func that overloads with an enum or something and just have a small little library of easing functions. But if you want that fancy stuff like dynamic models or train tracks that's a bit more complicated and I wouldn't make that lol
Alright
Forgive me for being crass here
but i feel like this needs saying:
I'm kind of slow in the ticker
(right now anyway)
so if my ooga bunga brain has to write more than 6 lines at once at 4 in the morning we (me and my keyboard) are going to have a problem
What do you mean an external component ?
I have an outline component which has a strokeWidth Value, what i'm trying to achieve is, in another component in the same gameobject, tween the strokeWidth value of the outline component
but animated
Only when it is mostly necessary. 90% of coroutines can be replaced with a timer with a few callbacks.
So essentially GetComponent<Outline>.strokeWidth = X; per frame
Pretty sure you can just use the Bind method to bind the motion to a specific value if you have a ref to it
i mean it's not exactly this, it's checking a state enum
enum Action { None, Dash, Attack }
Action action = None;
Coroutine activeCoroutine;
void OnDash() {
if (action == None && Grounded()) { // precondition
activeCoroutine = StartCoroutine(Jump());
}
}
IEnumerator Dash() {
action = Dash; // lock
rigidbody.gravityScale = 0;
// etc
rigidbody.gravityScale = 1; // postcondition
action = None;
activeCoroutine = null;
}
i guess it makes more sense to say "if precondition, jump" rather than "if not precondition, cancel", to me at least
Opens on my phone
well
for now, guess i'm stuck with dotween
And it seems really, really hard to understand how the hell i tween a float
jesus
Get some sleep
Never underestimate the power of sleep to make an answer obvious.
Hi all!
I have a child GameObject (Pavis) on a loop, following a fixed course. The parent object (PlayerShip) is a ship in a top-down shooter, the child is also a ship, but it is supposed to hang out in a fixed area in front of the nose of the parent. I have given the child a set of 3 positions to seek as vectors. However, it seems like the vectors are relative to the play space, and not the parent as I expected. Here is a video showing what I have going on.
Waypoints:
List<Vector3> {
(-0.52, 0.82, 0.00),
(-0.07, 1.12, 0.00),
(0.48, 0.82, 0.00)
}
so how are you using those waypoints?
The Pavis has a script called "Pathwinder", which reads the waypoint vectors from a scriptable object.
The Pathfinder takes those locations and directs the Pavis to those coordinates.
Here is what it looks like when it is running
that tells me nothing. is the code using transform.position or transform.localPosition?
The code is using transform.position.
there is your problem then
Sounds like it. Local position is the position of the parent, the direct local space.
yeah?
no, localPosition is the child position relative to it's parent
Much better. Not quite right, needs some tuning, but you put me on the right track. Thank you.
How can I only generate a navmesh around a certain area?
im making a survival game and wants to implement ai, but don't know how to control the navmesh generation
nevermind got it
so i made this script to move my player character around and activate its animations, but when i play the scene he just repeats his idle animation and when i press a or d he just freezes when he reaches the end of his idle animation cycle and then keeps going??
hol up lemme get the code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
// using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] TextMeshProUGUI healthText;
public float moveSpeed = 6f;
public int maxHealth = 100;
public int currentHealth;
bool deadCheck = false;
float moveHorizontal, moveVertical;
Vector2 movement;
int facingDirection = 1;
Animator anim;
Rigidbody2D rb;
private void Start()
{
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
if (deadCheck)
{
movement = Vector2.zero;
anim.SetFloat("velocity", 0);
return;
}
moveHorizontal = Input.GetAxisRaw("Horizontal");
moveVertical = Input.GetAxisRaw("Vertical");
movement = new Vector2(moveHorizontal, moveHorizontal).normalized;
anim.SetFloat("Velocity", movement.magnitude);
if(movement.x != 0)
{
facingDirection = movement.x > 0 ? 1 : -1;
}
transform.localScale = new Vector2(facingDirection, 1);
}
private void FixedUpdate()
{
rb.velocity = movement * moveSpeed;
}
}
it's probably an issue with how the animator is set up, not with the code
though i do see an issue; your code is saying there's both velocity and Velocity? either the animator is set up wrong, or you typoed one of them
alright that makes since, i'll check that out
ty
I was beginning to learn a tutorial but the colour of all materials is kinda deformed why it’s like pinkish
Looking at a video by unity installed their sample assets
still not working, i asked about it in the person who made the tutorial's discord server
so we'll see how it goes ig
i mean.. you could show your animation states
(not here though, maybe #🏃┃animation)
they're in
hi i have a question who do a script who a enemy follow you and when he touched you , you respawn. Sry for my english
for the latter, just set up colliders and rigidbodies and have the player respawn when it collides with the enemy
for the former, depends on your level geometry. could you provide more context?
i do like a backrooms and i want to when the Enemy see the Player he follow you and want to kill you and when he touched you , you respawn
so 3d, yeah? you could make it check for line of sight and then just follow the player (or where it last saw the player to simulate object permeance)
yes
Can anyone help me with this. The stats for the specific things are accurate, but why the final build jumps from 11mb to almost 800? It's a very basic and simple game
it's gotta include the unity engine itself too
wdym
"total user assets" is just, well, assets
it's gotta include the unity engine to run scripts, render sprites, play animations and sounds, etc to actually run the game
@naive pawn have you a script like you say ?
or a video
try googling it
Shoutout to @languid spire who pointed me in the right direction and helped me to solve my problem with position vs localPosition. I have two ships hovering around my player now. One taking point to sponge up bullets, the other to stay on the six. And they move as one unit. Rock on.
I have a function with a list as a parameter but I can't see it when I want to select functions in the onclick of a button
here's the code
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
public class GlobalUIManagerScript : MonoBehaviour
{
public AudioSource playSound;
public void loadGame()
{
DontDestroyOnLoad(playSound.gameObject); // Prevent destruction of the AudioSource
playSound.Play();
SceneManager.LoadScene("slurpy blurb");
}
public void openPannel(GameObject pannel, List<GameObject> buttonsToBeDisabled)
{
foreach (GameObject button in buttonsToBeDisabled)
{
blockUI(button);
}
pannel.SetActive(true);
}
public void closePannel(GameObject pannel, List<GameObject> buttonsToBeEnabled)
{
foreach (GameObject button in buttonsToBeEnabled)
{
unBlockUI(button);
}
pannel.SetActive(false);
}
public void blockUI(GameObject toBeBlocked)
{
CanvasGroup canvasGroup = toBeBlocked.GetComponent<CanvasGroup>();
if (canvasGroup != null) {
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
} else
{
Debug.LogWarning("CanvasGroup not found on the specified GameObject!");
}
}
public void unBlockUI(GameObject toBeUnblocked)
{
CanvasGroup canvasGroup = toBeUnblocked.GetComponent<CanvasGroup>();
if (canvasGroup != null)
{
canvasGroup.interactable = true;
canvasGroup.blocksRaycasts = true;
}
else
{
Debug.LogWarning("CanvasGroup not found on the specified GameObject!");
}
}
}
doesn't like two arguments
I've tried instantiating something out of OnDestroy which caused errors when reloading scene, and tried using a coroutine to get around it which also causes an issue (cannot start coroutine because gameObject is inactive) - what is the proper way to do this? i feel like im missing something really simple https://hatebin.com/sltzosoytb
Note: You can stop a coroutine using MonoBehaviour.StopCoroutine and MonoBehaviour.StopAllCoroutines. Coroutines are also stopped when the MonoBehaviour is destroyed or if the GameObject the MonoBehaviour is attached to is disabled. Coroutines are not stopped when a MonoBehaviour is disabled.
that makes sense
okay I just realised the simple thing I'm missing is I'm destroying the object with an external script, so I can just call a method there before destroying
Instead of using OnDestroy() just make your own Destroy method which you call when you invoke a delayed destroy call, and scale the time of the coroutine to last until the Destroy happens
I've been having this issue for a really long time now where the camera occasionally just sort of "snaps" and i know its the camera because in this video i just disable every other thing, id say it gets worse the more scripts were enabled but idk i felt like i should just start with wherever i first noticed
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
im pretty sure i was following a tutorial at the time because i couldn't figure out how to get the camera to rotate where i wanted, but perhaps im simply not understanding something in it and thats causing the problem
if anyone has any suggestions or ideas on how to avoid whatever is going on, it would be appreciated
changed from GetAxisRaw to GetAxis.The sensitivity is moving more comfortably which was its own issue but the snapping issue just got way worse.
Hey guys, I'm using the new unity input actions and I'm trying to add when the player performs a mouse scrolling the game will perform some actions. However it seems like I do not have the binding for the scroll wheel as it only have scroll lock from the keyboard?
you could also use this : Mouse.current.scroll.ReadValue();
#🖱️┃input-system probably better place for this
Okie thank you
I will definitely try that out
would you say creating a game similar to minecraft would be a good start? ive started a few games but gave up halfway cos i either dont know how to do something or i have no idea what to do next. Just looking for a good beginner game to learn the basics (aiming towards freeroam, open world type games)
nope
not at all
simpler
what would u have in mind?
if you gave up other ideas because it got diffcult, imagine something as diffcult as procedual generation
true
I can recommend a channel I am watching to learn absolutely beginner friendly
idk what do you like
i wanna aim at survival based games
in that case start simpler though
then work your way up, learn what systems you need
smaller projects
And that's what they are teaching there XD
that would be great!
Try watching Game Maker's Toolkit tutorial on Unity
It's the one I used. Granted, I'm still a beginner, but I've learned a lot with it :)
I sent u link in private as I dunno if we can send links here
got it thank you
Also unity learn can be a good option to learn too
hello, when i try build my game for android the compiler give this error * What went wrong:
Could not determine the dependencies of task ':unityLibrary:mobilenotifications.androidlib:compileReleaseJavaWithJavac'.
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-33 Android SDK Platform 33
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html how can i fix
yes. in fact you should ideally do that instead
this is a code channel
oh sorry
I suggest you to do whatever you want. If you are not aiming to create a 1:1 minecraft replica you are going to quit halfway anyways, but the things you learn while making it could stay. However, there is one thing with this: If you use blocks as seperate gameobjects you will lag a lot. In order to overcome this, you’ll need to create a complex system. If you acknowledge this and still want to make a game similar to minecraft, go ahead
why does rb.velocity not work, it just tries to make me do rb.linearvelocity or Angularvelocity?
it has been renamed to linearvelocity on unity 6
ok ty
because its the linear velocity, as oppose to angular velocity
Wait until the end of the current frame before taking the screenshot or before calling the Texture2D.ReadPixels function. This can be done with the WaitForEndOfFrame class. Notice how I cached it to avoid creating new Object each time the TakeSnapshot function is called.
good ol stackoverflow
hi y'all, I try to display a text in black with green background (working in passthrough), but the green background doesn't work. What am I doing wrong?
string displaystring;
displaystring="Running | Coord: x="+xr+" y="+yr+" z="+zr+"\r\n| Target x="+targetx+" y="+targety+" z="+targetz;
mainText.text ="</mark=#1eff0000>"+displaystring+"</mark>";
The starting tag shouldn't have / in it and your color has 0 alpha (=it's invisible)
thanks!
I think it won't work well for my application as it is still transparent. I believe there is no possibility to fill behind the text to make it opaque? We can only highlight?
what is an easy to implement to make it more accurate on the waypoints because it rotates too high
rotates too high?
make a video or something
use something like OBS or the built in windows gamebar
gonna have to show the pivot points of the sprites
guess i have to download obs then could prob also do it with the nvidia software
like this?
now what about the things that move
and yes nvidia software works too for vid
just make it mp4 or use streamable to host if its too big
Why is it not working?
probably because it says there is an error
yeah but tell me why is there the error when it is referenced?
trying don t understand why it won t work for unity tho works fine for ue
show the code
what does?
Snipping tool
the Animation variable is referenced by public to the object where it is pluged
do you have any idea tho nvidia software also doesn t wanna help lol
no idea works fine for me
in what way? or just get OBS or ShareX
what type is Animation
Animation
show the full script
use site from !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
where do you assign Animation reference
which one is Panel
the panel in canvas with +
6 . also
#💻┃unity-talk
why are you using animation instead of animator anyway, iirc thats legacy
thats because there is no point on the corner
because when I used animator I wasn't able to stop the animation from infinity playing
you uncheck the Loop option on the clip
if i'm changing an object's linearVelocity in a FixedUpdate() function, do i need to add Time.deltaTime/Time.fixedDeltaTime to ensure the fps gameplay consistency
okay so whats wrong wtih it now?
it doesn t take line between those points it is off
see they should walk way lower then they do and they cut off
send the !code via link
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
no
velocity is already moved wit consistent physics rate
alright
can i sent it in dm? (don t wanna have plagarism if i put it online)
what?
what is the difference between Update and FixedUpdate, i think fixed update is frame-by-frame, but that might not be correct
no one's gonna copy your code, especially if you dont give your entire project
FixedUpdate -> Every Physics step
Update -> Every Frame
in uni they check for plagarism so if i put it online they could think i stole it but it was me writing it 😮💨
unless there was a dataleak, or they were in the server, they wouldn't be able to read messages in a discord chat
using UnityEngine;
public class Enemy : MonoBehaviour
{
public Transform[] waypoints;
public float speed = 2f;
private int currentWaypointIndex = 0;
void Update()
{
MoveToWaypoint();
}
public void SetWaypoints(Transform[] newWaypoints)
{
waypoints = newWaypoints;
currentWaypointIndex = 0;
}
private void MoveToWaypoint()
{
if (waypoints == null || waypoints.Length == 0) return;
Transform target = waypoints[currentWaypointIndex];
Vector3 direction = (target.position - transform.position).normalized;
transform.position = Vector3.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
if (Vector3.Distance(transform.position, target.position) < 0.1f)
{
currentWaypointIndex++;
if (currentWaypointIndex >= waypoints.Length)
{
Destroy(gameObject);
}
}
}
}
aint nobody in uni checking anything lol if you're so worried use Gist and send the hidden public / private link
yeah i meant online like pastebin etc
what the hell is gist?
i mean it aint hard to google it
this ok tho?
try chaning the trahshold to something smaller like instea of < 0.1f do 0.003
tried that alr 😅 doesn t seem to matter
did 0.01
also you gotta show your gizmos of the moving object
gizmos?
how can i show all at the same time?
ohh pivot never heard gizmos😅
whut it changes when taking a screenshot but it is on the top right corner
seems like they take the top of each box
gizmos is the things that show the pivot like origin arrows
the one on the moving object
is this the root of the object, please try not to crop the entire editor is a pain to ask each part
is the script Enemy on this
yeah
can place it like this and it works but looks weird
did you fix the min distance until it goes to next point ? it should land exactly in the middle though of transform.position
wait you have your Pivot on Center dont you
show me this
he walk now just above the grey area when my red dots are here
i forgot that sprites can have their own origin elsewhere incenter mode
sprite editor, but you should first restore that menu
im confused i don t have any sprites to edit right now
like this?
ya just wanted to veirfy it in the scene view
@rich adder thank you it fixed it 🤩
what did ?
slowly going from ultra noob to noob 😂
set the pivot point to center
ohhh it was to something else there?
it was custom
last question for today how can i clean it up so i can start with the purple dude 😅
clean what up ?
the guy with dynamite for the purple guy with the torch
wdym start with it though ?
Does anyone know why when a gameobject with an animator on it gets disabled and then renabled the animator doesnt work properly anymore?
in what way doesn't work properly
when im going from idle to walk it just spazzes out like it constanly goes between both of then in stead of going to just walk
i tried to just disable the sprite render instead of the gameobject itself and still does the same thing
going to have to show what conditions you have setup
their bools
then its likely the code or something else unrelated
but it works perfectly fine before i disable the object and renable it
how can we possibly know the cause without seeing anything on how you set it up
like change the way i did it now was restart the project 😅
also how can i select all and edit the pivot point ctrl a doesn t seem to work 🤔
cant select all in sprite editor for some reason there is no such selection type afaik
you want to swap it in the game or just the scene, idk what you mean swap
like edit another sprite character from dynamite to purple goblin
in the inspector? where it says Sprite Ediotor you click that?
share the code properly and use links , pretty sure this was told to you before
also showing animator setup
this?
oh i just did it with window does it matter?
public IEnumerator FeedBone()
{
Debug.Log("FEED BONE IS GETTING CALLED!!!");
ralph.GetComponentInChildren<SpriteRenderer>().enabled = false;
ralphsPosition = ralph.gameObject.transform.position;
tongueRalph.gameObject.transform.position = ralphsPosition;
var animm = anim.keepAnimatorStateOnDisable;
//ralph.gameObject.SetActive(false);
//ralph.GetComponentInChildren<SpriteRenderer>().enabled = false;
//ralph.GetComponent<RalphController>().enabled = false;
//ralph.GetComponent<CapsuleCollider2D>().enabled = false;
anim.SetBool("feedBone", true);
yield return new WaitForSeconds(3f);
tongueRalph.gameObject.SetActive(true);
anim.SetBool("feedBone", false);
moveSpeed = 0;
runSpeed = 0;
mikey.transform.position = new Vector3(transform.position.x - 5f, transform.position.y, transform.position.z);
fedBone = true;
}
public IEnumerator TeleportRalphToMikeyAfterFeedBone()
{
Debug.Log("TELEPORT RALPH IS BEING CALLED!!!");
_tongueControls.tongueFinished = false;
yield return new WaitForSeconds(.5f);
ralph.GetComponentInChildren<SpriteRenderer>().enabled = true;
//ralph.GetComponent<CapsuleCollider2D>().enabled = true;
yield return new WaitForSeconds(.5f);
mikeyPos = mikey.gameObject.transform.position;
ralph.gameObject.transform.position = mikeyPos; //+ new Vector3(-3.3f, -.4f, 0f);
yield return new WaitForSeconds(.5f);
// ralph.gameObject.SetActive(true);
_ralph = GameObject.Find("Ralph").GetComponent<RalphController>();
//anim.enabled = true;
//_ralph.anim.enabled = true;
_ralph.moveSpeed = 9f;
_ralph._jumpForce = 19;
}
no as long as you do it on correct asset. inspector is faster tho
have it like this but should be able to set the pivot point of multiple sprites at the same time🤔
private void SwitchRalphControllers()
{
if (fedBone == true)
{
_ralph = GameObject.Find("TongueRalph").GetComponent<RalphController>();
_ralph.moveSpeed = 0;
_ralph.anim.enabled = false;
_ralph._jumpForce = 0;
}
if (_tongueControls.tongueFinished == false)
{
return;
}
if (_tongueControls.tongueFinished == true)
{
tongueRalph.gameObject.SetActive(false);
StartCoroutine(TeleportRalphToMikeyAfterFeedBone());
}
}
check the specific object with animator during runtime and see what the conditions are doing in the animator window @upper forge
Besides the code, how do I have to configure the models inside the prefab object?
Like, do I place everything inside or how do I do that?
I figured it out thanks sorry for the trouble!
will write a custom script for it ig if it waste too much time 🙂
Okay i Guess I didnt.... this is what the animator is doing during run time after the object gets reenabled
The jump anim works the same its just the transition from idle to walk @rich adder
hey yall, I have a question about animations-
I have two animations, one while the player is walking, one while the player is shooting
while the player is shooting with spam clicking, i'd like the shooting animation to continue playing normally
currently, the animation just resets from the beginning frame every time it is being triggered, otherwise it transitions back to the walking animation just fine
how should I go about this?
Change the clip into a loop, and instead of trigger make it a bool condition for the animation tree
hmm how do i change the clip into a loop? for extra context i'm using sprites so it's hand drawn animation
looked around in both the animator and the animation window
the clip itself has a loop property on it
good, now satisfy the second condition ;)
alrighty let me see
a bit of an improvement, though the issue now is that the shooting animation only plays the clip once and then goes back to walk, and then back to shooting, back to walk etc.
i'm guessing it's because of the bool being triggered for like one frame, so it's not continuously "held down", but i've no idea how to solve this or even look it up
How many times is shooting animation intended to play?
is walking animation playing too? You need to disable that condition
i'll send a video of the current situation, maybe it'll help explain better
otherwise what you have here looks fine as it should always be true when held
Are you spamming to shoot?
yep
Is that how you want it, or do you want to shoot while held down?
spamming is how i'd want it yeah
Then you need to make it so the animation for shooting cannot be interrupted
how do i go about that?
I think you can give it an exit time
In the transition arrow going from shoot forward to idle
hmm it already has exit time, even tried adjusting the time just now
Your video of the tree there is going back into walkstate, so are you not releasing firing? Not really seeing the issue
i'd like the animation to be playing while spam clicking
which would release the firing
GetButtonDown is only true on the first frame that the button is pressed
Oh right you need GetButton
Yes, but BroSkemp mentioned they don't want to be able to hold to shoot, rather they want the need to spam
and chop off the exit time probably
"while the player is shooting with spam clicking, i'd like the shooting animation to continue playing normally"
Getting mixed messages here then
In the inspector of the animation
I have that on "None"
I haven't used that setting before, but try out the other settings, one of them should do the trick
lets see
BroSkemp wants the player to shoot only once when a button is pressed, then this button needs to be released and pressed again to fire another shot. The way it currently it is, the animation works the same, but this is not the desired outcome for the animation specifically. There needs to a bit of leeway for the shooting to continue while spamming so that it does not instantly stop the animation
it "kind of" works with the Interruption source: Next State, but then it returns to the problem of it playing from the first frame over and over, instead of being a stable animation
Do you have a "Can transition to self" option?
nope, don't see it
fixed duration is also on, maybe if i turn it off it might help
still the same issue
Can I see the frames of the animation in the animation window
Also, what is your exit time set to?
Yea the animation window looks good
Ah, ok I think I see what you want. Probably do want more exit time on it assuming you want like an idle stance
See if increasing the exit time helps yea
alrighty
because you would look funky going back into walking, so you'll need to have a specific fix time for that (you instantly want to jump back into walking animation if the player moves)
but what it looks like is you do need a sliced animation for both the hands and walking
so you can walk and shoot
or have an animation clip of a walk/shoot sprite
ok it's better now, though now my lil guy is stuck in the shooting animation 
likely due to alot of the animations being queued up?
happens around the end, the first few times works as intended
oh yeah that looks pretty good. I guess the shooting animation already incorporates some of the feet
or just fluid enough that it looks like he's walking ;p
yeah the shooting animation is just him bringing his arms up, otherwise it's the same as the walking
Interuption can be the problem here?
Seems to be stuck in the state regardless of the condition
honestly unity's animation tree feels too convoluted for sprite animation lol
yeah its a lil strange
though the interruption source is what seems to make the continuous animation work
if i put it on None then it'll go to walking for a split second and then back to shooting
huh, i think i fixed it by putting it on Next then Current in the interruption
Looping could also create a problem with the interruption (stuff isn't that intuitive)
Is there a way to get some black background color on text? I have a hard time seeing the interface in passthrough when there is too much light
yeah i think Next then Current fixed it
yipee!! thanks a lot
now i have to do this for shooting diagonal left and right too
since i'm recreating Gun Smoke for my class' first portfolio project, where everybody has to recreate at least a snippet of a list of games
neat, good game choice too
Gun Smoke controls are left click = shoot diagonal left, left + right = shoot forward, right = shoot diagonal right
i'll play around with that tomorrow since it's late, thanks a lot again
how do I make a phone or gamepad vibrate with c#?
There seems to be multiple ways but I search a solution that is simple and adjustable, like adjusting the lenght of the vibration.
How to make an "accelerating movement", for example I've got a selector that moves based on player input (Think of a cursor in an TRPG or a UI element)?
How can I make it that on hold, the speed increases gradually till it reaches a limit?
Example: if my map is 32x32 tiles and the player wants to reach the right-most tile, I don't want the player to press right 32 times. Nor do I want them to wait 32x movement time.
A sped-up movement if the button is held makes more sense, but I'm not sure how to tackle it
(I don't need full working code, I'm asking for guidance/pseudo/anything that points me in a working direction)
essentially, this is what I'm going for
isn't this just basic acceleration?
just increase the velocity each time unit
pseudocode:
float velocity;
float tileFloat;
float acceleration;
int currentTile;
void FixedUpdate() {
if (holding) {
velocity += acceleration * Time.deltaTime;
tileFloat += velocity * Time.deltaTime;
currentTile = Mathf.FloorToInt(tileFloat);
}
}```
I see one Code with double. But in the learn pathway most time using float, bool, string, int.
So what is double and when use it? 
double is the same as float just with 64 bits instead of 32 bits
It's more common in "regular" C#, but since Unity uses mostly float in its apis, you will see float a lot more often in Unity.
Thanks, I was able to get something close to what I want with this. I'll tweak it further to fit my needs 🙏🏻
hey, is anyone here sufficiently versed in litmotion?
How can I learn how to code effectively and not just watching tutorials to just copy it down and not actually learning things?
make sure you're understanding the things you're writing. try integrating multiple things into a single mechanic/feature
follow courses/tutorials to learn what exists and how it can be used. try and experiment with the code you're copying, change values and see the outcome. use that knowledge to solve problems, there are many sites that give problems like leetcode. or try to recreate features that you'd want in a game and research what you'd need to learn in order to make this
Thank you, greatly appreciated! @eternal needle @naive pawn
My recommendation is to watch a tutorial on YouTube. To create a basic scene.
And then after the video is done. Delete and modify random lines of code to see what they do.
Adding debug log statement helps to understand the order of execution.
Yesterday I watched a 7 minute long and 18 minute long tutorial on URP and shader graphs. I spent 4 hours struggling with it. I eventually deleted the programs and gave up, and then I found a new tutorial that as 1 minute and 45 seconds long. Within 10 minutes it was working and i understood how it worked.
If the tutorial isn't making sense, try a different one on the same subject
Do you copy/paste or write down every line of code?
Before moving to the next part of a tutorial, ensure you understand every line of code added. If not, look up what method or terms you don't know. Plenty of people copy/paste without knowing what it does. If you can't understand what you have written, you won't understand the help given or how to improve your own code further
When you finish a tutorial, redo it without following along. See if you can retain and replicate what you just learned
Lastly, after you finish, add something to the code yourself. I.e., if you followed a jumping tutorial, try adding two jumps
When stuck, this helps you learn how to search topics to figure out and debug your work
The problem most people have is constantly watching and not attempting (at least you're doing that) . . .
i have a bunch of visible outside mask objects clumped together can i make a bunch of masks each only affecting a single one of them in unity
Wdym?
I have a lot of objects with the setting visible outside mask. I also have a bunch of masks but I want each mask to only affect one of the objects not all of them
Would this work. Weapon is a scriptable object that inherits from Equipment (scriptable object) class. Equipment dosnt have a damageType but Weapon does, will it just return null as the damage type or will it work?
equipment.GetSlot(int) returns an Equipment from an Equipment list
you can do
if(equipment.GetSlot(3) is Weapon weapon)
{
// use weapon here
}
though if you need to manually check the types when using inheritance, it might be a sign you're doing something wrong
and also !code on how to post code properly
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
ok
Hey everyone! I'm trying to implement a feature in my game where when a player puts down a building, the terrain below is painted with a different material. It works but... it absolutely freezes my game for about 2 seconds every time I do it
Is there a better way? I notice when editing the terrain with brushes it doesn't seem to lag at all. Can't I make the same brush painting effect through code?
I use terrainData.GetAlphamaps on the center of the new building:
float[,,] splatmapData = terrainData.GetAlphamaps((int)(centerPoint.x * 2 - rads / 2), (int)(centerPoint.z * 2 - rads / 2), rads, rads);
Then set the new pattern and finally apply it to the terrain with:
terrainData.SetAlphamaps((int)(centerPoint.x) * 2 - rads / 2, (int)(centerPoint.z) * 2 - rads / 2, splatmapData);
can i close this or is normal that take many time now? i dont save my scene 
How do you detect navimesh collision?
im trying to knock an enemy back whenever it hits the player, but for some reason the OnCollisionEnter isnt working
The player is using character controller, though I have tried attatching a trigger collider to it, still doesnt trigger OnCollisionEnter though
Hey All,
Just had a quick question in regards to reading values or bools that are meant to be private for security (such as player can move or player is running).
Would this be the best way to read from one script to another whether the player is running or not.
public class PlayerController : NetworkBehaviour
...
private bool isRunning = false;
public bool IsRunning => isRunning; // Public read-only property
Script trying to read the bool to determine another thing...
public class PlayerCamera: NetworkBehaviour
...
bool currentlyRunning = playerController.IsRunning;
I'm worried for security that i cant just set these bools to public. Any info would be greatly appreciated.
Enum could be a better soloution
So like a public enum with the players movement states?
public enum MovementState
{
Idle,
Walking,
Running,
Jumping,
}
ye
Cheers ill have a read into it
Many thanks that will work really well!
How do i code a grapple hook
You can someone help me with this script? It keeps telling me to put a " , " by the parts where it says ...EasyHand LeftHand... https://hastebin.com/share/uzuyuqerox.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Nvm I fixed it
The internet is full of grappling hook tutorials
I dont wanna watch youtube
Just need someone to code it for me instead
Wouldn't that be the same?
Youtube wastes more time
Also i never mentioned youtube
Ok
how much you're offering? realistically, none one is gonna code something free for you, why would they lol
@fading barn I think you are on the wrong server. This one is for people who actually want to learn
This is the type of mentality that gets you back to this server every hour because your code is broken and you lack the experience to fix it
Unlike basically anybody that puts in the effort and figures out how to write code
private void OnTriggerEnter(Collider other)
{
if (other.transform == player) // Ensure it's the player colliding
{
// Apply knockback force
Vector3 knockbackDirection = (transform.position - player.position).normalized; // Direction away from player
m_Rigidbody.isKinematic = false; // Allow physics to affect the Rigidbody during knockback
m_Rigidbody.AddForce(knockbackDirection * knockbackForce, ForceMode.Impulse);
// Temporarily disable movement for the knockback duration
StartCoroutine(ApplyKnockback());
}
}
private IEnumerator ApplyKnockback()
{
m_Agent.velocity = Vector3.zero; // Stop the NavMeshAgent's movement
isKnockedBack = true;
while (m_Rigidbody.linearVelocity.magnitude > 1f) // Continue until velocity is less than 1
{
// Apply knockback resistance to gradually reduce velocity
m_Rigidbody.linearVelocity *= knockbackRes;
yield return null; // Wait for the next frame
}
// Ensure the velocity is completely stopped at the end
m_Rigidbody.linearVelocity = Vector3.zero;
// Re-enable NavMeshAgent to continue movement towards the player
isKnockedBack = false;
m_Rigidbody.isKinematic = true;
}
for some reason after the AddForce is applied, the linearVelocity is still zero
I suspect the problem is the switch from normal rb.velocity to linear, but can't quite figure it out.
this is for a simple navmesh ai system
Isn't rb.velocity deprecated now? You've got linearvelocity and angularvelocity
Either case, I see no logging in your code and that's something so I suggest adding some in when applying the force and disabling the agent
I would also consider not switching between kinematic and force-simulation, pick one and implement everything that way
Problem though is unity's navmesh is sticky and doesn't like physics too much
Then pick kinematic
Yeah, unfortunately that's probably for the best unless you want to pick up A* project
Even then, ai movement and force simulation is, in most situations, quite difficult to get working as intended
kk
so how would I simulate knockback in kinematic?
just apply deceleration and things myself?
and would I set velocity in rb or the agent?
aren't they overriding the force when they assign the velocity to 0?
yes
isnt the navmeshagent velocity and rb velocity seperate
Kinematic means basically that you implement custom physics
They are, but probably conflicting with each other and that's the only thing I'm seeing that could be wrong.. but this is something you should be testing anyway
ah, alr
Ill just make it so everything is in kinematic
so do I have to indivisually change the position every frame by a self set velocity value or can I still get away with using a rb one
You need to update it yourself each physics frame on the rigidbody
ok, last question
can I directly edit the agent's velocity in code, or is it hard set via destination and acceleration?
velocity is its speed. you set it to 0 immediately after applying force to it. you're telling it to stop its movement as a navmesh after you tell its rigidbody to move. regardless of how you move it, you're overriding one movement by setting the other . . .
I've had RB working with navmesh, but like I was saying the agents are sticky to the map, so there's a lot of refining that needs to be done else they will snap onto it if the agent is re-enabled too soon.
actually ill just test and see
-# bad question
Guys I have an idea for game which I want to create. Initially the concept is 3d but my friend suggested to keep it 2d for now. Is it possible to create a game from scratch with no prior knowledge ( I have done unity essentials from official unity learn tho) ? If yes please suggest how should I proceed. I also require some gamers who would like to join me on this project.
Hi. I have a question: How do I return to the original state (what was before the start of the scene, before the player changes). Anyway, he was probably just surprised to see you. How do I cancel the action for 1 step and how do I return everything that was when loading the scene (before our change)?
this is how everyone here started, you want to make something, and you just start somewhere and learn along the way. Ofc it’s possible 🙂
Your first project won’t be perfect though and you will make lots of mistakes but that’s good, it means you are learning
how do i fix this error:
Type or namespace definition, or end-of-file expected
this is my code (im following a guide):
https://pastebin.com/yU8UEAFA
you don't have a class.
you might want to get some fundamentals down if the guide isn't doing a good job at that: !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
(weirdly enough, you do close the non-existant class...)
Not a code question but !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
This is a code channel
I dont see a !learn channel, where is it?
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
click the link
Click on the link shown in the bot message
Hello! I am making a shop for my game and I want to know how to do the scripts for the purchase and then transferring it to the player (not real money, in-game currency) and also how to go back to the game itself with the new items. Appreciate the help!
This is way too broad of a question and the answers to all these things depend heavily on the rest of your game and code.
I have little to no code
Then there's not much to work with here
you'd need an inventory system
some way to track money
A way to specify items
Yes, I know, that's what I want some guidance on
this is the confluence of several systems working together
Could someone help me with why my text is showing up like this? I cannot for the life of me figure out why it's happening. It shows up on scene, but not on the game menu. My font is set to legacy runtime (the only available one), and the text is within the camera
will expand if needed
Using Text (Legacy)
How do I assign gameobjects with a certain tag to a list? Unity is giving me an error when I do that
here's my current code:
public GameObject[] coverPoints;
private void Awake()
{
coverPoints = GameObject.FindWithTag("cover").transform[];
}
Pick one thing at a time.
First off that's an array not a list
second you're using a function that returns ONE object here
This will return an array: https://docs.unity3d.com/ScriptReference/GameObject.FindGameObjectsWithTag.html
and this whole bit: .transform[] is just... that's not a thing, get rid of it.
fixed it, ty
Inspector for the text bc I probably should have just pasted this
well, obligatory: use TextMeshPro.. the legacy Text component is doodoo
heres the two compared
Same issue with both (i think), except tmp has solid text instead of blurred out when on scene
just some generalist advice.. stick to TMPro.. fix that version instead..
soo whats the actual problem?
So I was following a yt tutorial on how to copy remake flappy bird because I don't know how to unity, and I cannot make the text appear for some reason on the game menu
It shows up on the scene, but when I swap over to game its just not there
scene vs game
during runtime press pause.. select the text element in the hiearchy, hover the scene view and press F to focus on it..
im thinking its scaling issues.. but idk
could be just off the side of the screen (if the anchors arent set corrctly)
Scalings are all set to 1
Could also be a layer issue
Nothing's happening
yea, but the UI scaling... is what im talkin about..
the anchors is what i meant might be set wrong
The text isn't inside the canvas
it should focus on the text.. 🤔
ohh that might do it ^
If you are on URP make sure the Ui layer is rendered with your camera and the layer is specified within the forward/deferred renderer
The part marked with red is the bottom left corner of the screen. Move the text inside it
I moved everything inside because I couldn't move the canvas, still not there (i also tried pressing f again, still focused on nothing when I did that)
exactly.. you'll see the white border of where the canvas is..
Take new screenshots
i put it in an arbitrary place in the canvas, just wanted to make sure it was visible that it was
ur actual canvas is gonna be MUCH MUCH bigger than ur play area..
ur lookin at the camera bounds.. not the UI bounds
It's in the game view now... very small, white on cyan
Oh I missed that
So should I scale up the other things to match the canvas?
bros got hawk vision
I couldn't see it for a moment after it was circled ;-;
You should change the font size to what you want it to be
the canvas isn't really tied into the camera view
dont try to make them overlap.. they dont really work like that..
the canvas is just off to the side.. it gets rendered over ur game.
Yeah the only thing that you should change is the text. Nothing else has anything to do with the canvas
that would have been nice to know like 6 hours ago :D
No site I could find on google said this
😅
i can actually see text now, tysm
I'm now gonna go find a way to break something else entirely unrelated to this, have a good day
heres a visual
no matter where my player is moving around.. the canvas stays at the same point on the screen
the only exception to this is World Space canvases.. those will be in the world isntead of off to the side
How can i disable PhysX errors from displaying in the console? Would catching them still keep the Mesh Colliders i add in the try?
Why do you get PhysX errors? What kind of errors?
Some MeshCollider Errors about too Many smooth Surfaces, although they dont affect gameplay. It would just be nice to remove them
Generally errors are no good, you shouldn't try to hide them but fix the underlying issue
There are no issues though
Well, there's an error and something must be causing the error
Well errors dont disappear once you fix them, Since this error happens in runtime.
Why are we fixing errors when they already appear and not try to prevent them in the first place? Would also help to know what errors where are talking about exactly
Well i cant prevent it im quite sure, this is whats causing the error: cs MeshCollider mc = c.gameObject.AddComponent<MeshCollider>(); mc.sharedMesh = c.gameObject.GetComponent<MeshFilter>().mesh; mc.convex = true; mc.inflateMesh = true; mc.skinWidth = 0.52f;
What exactly? Is there a specific reason to add the collider manually and not using prefabs for example?
Use a less complicated mesh
Im making a Plugin System and ive made some functions to add in Obj Models at Runtime. So i cant add them manually.
But what exactly is causing the error? exceeding convex mesh collider triangle limit?
These are the Errors:
.skinWidth and .inflateMesh have been obsolete for a while so I don't think you should touch those to try to fix the errors if that's why you have those
Well isnt there anything else i could really do?
Anyways convex mesh colliders can be made of at most 255 polygons. It seems like your mesh is more complex?
I guess so
But that's a limit. Can you reduce the poly count to satisfy the requirement?
well i can yeah, but the thing is that its a plugin system where people can load their own obj files. And i cant use Non-Convex mesh Collider's because the GameObject has a Rigidbody attached to it.
What sort of meshes are these? Any type imaginable or some specific category?
Hold on, im going to quickly inspect the mesh i used for testing
Well this is the Mesh im testing
wheres undo button
Theres no Button, But Ctrl + Z should do it.
Ctrl + Z
this is a code channel, keep general questions to #💻┃unity-talk
Well that's more than 255 triangles. It would be possible to split it up into smaller meshes or use compound colliders but neither is likely easy through code to an arbitrary meshes
Alright, well thanks for helping!
Unity apparently does at least try to simplify the mesh into convex hull (that's why it works still) but it may throw an error regardless. You could try to catch the error but catching errors is not really great for performance and it also isn't really a good coding practise to write code that causes errors, errors should be something implicating a failure in the code, not a tool for flow control. I'm not sure catching would even prevent the error message since the mesh collider stuff likely happens on the C++ side of the engine, not sure
Alright
@lunar hollow Btw. what kind of meshes are these? Is this a plugin for any kind of meshes the user may want or is it more specifically for certain type of objects like characters, vehicles etc.?
Nothing Specific, it can be anything Since the game is a Sandbox.
hey guys i juste downloaded unity so i don't know anything about it but do you know why all my materials are pink
sorry for my bad english btw
If I had to guess, what unity does to simplify the meshes anyways is likely it just throws away enough vertices and generates the convex hull out of it, something of that nature. You could do something similar yourself to generate a separate mesh for the collider
Alright
don't come in a code channel asking a non-question you've already asked in another (do not cross post and use the correct channels -> #💻┃unity-talk for this one)
how do i open this?
!ide 👇
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
clearly wrong
might need a bit of urgent help with this but my external drive with visual studio stopped working, the E drive doesnt exist anymore yet visual studio wants to install to this drive
how do I un-grey this box
how is that a coding question
then you are totally fucked
i cant find that so i clicked that app
it tells me to download stuff
i only know what python is
scroll down..
and they are rly large
I cannot get my character to move left or right here is the code for my player
there should be Unity Developer
You have to select "game development for Unity"
something something
ok
A couple of ways to configure Visual Studio and Unity.
- You already have Visual Studio : 0:25
- You need to download Visual Studio,
- through the Unity Hub : 2:09
- through Visual Studio's Homepage : 2:49
Visual Studio Download Page :
https://visualstudio.microsoft.com/downloads/
If you also, hopefully, want to use .NET, which is "normal C# without Unity", you should also select it. Just a few gigabytes more
timestamped at where your at
it seems like you are overriding your velocity use Debug.Logs inside the if statement,. also make sure the offScreen is what you want , check the state of it.
and you better use Axis instead KeyCode (keys)
Unity doesn't support covariant return type in script, but does it support dll that use covariant return type ?
For example, if i import a dll with covariant return type, will it throw error in unity
I've done some covariance, so yes you can do much of it in Unity besides serialization of it all
as for the dll problem, I'm not too sure
Off screen is set as false at the start and I realize now that there is a problem with it but I do not know where it went wrong
Which covariance you meant ? the documentation says covariant return type is unsupported features
Want to link me to said documentation? The only thing you can't do like I've mentioned is serialize covariant types as it's too ambiguous for the editor without the support of serialized references.
otherwise you handle it like basic c# scripting
here is the code for the bool and it only changes under the condition if the x position is larger than the screen width
Ah, ok so I think what it means is without type control from generics that this isn't possible.
you need some constraint I believe
it support generic but not covariant return type, it is two different thing
!ide
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
Unity 7 (or around that time) we're probably getting .net updates so at the moment, you'll probably have to stick with the generic constraints if you do want some pseudo type covariance
i doubt. In the forum unity staff said that there is no ETA yet, so very likely it wont make it to unity 7
Yeah, don't quote me on that. Just wishful thinking here ;)
Maybe the beta start in/before unity 7, but i doubt it will be released in unity 7
i have different cities i want it so thats its buildable in each city and if u upgrade one city it doesnt upgrade in others i know what im doing is wrong but is there a way to do something like this
When I reset my scene, my gun reload coroutine does not run and gives this error. It is not a root gameobject so DontDestroyOnLoad does not work.
The object of type 'Gun' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
How can I fix this?
don't use whateverObjectDestroyedGun.Method(); or .Parameter = 0; after calling :
Destroy(whateverObjectDestroyedGun);
Reset the coroutine maybe ? By restarting it
and if u do.. do
if(whateverObjectDestroyedGun != null)
{
// use it
whateverObjectDestroyedGun.DoThing();
}```
If the coroutine belongs to a destroyed object, you need to stop it before the object is destroyed.
private void OnDestroy()
{
if (reloadCoroutine != null)
{
StopCoroutine(reloadCoroutine);
reloadCoroutine = null;
}
}```
```cs
public void Reload()
{
if (reloadCoroutine == null)
reloadCoroutine = StartCoroutine(ReloadCoroutine());
}
private IEnumerator ReloadCoroutine()
{
Debug.Log("Reloading...");
yield return new WaitForSeconds(2);
Debug.Log("Reload complete!");
reloadCoroutine = null;
}```