#💻┃code-beginner
1 messages · Page 741 of 1
I don't see why the genre matters.
grounded enemies, going left and right.. why would they need path finding?
fair enough
all i would need to make them do is jump at walls or ledges
that's if i even want them to jump
hollow knight got away with it, right?
no idea
hollow knight enemies are very stupid outside of the bosses and big enemies
some of them just kinda walk or run at you
not much else
some of them don't even do that, they just act like mario enemies
i'll get on with aron's a* for now then
since flying enemies need to actually know what the hell they're doing
I was never this hopeless, I had push notifications but now it no longer works and I still don't know why... In logcat it throws java internal error and then it hangs. I tried to re-upload google-services.json and checked settings several times but still nothing
i presume this is firebase?
Unity Push notifications package, and yeah, it is powered by firebase
These are 2 different things
the unity package lets you schedule notifications locally, firebase lets you push notifications over the internet
That's mobile notifications package, something different
Oh the unity cloud one?
Yes
strange, why do they do it via firebase when you can just use firebase for this to begin with...
Make sure that external dep manager is working correctly and if using proguard then you need custom user rules to prevent issues
I checked it, force resolved it and in building process it didn't throw any errors
Whats the error it gives?
Let me check
if i'm making a grid graph for a roguelike game with multiple rooms like tboi, should i have the grid encompass the whole area where rooms could possibly generate or should i change the grid based on where my rooms are located during generation?
i feel like the former would be far easier but the latter would possibly be more useful
tough call then
i like my grids to extend out into the fog of war
but its just all about what u plan for ur game.. make it easier on urself if u can
alright
i think my rooms should be generated as units on a 6x6 grid so i should just be able to multiply out for the width i want
but i haven't even gotten to generation yet so i could just make sure i know what i'm doing with the one room
Here. 2025.09.27 16:10:07.257 6261 6362 Error Unity at com.unity.androidnotifications.UnityNotificationManager.initialize(UnityNotificationManager.java:106)
How unhelpful 😂
Wait, that was not full, sorry. ```2025.09.27 16:10:07.257 6261 6362 Error Unity at com.unity.androidnotifications.UnityNotificationManager.initialize(UnityNotificationManager.java:106)
2025.09.27 16:10:07.257 6261 6362 Error Unity at com.unity.androidnotifications.UnityNotificationManager.getNotificationManagerImpl(UnityNotificationManager.java:129)
2025.09.27 16:10:07.257 6261 6362 Error Unity at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
2025.09.27 16:10:07.257 6261 6362 Error Unity at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (System.IntPtr clazz, System.IntPtr methodID, System.Span`1[T] args) [0x00000] in <00000000000000000000000000000000>:0
2025.09.27 16:10:07.257 6261 6362 Error Unity at UnityEngine.AndroidJavaObject._CallStatic[ReturnType] (System.IntPtr methodID, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0
2025.09.27 16:10:07.257 6261 6362 Error Unity at Unity.Notifications.Android.AndroidNotificationCenter.Initialize () [0x00000] in <00000000000000000000000000000000>:0
2025.09.27 16:10:07.257 6261 6362 Error Unity at Unity.Notifications
Maybe this is a class not found issue but the error doesn't really say anything specific
Yeah, it's a logcat error
So I also don't know where the issue is
I tried lowering the version from 4.0.2 to 4.0.1, we will see what happens now
Sorry if this is the inckrrect tab to place this but Im working on a horde AI system but im pretty unskilled and unknowledgable in the grand scheme of game design. Is there any AI experts willing to DM me to go over what ive built? I want to know if what i have is original and feasible or if I just rediscovered old tech that isn't used for some reason. Currently, in my unoptimized state, I can have 200 capsule enemies on the map and fully active with a dip to 45fps. None of them have a behavior tree or a FSM on them. I think its a clever system but I am very far from an expert. Barely even a hobbyist. I just want to know if what I have is worth pursuing before I push to optimize it and try to make it better.
do you normally have the nav grid nodes on the corners of tiles in tilemaps or in the middle? i'm not sure which one i would need for what i want
nah i typically just grab the vector of the tile
oh
i dont actually use th tilemap system so anything related to that im unsure of sorry
i don't know how to do that, i've only just started using aron granberg's a* solution
It's a weird question but is it ok to use chatgpt for making unity scripts? Or should I code everything myself. As long as I know what scripts are doing is it ok for me to use LLMs to generate code to speed up development process as a solo developer. Or is chatgpt bad for optimized code/ steals code from open source projects so is wrong to use?
i wouldn't, personally
it's bad
learning the code for yourself is both far more satisfying and lets you do far more later on
its great as as tool..
i wouldn't have it generate code for u tho
skipping out on that for what boils down to something that googles simple solutions to what it thinks you're trying to do isn't a good idea
use it to brainstorm..
learn of concepts and terminology
maybe have it refactor ur own code..
but i wouldnt trust its hallucinations
Use AI to learn, and develop your own skills
besides, if it gets anything wrong then it would probably just self destruct
its a snowball
1 little bity mistake will just get worse and worse unless u hold its hand
If you're going to need to learn the things well enough to fact check it why not just cut out the middleman and use that knowledge to just make it correct without consulting the spam oracle?
if u learn how a chatbot actually works its almost incredible it can build any script
I know how to code but like I know gameobjects are made of components and I can add components make custom components and manipulate components and gameobjects but for eg I am building a flight sim I have not studied physics and on my own would end up copy pasting a tutorial or open source code so instead should I use chatgpt as it can give me more personalized results
If you're intending to make a flight sim you're gonna need to learn the physics
there's not really a way around that
Or at least hire someone who knows the physics
chatgpt can be used as a tool to learn, but never to do in this case
https://www.youtube.com/watch?v=exf8TkLLMPA
https://github.com/gasgiant/Aircraft-Physics/tree/master
check this out if u wanna build a flight sim
Nobody actually copies open-source codes and it works instantly
its a really cool project to look thru and see how hes doing it
Using ai generated code and tweaking variables to costomize it wouldn't be enough
- How would you know the generated code is right
- How would you know what needs to be tweaked
You're gonna need the knowledge at some point
u might get it to build a simple arcade aircraft sim but thats about it unless u micromanage it extensively lol
Your name is reversed cool haven't seen that a lot
umopapisdn
There is a better way, buy a flight sim license from the store
Technically just the engine, if u want to skip the hard part
Nothing is free
Asset store?
Yes
Wdym license isn't asset store item called an asset
Are you referring to any specific asset?
What does that even mean
As am I
U should also study copyright law if u want to pulish ur games
Just the surface stuff
upsidedown
umopapsidn
So u don't get in trouble
Ohhh now I get it
for copyright stuff just pay attention to the Licensing you have for the assets
if it doesn't have a license don't use it.. just to be safe simple as that
Yeah I need to learn that like how to make something generic like a car that is inspired in design from a real world car but isn't a direct copy and looks different. For eg cars in gta games. How do I make it in a way that I wouldn't get sued from the car manufacturer
Infernus car in gta looks like Lamborghini for eg but doesn't infringe copyright for eg
don't make any money 😉
a. they only care if u start making money
b. or, you somehow tarnish their brand / hurt their sales
all about that money 🤑
For instance, u can simply not put the logo of the brand in the model. They would likely notice the similarity but they probably don't care, except Nintendo
but yea that would be something u should look up if ur making a car game..
and any of ur models have a "Likeness" to popular car brands
something to watch out for 👀
Imagine having real cars in gta and being able to shoot rpg on them
is anyone here experienced with using aron granberg's a* project
the beginner's guide is telling me to use "Follower Entity" but it's just not there
ive experienced it as in checking out its example scenes
search for it in the project window..
it may not show up in the Add Component menu if its in a namespace for example
would be like Pathfinding.FollowerEntity
the docs aren't telling me the actual name
idk what i'm looking at
if its called Follower Entity that'd be the class and filename as well
use Pathfinding when u look for it
Class documentation for FollowerEntity: Movement script that uses ECS.
last i checked they're all inside that namespace
using Pathfinding;
this is what i'm looking at
ohh are u using ECS?
i think so?
i haven't seen any prompt telling me to install it yet
so i just assume it's installed already
ohh, im not familiar with it..
throws me off a bit
i don't know much about it but i can install it and see if i can find it.. until someone else helps..
.. ¯_(ツ)_/¯
it's saying this, i tried looking for ecs in the package manager window but i didn't find anything
#🤖┃ai-navigation maybe guys over here would know more about it
Is ecs only useful in games that have huge amounts of gameobjects to manage
thank you
ya, i think thats the reason to use it
Would a walking sim benefit from ecs
from what little i know
You do not need to know anything about ECS to be able to use it.
doubtful
but then again no clue lol
What?
he was talkin to Robaster i believe
that is in regards to the follower entity component. it says that right on the page that was linked
What is lacking in built in unity navigation that made you use an external package
2d
idk how to make unity navigation work
they are using 2d which navmesh does not natively support
i've never really used it before
Does 2d pathfinding even exist in unity?
i'm a he
i just have my pronouns set to that on discord bc i'm dumb
They/them
don't ask me
i hardly know anything
there is nothing built in for it, no.
Tell us what u are to do and may be we can offer a simpler solution
Doubt
:|
if the issue is that the component does not exist when you try to add it, it's likely because you are using the free version but that component is only available in the full, paid, version
if that was the case i'd have thought it would specify in the guide
it did for the graphs
is there a method in unity that returns an array of GameObjects within a certain radius if they have a certain layer?
physics queries like OverlapSphere/Circle?
Thank you
OverlapSphere exactly what I was looking for
Is there a way to make world space ui more convex? Like for an old CRT screen
Render it to a render texture, slap that render texture on a mesh and you can make it whatever shape you want.
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/RenderTexture.html
I'm trying to cook up a Half-Life 1 styled FPS game and need a little help with the weapons system. You can pick guns up, they all fire, and do important gun stuff. Only problem is my method of equipping different guns involves and int to simply activate/deactivate children of my weapon manager. If the weapons are picked up in a different order, the key binds / selection order changes.
Is there a good way to assign each weapon a dedicated int so it's always in the same slot (Lists, Arrays, Etc)?
(Or give it a dedicated child position in the manager)
I cant find out why or how to get IInteractable called from a raycast. much like interacting with an object by looking at it. I have the code and reference here https://paste.ofcode.org/HUSvbVkGzHm3cCxZDn8ZqY
nvmd. LayerMask was private
What is the process to make animations align with other objects?
like is the answer just to play with position and rotation of where the animation is played at until i get it where I want it? that doesn't seem correct
Hello, what is the best way in order to have a clean code, to have a player and some HUD (like health bar or something), going through differents scene (some different levels). I was thinking about DDOL which is kinda mandatory in my opinion, but I wanna know if using singletons is a good practice. (I precise that player and canvas will spawn each time the player start his game, to respawn where he was in the good scene)
in the weapon script, you can make an int and change it for each prefab
Why can I not get this to work, I'm trying to tip something over when it gets hit, and it just ain't working.
I've got a duck, it's a 2d sprite renderer with a rigidbody, and a box collider. The "hit" on the duck is registering fine, but my code to make it tip over essentially makes zero change to it's X rotation.
public void OnHit()
{
rb.isKinematic = false;
rb.angularVelocity = transform.right * Mathf.Deg2Rad * fallSpeed;
With the fallspeed set at 30 (should be 30 degrees per second, so 3 seconds to tip over)
I also tried using the add torque option, and it doesn't seem to do anything either
using singletons in c# in general is bad practice. gets even worse when using unity as it produces untestable code and also breaks hot reload
It will happily spin on other axis if I don't constrain it, so I'm wondering if transform.right is the problem
Okay thanks, so what do u recommend me then ?
I'm developing a metroidvania game, so i think it can be ok to test code easily, because player can spawn where he rested for the last time
If you do not want to use automated unit tests and the hot reload function of the editor a singleton will be ok but really do not see a reason why youd need a singleton for this.
no clue what your on about hot reload wise
and a overwelming majority of anyone coming into this channel is not unit testing
I guess it's when u update a script and u reload while playing mode is active
i know what hot reload is
Yep
i dont know why they think singletons as a concept break it
Then you should know hot reload breaks them
Yeah, but with singletons, when u reload, singleton is passed to null after reloading
so you use a getter that null checks?
yeah but if u need the singleton in the code u're currently writing, it won't work lol
no?
doesn't sound like that would work for behaviour singletons
or you could just stop being lazy and do it right instead of spending more time adding bandaids to fix the problem
or you should know your audience
people are making indie games here
I just asked for a clean structure code for this kind of stuff I wrote guys, chill x)
unity's biggest games use singletons
That doesn't mean its the right way to do something
and your free to hear it! Just providing another opinion
he came in here specifically asking for the right way to do something
dude idk i just asked a question, i didn't expect that at all
I just think mentioning unit testing as a major factor in the context that this is code-beginner is just not really relevant to the extent the comment implies it might be
unit testing is great but like
singletons (both the c# and the unity kind) are not bad practice, singletons are just a pattern
misusing the pattern is bad practice, and some patterns are easy to accidentally misuse - singletons kinda fall into that category
If a patterns only benefit is convienance but it breaks features of the framework youre using it in its a bad practice imo
hot reloading breaks the features of the framework your using it in 😄
also your kinda downplaying the value of that "convenience"
having a single static known reference to the only valid instance of a component/class isn't a "convenience" thing, i'd say
So if i understand well, singletons is not a bad practice, but if we can misuse, can you give me some advice to not fall in misusing the pattern? (sorry if that sentence is bad, i'm not really english 😭 )
if you're not doing dependency injection and you're handling domain reloading (or lack of it), I don't see why the singletons would be bad
well, as russell mentioned, don't use it out of convenience
design the structure and logic flow, and only use the pattern if it makes sense (for example in the situation i mentioned)
They''re brittle and cause hidden dependencies, you can also wind up with stale data in editor because static fields dont reset between runs, they survive scene swaps as well which can be undesired. you cant replace an implementation without editing the callers I could go on and on
You can make a nice cleaner solution with interfaces/scriptable objects that have none of these problems
about your original question, i don't think a singleton really fits in there at all? the player can just manage itself
static fields dont reset between runs
isn't that the point of reloading the domain
they survive scene swaps as well which can be undesired
that is also kinda the point of a singleton
So for example i have my player with a playerhealth script, and a canvas (the entire object will be in DDOL), i can do PlayerHealthUI as a singleton, to call it like PlayerHealthUI.Instance.UpdateUI(healthValue); directly ?
if they're DDOL, why not just maintain a reference to it directly
what benefit is the singleton giving you
what if you want to reference the player from a non DDOL script?
in my case, the player and the canvas is in DDOL
it's not even about referencing the player
so i can reeference directly ?
yeah
oh really, i didn't know that, that's crazy man
and if i load a new scene asynchronoously, it will work ?
like the reference won't disappear ?
yeah, the DDOL stuff is effectively in its own scene
the reference will only disappear if the object is destroyed, and a singleton wont change that either.
i'm just curious
yeah but generally I use singleton only if i can't use references
then a singleton might have a use - depends on the structure of your game
For example, a game manager script can be singleton, because drag a game manager everywhere can be a problem
for example in my project, my structure has "central" stuff in a central scene with a GameManager singleton (where the central scene is kept loaded, like DDOL)
the gamemanager then controls references to important objects like the player and the camera
there's a lot of ways to design it
Oooh i see, that's a nice point of view
And another question (yeah i have many, because i didn't see anything about this when I googled this), is it better to have multiple canvas with some objects in each, like one canvas for HUD, one canvas for pause menu, etc or have one canvas with everything
in terms of structure or performance?
performance, because structure might be quite the same i guess
iirc there's some stuff about dirtying canvases and batched draw calls in terms of performance, i don't really recall which is better
yeah multiple canvases is good for performance, but you can have them all as a child of a parent canvas
because changing something within a canvas dirties everything else in that canvas
i personally have them in separate root canvases just to make it easy to modify them, but that's with my preferred editing style
U mean having one canvas component, and the children of this object are also canvases? i don't understand
your mileage may vary
yeah that's what i meant. you can also keep them separate as chris said cause i dont think it matters
Yeah but having a canvas like this
Object (parent) -> Canvas component
- Object (child 1) -> canvas component
- Object (child 2) -> canvas component
The canvas component on the parent is useless no ?
well keeping them separate actually requires you to set the settings for all of them, but the child canvas will inherit from the parent canvas, so it's easier to keep them all under one canvas i guess
Oh wait the text is really bad with the dots 🙁
just commit to the list!
- parent
- child 1
- child 2
Usually for my health part I wanted to use an event on playerhealth, and playerhealthUI listens to it on OnEnable() method , and unsubscribe from it on OnDisable() method. However, i don't think if it can works with DDOL
why not
Object 1 (canvas component)
- object 2
- object 3
- object 4 (canvas component)
- object 5
for example this works too
if object 4 has lots of stuff happening and you dont want to dirty the other objects whenever object 4's children change
I've already seen some OnEnable() not working due to script order or some stuff like that
so since this problem i'm kinda not using those two methods
that sounds like a misdiagnosis
oh i see okay thanks 😉
OnEnable will be called when an component gets enabled, including as part of its parent object getting activated
oh okay, yeah I was using OnEnable() method with SomeClass.Instance.OnAnCertainEvent += Method
and the instance is not created yet
I did that for the InputController in which i manage all of the inputs, so i put inputcontroller before all the scripts, and that fixed my problem
so OnEnable is working, it's the subscription that isn't
yeah yeah true, i didn't explain correctly mb
if it's a singleton, could you perhaps just make the event static
i don't recall if that's a thing you can do
hi,I'm moving a door by script, a script I've made months ago that worked really well,it's basically rotating a"pivot" parent gameobject of the door that's in a good position, but this time I've simply exported the prefab of the door from a project and imported it into another project and now, when I try to open the door, the door moves,I can go thru, but the mesh doesn't,basically,I don't see the door move, but my player can go through it and collides with the part where the door should be when it's opened
hi again
i think its not really a beginners code question...
but how can i show a object type variable in the inspector?
you're going to have to show the full setup if you expect any practical help
only with custom editor?
you mean like, System.Object?
"object type" is very vague
they're all technically objects..
would you mind explaining the usecase ?
no
What are you intending to actually use for this in the inspector?
not the class one the variable one
What kinds of things are you expecting to set this to?
yeah ok that's the same as System.Object
but no, it's not a serializable type, unity won't serialize it
what aree you trying to do
this sounds like an x/y problem
im doing a custom if else system for nodes on unity
https://xyproblem.info (hence everyone asking why you want this)
you would probably have some base type that you've marked serializable for that, no?
ok, wait
Considering that you'd need an inspector equally capable of referencing "The enemy that's on the left side", "7", "False", and "The vague notion of a burrito", you'd need to have a pretty damned good idea for a UI for this to make a custom inspector
take a second to collect your thoughts first
while taking screenshots of the setup,I figured out they were set as static, it was a dumb question, sorry
im making a date sim.
to make my other teamates lives easyer im also making a custom dialogue system with nodes.
the node system is tied with a scriptable object that have all characters data on it.
so every image, sounds are in this scriptable object and the node system has a quick acess to it, making it more easy to acess...
currently im making the characters savables (idk how to say it) stuffs... like how many times the player gives a flower to a character, if the player has done a X action with the character and so on...
from the idea of the game most of the variables are unique (not all characters have the same variables)... so thats why im making it this way
i was checking on the class insted of the node to see how the class i maded was show in the inspector
and its only displays the variable name
So, what kinds of things do you expect to set "value" to
Like, strings, numbers, etc. or are you going to have to refer to specific game objects
thats why im using object...
idk all the stuffs they want to place
/ store
/ save
from the node itself i can filter it and give it a proper field
You're not going to be able to design a system without first thinking about what kinds of data is going to pass through it
but i wanted a quick display on the inspector as well
So am I understanding you right when I say you have a different script for every character and you want to use object so you can assign any of them to it?
actualy no... but in some ways yes
all npcs have the same class
to dont fuck with the dialogue display
but i needed a independent variable storage
let me give a example
try this
and this goes in editor script folder
https://github.com/rybakatya/Utility/blob/main/Editor/CustomDataDrawer.cs
I think thats what you're looking for
^-^
just put public CustomDataContainer customData; in one of your scripts and check it out in the inspector
https://paste.mod.gg/jrriobfhxcbp/0
I was following a tutorial and came across a section where the guy made some code to make it so when the player hugs a wall and moves diagonally, they actually move (lines 36-60). I followed the code down to everything, but for some reason my charactter isnt moving, the input values and boolean are working but the character wont move, what did I do wrong?
A tool for sharing your source code with the world!
Hi guys I don't know if that's the right channel to ask, but I am really trying hard to build my game but I am so bad at programming, does someone know how I can do a camera which works like the one in genshin impact ? I wouldlike to do a camera like this in my game
look into Cinemachine
you need to start debugging your code
what's with the #regions around your comments btw
And for god's sake don't write comments like this: //we need this method for the setbool code in playerAnimator, whenever it is run, it will return the value of the isWalking variable you're absolutely wasting your time
That's just so I can refer to the code if I ever get stuck and understand it better
How do u mean?
Put in some logs. See what the values of the variables are
debugging is the process of using ddebugging tools such as log statements or a debugger to step through your code and see what's going wrong.
Oh, debug.log, mb, no idea why that confused me
Debug.Log is one technique for debugging, yes. I just mean you need to debug your code in general
Anywhere I can talk about NodeJS and NetCode server handling? It involves a lot of C# Unity too xD
My project it is close. Just missing something and cannot pinpoint the issue.
Would appreciate very much if perhaps someone familiar with backend code could message about it, considering this may not be the correct channel to post in for backend coding.
It just relates a lot with my Unity project.
My issue is basically about NetCode Player synchronisation in Unity clients with NetCode.
Players they just forever go in the same direction from last input!
So one clicks D to move left and X+ forever
Nobody here talks about node stuff.
Ah thanks. Is this strictly C# Unity channel?
Sorry just learning about Discord stuff xD
Make a thread in #1390346492019212368 and see if anyone there can help you with the unity specifics of your issue.
It is strictly about unity. And in unity-land, ‚nobody‘ cares about node. But some have in their previous/other lives, so you may get lucky.
Ty for posting this channel and apologies again! XD
How can I get a canvas Unity to adjust itself to the players screen so that if someone else is playing the game the UI is not all over the place?
Read this to understand the basics of RectTransform layout: https://docs.unity3d.com/2022.3/Documentation//Manual/UIBasicLayout.html
Not a code issue though - next time use #📲┃ui-ux
Why is it sometimes the door/hand animations sync and other times they dont?
var st = anim.GetCurrentAnimatorStateInfo(0);
var nxt = anim.GetNextAnimatorStateInfo(0);
// Ensure we’re in the target state
int activeHash = st.shortNameHash;
float t = st.normalizedTime;
if (inTransition && nxt.shortNameHash == stateHash) { activeHash = nxt.shortNameHash; t = nxt.normalizedTime; }
if (activeHash != stateHash) break; // left the state
// Phase = 0..1 in the current loop
float phase = t - Mathf.Floor(t);
if(phase >= 0.08f)
{
vehicleAnimator.SetInteger("doorIDX", vehicle.entranceData[idx].index);
}
if(phase >= 0.55f)
{
vehicleAnimator.SetInteger("doorIDX", -1);
}
This looks like the kind of thing you should be usinbg animation events for
Not really an option with my current setup. The code that is applying the animation is in an abstract class and unity doesn't let you apply an animation event to a method in an abstract class
unity doesn't let you apply an animation event to a method in an abstract class
Um what? This is an artificuial limitation if I've ever seen one.
At worst you have a glue script that calls the abstract method
it can absolutely be done with an animation event
It can but its going to be a pain in the ass. Is there a reason why my current code is providing inconsistent results? almost seems like its framerate dependant or something which doesn't seem correct cause all the code is doing is playing an animation on a different animator when the currentAnimation is at a certain time.
yes of course it's framerate dependent
you're trying to do things at specific points/times in the animation
but that's just not how frames work
this is precisely what animation events are for
the other thing is there's nowhere here that you're passing the "phase" into the other animation
you're just starting it fresh whenever you see it
and since Unity doesn't have a fixed framerate, that's going to be at different points in the animation each time
you would need to pass in the actual animation progress and match it on the other animator
All phase is is the current percentage the animation is at. in 0-1 range. Im confused why the other animation would need that info. I am just trying to play an animation when the current one is 8% complete, and then another when its 55% complete.
var st = anim.GetCurrentAnimatorStateInfo(0);
float t = st.normalizedTime;
float phase = t - Mathf.Floor(t);
I guess that is why I am surprised its framerate dependant
because its going off percentage completed not time.
oh wait I understand now. If animation is running at 30fps and its a 60 frame animation it will take 1 second to complete at 60 fps so the percentage complete is going to be wrong cause its using normalizedTime to calculate it.
I am new to Unity and I am working on a program for school where I need to add UI that appears on the camera view and shows the buttons for movement, could anyone help me with this? I cannot find any tutorial for it online, although i may not be searching the right thing. Thank you!
If you're looking for someone to work with you, try collab
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
because your frame is not going to happen at exactly those points
it's going to happen at a random point between them
so you will need to fast forward or rewind the other animation to sync with the point the animation is actually at when your frame happens
If you're needing help with something specifically, post the necessary information and question in one of the appropriate channels
Yep this suggestion fixed it
Thank you
for some reason when i walk on a slope it slows me down but i can still go up them. when i walk up terraign thats high it stops me. Is there any way to make the slopes be treated like flat ground. the tutorial i followed had the guy go up slopes just fine and i have everything he has applied https://pastebin.com/NVf7eMiC
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Is this a bug? idk why i cant enter anything into this scriptable objects char variable. Why will it let me to everything else but this one char entry?
Are you able to convert them from char to string and enter data that way? Also why is there a bunch of variables on 1 line in one of your scripts, is this AI generated code?
i changed it to a string and it seemed to fix things. Idk why it works in the last script im pulling it from but not in this one. weird
its not ai, handwritten. Im converting my project to Unity 6.2 and also upgrading some stuff and pulling it over is a bit difficult
It would be easier if each variable had a line, it may be a bug with char but odd if it is... If it works as a string and you are happy going forwards with that then do so. However if it's literally just for selecting states IE is state a do X then enum, that's what it's there for.
As for converting.. unless you went from pre 2022 to 6.2... a lot of your code should be fine
this just looks like a unity bug, you should report it and maybe itll get fixed later. theres nothing wrong with the code unless you're using some custom editor logic thats clearing these values (which id imagine you remember writing if so)
it doesnt matter if its on one line, its the same. its just not a commonly used way of declaring variables but has been valid for a long time and in other languages too
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/declarations
You can declare multiple variables of the same type in one statement, as the following example shows:
string greeting;
int a, b, c;
List<double> xs;
trying it myself it also is a bug in 6.1 so its been there for a few months at least
I agree it doesn't matter, but for bug fixing and changing your code. It's easier if it's not and that's what I was saying.
<@&502884371011731486> spam
yea I never use it either, i get what you're saying
i dont see any posts online about this bug either so it really is worth reporting too
It seems an odd bug.. can they be attributed in the code itself and then show up in UI or as a debug log? Or is it just UI bug?
you can still assign the value in code yes. It seems that also allows you to change the value to another char but not actually remove the value (cant go from 'a' to ''). Anyways its up to unity to solve if they are merciful enough
im also making a bug report
If you can, don't forget the how to replicate part.. as obvious as it seems.. I work with buggy software daily and wish they had bug report features that allowed it
hey, need some help with UI. i'm getting a null pointer with "object reference not set to an instance of an object." narrowed the issue down to the following lines of code:
Text startText = startMenu.GetComponent<Text>(); //also tried GetComponentInChild
startText.text = "text";
where startMenu is just
public GameObject startMenu;
my goal is just to get access to the text object in here to edit it. what's wrong with the way i'm trying to assign it? getcomponentinchild is what most people are suggesting to use to pull a child out from what i can tell
something is null and you are trying to do something with this null object. your error messages will clearly tell you which line it is. If its the first line, then startMenu is null. If its the 2nd, then startText is null because theres no object of type Text on your game object
unless you're using legacy text, that should likely be a text mesh pro component
oh it's startText, sorry for not specifying
oh wow i just really did not comprehend text and textmeshpro were entirely separate from eachother 😭 thank you so much
okay nevermind it didn't fix anything
my bad on that one, i think i may have implemented it wrong but i do think it probably has something to do with this
TextMeshPro startText = startMenu.GetComponentInChildren<TextMeshPro>();
``` is what i changed it to
TMP_Text
thank you both so much it's 100% working now
You can also just have [SerializeField] private TMP_Text startText; and drag the text element there so you don't need GetComponent at all
oh yeah this is fair, main reason i wanted to do this way is because i have a handful of different menus, and they will each have a lot of text that will need to be changed within them from this script. i would need to drag every individual objs in
unsure if this is the most efficient way to change the GUI and i would likely alter my approach if I needed this for anything larger scale, but GetComponents is saving my life atm
im dumb
how to check if a cube and a sphere touches eachother
i put the script on the cube
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Basketball"))
{
//Reset the basketball position
GameObject basketball = GameObject.Find("Basketball");
basketball.GetComponent<Rigidbody>().useGravity = false;
basketball.GetComponent<Rigidbody>().velocity = Vector3.zero;
basketball.transform.position = new Vector3(0, 1, 0);
//Reset Score
Bounce.score = 0;
GameObject.Find("ScoreText").GetComponent<TMPro.TextMeshProUGUI>().text = "Score: " + Bounce.score;
}
}
void Update()
{
OnTriggerEnter(GetComponent<Collider>());
}
is this dumb chat
for graphics api you can render submeshes with different matrices is there a way to do that for mesh renderer or would i have to seperate the submesh to its own gameobject
if it's supposed to be colliding with the basketball, why not just use other.gameObject/other.attachedBody instead of the Find
because i dont understand this shit engine
you also don't need that OnTriggerEnter call in Update. that's not how messages work
is that supposed to be a deflection, or...
perhaps step back and take some time to get that understanding first, then
Question, not sure if this is the correct place. I'm having trouble to wrap my head around a good/practical way of implementing a cutscene. Just to sketch the situation. There are 3 phases
- Intro - Includes flickering of lights and spawns an NPC
- Dialog - The player is shown text and needs to confirm to continue
- Ending - npc goes away and a menu appears
How would you approach this?
Edit: I've looked at using a big timeline for all the phases with a pause or time machine (austin 2017 - A Terrible Kingdom (Scripting for Timeline)), having different timelines for each section or none for the dialog. Doing everything with scrips, etc etc. Kinda lost in the woods 🙈😂
timeline(s) with signals
What tutorial can you recommend for this approach? I'm worried of losing overview if the timeline becomes too divided.
I haven't watched any timeline tutorials for years, so none come to mind. If you haven't touched them before then start with whatever !learn 👇 has
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
You'll want to find newer stuff, I think. Something from 2017 won't have signals - they didn't exist then
Alright, thanks 🙏
Hey can someone help me with my assignment if you’re free
I really don’t understand collision with the coins or collision with the potions
ask about specific issues rather than "help me do my assignment" please
also, https://screenshot.help
How do I get a sound effect to play in the code and how do I update the inventory for each potion. Where do I call update data and game manager
those are gonna be quite specific to what code is already given to you
Wdym
Isn’t that basic stuff
as a start, you can use collision messages to listen for collisions as a whole
for 2d: https://docs.unity3d.com/6000.2/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html
for 3d: https://docs.unity3d.com/6000.2/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html
Thank you
i mean, if you think they are, sure. but there are multiple ways to do them, so which method is appropriate depends on how your project is already structured. it sounds like you've already been given a project with some scaffolding, is that correct?
Yeah we made some prefabs called “potions” but other than that there isn’t any prior information
you don't have a script with an inventory system?
or an existing audiosource, stuff like that?
yeah an audiosource is just a component in unity, why would you get it online lol
Yeah lol I just don’t understand the coding itself I understand where to get an audio source
have you tried googling just something like "how to play sound effect unity"
Yeah I have it’s mostly just the update inventory and calling the update data and game manager that is confusing
you gotta ask more specific questions man
How do I update the inventory for the three prefabs I have
that wholly depends on how the inventory itself works
you aren't really giving us much info to work with
When the player object collides with the potion prefabs it’s supposed to add to the score of how many potions the player has in the UI of the canvas
It’s supposed to start at 0
And whenever the player touches a potion it goes up by 1
so sounds like you have an UpdateData method that is supposed to handle that
Wdym supposed to handle that
How would I type that out
you call UpdateData, the method that it's telling you to call, with the appropriate parameters
i'm not over your shoulder, i'm not psychic lmao. i don't magically know the entire project structure
if you can't figure out how to call a function, there are beginner c# resources pinned in this channel
Does this help?
not really, no.
images of screens are just horrible to look at, code should be shared as text, and this isn't even the context i'd need to help you lmao
you gotta put in some effort into understanding what you need to do, or at least explaining what you actually need help with
im not playing this game of telephone to tell you what you need to pass to a method that you know of
The game manager picture is not loading
That’ll help you with more context
Sorry where I’m at right now I can’t send the code as text
Is it making more sense now?
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
you can use discord in the browser
Why would I do that though
so people want to help you?
its unplesent to read code from a cruddy picture of a screen
No I mean like how does that change my ability to send screenshots
then you SEND CODE AS TEXT
Do someone know why player is unable to contorl vehicle?:
Idk what you mean I dont think there’s any way to send my code from my computer to my phone
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
you can use paste sites
Ok
you can also open discord in browser, as previously mentioned
good lordy, you do it on the same pc 😐
if its not yours then try to use a paste site still
A tool for sharing your source code with the world!
You’re not very patient are you
they are simply asking to be met halfway, vs providing help while the information is provided in the worst way possible
many people ask for help here. the one asking should try to make receiving help easy
Idk what you’re talking about because he didn’t help me with my original problem he told me to use my browser
That was a good response
so code as a screenshot is terrible to read, and even worse in your case where its a picture. Its way easier for others to read and edit it, and talk about it with line numbers on a paste site or as tiny snippets in chat
you should share the full class, not just Update()
Ok
Full codes:
https://paste.mod.gg/lyuranzzghug/0
A tool for sharing your source code with the world!
Yeah that’s true
your inputActions are setup for your player in Start() .. it's not enough to swap the player/vehicle controls components. You need to find out the correct way to swap input actions (ask in #🖱️┃input-system )
Im wondering how can I make or configure lighting on through script?
Im trying to make an impact frame and as for my past developing experience that's how I do it outside unity
"impact frame" ? Like a flash of white ?
If that's the case, you'd be better off doing that with either:
- a white image (UI) that covers the screen and you change the alpha of it. Though this is a cheap, meh way.
- Use post processing for that "impact frame" and lerp the weight from 0->1->0 in whatever timeframe you need
Impact frame is technically a flash of white but it focus some defined effects and focus on the subject
Lemme explain how I do it outside unity
when I want to focus it to an object I make the saturation -1 to make it black and white and make a kinda like fog effect that's black to focus on its surrounding, then optionally highlight the focused Object
You are the one who needs assistance. Why make it difficult to offer any?
Now im asking if you can configure lighting through script hehe
you'll be needing to do this with post processing then, and maybe shaders for the highlighting + other effects - possibly with lighting too
You can configure lighting through code. Your scene lighting won't be what you want, you'd need to have a list of all the lights that will be affected by the impact.
Thanks, really help
I’m not able to take a screenshot rn I said that
I’m not intentionally making it difficult I didn’t think people cared how I sent my work until someone told me since it’s basically the same thing just not completely flat like a screenshot
So then send the code as text in a bin site which is the preferred way anyway
People can't Ctrl+f a screenshot
People can't copy out a screenshot to their own installations to check something in their own setup
One more though,
Lets say I have a script that doesnt inherite something, how do I attach an object or define an object to that? Since there's no variable to pass it through
A class doesn't have to inherit from something to have variables. You'd just access the class as you would any other and have a property or method with parameters to give it the values you need to
An example of a script that doesn't inherit anything:
public class SaveData {
public Vector3 lastPosition;
public float money;
}
You don't attach this to a gameobject. You can reference it in another script like such:
public class SaveManager : MonoBehaviour {
SaveData data;
public void Load() {
// Set data to the data you've saved somewhere.
}
}
Yes,,,
Lets say I wanna get an object in a normal class, not in a MonoBehaviour class
How do I make a reference with that?
does GameObject.Find work the best?
Never use GameObject.Find .. and if it's not a MonoBehaviour (on a gameobject), that wouldn't find it anyway
How would you create this object?
GameObject.Find finds GameObjects
unles the class is like static, you'd need an Instance of it.. usually thats inside a MonoBehaviour or something
depends on the type of design people are doing, very large portions of the game i am on are not using mb's
hmm yea thats true depends on the project and what you're trying to do
but yeah Find is def horrid..don't use that lol
Alr
public class SaveData {
public Vector3 lastPosition;
public float money;
}
public class SaveManager : MonoBehaviour {
public SaveData data;
}
public class PlayerData : MonoBehaviour {
[SerializeField] SaveManager saveManager; // drag your SaveManager in here!
public void Start() {
Debug.Log($"The player has {saveManager.data.money} coins!"
}
}
SaveManager has a reference to SaveData, which doesn't inherit anything. SaveData has money property.
Since you have a reference to SaveManager, you can access the SaveManager's saveData and then access the money from there
I usually have SaveData living on a DataManager singleton or something most times
so i just do DataManager.Instance.SaveData
hmm yeah so like [SerializeField] is your best bet usually, unless you need cross-scene or runtime references
I mean im just trynna do OOP for absolutely everything but what im thinking now is making new Class with a variable/argument we need for it to work
I guess this knowledge isnt that big of a deal so you guys can rest now lol
that would technically be saveManager.data.money
yes
I mean yk them
Var var = new Var()
Yeah
this is how you create a new Instance of a Poco yes
Yep so im right? good thing my Java and C++ Knowledge are helping me with ts
Does that work the same?
c# is basically Java
Yea
*improved java (arguably)
public class Class
{
Class()
{
}
}
Does it also work this way?
i would say greatly improved java
sure but you dont need to specifiy constructor if you're not doing nothing inside
like java did not even have value types outside of primitives for a long long time
Yeah ik im just trynna see if technically thts the same structure
Appreciate you guys for helpin me lol
speaking of value types, you also have struct you can use instead of class
But they have magnificently long namespace names available to crush any line length limit!
its debatable on benefits but I usually prefer struct over class when dealing with just value types contained
also its more efficient / a requirement sometimes for net..
look its jsut a sign your display is not wide enough
well would depend on how its passed and mutated
Considering that I only knew a fraction of whole C family this is good to know
C# is not really part of the C/C++ family
Really?
its Microsoft Java
i mean it kinda depends on how broad you're thinking
ya lots of things in software is 
i' just so used to certain frameworks that prefer structs
(netcode in unity doesnt let you use classes for NetworkVariables / INetworkSerializable for example )
Ive cursed Microsoft a couple thousand times
syntactically, the c/c++ family encompasses c#, java, js too
by that def more then half of all langauges are C family
that is like C or Lisp that would cover everything
Hello, I am new at Unity. Does anyone know why I can't set tilemap's tile anchor values? I cannot add a new layer because of this.
mp4 to embed in discord
please convert to mp4
also this is a code channel
Python is made in C, is it technically at C descendants lol?
#🖼️┃2d-tools . #💻┃unity-talk @ancient quail
you can basically write stuff in java and itll be valid c# a lot of the time. The real differences will be smaller details like in how comparing strings work for example
right, and it's useful when talking about syntax, but not for say, ecosystems
different definitions have different uses
we splittin atoms here
i was just mentioning since its not a superset like C++ and works on very different principals and is managed unlike actaul C and C++
also syntactically there'd also be the if..then and if : groups
yeah im not saying it isn't like that, just saying "c family" is an ambiguous term that can mean a few different things
all I know its a pain in the ass sometimes working with Marshalling and Goddamn C/C++ structs to c# structs 😵💫
...embedded systems..
Ahh at the end of the day it all just convert it to binary
lol you have not done that in Java, C#'s version of that is like worse then like C/C++, Zig and Go but way easier then like Java and Python
Yeah I admit I never touched Java like that so I'll take your word on it and count my blessing, still sometimes you're rippin hairs wondering why the hell I have to learn about how certain hardware deals with incoming data "offset" and things that affect the final data
"oh yeah my value for xPos is now 128328123" wtf
well because systems are 64bit not 8bit
The first programmer was a woman prolly why we're all debating what is on or what is with lol ( no offense for all woman out there dont unalive me)
Peace be with yall, imma go out with ma baddie
yeah and apparently even how macs and windows process them differently too.. all my data was getting different results on my win vs mac machine
Lets convert to punch cards again!
Where bugs are physical and the world was better
sounds.. fun
let me guess, endianness also reared its ugly face lol
ah yea i think that was the keyword I think "endianness"
assuming endianness you ran into
now you somewhat know my pain 
oh my god i just realized 
i have ported older games to new engines before, so had to get all the old file types working
damn that's way off topic, not sure i can adequately summarize it avoiding a tangent lmao
I bet it was joyous wasnt it...
i once wrote a solution to a competitive programming thing and i used a char[] representing 48-bit numbers (32 bit had overflow, 64 bit used too much memory)
im just now realizing i couldve just used an array of a struct of 3 chars and that wouldntve used extra memory for alignment and i couldve had a method to read out 64bit values for math easily
it always starts out slow with a lot of wtf's but you get used to it and a rhythm after a few days, any time i done porting or backwards engineering stuff
true. luckily for this one project just dealing with some minor data transfer , I ended up learning a lot though.. made things simpler and ended up just using json for this one project since it was esp32 so it was easy to find a json serializer for it lol
in case they plan on using that data into another backend / front end like javascript
I followed unity guide, but use Rider instead of visual studio. I have tried to add project Class Library inside unity project Solution, but it disabled in Solution view. Also it inform me that it deleted project, why?
dont bother modifying vs/rider/whatever projects because they are generated by the unity editor so any change will be lost
and they have no affect on code compilation
all that matters for the source generator is the DLL you produce
use a separate C# project for developing the source generator and use it to export the DLL
Any clue why VSCode makes use of ripgrep when tabbing back into unity?
Its maxxing out my cpu causing the editor play to take about 20-30 seconds. Closing vscode makes it almost instant
I've disabled all the AI features, and use of symlinks.
This project is fairly large but I've had no performance issues until recently
Iteration time is way too slow now
that is indeed the case
Should I switch to Rider?
I'm running short on time, tired of updates making tools unusuable
Rider and VS are "better" than VSC.
Rider isn't free though.
well, it is if you're using it for non-commercial or open source work
doesnt hurt to try.. I'm using VSC but have no such problems, are you sure its not some extension you got thats causing issues
ya VSC C# Devkit and VS both have the same license.. but at least you can do commercially.. until you need to use the enterprise edition
I’m using the suggested C#/Unity/Devkit by itself, no other extensions
Big cpu spikes on processes relating to ripgrep.exe every time I tab from vsc back to the editor
ohh then thats..weirdd.. if it helps I havent updated c# extension since like May
I’ve turned off background analysis which seemed to lower the general cpu usage, but not these spikes
Idk if it’s the “hot reload” settings in c# dev kit
sounds more of Windows issue.. I search ripgrep.exe some old from 2022 VSC forum posts also come up..
idk about devkit itself cause latest causes me no issue but, I use this old version of c# maybe you can try rolling back and see if there are no issues
hey what can cause my OnTriggerEnter not to get called?
thanks it works now
Rider is only free for non-commercial use
keep that in mind b4 swapping over
hi
this is a channel for help with code. Im not sure if this question is even relevant to this server.. if it is delete from here and ask in #💻┃unity-talk
ok sorry
Hi guys, im from italy and i have some questions to do to someone who knows about netcode and how to do a multiplayer game.
Just have some questions about it and i absolutely dont want to disturb anyone, if someone want to help me, please dm me
|| (idk if i can ask this thing here, tell me if im wrong or something else) ||
Also it's a good idea to just ask the questions instead of looking for one-on-one support
yeah i know that, but i wanted to have a conversation with someone about it
Hi, I have just begun learning Unity, I was writing the scipt and an error CS0103 showed up. It said the name "spawnPipe" does not exist in the current content, but the name is literally established below this. Why is that?
You have a function in your function
It's contained within your Update method, so nothing outside the Update method can reach it
SpawnPipe exists only inside of Update.
what does that mean?
hmm how do I fix that?
you put a function inside a function
Chances are, you don't want to do that
Move SpawnPipe() outside of Update(), right now it's within its enclosing brackets

yayyyy its workingggg :0
hm the tutorial did it the previous way, so that was confusing
Hello everyone. I have a good idea for a 2D game, I think. But I don't have any experience creating it. There are only a couple of artists.
If anyone is interested in creating my idea, you can message me. I don't speak English.****
you sure?
Thx guys! Also, since im still grasping the basics, the words in the script r sometimes colour-coded in yellow, green or blue. What do those represent?
!collab 👇
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
Yea 👀
the exact colors different depending on your editor and theme, but its just to help you tell things apart. makes it easy to tell whats a comment or a string or a keyword etc
ooohhhhh i see it now, it's so hard to catch XD
man, coding for the first time makes me feel dumb lol
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 193
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2025-10-02
it does not come natural to anyone, and is a lot of information to learn upfront
it gets easier once you been at it for a while
192 other people have made similar mistakes, and those are just the ones I've noticed
(yes this is a real counter)
hey folks, can yall help me a fix somethin, shouldnt take too long
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
I have this weird glitch where I built an interaction system, but it would only register from one side of every object
did you end up configuring your IDE yet? because if so i can tell you what your issue was
I think so
show it
how do I check
screenshot your entire vs code window
trying to edit the unity starter third person template to work with root motion jumps what's the best way tot do this I can figure it out for the life of me need the character controller to attach the player when jumping or something https://pastebin.com/6JCw1Rms
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
still not configured. https://unity.huh.how/ide-configuration/visual-studio-code
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
like, you can literally see on your screen why it isn't configured too, so consider actually paying attention to the information presented to you
Oh i know about the error there im not actually using the animation event thats why it gives the error but has nothing to do with the root motion jump
after its finished and installed make sure to stop and restart..
thats the best bet to make sure its fully set-up and ready
but from what little we can see the .net was the reason it wasn't configured correctly
the link i provided also has thorough troubleshooting steps to get it fully working
How do i parse a hex string (like, lets say "00ffaa") into an actual colour struct?
is there an easy method, or do i have to do parse it as individual r, g and b values and then combine em into the struct
THANKS
you should now have syntax highlighting for unity types as well as built in stuff
still not configured. make sure you have completed all of the steps. then go through the troubleshooting steps if you are having issues getting it configured
https://unity.huh.how/ide-configuration/visual-studio-code
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
you'll know it's working when MonoBehaviour, Transform, Input, Ray, RaycastHit, and Physics are all the same color as IInteractable since they are all types
great! now your issue is that you are using Vector3.forward for the direction of your Ray, that's forward along the world Z axis and will never change. presumably you want it to point the same way your interactorSource is so use its forward
how do I determine its foward
hint: look at the docs for Transform
so I change it to vector3.interactorsource ?
no
no, that would make 0 sense at all
I suppose youre right
did you look at the documentation for the Transform class yet? considering InteractorSource is a Transform?
interactorSource is a transform, just use its direction
not at all no
localrotation
you want a direction not a rotation
stop guessing and read what i told you then read the properties of the class
only the "Properties" section is important, you can ignore the rest.. Look carefully
i already told you exactly what property you need, you just need to fucking read what i said
hint hint: keyword you're looking for the word forward
Damnit
based on what was said to you .. if its not Vector.forward then it must be.....
Vector.localrotation ?
jesus christ
Yeah, I get it, fuckin hell
Vector struct is unrelated right now..
thats why Transform was mentioned
its literally one of the top results in the doc page I sent
com on man lol
InteractorSOurce.foward ?
there we go..
if you click the docs for it
Returns a normalized vector representing the blue axis of the transform in world space.
Unlike Vector3.forward, which is a constant direction in world space, Transform.forward is the local forward direction for this GameObject. Rotating this GameObject will change the Transform.forward direction.
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Transform-forward.html
Yeah, Ill be looking through those and trying to piece it together next time
bookmarked the docs already
have a nice day
Is anyone getting issues with fields appearing invisible in the inspector in Unity 6.2 (6000.2.6f1)? Happens often when I click on a game object
seems there are a bunch of issues with the inspector in that version. you can try restarting the editor, if that doesn't work then close the editor, delete the Library folder from within your project, then open it again and it should hopefully work properly again
I'll have to try that tonight. It also spams a lot of errors to console related to its own inspector UI
Unfortunately the issues still occur after deleting the Library folder. Same with getting errors log in console relating to the UI
that version is probably busted
yeah seems that way, i've seen a lot of issues with it from people
lots of people seems to be having issues with inspector not drawing properly
!bug file a bug report 👇 then maybe switch to another version and test that
🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.
📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!
💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.
For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting
Bug sent 📧➡️
It's been a little while since I was on Unity for a student project, and certain systems seem to have changed in that interim. I've got:
public class Paddle : MonoBehaviour
{
public bool isPlayer1;
public float speed;
public Rigidbody2D rb;
private float movement;
// Update is called once per frame
void Update()
{
if (isPlayer1)
{
movement = Input.GetAxisRaw("Vertical");
}
else
{
movement = Input.GetAxisRaw("Vertical2");
}
rb.linearVelocity = new Vector2(rb.linearvelocity.x, movement * speed);
}
}
I'm getting:
'Rigidbody2D' does not contain a definition for 'linearvelocity' and no accessible extension method 'linearvelocity' accepting a first argument of type 'Rigidbody2D' could be found (are you missing a using directive or an assembly reference?)
There's probably something I'm missing, but I'm not sure what it is since things have changed from the tutorial I'm using.
linearVelocity is new in Unity 6
make sure your IDE is configured so you don't make silly spelling mistakes like that
!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
Maaaa, I need help
Whenever I boot up my game, these error messages come up. They dont affect anything but I was wondering how I make them stop popping up every time I open my project?
I tried deleting the Serialization file but that didnt do it
What happened is I paid a friend to write a script for me, then he changed the names of things for the second revision.
I dont know why, but I keep jumping without me pressing the key
I also seem to be going backwards
Yeah, I'm trying to figure out how to get it to work. My IDE being Visual Scripting 2019 was working too, so I wasn't sure what else was wrong.
if your IDE was configured then you would have been able to autocomplete the name of hte property so that you didn't make the simple spelling mistake that is the source of your issue
Is it underlined in red in your IDE
Is this array Im facing same problem it's like glitch or bug there another window +, - when you click on it's flicker also when you drop down sometimes it's not show exactly object you add try add, delete until it's show object name also it's give red error
It was, but I've now fixed it to both of them being just standard velocity and they're working fine now...theoretically. Except now I've got this error, when I try to go live.
Input code differs between the built-in Input Manager and the Input System, and changes are required.
configure your visual studio to work fully with Unity!!
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
I just did! I just went through the entire process, and I do get error messages and stuff, but if there's something I'm missing I'm not understanding it.
Wait, why did it change back to linearVelocity...?
that's what it is now, Unity will auto change it - but it prompts first asking you if you want
This whole process is what I mean by configuring and IDE.
If the screenshot you shared is after you configured it.. you've not finished, as that is a screenshot of an unconfigured VS
scrolling up, I see now others have said about this, I'll leave it there
Okay, I'm trying to find the extension in visual studio.
Which extension
you don't install any extension in VS, there's a.. module? that you install with VS through the installer.
I'm looking for the official one, but it ain't showing up, which is frustrating.
You don't need that, it has nothing to do with VS being setup correctly. It's just additional if you want it.
literally just follow this guide..
Yep same thing!
I've sent a bug report
what should i use if i want to recolor segments of a 2d Sprite according to data from the GameObject (i.e. a table of colors which changes over time)? in other words, tinting different parts of the image on the left to make the image on the right (ignore the stuff that's not the cylinder)
i think shaders might be what i want here but i don't know how i'd make the color data accessible to a shader
..also i've never written a shader
having trouble learning animator
for some reason, I cant have the rigidbody affect a sprite unless root motion is enabled, but if it is enabled the animator wont animate the transform. How do I fix this?
Yes you'd use a custom shader potentially using a mask texture for coloring the pixels from the primary texture
Alright. Having followed those instructions and having seen that everything is in the right place, this is pretty much what I've got. I think I've got the IDE set up?
now you can correctly use linearVelocity (provided you spell it correctly this time)
You're good. Now you can see those underlines and they'll tell you the problems
Does anyone has an easier way of finding all objects within a bounding area that doesn't include iterating over all objects in the scene?
Iterating over all objects can take a considerable time if there are thousands of objects.
And they don't have colliders, for physics.bounding
i know potentially i can make my own n tree, but i assume that unity has it's own for collisions
give them colliders then you can use a physics query like OverlapSphere
for some reason when i walk on a slope it slows me down but i can still go up them. when i walk up terrain thats high it stops me. Is there any way to make the slopes be treated like flat ground. the tutorial i followed had the guy go up slopes just fine and i have everything he has applied https://pastebin.com/NVf7eMiC
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
you've already got a thread for that in #1390355039272439868 , rather than crossposting it to here you should just bump your thread
Is this performant?, i'm talking about >10k objects
just post something in the thread and it bumps it up to the top
well it's certainly more performant than iterating through all of them. otherwise you should register their positions into some quad tree that you can query yourself (this is basically what physics queries do)
no, not repost. just post in the same thread
Is there a method that I can use to determine if a position is possible to be reached by a navmeshagent?
you probably want to be using this https://docs.unity3d.com/6000.2/Documentation/ScriptReference/AI.NavMesh.SamplePosition.html
Use a spatialhash or a quadtree if the objects are static.
When I build in separate scope and copy dll into unity project, it coplains about missing dependecies (in my case Microsoft.CodeAnalysis.Csharp). How could I automate dependency importing in unity project to use dll?
thats not what I am looking for unfortunately 🙁
Thank you anyways tho!
im trying to see if something is blocking a destination
did you know that you can use sample position and if the position you pass isn't the one returned then that means that position is technically not reachable?
there's also CalculatePath which will calculate the whole path
Ok you are right I can totally use SamplePosition then thank you!
unity ships with the codeanalysis dll already, you just need to make sure your source gen project uses the right version of it
Tried it, tanked my fps to 3
looks cool, however i see that it's bucketing instead of quad trees, any idea why?
- if there is a quad tree implementation in unity
that i can access
Yeah there are tons of them on github
that is what you need
spatialhash is better for dynamic objects
sounds cool, i never heard of this data structure
I use the one I linked for a level streamer
yeah looks like what i'm looking for, essentially I want to find the objects to apply a force to in a spring mesh
Its quiet a handy data structure tbh
Text
Assembly 'Assets/ExampleSourceGenerator.dll' will not be loaded due to errors:
Unable to resolve reference 'Microsoft.CodeAnalysis'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
and you've made sure that your source gen project (the actual c# project, not your unity project) has the correct version of the code analysis nuget package installed? and that you've set up the settings for the dll in unity correctly?
based on the error, the latter is the issue
I got a parent with Vertical Group Layout, and it stores some kind of cards and those stuff, but if I have too many cards, it will go over the screen, how do I make it that you can scroll down to see them?
Documentation says to do
Under Asset Labels, click on the label icon to open the Asset labels sub-menu.
Create and assign a new label called RoslynAnalyzer. To do this, type RoslynAnalyzer in the text input field
of the Asset labels sub-menu and press enter. This label must match exactly and is case sensitive. Once created, the label appears in the Asset labels sub-menu from then on. You can click on the name of the label in the menu to assign it to other analyzers.
But there is no Asset Labels in inspector
okay, and what about the first part of that message you are responding to?
I am blind, I didn't notice it on the very bottom
Version of NuGet package is 4.3.1
and which version of the editor are you using
6.2
then, assuming you've applied the label, you've done everything correctly
I don't get why, but after applying the label, there is no error
how does it work?..
So what if the spot is on the navmesh but just has some obstacles surrounding it? it will still return the position right?
yes, but i gave you an alternative that you can use
yeah looking into that now just was making sure I was reading it correctly
Hi everyone! I'm a new Unity user, and I'm trying to have a score in a game. The player throws food and when food collides with deer, I want the score to increase. The score variable is in the PlayerController script, and currently I have a public method in PlayerController to increase score by one. the public method is called by the script that detect's collisions for the food. Is this the correct way to do this? Or should I be using serialized fields? Serialized fields are a new concept for me so I'm unsure how to use them.
serialized fields are not a replacement for what you are currently doing. you can use a serialized field to assign the desired references, but it wouldn't change the workflow for calling that method (with the exception of removing any Find and GetComponent calls)
Okay, that makes more sense now, thank you!
For handling UI, does it make sense to use visual scripting for this or no? Specifically I am talking about presistant overlay UI that shows with information on screen.
I also want a sub-ui to open when you click on objects at the cursor
This channel is more for c# code. In general it doesnt make sense to use visual scripting for anything if youre capable of writing c#
It applies to anything. Visual scripting will always be more limited as youre limited to the nodes that exist. The nodes may cover exactly what you need, it may not. Not many people here really use it to give you an answer. There is #1390346878394040320 but still if you can write c#, its better
What do you mean? Deal with what?
Like does using state machines make no sense if you can already use C#
You use C# to write your state machines . . .
Ah
You can write everything and more in c#. You use a state machine if you need a state machine
You need to create your state machine using code . . .
It has nothing to do with visual scripting . . .
state machine is just a design pattern, it has almost nothing to do with visual scripting vs actual code
In your UI goal, I dont really see the need for this to be a state machine though, unless youre referring to something else
State machine was unrelated to UI
For input actions like buttons, is there a way to listen for when it is pressed rather than checking if it is pressed every frame?
input actions
this implies you are using the Input System, and if so you can subscribe to the relevant action's performed event
How do I do that?
You should look at a tutorial. There are a bunch on using the new input system . . .
InputAction has events that get invoked when the action phase changes, see here: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/api/UnityEngine.InputSystem.InputAction.html#events
Thank you
fwiw, you should have a look at InputActionReference and understand that you can use that type to reference specific actions from your input action asset in any component. The documentation and most tutorials do not tell you that, but its the most useful way to work with InputSystem. https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/api/UnityEngine.InputSystem.InputActionReference.html
So that would replace using the interactAction = InputSystem.actions.FindAction("Interact"); method to get inputs?
yes
Got it
I assume that is better for performance or does it just offer more functionality?
it primarily avoids coupling code to data via arbitrary and brittle string names or hardcoding the input map through the code generator or static API
once you have the action reference, functionality is identical
But to find the reference there needs to be something to distinguish what input you're getting. I dont understand how it would do that without the name of the action
a InputActionReference is a scriptable object you can reference directly, you don't need to look up anything, you get the exact reference directly
Okay, so instead of searching for the origional action, I assume you would add it as a public variable to the script?
because the declariation: public static InputActionReference Create(InputAction action) Still require a inputaction, thats why I am confused.
how do high distance renderers have enough RAM to load in that much data?
i know they use LODs but they arent cheap in memory
What kind of data are you talking about? Aside from assets, it's mostly just transforms, gameobject data and similar stuff. This doesn't consume that much ram. Probably less than a kilobyte per object. With that assumption, a million of GameObjects would consume less than 1GB of RAM. And then there are various techniques to address that as well, like level streaming.
this is an InputActionReference, you do not (normally) create those manually in a script, the InputActionAsset contains them.
Ohhhh okay
Okay I got it working but I want to make sure I actually did this correctly:
public InputActionReference interactAction;
private InputAction _action;
private GameObject selectedObject;
void OnEnable()
{
_action = interactAction.ToInputAction();
_action.Enable();
_action.performed += MouseClick;
}
This works but is this leveraging the interact Action Reference appropriatly?
there is no need for the _action variable and the ToInputAction()., you simply use interactAction.action;
Got it
minecraft data. you would need to store the mesh of each LOD chunk and meshes are expensive
the MouseClick handler is badly named, you are making an assumption about what the input action is, which contradicts the design intent of the whole InputAction abstraction.
You typically wouldn't store the meshes. A grid of points with some metadata should be enough. It should be easy to generate the meshes at runtime.
If you do decide to store the actual meshes, you'd probably have some kind of asset/level streaming system that saves and loads from disk. In fact I think that's what Minecraft does.
if you are storing a grid of data points isnt that also a ton of memory
It's still less than a mesh. And you could use various compressions techniques to represent uniform areas. But yes, ultimately you want some kind of streaming solution.
the issue im running into is when i turn the camera and move the frustum, the chunks cant load in fast enough
and it ruins the illusion
you can preload stuff.
wym?
load before you move into view
that creates a memory issue and also an issue of widening the loop that validates whether each chunk is still needed to be loaded
the loop is already slow
then maybe you are loading too much in the first place, sounds like your individual chunks are already too big or inefficiently implemented.
my chunks are tiny
otherwise it should be a simple issue of tuning your chunk-load-trigger logic
i trigger load on frustum change or player transform change
well, you may need to add some padding to that
wym
Pretty sure you can have a similar issue in Minecraft in certain scenarios.
But yes, there are ways to address it. Like starting loading the data before they appear in the frustum. Or maybe avoid unloading objects outside the frustum entirely and only have some distance based loading/unloading flow.
i can load everything in a sphere around the player instead of frustum. But then how do i efficiently determine what needs to be unloaded or loaded. That involves a massive 3d chunk iteration over the enter render space
How are you doing it with frustum then..?🤔
loop the frustum's aabb
This sounds more expensive than a simple distance check though.
if i have to distance check a million chunks its not more expensive
also, maybe put your chunks into a spatial lookup datastructure
it IS LOD
time for you to hit the google
nobody here is going to give you a tutorial in algorithms and datastructures.
you've got the keywords and principles, you need to do some work on your own now.
can you tell me the structure of the spatial LOD lookup thingy?
or if it has a name what its called
octtree, rtree, kdtree, bounding volume hierarchy
oct trees dont allow moving a chunk from one branch to another
i have banned them from my vocabulary
you have to rebuild them constantly
well, you cannot have fast lookup and fast update, thats just the nature of things
but you can make update locally bounded, and octtrees are fantastic for that.
if you rebuild the entire tree, you need a better algorithm
or use another tree
hmmm ok thanks ill try to implement this
BTW, what you're doing is definitely not on beginner level. I'd suggest moving future questions to #1390346827005431951 instead.
i dont like threads
wat
I don't see what this has anything to do with likes/dislikes. This is simply not the appropriate channel for your questions.
Can you stop the spam?
I am very calm. I recommend checking the #📖┃code-of-conduct before you've been calmed by an actual moderator.
its solved ish its fine
<@&502884371011731486> theres seem to be a person having a problem with reading the community conduct here...
!mute 1358741545708425239 1h muted while we go over this
@resentvu muted
Reason: muted while we go over this
Duration: 59 minutes and 59 seconds
!warn 1358741545708425239 if you have nothing meaningful and on-topic to say on this server, say nothing at all. There is no off-topic on this server.
@resentvu warned
Reason: if you have nothing meaningful and on-topic to say on this server, say nothing at all. There is no off-topic on this server.
Duration: Permanent
hey I'm currently trying to create a character selection screen for a game I'm working on, and I'm running into a weird problem where even though I can see the characters listed under the parent gameobject in the scene, I can't seem to see them in the game no matter what I do, I'm happy to check anything or get screenshots of specific parts if anyone has any suggestions or might be able to help
it's 2D, they don't appear even when theres no background image, the next character and last character buttons are working to disable/enable the prefabs correctly, I'm not sure what else to check
using this tutorial: https://www.youtube.com/watch?v=3qlRgICRoeA&t=110s
Download link:
https://drive.google.com/file/d/1Mb9YauxG7UYXAb1Fp7v1xINrMJVLjx0C
All feedback is welcome!
My website: https://rumpledcode.com
Company website: https://double-lens.com
Music:
Prod. Riddiman x oldboyy - Radio
Project: https://voxbox.store/ - share and download MagicaVoxel assets for free.
Start from sharing screenshots of the issue vs when it doesn't happen. Ideally capture the whole editor window for us to have some context.
ohh man this is embarassing how do i make a script that makes a plant grow 😭 sorry im new and stupid
The issue never doesn’t happen, I’ll get a screenshot rq of what the scene layout is and what it all looks like etc but I’m not sure it’ll help much
what do you mean by "plant grow" just scaling the object or more like farming game ?
here's the scene itself
I feel like the issue is likely due to you mixing up canvas ui with non ui objects(character sprites).
As well as misunderstanding how canvas is working in the scene view.
starting the game, then clicking play, then clicking next
honestly probably, I've never done much ui stuff or messed around with scenes
the two players under the characters parent are prefabs of the full players with all of the scripts etc
break down the problem into steps. you need something to happen over time -> you need a timer. You need the plant to grow based on this timer or in increments. What does growing mean? Could be a matter of having multiple visual objects that you swap out at runtime. Could be scaling up an object
here is the thing i need to click on the seed and the seed will disapppear and plant model will appear it will slowly grow into a targeted scale
ohh thanks
I don't know a lot but you probably need more context
depends on if you wanted animated growing, something to cause it to grow etc
not that I could probably help anyway but it would make it easier for people to help who can
nah thanks for talking about it appericiate it ima figure it out eventually
For context are you working in 2d or 3d
3d
I thought I needed the actual character in there so that it would load the selected one into the game
Yep. We'll, that's the issue. The ui is render by the canvas in screen space, but your character is rendered by the camera in world space. While they look to be in the same place in the scene view, the character is way outside the camera view in reality.
I asked because 2 different methods
yeah should be easy to implement, break down each part you need to do into a smaller problem to solve then put it all together
No, you don't.
A simple solution would be to use a ui Image component with the character sprite assigned.
Ah so I need them to simply be sprites/images
are there more aspects supposed to happen on click, or is this some predetermined start where it must be clicked and then always grows over time?
And a seperate script can deal with the actual prefab spawn?
for now its just click and then grow over time ill improve as i go later on
yeahh i just finished the tutorial yesterday so its a bit difficult
Oh that worked perfectly, thank you for the help
if it always stays as click then grow, then the logic is pretty easy to setup. You would just need some sort of public method to indicate that the plant is now allowed to grow. Then in update you can do the timer if its allowed to grow.
If the logic is more complex in the future, you'd probably need to come back and refactor it entirely to allow for some list of actions to happen in order
depends entirely on your requirements so it's pretty good if you're able to sit and think about what you actually need in your game. Theres a world where you could just have each plant reference a "next plant" and replace the spawned object if you need some stage system