#š»ācode-beginner
1 messages Ā· Page 799 of 1
this is for example 1-3 blocks, the game is 6-7 blocks in total
i mean all that did was just outline how your project files are going to look lol
I just finished wasting over an hour arguing with someone over AI hallucinations
but once again thats purely useless to you lol
that is nothing
that block is nothing lol
i dont wanna look dumb infront of everyone, can i dm you something?
just ask here
dont worry theres no stupid questions
people of all skill levels come here
(i have to wonder what a ScriptableObject "balancer" would do š )
i asked the ai to give bullet points as to what it did, and im gonna send it if thats okay
-
Core Simulation & Engine
Three-Stage Battle Engine: Built a deterministic simulation that resolves every snap via Trench Battles, Skill Duels, and Play Results.
Tactical Loadout System: Developed a "coaching instruction" layer allowing users to set situational weights (e.g., pass/run bias, 3rd-down aggression).
The Brain: Created the math-heavy SimulationEngine that calculates yards and success probabilities using player skills, morale, and scheme modifiers.
-
General Management (GM) Systems
Roster Architecture: Implemented a 53-man roster system with Practice Squad, Injured Reserve, and salary cap logic.
Scouting Fog of War: Developed a tiered discovery system where player attributes are revealed from vague letter grades to exact values.
Draft & Trade Machine: Built an AI-driven trade evaluator and a 7-round draft state machine that prevents logic loops.
-
Narrative & The "Human Element"
Locker Room Conflict Engine: Modeled player personalities (Diva, Maverick, Team-First) and how they react to triggers like benching or losing streaks.
Morale & Performance: Linked psychological states to on-field output, where low morale significantly debuffs player success rates.
-
Technical Architecture & Data
SQLite Persistence: Established a robust data layer for saving 15-season careers, player stats, and league history.
Modding Support: Created a safe import workflow via JSON manifests, allowing users to re-skin teams and logos without breaking the simulation.
Unity Project Structure: Organized the MVP using UPM (Package Manager) standards and Assembly Definitions for optimized compilation.
-
Release Readiness & Quality Assurance
1,000-Season Audit: Ran a headless stress-test harness to verify that league-wide statistics (passing yards, interceptions, etc.) mirror real-world NFL benchmarks.
Edge-Case Guards: Built "Nuclear" safety protocols to handle bankruptcy, empty rosters, and infinite loops.
Legal & Launch Prep: Drafted the App Store/Google Play metadata, Privacy Policy, Terms of Service, and Day 1 Patch Notes.
Final Project Status
MVP Ready: YES
Single-Player Career: 100% Feature-Complete.
Multiplayer: Intentionally deferred to the post-launch roadmap for stability.
right
jfc whats with all the "AI" crap
unfortunately, this is nothing
i doubt it wrote any scripts for you
omg nav you missed the most hilarious thread
a few hours ago
it is just a very enthusiastic list
i asked it for bullet points as to what it did
its just gobbledygook
make a game like NFL Head Coach 09 but for mobile for a friend
do you and i mean this without any offense even understand how game development or development of any kind works on a fundamental level
oh it did, just not sure how to put them in or how to use them tbh
something these generators excel at, spewing words with no real coherent plan
you should understand that the LLM is just emitting words that you want to hear
i saw this exact situation in a GitHub repository a few months ago
honestly no
it was allegedly a system for doing full-body tracking by measuring wireless interference
this is the problem
it was a very impressive looking repository
you cant shortcut around this
no amount of ai can help you, youre going to have to learn on your own
unfortunately, it didn't actually...do anything
it was a mile-high pile of framework ideas and no actual software
amusingly, this included an AI-generated review of the source code
it reported that the code looked great, but that it didn't actually do anything
;-; how long would it take to build a game of what im trying to have the ai do?
damn
you wanna recreate nfl head coach 09?
probably a real long time
yeah
rip
i dont see it being in your cards any time soon
if you are interested in developing
im happy to show you where to start
but youre going to have to start small
you might not even complete a full but very basic game in a year
i dont mind starting somewhere, as long as i can get to where i can to achieve what im trying to, im sure itll take time as i have one year left in uni and work as well, so def more than a year i guess
you probably wont recreate nfl head coach 09 for some long time
even longer than a year
that's the spirit (:
I started doing game development after quite a few years of programming
heres the thing, and you dont have to promise anything
but you should not use ai
while working, while learning especially
it's fun to bounce ideas off of, I suppose
but it gets really messy once you start asking LLMs to make something for you
for example, this is a good idea
yeah i understand, but i mean is it really wrong 100%?
Locker Room Conflict Engine: Modeled player personalities (Diva, Maverick, Team-First) and how they react to triggers like benching or losing streaks.
...although "Locker Room Conflict Engine" is one hell of a name for this, haha
its wrong 10% of the time enough times to be a problem
fair enough
not always but you wouldn't be able to distinguish if you don't know better
Iāve found AI can be useful for summarizing stuff, or digging up obscure info on something. That kinda stuff.
Like a less reliable Google but can find rare / hard to find info quick.
also this
and if you know better, you don't see a point in it
ai is a yes man
we just had a guy here a few hours ago in this server
who was convinced he discovered some new revolutionary technology
idk whats wrong with that 
i see
and it lead to what can only be described as delusions of grandeur
those are one of the many dangers of relying on ai
thats funny ngl
too much or at all
I give GPT some basic clerkwork type of shit
if you must use ai, use it sparingly and with caution, never use anything it gives you if you dont understand it
"give me a nice json list of first and last names" or some shit
i wouldnt rely on it fully, but with coding i know f all, so id usually just ask it to do the code and if any errors come up i send it the error log to fix it
then you dont learn how to fix your own issues , you never improve
problem solving is 80% of the job
Iāve described Unity related problems to AI with very precise wording and specificity,
It often dug up the exact line of code / solution I needed to solve the issue.
That's not good enough. You need to be able to read and understand what it wrote. It could be going in a completely different direction or looping on several alternating errors and you'll never know.
this is a thing that happens as well
you have a problem a, ai figures solution b, solution b causes problem c, problem c is now fixed by solution a which is also problem a
this still creates over reliance and not improve critical thinking skills / dissecting a bigger problem to get that aha moment when you figure it out on a quantized level
The AI knew something about a Unity function that I didnāt know, and simply explained why my issue was happening.
Canāt lie it was really valuable.
you know by learning, you keep using it and its the calculator effect
sure they are quick, but then you kinda lose your own ability to quickly do something in your head
if GPT is offline, what now you can't solve something?
yeah skill atrophy comes quickly if you use ai, even if you use it every now and then iirc
a lot of people who use ai to "diagnose issues" and "debug" are just using it to quickly parse a shit ton of google searches that they could have done manually
Definitely not. It was more of a āthis deprecated function in Unity has this behavior and itās not described in the docs, so you have to do _ to counteract that.ā
if gpt found it , technically the info is there if look hard enough
Maybe I couldāve found it searching on Google ā yes exactly
where do you think LLMs are grabbing this data (mostly reddit š„² )
yeah thats true
love when i google something and the ai decides to just copy what the very first real search result is saying
like hmmm what a good use of resources
i think its a sign of bad things to come
laziness and dependency on instant gratification and results
I set my search to bypass the AI crap
theres going to be a generation in a few years that will never venture to the second page of google search results
there probably wont even be, they are slowly phasing out that structured internet and will soon just be spoon fed answers from an LLM
To be fair, you would rarely do it even before AI. At least in recent years. The search algorithm is good enough to a degree there are no useful links on the second page.
we just offtopiced a real question
Mb, go ahead Whiterun Guard. Dam even deleted the post
Let's say we have a GameObject that has a script attached to it. I make a static class that holds a reference to the script on that game object. What happens to the reference when GameObject gets destroyed?
Yeah sorry, pressed enter too soon XD
goes null
/ missing
you can have scripts on a gameobject directly...?
Like, a Component.
Oh. Okay.
literally the entire point of Component based gameobject
I thought they meant in the ScriptableObject sense
an SO is just a data container
it would have no use even if you could add it directly to an object
I'm aware
I dont think that can be attached to a GameObject. But a Component can have a space to contain a ScriptableObject instance.
ScriptableObject are pretty wacky , they are very similiar to static classes in certain aspects mixed with some POCO
Gotcha ty
After doing a bunch of config related stuff in the inspector with SerializedField,
And then Unity crashing and me losing all that,
I always vouch for ScriptableObject
they certainly can be very useful also for sharing data across gameobjects without them referencing each other
Yikes
I had the editor crash on me from adding a PlayerInput component to a GameObject a few days ago
I still have no idea what that was about
Never did it again either
Perhaps it was a coincidence? I have no clue.
could be anything
Havenāt heard of that one yet. Yeah ^ could be anything literally
if you're interested, best check the crash log with the stack trace usually you can get some kinda of idea
Okay so this is just a thing that has a chance of happening lol noted
One downside of learning a new engine: learning all the ways you can make it unstable I guess
but also the version of unity you use matters too
Honestly when I was more careful and writing simpler code, my Unity didnāt crash even once for months and months.
been using the same unity version and have yet to encounter a crash, I think it only happened once cause of Probuilder
True, this one is a couple minor versions behind current
I didnt even touch 6.3 yet
most of my projects are still on 6.0.33f1
I use patcher for binary and have old Unity Hub so it doesn't bug me about "security fix" bs
My unity hub keeps pestering me to install 6.3 so I can go through its tutorial stuff
ima let 6.3 mature a bit before switching over
Very valid
CoreCLR is the main thing me and most been waiting on
I mean I'm sure an in-engine tutorial is nice for some people but that's what I have the docs for. And this discord
What's that?
basically the new .NET thats multi-platform
compatibility for one, newer packages, having the latest c# features etc.
Oh that thing
FYM 6.4 will be a "Unity 6 proof of concept", what
Is this like
Some weird unity specific versioning system I don't know about
Half the time I think even Unity doesn't know what Unity says
Something something pricing fiasco
is there a way to adjust the speed a cinemachine camera will re adjust at when i change the Follow
don't think there is
maybe you can have two of them, one with diff target use the blend mode if you need to control speed from one cam to another
This is the only version gen alpha is gonna use
of unity
forever
would it not be better for the lts to get more features? or are they scared that if they screw something up they'll have to actually maintain it
just FYI, this is not referring to the version 6.4 being a proof of concept, but rather their internal proof of concept for the .net migration
that just happens to coincide with the 6.4 release
6.4 is definitely the proof of concept for the version of unity that's been out for a long while now
also this graphic is purely about the expected progress for the .net migration and not the only features those versions will have
confession: i have no idea how to think about .NET versions
i have no clue how to order these things
Ahhhh
Hello. I've been trying to get the material swap animation to work with an object in Unity, but everytime I enter play mode, all the skinned mesh renderer keyframes disappear for that animation, and only those. Is there any fix to this?
So, I'm trying to wrap my head around adressables. But at this point I'm not sure I even have the right use case for using them.
My thought process was to have some easy data structure that lets me easily add prefabs and scriptableobject data in a way where I can reference subsets of them all at once.
That SOUNDS like something I should be able to do with the Adressables right? Even resource I've come across has started to make me question if its really just intended for remote stuff.
hay I'm having an issue with my wall grabbing. its working mostly fine now but when jumping and then try to grab a wall the player will often times just launched up into the air.
What you described doesn't necessarily require addressables. Addressables are simply an alternative way to load assets into memory. As opposed to referencing them in the scene or loading via resources. That's basically it. There's no higher level subsets management system or whatever. This is up to you to implement as you see fit.
I only figured I'd give them a try so I didn't have to use streaming assets or resources tbh
But there isn't any cavet to using it that way is what you're saying?
I don't entirely understand whta you're trying to do. But addressables is just a way to load assets. That's basically it.
You should probably open a thread in #1390346827005431951 and share all the info you can: the relevant code, screenshots of your setup, video of the issue, a good explanation.
That pretty much answers my question tbh
hi ive had something thats been putting me of starting unitty its that when i was following a tutorial my coding stuff wast like linked ppl told me to activate it in unity but idk how
!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
yo its different though like it doest look the same
what do you even mean by that
i have
do you know the difference between the unity editor and the unity hub?

How Optimize my Game?
use the profiler to identify bottlenecks and fix them
start by using the profiler to determine where your actual performance issues are coming from
this is not a helpful response. you will need to use your words if you wish to communicate and receive help
let me see on yt thanks i am using occulation culling
i dont think i have unity editor
So install it
i dont think ik what it is either
trying too its taking me to unity engine
unity editor is literally the unity application you make your game in. your screenshot was of the unity hub which is just used to manage your editor installs and projects
oooh ok holon
presumably you are referring to the editor as the "unity engine"
Because they can't moderate them
But blender Have?
their problem to deal with then
im in but idk what im doing basicly the line of in the bottom right is supposed to be attached to stuff but its not
(see the read before posting) @austere kraken
You have to fix your compile errors
you likely won't get IDE configured properly until the compile errors are fixed
!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
Statements in C# need semicolons at the end.
HOW DIFFICULT IS UNITY FOR AN ABSOLUTE BEGINEER AT CODING I ONLY HAVE EXP IN CODING C# FOR 2 APPS I MADE
If there are compile errors doesn't it sommetimes block/stop the IDE packages from compiling?
sort of a chicken and egg problem
no? those are separate
Sorry For it i m new
difficult at first, easier as you gain experience
so which part would need ;
the error message tells you exactly which line
read it
DID YOU LEARN FROM UNITY LEARN LIKE THEIR TUTORIALS?
no
@lilac coral configure your ide, and there'll be a highlight telling you where
stop shouting
Show You script Screenshot bro
IVE BEEN TRYING TO FOR LIKE AN HOUR
trying to configure your ide for an hour?
lol
how much money can i make as a solo dev using unity
12Ā¢
every day?
there's no solid answer for that
oh wow thats allot
wut does this mean
all the solo devs you know of are successful, because you don't hear about the unsuccessful ones
Survivorship bias or survival bias is the logical error of concentrating on entities that passed a selection process while overlooking those that did not. This can lead to incorrect conclusions because of incomplete data.
Survivorship bias is a form of sampling bias that can lead to overly optimistic beliefs because multiple failures are overloo...
Bro For Income in World Many ppl Work Bro it hard to make your game popular
and play store take 25$ to Publish games
whats harder making game on pc or mobile?
for me mobile because you have to create sprite for diff button and for UI
do you mean developing on mobile or developing for mobile
those are very different questions
oh, then it's impossible to answer then
Mobile one harder like godot
all the questions you're asking here are subjective and specific to you, your experience, your preferences, your expectations, your goals.
so its easier to make a game on pc for mobile
no
ok
and neither is the inverse
is C# used in Unity
yes, have you done any research
no thats why im askin
you should do research
can anyone tell me what to know from frame debug i m new in it
ok but thats boring
it's boring to answer these very googlable questions for a beginner who doesn't want to utilize any other resource too
the internet is a vast expanse of knowledge, use it
knowing how to research for information is a crucial skill, you won't get very far if you refuse to practice that
hey i need a friction system in my game some one can help me
what's not working about it?
looks like you have a compile error, and your IDE is still not configured š¬
wtaf
did you save the code?
Hey a question if you will. When using the "AddComponent" method, can I pass a script I instantiate ?
Like I make a script = new MyScript(); then AddComponet(script) ?
You canāt make a new Instance of a UnityEngine class because of Unity specific reasons but AddComponent does return the component itās going to make, as stated in the docs
So you can just do
MyClassType newInstance = go.AddComponent<MyClassType>();
Ok well too bad. Adding the script to a gameobject and getting the returned script instance was what I was doing but i was hoping to refactor that code
Why would you want to refactor that?
"The code is not good enough! Let's make it worse!"
I have three class deriving from an interface, I randomely assign one of the scripts to a gameobject and use it through the interface
So I would have like to : create a Iscript variable, attribute a random derived script then add the Iscript variable to the gameobject
You can freely cast an instance of a class to an interface that it implements.
Not entirely sure if you know that and whether that's related to what you're trying to do or not though. The explanation is all over the place.
Iscript maybeClassField = Instantiate<IscriptImplClass>();
Right now i have that :
private IPickUp ChoosePickUp(GameObject pickUp)
{
IPickUp script;
if (GetSpawnOccurence(_tailKillerPUSpawnChance))
{
script = pickUp.AddComponent<TailKillerPickUp>();
}
else if (GetSpawnOccurence(_enemyKillerPUSpawnChance))
{
script = pickUp.AddComponent<EnemyKillerPickUp>();
}
else
{
script = pickUp.AddComponent<NormalPickUp>();
}
return script;
} ```
I would have preferred to add the component right at the end in an agnostic way
What component though? There seem to be several.
Only one component can be added in that method, depending on a random chance of spawning.
Yes, but you still need to decide which one is added. Thus I don't get what you're trying to do.
Oh, you want to avoid writing Add Component several times?
I just wanted to assign an existing instance of a script
Is that it? Just reducing code to type?
Yes
Well, you can't really do that. The problem is that MonoBehaviours can't live outside of a gameobject, so you can't create it separately and add later.
What you could do is either make it not a MonoBehaviour, or use generics maybe.
Can't we somehow get a variable for the type of script we want to assign ?
Something like that ?
System.Type type = typeof(NormalPickUp);
pickUp.AddComponent<type>();
It looks like a unnecessary helper method.
I have to test but apparently I can write that :
script = pickUp.AddComponent(scriptType) as IPickUp;
is using ScriptableObjects as sort of "builder/template" object for creating runtime objects from them - bad idea in general? they would just populate configured data into object on creation and give it to someone else and not store the reference itself.
Just a warning, script is null in the method.
Why ?
The pickUp gameobject exists, and I'm just adding a component.
previously I was doing that : script = pickUp.AddComponent<NormalPickUp>();
And it worked
Nevermind, it's late night here
Is it sleepy time ?
If your comfortable with your understanding of what your doing it can make sense in some contexts yeah
what happened to my project??? i tried to build it normaly but it gave me this. and now nothing is working
You have a script that fires errors when building, so you gotta find out, what scripts are having issues
Maybe you have some platform dependent code or you have some editor code that cant run on build.
The error tells you when there's editor only code
hey all, i had a small curiosity, i have a dream of making a metroidvania and idk if i will ever get to it but i do like to gather some knowledge if i would start on it.
Im making a movement system rn and i had a curiosity on what the best way is to make a grounded check, most of my friends/classmates just use the rigidbody of the player with on colission enter colliding with the ground tag and i found another way to do it recently by putting a small trigger under the player's body so it doesnt give you your jumping capability back when colliding with the roof or walls, but it has some flaws here and there and i had the curiosity, how do u all do it usually and whats the most practical way to do it?
im doing 2d btw, and im trying to figure out what works best as i seem not to be able to bunny hop like for example in hollow knight or silksong, it sometimes bugs a little and stops me from jumping for a sec.
From my experience and what I have seen done by others, you can also do raycasts to all sides to know, where you are at with your player. So you could raycast down to groundcheck (which also gives the ability to include player last resort mechanics if you want) and raycast to the sides to check for ledges for example.
hmm sounds interesting! i havent rlly worked with raycasts yet so i may needa do some research on that to make it work, but ty for the help btw :)
does anyone know how silksong and hk do it btw?
Try switching build profiles and then back. Change it to something like iOS and then back to your actual target, it should reload the stuff it needs then
ok
man you're a life saver. i thought for a second that all my hardwork has gone like ashes.
it was justa faulty compiler error
To be honest I just plugged in the error into google and scrolled past all the AI and found it pretty quick on stack overflow. But it makes sense, some sort of file failed to load, and since build profiles are cached a restart wouldn't fix it, so you gotta swap em out
hay is it possible I could talk to someone in a voice chat to get some help
no, there are intentionally no vc's here.
!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
voice chat eliminates the benefits of a community server.
ok then here. I having an issue with my ledge grab. can you help?
!code without any code, no
š 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.
not with that limited context, no
Please dont ask to ask and just ask you're wasting peoples times
didn't you have a thread for this
I did at 1 am.
doesn't seem like you've added any further info about what issues you're having
use your thread, and this is not an appropriate method to show code
you were given instructions above
Why is TMPro grayed out?
Because you don't need it
You probably already have the namespace imported
It remains white on my other scripts except for this one
presumably, you don't have a using TMPro; directive at the top of those scripts
This script doesn't have any problem
https://paste.ofcode.org/hppguB3hNmdr9LAXwyPkzx
There is no problem in any of your scripts. The IDE is just pointing out that the TMPro namespace is not necessary in this instance, because you already have a using TMPro; directive at the top
This has an issue
https://paste.ofcode.org/B9hkgudjLJHr5FffX6ifrY
Because those ones probably don't have the namespace imported
In the script you linked here, there is no using TMPro; directive
how can i remove that?
So you'll notice how this one doesn't have the namespace imported.
The other one does.
therefore, you must refer to TMP_Text by its fully qualified name, which is TMPro.TMP_Text
If you don't have the namespace imported, you need to fully qualify the type, including all namespaces
If you import the namespace at the top, you don't have to do that
has anyone any idea how to make my cam to be 3d person but will be semi top down
this is a code channel.
also obligatory: use cinemachine
So is dynamic rigidbody supposed to be the catchall for practically everything that isn't static?
Kinematic seems very... unuseful
A kinematic rigidbody is one that can exert forces, but doesn't respond to them. It's meant for things directly controlled by code, so it's great for player characters
Hey, can I make a coroutine run faster than update?
yea, do two loops each update š
No way ahaha
You should share your code because its probably something easy to do
I was thinking like 0.001ms
!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.
Cna I do yield return new WaitForSeconds(0.001f
that would be pointless as you are bound by the speed of Update
okok
Yes but there is no guarantee it has waited that amount of time (its framerate dependant)
60 fps is 0.016ms per frame
okok thanks
Usually we use delta time to adjust things to be framerate independent and for us to count up accurately
You mean 16ms per frame
Or 0.016s per frame
haha yea my mistake
guys what is a dot product š all the answers i saw on google i dont understand. if someone could explain it a bit that would be nice
Dot product is 1 when two vectors are pointing in the same direction.
-1 if they're opposite
0 if they're perpendicular.
It's basically "sameness percentage"
so its always either 1, 0 or -1?
or in between too
no, those are the extreme values
alr yeah makes sense since its a float
Take a vector and check its dot product with, say, due north. If it's got a dot product of 0.7, it's about 70% north
So, not quite due north but still pretty north
so dotting (10, 0, 0) with (1, 0, 0) gives you a result of 10
Example use: "When someone is looking somewhat in the direction of Slender Man, play a static effect" becomes something like:
if (Vector3.Dot(player.transform.forward, directionToSlenderman) > 0.8f){
playStatic();
}
You can also use Vector3.Angle if you want an angle
(the dot product gives you the cosine of the angle, hence why it's 1 when the vectors align and -1 when they're opposing)
alright this makes much more sense than any other explanation
It has some major importance in math, but we don't care about how to compute it or any of those other properties, we just care about the results. Game developers get to cheat on a lot of this vector math stuff by not needing to know the why of things
yeah which is good for me
Quaternions š
Euler Angles š
What if I use the physics engine? Can that go higher than framerate?
what is your objective?
so should i normalize the vectors before i use it or does it automatically normalize them?
No, really what are you actually trying to do š
I want to get data
If you want to use Vector3.Dot to decide how well aligned two vectors are, and you don't know if they're already normalized, you have to normalize them
share some code
I want to simulate something higher than the framerate to get the data
Vector3.Dot(foo.normalized, bar.normalized) is sufficient
you can run a block of code many times per Update step, perhaps
alright yeah i didnt normalize em before
thx
void Update() {
timer += Time.deltaTime;
while (timer > 0) {
RunStep();
timer -= 0.001f;
}
}
this executes RunStep once per millisecond
note that it's not running the method, waiting one millisecond, running it again, waiting again, etc.
it's running the method many times in a row per frame
Yeha but it's framerate dependant
You'd need to share more to get some actual useful help
do i need to also normalize cross products?
i would guess so
RunStep executes once per millisecond of in-game time.
If you care about the length of the resulting vector, at least
Like what data is this and why does it have to be every ms. You cant render anything with this within that time step regardless
Till you share something we cant show you how to actually do this properly š
Idk how to code what I want to do tho ><
explain what you want your game to do
So say what you actually want to do
do not tell us any technical details
Then you need to learn some things first and see why your initial thinking is wrong and naive
I want to create an array with the position of an object every 0.001s while it's moving
If you want something to run faster than the frame rate, run it multiple times a frame.
void Update(){
doThing();
}
Does 60 things a second.
void Update(){
doThing();
doThing();
}
Does 120 things a second.
this is a technical detail; explain what you want the game to do
do not express this in terms of code
The position is never gonna update between milliseconds if update hasn't run..
only tell us what the resulting gameplay will be
Why do you need this
Not what are you trying to do
I want to make an array like this
t= 0s x=0 y=0 z=0
t= 0.001s x=1 y=0 z=0
If you literally do not know why you need to do this
then why are you doing this
The solution? Don't do it.
Is this rage bait or what
If that doesn't work to solve your problem you'll need to explain why
Because until you give a reason otherwise, the solution is "Don't"
Not doing something is always easier than doing something
we want to know what you're trying to make your game do
WHo said I didn't know why I needed to do this
because you are continuing to not tell us what your actual gameplay goal is
Well, considering you've got like five people who are asking you and you cannot tell anyone
it seems like you don't even know
we know you're trying to make an array with the positions of an object at sub-frame intervals
i wonder if you're trying to draw a trail behind a fast-moving object
There's a cube that moves along axis X in game at 1 unit per second.
The cube is shown to the screen every frame.
I want to move the cube along the X axis in game, AND get its position with better precision than the frame rate
but why
Why do you need the position more precise than the frame rate
What is the purpose of doing that
If you move by x amount a frame there is no better precision
To get the data
For what purpose
Say put it in a notepad whatever
If its a linear move then you can just fill in the gaps yourself
What data? It's a position
If it moves 1 unit per second just do the math lol, you dont need to read the position then
So lerp between where it is, and where it's gonna end up, by how much of a percent of time you want to slow it by
Or you simulate physics yourself with the step required to get this precision but at very small steps this will take longer to process than the step time
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Physics.Simulate.html
Holy shit I understand sorry I'm dumb ><
You see how asking the attempted solution got you nowhere, but stating the actual problem found a better way?
Read this
https://xyproblem.info/
Honestly I dunno if this was an X/Y problem it was just confusing
We didn't get any information on what Y really is
It most definitely is. With the current info, id see no reason to even use unity for this. Just write a for loop interval of 0.001, printing t and x as the same value
Okay yeah that's true I guess it's an unsolved X/Y problem
Unity is gonna be less accurate than the data they want. I'm sure floating point precision alone would cause some of those values to not line up 100% mathematically
hey guys im trying to make a vr game in unity and i managed to link my vr to my pc but when i try to run the project it says i cant because its an unknown source or smth does anyone know how to fix this?
better off asking in #š„½āvirtual-reality n provide more info / screenshots
oh sorry mb
i didnt find the channel
try test without vr. if still has issue post in #š»āunity-talk instead
anyone can help me make this code rotate based on the players direction of looking? cus rn the 3rd person pov just stays in place while following the player regardless of their rotation
you should use Cinemachine instead
Elaborate if possible
Nvm i found a yt video
Thanks for the tip tho
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Quaternion.LookRotation.html
LookRotation if you want to supply a direction over a transform target
I think this is more beginner friendly
Cus im trynna learn not use a tool
Ty @timber tide
well if you want to learn and you don't want to use any tools, then why are using a game engine?
Thats not what i mean , as someone who is 5 days into unity if i dont learn the main concepts of gamedev and rely heavely on plugins / addons that make life easier then my entire base of knowledge would be based on shortcuts created to help experts make games faster
but it's literally the same concept
Twin its a personal prefrence it doesnt have to make sense to u š„
you're using a game engine so you don't have to learn the fine details about rendering, asset management, etc.
cinemachine is a unity package that is meant to help you set up a good camera easily without needing to manually set it up just like all that other stuff you are skipping learning
and if you're against packages then you can't use the built in UI stuff because that is a package, so does that mean you're going to learn how to manually create and render UI? or is that a package you're willing to use?
Idk , i'll see when i reach the point where i understand how a UI is even made
Thanks for the info tho 
here's a hint: you'll be using the components from the UI package. especially if you follow literally any tutorial for it
following along with the make a rogue like game, and having trouble with the make a character step, specifically a NullReferenceException, stopping my character going into the tilemap, is this a hierarchy issue or code or something else?
I had a look through here while researching my problem, but haven't been able to find a solution, also it's not mentioned in the docs so I guess I've misunderstood an instruction:
https://learn.unity.com/course/2d-roguelike-tutorial/tutorial/add-a-player-character?version=6.3
In the previous tutorial, you created the game board for your game; the next piece of functionality to add is a player character that can traverse the board.
By the end of this tutorial, youāll have done the following:
Created a
PlayerCharacter
GameObject using one of the provided assets.
Ensured that the
PlayerCharacter
GameObject ...
did you read through all of the information that is provided by the steps in the page i linked?
As far as I am aware, yes
then you should know that the stack trace is necessary to even begin to troubleshoot this
oh i misread ur question, my bad, 5 mins
BoardManager.CellToWorld (UnityEngine.Vector2Int cellIndex) (at Assets/scripts/BoardManager.cs:20)```
this is saying the stack trace issue is occurring here:
public Vector3 CellToWorld(Vector2Int cellIndex) {
return m_Grid.GetCellCenterWorld((Vector3Int) cellIndex);
}
but I init m_Grid several lines beforehand, using ` private Grid m_Grid; `
that's where you declare it, but where do you actually assign it
sorted, cheers š
If I used a scriptableobject to hold data (sprites, textures, etc) for a single object, then made everything addressable. I should be able to reference just the parts of the object I need by instantiating them via the handle for the scriptable object data?
Does that sound right?
So long as the handle's for the scriptable objects stay alive, the referenced textures, sprites, ect should also be loaded?
Why does it say Mismatch at my prehabs but in my hierarchy its correct?
using System.Collections;
public class NpcMoveManagement : MonoBehaviour
{
public float moveSpeed = 3.0f;
public float arriveDistance = 0.1f;
public float turnSpeed = 720f;
public Transform targetPoint; // NPC_DoorEntrance
public float waitAtTargetSeconds = 2f;
bool isWaiting;
bool hasArrived;
void Update()
{
if (isWaiting || hasArrived)
return;
if (targetPoint == null)
return;
Vector3 toTarget = targetPoint.position - transform.position;
float distance = toTarget.magnitude;
if (distance <= arriveDistance)
{
OnArrived();
return;
}
Vector3 direction = toTarget.normalized;
if (direction.sqrMagnitude > 0f)
{
Quaternion targetRotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, turnSpeed * Time.deltaTime);
}
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}
void OnArrived()
{
hasArrived = true;
Debug.Log($"{name} reached {targetPoint.name}.");
StartCoroutine(WaitAtTarget());
}
IEnumerator WaitAtTarget()
{
isWaiting = true;
yield return new WaitForSeconds(waitAtTargetSeconds);
isWaiting = false;
}
}
Whatever it is that you've reference doesn't seem to have a Transform strangely..
What're you attempting to reference?
Are you attempting to reference a scene object using a prefab field?
I was following the Roll-A-Ball course and I can't playtest it becasue I "need to fix errors", can someone help me pls?
Clear the console and try again. Initially you were missing a semicolon on line 19
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)
is that why its not working?
that's why your visual studio isn't highlighting errors
it's also a requirement to get help in here
there is another problem with line 19 that VS hasn't highlighted because you haven't got it setup correctly
Actually you're missing an assignment operator.
And yeah, it's required to have a configured ide to get support on the official unity discord server
That NPC go to entrance, and then do his stuff. this the the entrance "door"
What is the prefab asset referencing? Is it a scene object that you're trying to reference? Prefab assets cannot reference scene objects.
and the test npc in my hierarchy it works fine ,
but when trying to set the target script from the assets > prehabs it doesnt see it?
Assets cannot reference scene objects. Any scene can be present.
I think I set it up correctly now, not sure but that's what chatgpt told me š , what is the error on line 19 and how can I fix it/
how do I make it so when they get cloned they get that target? as now they just choose a random target?
I need to set the target in my script or?
var instant = Instantiate(...);
instant.field = ...;```
The manager or whoever spawns it should somehow have a reference to it.
Thanks
You're missing an assignment operator #š»ācode-beginner message
uhm, what is that? if I may ask
and how can I add that?
Look at their line closely while reading this:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/assignment-operator
Compare your line with their line. You should've missed the assignment operator.
š
Thanks I did:
void SpawnNPC()
{
if (GameObject.FindGameObjectsWithTag("NPC").Length >= maxNPCs)
{
return;
} else {
int randomIndex = UnityEngine.Random.Range(0, npcPrefabs.Length);
GameObject npc = Instantiate(npcPrefabs[randomIndex], transform.position, Quaternion.identity);
npc.GetComponent<NpcMoveManagement>().targetPoint = GameObject.Find("Npc_Entrance").transform;
Debug.Log("Spawned NPC: " + npc.name + " at " + DateTime.Now);
}
}```
And now it works
hi does anyone have good yt video that introduce to doing ai in unity?
what kind of AI specifically? enemy behaviours or ML agents?
Why are you asking ChatGPT about setting up your VS correctly when you were given a guide to do it already.
Also, If you'd set it up .. VS would be telling you the error on line 19..
enemy behaviours. ML angents are too advance for me
you should understand basic concepts such as navmesh (so that your enemies avoid obstacles), raycasts (so that your enemies see) etc. you could start with a simple enemy that chases the player when they see/it gets too close, a quick youtube search should give you one of those tutorials. it will help you to understand patterns such as a State Machine if you want to create more advanced enemy behaviours. you could also take a look at how other games do these kind of enemies, such as Lethal Company
thanks
how should i go about making a keyboard based movement system on an isometric map/game with direction based animations? (2d)
!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.
this is my code for making the gameobject move along with the cursor
the value for Mouse.current.position.ReadValue() is in the 100s when its pointing at 0,0 in game view?
using UnityEngine;
using UnityEngine.InputSystem;
public class SetBlock : MonoBehaviour
{
// Update is called once per frame
void Update()
{
transform.position=Mouse.current.position.ReadValue();
}
}
With seeing the correct way is a box or cone object that checks for objects inside and shoots a raycast to the player or target, no?
please consider sending your question along with or even before sending the code
there are a couple of different ways to do that, but a raycast/linecast is basically always used to determine if there can be a clear line of sight with each other. for the vision cone itself you can simply compare angles, check if the object renderer's bounds are on the screen etc. angle check is the easiest
You're mixing screen coordinates with world coordinates. You'll have to look up how to convert between them. There are plenty of resources, google for "unity follow mouse 2d" (or 3d depending on what you have)
mouse position is often provided in screenspace, not worldspace.
though seems like the inputsystem one is provided in window space, according to docs: Pointer.position
i haven't actually seen this space before tbh, not sure if it'd be interchangeable with screenspace.
for screenspace, you'd use Camera.ScreenToWorldPoint to convert to worldspace.
i guess try that? i couldn't find a specific conversion function from windowspace to.. anything else, really. the Display class seems pretty barebones
is this windowspace/display thing just to disambiguate between the entire physical screen vs the rendered screen 
the movement works after converting but for some reason the sprite doesnt render in game view (my cursor isnt there cuz of taking the ss)
Check the position.
Normally you'd have to set the z value of position to some value away from the camera position (which the screen point would be relative to)
Ahhh forgot abt the z axis, thanks!
I'm new to unity and I made this code for player movement with an input for every idle position sprite. BUT when I put .png sprites or .gif sprites in the input they don't show while I'm playing the game the player is invisible... why?
code: https://paste.mod.gg/byaxpjxqifem/0
A tool for sharing your source code with the world!
YOO anyone able to help me understand constructors and why i have to compose new objects on awake ?
What about constructors? And what do you mean by "have to compose"?
anyone able to help me understand constructors
is there a specific question you have in mind, or a specific aspect you don't understand?
if not, go look at existing resources.
why i have to compose new objects on awake
you don't in general. maybe you do for the specific task you're doing, but that's unrelated to constructors in general
hi when buttons clicked my panels not working please help me
what do you mean by "not working"? what do you expect to happen?
When I click the buttons, nothing happens. Specifically, the 'Security Camera' button is supposed to show the camera feeds, but they aren't appearing
start debugging through the chain of events that should happen. check your listener - is it being triggered?
if so, the issue is in the activation or whatever after that
if not, the issue is with the button or the event
you can tell if a function is being called by using Debug.Log
I checked with Debug.Log, and the listener is being triggered. The message shows up in the console
ok, then something after that isn't working. if you have conditionals, check if they're being passed
okay, that's a good start
if you're not sure what to check next, start with sharing the relevant code so we can give more specific advice i guess
!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.
let's see some screenshots of the player setup, with the inspector for this component
ok
can someone please point out whats wrong with this code because it says "NullReferenceException: Object reference not set to an instance of an object" for lines 15 and 23-https://paste.mod.gg/vnfzeajvqukf/0
A tool for sharing your source code with the world!
ok, here: ( the .png sprite is shown before the game start but when the game actually starts there is no game sprite .png or it spawns not as part of the player far a away and falls through the floor because it isn't locked in with the player )
You've got 2 game objects called player.
The inspector for PlayerMovement only shows 3 sprite fields, the code shows 6 - what is going on?
The sprite can't fall on it's own, it is on the Player game object, if the sprite is falling through the floor, it is because the player is falling and there is a problem with collision.
oh sorry I updated the code
When sharing screenshots, pls make sure that the inspector is actually visible, you've got it squished over hiding a lot of information
A tool for sharing your source code with the world!
NRE means you're trying to use a variable which hasn't been assigned a value. You probably haven't assigned a button to the button field in the inspector
well, the only thing that could be null on those lines would be _button, so presumably _document.rootVisualElement.Q("StartButton") as Button is null.
either that element doesn't exist, or it isn't a Button. do some debugging to figure out which is the case, and then go from there
the inspector value isn't being used
ah, overridden - didn't read that line
the player isn't falling the player moves normally and with controls and walks on the floor but is invisible and doesn't have a sprite even tho I have a .png assigned to it ( also sorry for the extra player I was doin some testing and forgot to remove it, i removed it now )
you're gonna need to record a video of what's happening.. show the issue, and then pause the game -> select the player, the scene view and find where the player is
Make sure the inspector is visible and actuallly useful (not hiding like in the screenshots)
ok gimme a sec
Should I use Player Input
Hey everyone so im learning C# and in the lessons about variables and declaring them it says to declare them right before you use them so essentially in the same line of code. Although for game developpement is it better to declare all the variables before at the top or while using them since in gamedev we reuse variables quite often?
it really depends for which reason youre declaring them
Declare your variables as close to the action as possible
in the minimal scope required
if it's something you need to store state over the lifetime of the object, then it should be a field at the top.
If it's a local variable, declare it as late as possible.
the smaller the scope of a variable, the easier it is to read the code, because you need to remember less context.
oh okay thats why i see everyone declaring them at the top on tutorials
yeah alright ty
"at the top" are typically fields, yess
beginners tend to overuse fields in places where local variables will do fine
wdym by fields?
field is the name for the variables declared (usually) at the top of a class, outside of a method
okay
They're essentially bits of data that are part of the object that the class defines. Like properties of the object. For example a balloon might have a color field, or an Animal might have a legCount field
okay
this is opposed to a local variable which is ephemeral and only exists for as long as the scope it's defined in.
For example you might declare a local variable to hold osme intermediate calculation value that is created and consumed immediately.
// Calculating the area of a triangle:
float baseByHeight = b * h;
float area = baseByHeight / 2f;```
I redid the code and player and now sprites appear but player can't move even tho there aren't any errors
https://paste.mod.gg/iinbujscodsi/0
A tool for sharing your source code with the world!
okay so in this code for example : the string UserValue is a field and message is just a regular variable correct?
No, there are no fields in this screenshot
both of those are local variables, because they are declared inside a method
okay i dont understand then
a field would be declared inside the class, but outside of any method
okay
class Example {
string myField;
void SomeMethod() {
string someLocalVariable;
}
}```
oh so it would be in between class program and the curly bracket?
ohhh okay
so i still dont understand how i would choose which to put in field and which to put as normal is field for variabled repeated many times throughout the whole code and normal variables just used a few times or otherwise?
then you lack of c# basics
i wouldnt say this is necessarily c# basics
mostly just basics of programming in general
fundamentals* should say
it should exist within the narrowest relevant scope.
if it's specific to the logic of a method, it should be local to that method.
if it's specific to an instance of a class, it should be local to that class instance (aka an instance field)
if it's specific to the concept of the class, it should be local to that class (aka a static field)
okay well is that wrong
i dont think he was implying its wrong
he was just pointing out why you lack that understanding to begin with
idk it seemed like he was but ok
i think you might need to take that chip of your shoulder
okay but thats kinda of normal like i just started
we are here to help
of course
its not abnormal nor was it hostile lol
there are some prerequisites in programming that you need to know before going on to learn other things. that's just a fact, it's not bad to not know them - nobody starts off knowing everything of course
i am trying to tell you that you need to learn the basics of programming nothing more nothign less
okay well im not trying to be rude i just don't feel there is a need to say you lack of something in programming to a beginner whos young so might have a harder time understanding different notions?
thats literally what im doing
fine, keep up the hard work
thank you
i feel like you're taking more than what was implied.
murado just pointed that out, as something that you need to work on, if you weren't aware (because some people definitely aren't)
we aren't psychic, we don't know if you're aware
since you are, take it as a confirmation that you're at the stage where you think you are, so you can pace yourself properly
okay well im pretty sure this is one of those prerequisities because im just following the official C# course
alright
theres more to programming than jut understanding a certain syntax as well
i understand that
i'd also like to note that there's kind of a separation between knowledge and experience - this is kind of a concept that relies on both
knowledge about how scoping works, and the experience to understand what should be scoped where
yes i totally agree
docs/guides can only get you so far, specifically in the knowledge aspect
you gotta try stuff yourself for the experience aspect
thats what ive been trying myself i just wanted to specifically know perfectly how different variables should be used because its abit confusing but i understand it a lot better now
going by this rule of thumb, i guess you could have them in the smallest scope to begin with and then move them to outer scopes as necessary. with experience you can forsee the necessary usages and put them in the relevant scope directly
ides also have great tools for that process, namely moving lines (alt+up/down in vscode, not sure for other ides)
alright
Iām of the opinion that starting out itās fine to overuse fields. With experience you will learn why itās bad to overuse them, but to start out you shouldnāt be too concerned with scope. Just take the approach that helps you best understand what youāre trying to implement
I think every programmer years down the line (or even weeks or months) can look back at their old code and cringe at how poorly itās written. Thatās normal. Itāll happen to you. So donāt worry about doing things in ideal ways yet.
cringeing at your old [anything] just means you've improved
honestly when im looking at shit i wrote a month ago i have no clue how or what i wrote š
documentation is very essential
[insert sheldon "Why? WHY?! Oh, that's why." gif here]
I wanted to send the gif of grandpa Simpson saying āItāll happen to you!ā with my comments but sadly cannot⦠š„²
It inevitably happens. You'll start with a small class that grows into some big, yet efficient production-ready asset (code) . . .
Hey guys, Im trying to have scoring system that will update after player pick up object, then the object dissapear. The disappearing part is work but the score is not.
Do you have any errors?
Is cm correctly assigned?
I thought this tells the compiler to ignore it, but it is treating it as a duplicate variable name - could someone explain this to me?
I have NullReferenceException error popping up. cm is assing like this.
The error means you have a reference variable that is not assigned on line 11 of CoinManager . . .
i think you need to not have a type to treat it as a discard?
otherwise if it were treated as a discard it'd be ambiguous
You have two names that are the same because it's the same character. Just put separate names for each parameter . . .
Are you trying to drag this script onto a GameObject?
yes
ah ok thanks
When I try to put my text in it wont let me.
From the error message that popped up, does the class derives from MonoBehaviour?
It's not a component if it doesn't inherit from Mono Behaviour. What exactly are you trying to do?
I just started scripting for the first time and I try to do basic 1 person movement
Make it inherit mono behaviour
this isnt the script giving you the error message.
The error seems to be referring to something else
im new so i dont really know
no this was in a old project this one is another but still giving the error
so youre getting the error for "PlayerMovement" when you try to add FPSMovement to the object?
The error says the script is called PlayerMovement . . .
but you sent us a script called FPSMovement. Did you rename it?
The types likely do not match. Make sure the object you're trying to drag in has a coin manager component. Other than that, prefab assets cannot reference objects in the scene.
forget the playermovement this was a another project
Step one make sure there are no errors in your console window on Unity
Where are you dragging your text from? The scene? Are you dragging the text to another scene GameObject or onto a prefab?
are you seeing any errors in the editor
where is the console ?
Onto prefab. I think, Im working in one scene.
Well that's confusing since it's the error/problem you sent us . . .
Window -> General -> Console
It should be open at all times, it's vitally important
As Dalphat mentioned above, a prefab cannot reference a scene GameObject . . .
can you send your entire script here
š 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.
oh can someone teach me to do basic 1 person movement ?
So if I move it to prefab would that fix it?
normally done
oh
please also read the bot messages...
š 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.
No, copy-paste it into a code website, then send us the link to view it . . .
ohhhhh
okay
A tool for sharing your source code with the world!
and its a chatgpt script sooo
AI assisted coding is frowned upon, just to be honest with you. Either way, folks will know if you've written it yourself or not.

No, you need to place the prefab in the scene. This will create a GameObject. Then you can assign the the text to the variable slot onto the created GameObject . . .
also people arent inclined to help with ai created code
because why should we
you didnt bother making it why should we waste our time fixing it
its just that i dont understand the monobehavior error i just want to know how to fix it
Because look at your script
it clearly doesn't derive from MonoBehaviour
you probably have more than one script with the same name or something
but the one you're trying to drag is not a MonoBehaviour
We explained the MonoBehaviour error earlier . . .
The volunteers here might be willing to help you fix something you've thought of and written up yourself (or with the help of a tutorial). But most aren't willing to fix code written by AI because the AI will likely not write coherent/good code - sometimes making absolutely no sense.
this code you shared here is not what Unity is seeing in your file
so either it's a different file, or you need to refresh your assets, or restart Unity
or save it . . .
i think its better if i restart a project
i think you should ditch the ai and learn unity the normal way
:teacher: Unity Learn ā
Over 750 hours of free live and on-demand learning content for all levels of experience!
can you suggest me a video or a website where i can learn basic 1person movement ?
:teacher: Unity Learn ā
Over 750 hours of free live and on-demand learning content for all levels of experience!
youre mising some important fundamentals of the unity editor
see that you learn that first
I was able to fix up the counter not updating, now I just have to fix the UI text not updating with it.
one step closer . . .
@sullen arrow Instead of directly accessing (and changing) the counter variable, you should call a method on the CoinManager. This method should add to the counter variable, and update the UI text. Doing this will avoid constantly assigning the UI text every frame in Update . . .
Im sorry, I dont think I understand what you mean by this, english is not my first language so technical stuff are sometimes hard to undrstand.
show new code and explain what is not working
I havent change anything so far, I incorrectly linked? the coinManager script with my player, os that was why the counter wasnt updating. @frail hawk
Are you certain what you've "linked" (reference) is the correct object in the scene?
maybe you are using Tmp instead Text
I dont have text option, only TextMeshPro.
using TMPro;
No, Im not.
How do I not use it? I dont have any other option or putting text in.
because your component is not of type Text that is why
put this at the top and then you can use textmeshpro stuff
If you have a TextMeshPro component for your text, you need to use the TextMeshProUGUI type, not the Text type that you have in your script. John mentioned to add the using statement at the top of your script to gain access to the correct type that you need . . .
or TMP_Text
Thank you so much guys! YOu are literal life savers, its finally working
Also Im really sorry if I was confusing, using text in unity is completely new to me :3
Agreed, TMP_Text is much better to use . . .
you did not explain well enough before that is why i asked again
how would you guys go about making a ticking system that ticks every second irrespective of lag (if that's even possible)
respect deltaTime
or compute it yourself if you also need to consider the max timestep thing
It depends what you mean by this. If you actually need a consistent real-world timer that runs exactly on the second every second, it can't be done.
But if you want something like FixedUpdate that just guarantees the correct number of runs over time, it's pretty simple:
public float interval = 1;
private float timer = 0;
void Update() {
timer += Time.deltaTime;
if (timer >= interval) {
timer -= interval;
DoSomething();
}
}```
i mean, if you have lag >1s, then it'd be impossible to make it update every second. you can still make it count more than 1 second after the lagspike though
it can't really be done within Unity.
i mean... you could just display the system time
ah, you ninja edited that out lmao
I really borked my edit
that's been my approach as well just with Time.time instead - I'm doing a damage over time system and I'm just (likely needlessly) worried about the edgecase where there might be a hiccup, and a bunch of ticks might not go through
The issue with Time.time is it slowly loses precision as it gets further away from 0.
if you need to guarantee the correct number of runs, you'd generally do while instead of if there
Technically correct yeah. The if statement version will spread them out to a max of once per frame which can be nice, however it will fail when TIme.deltaTime > interval
for some reason when I write this example I always use if, because I'm oddly worried about someone mis-copying it and freezing their editor and being mad at me 
hello
You should be able to resolve this by multiplying the amount of damage applied by Time.deltaTime
That way it accounts for variable frame rates
that could work
If deltaTime is larger, youāll take more damage the next frame
Depending on the game, that might not be a great idea. For example what if you step into a pit of fire very briefly but then there's a lag spike on that particular frame. You end up taking more damage than expected
since I'm doing it per second though, should I maybe do it as float damageMult = lastTickTime - currentTime?
these are the cases where a FixedUpdate style thing is better
Valid point
that sounds like a feature
this used to a be a problem with the jetpacks in the game Satisfactory. You would start flying then there's a lag spike and by the time the game recovers your character is flying super high in the sky and you're out of fuel so you fall and take fall damage
oh lol yeah that doesn't sound great
Because the game treated it like you were holding down the jetpack button for the whole lag spike
It might get messy but you could have some predefined threshold of deltaTime to account for a lag spike
Or yeah using FixedUpdate might just work instead
But that does mean you are locked to the physics tick
Which in the case of the fire example is probably preferable
there already is a max delta time, by default of 0.33 seconds
why would they be? they aren't actually logic or properties, they just allow you to remove the namespace for types in that file
I just kind of assumed anything the base class has, the children would too
but if the base class uses a Debug.Log for example?
Dont think using statements work like #include
if that makes no sense to you then dw about it
they aren't imports. they just allow you to omit the namespace for types you use in that same file
and that's in the base class. this Debug.Log is a new one, outside the base class
usings aren't related to classes, they're related to files - files don't get inherited
(they can also be in namespace scopes, but they still apply to just that specific declaration, and not the namespace as a whole.)
that makes sense, I'm just experiencing some sort of Mandella effect lol
If a class is in a namespace then it doesnt require a using statement for its contents
Oh interesting. Never knew that!
{
public int x;
public int y;
public Coord(int X, int Y)
{
x = X;
y = Y;
}
public static bool operator ==(Coord c1, Coord c2)
{
return c1.x == c2.x && c1.y == c2.y;
}
public static bool operator !=(Coord c1, Coord c2)
{
return !(c1 == c2);
}
public bool Equals(Coord other)
{
return this == other;
}
public override bool Equals(object obj)
{
return obj is Coord other && Equals(other);
}
public override int GetHashCode()
{
return x.GetHashCode() ^ y.GetHashCode();
}
}```
Hey everyone. I recenlty found out that csharp allows us to override opperators like == or !=. But after that, I was told that it was better not to do that. Then I started searching and found that it is acceptable in gamedev for simple things like coordinates. But is it true? Or it is better to use methods always?
Perfectly acceptable to override operators if your type needs that
best used with classes as by default thats reference equals
Afaik the only reason not to override operators is the readability which can get poor when used wrong. Especially the equality/comparison operators should be fine to override where such comparisons make sense for the class. Lets say you had a color class, overriding the more than operator for it I would really try to avoid since what makes a color larger than other color? If you wanted to compare the intensity of the color for example, it would be much more explicit to do it via method for example. For mathematical classes/structs (vectors, matrices etc.) it does make sense to override the arithmetic operations too since those are very clear to the reader what those would do. Overriding an operator which meaning is not automatically clear in the context of the class/struct is the only case in which I think overriding is a bad practice.
This is my script for a SFX manager for my game, i am new to sfx manager scripts (followed a guide to get myself going) and it doesnt cover how to make a looping sound function? could anyone help me on making a function for playing and stopping looping sounds?
The script spawns in an object with an audio source, and destoys it once sound is over.
my functions for the looping sound stuff is where i left off, only the PlaySFX one is actually complete
If you've got an actual question or concern, you ought to just ask.
https://dontasktoask.com/
Ok ok I see
So: I assume my function that loops audio (PlayLoopingSFX) is meant to be given the name of the audio (string audio name) and then, StopLoopingSFX is meant to also receive that same name and then it stops he audio and deletes the audio source object.
So my question is: How can I define the audio name (string audio name) in PlayLoopingSFX and then also check for it in StopLoopingSFX?
This is the code ^
Maybe have a field referencing the instantiated looped audio source instance.
I will keep that mindset in mind when asking questions, at first I was annoyed but I now see the valid issue with the way I came to ask for help xD
It could be a reference to a single instance, a collection of instances, etc
Iām pretty new to code stuff so Iām not rly sure what it means exactly, do you have any resources on how to do that?
Highly recommend stating clearly what is the problem you are having when asking. Of course we can see the error in the console but many here may not even open the screenshots. One tip for your code outside the issue in hand, think how you could simplify the two if statements so you would not have to write the same check twice (tip: else statement).
Regarding the actual issue, you are calling GetComponent on the gameObject your script is on, the renderer within the child object won't be found by that. There are ways you can access the child object (transform.GetChild for instance) but maybe easier and more robust way would be to expose the renderer you need to the inspector via [SerializeField], drag and drop the right object to that field and use the value directly without even having to do any GetComponent stuff.
i havent learnt how to use serialisedfields yet, im guessing i definetly shouldš
You already have public float aiSpeed which is exposed to the inspector. The idea with [SerializeField] is that you can keep the field private (so it can't be modified from other scripts) while still having access in inspector. [SerializeField] private float aiSpeed would be shown in the inspector exactly the same, just now it being private which everything should be unless it really needs to be public. Whether you use public or SerializeField do exactly the same thing in the sense that the value can be modified in inspector, from code quality standpoint, the latter is more recommended. What you want to do to reference the right Renderer is to make a serialized field (either public or using SerializeField) of type Renderer
Yea thats a core feature of unity but you may be using it already
public fields are serialized by default
so a serialised field makes it so other scripts cant change it but you can still change it in the inspector?
Yup. If you are not going to modify them from elsewhere, all of your public fields (ai, player, playerCam etc.) would be better that way
just so i can visualise it better, what situation would a game require a serialised field instead of being public
It's never required. public works just the same. It just makes for better quality code when you don't need to access the fields from outside the class. public should only be used when you need outside access
is there any drawbacks from using public then like performance?
No, it's just bad practice when it's not needed. Lets say you worked together with somebody else to make the project and the other guy saw that you have a public field called playerCam, they may want to set it to some other camera in their other script to switch cameras during play. Since you only wanted to make it public to modify in inspector, you probably didn't take into account in your code that the value can change from a frame to another. Maybe it wouldn't happen in this case but in general there can be cases where changing a field can break the code when it isn't being anticipated. Things being public usually indicate that it can be freely modified outside the class, if that is not what you want, you should avoid making things public. The SerializeField attribute is there just for that reason, to allow making things visible in inspector without exposing the field to other code. If a field is public already, SerializeField doesn't do anything since public fields are already being showed.
public fields show up in the inspector by default; other fields need [SerializeField] to do so
Also for properties
technically it doesn't work for properties, but you can target their backing fields
Properties with automatically-generated backing fields require special treatment, yeah
I've found that to be more of a nuisance than it's worth
There's also [HideInInspector] in case one wants to make something publicly available for other classes but doesn't show in inspector
Access modifiers, like public, only affect your development process. It'll have no impact on the final game
having an explicit field means I can rename the property without needing to deal with that change in serialized name
this also still let's unity serialize the field (which means if you set a value in the inspector before applying that attribute it will keep that serialized value)
NonSerialized would be the attribute to use to prevent that
Sure, you can even use both SerializeField and HideInInspector for a same field to serialize but not show. Serialization is definitely beyond what the original question was about though
i'm not saying that using both is what will do it, i'm saying that using HideInInspector on a public field will still serialize that field. it just won't be shown in the inspector. that is something that can be important to remember, especially if you add the attribute later on or you change what the value is assigned in the field initializer since the initial value will still be serialized for that field
@misty sand Anyways, this public vs [SerializeField] conversation is something good to be aware of but beyond the point. To recap the asnwer to the original error you had: if you want to get the renderer component from the child object, my suggestion was to make a serialized field of type Renderer and drag and drop the right reference in inspector similarly to what you have done with other fields like the playerCam. I suppose you could use GetComponentInChildren to find the renderer too but if you have multiple renderers under the parent object, you may face some trouble, dragging the references in inspector is often the easiest approach
Yes a very common footgun so suggesting HideInInspector is bad
noob question i just finished the beginner tutorial for unity and im trying to add a second AI enemy but its going through the walls i have baked
im doing the roll a ball tutorial
just starting out guys 
<@&502884371011731486>
hi. i want my mouse to control the flashlight and the camera slowly lerps towards it almost like this. however, the player body doesn't follow. how do i fix this?
if (canMove)
{
rotation.y += Input.GetAxis("Mouse X") * lookSpeed;
rotation.x += -Input.GetAxis("Mouse Y") * lookSpeed;
rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit);
transform.rotation = Quaternion.Euler(0, rotation.y, 0);
if (flashlight != null)
{
flashlight.localRotation = Quaternion.Euler(rotation.x, rotation.y, 0);
}
playerCamera.transform.localRotation = Quaternion.Slerp(
playerCamera.transform.localRotation,
Quaternion.Euler(rotation.x, rotation.y, 0),
smoothTime * Time.deltaTime
);
}```
edit: this is happening in the update function with time.deltatime on movement stuff
You're rotating the children but you forgot the axis Apply the Y rotation to the player's root and let the camera only inherit the local X movement. If you don't separate the axes your camera will always be independent of the body
š¤
so in stupid people terms (me), what fixes to the code would i need in order for this to work?
sorry its almost 2am my brain is cooked
hey, i got the shader graph to work with the simple noise node (creating waves) but now im having trouble recreating the noise node in C# like was suggested; does anybody have any ideas?
Relax, you're not stupid, you're just thinking in 2D in a 3D world. We've all been there. š¤
Look, it's simple: in your script, instead of rotating the camera on the Y-axis, find the 'Player' object (the parent) and rotate it. That way, when the body rotates the flashlight and camera will rotate automatically because they're attached to it Only use camera rotation to look up and down (X)
Try that and let me know. Don't overcomplicate things; logic is always simpler than it seems. Short and simple
so now i have this with the following code:
if (canMove)
{
rotation.y += Input.GetAxis("Mouse X") * lookSpeed;
rotation.x += -Input.GetAxis("Mouse Y") * lookSpeed;
rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit);
transform.rotation = Quaternion.Euler(0, rotation.y, 0);
Quaternion targetCameraRotation = Quaternion.Euler(rotation.x, 0, 0);
if (flashlight != null)
{
flashlight.localRotation = targetCameraRotation;
}
playerCamera.transform.localRotation = Quaternion.Slerp(
playerCamera.transform.localRotation,
targetCameraRotation,
smoothTime * Time.deltaTime
);
}
what have i done wrong and what knowledge do i n eed for it to happen horizontally too?
(i split them up and change a bit of it but im still not sure i've done it right)
You're on the right track; you've already separated the logic, and that's the hardest part. š¤ Look, to make the body rotate horizontally, you just need to add one line before your camera rotation In your code where you capture Mouse X apply it directly to the parent like this:
transform.parent.Rotate(Vector3.up * mouseX)
With that, the body (the Parent) handles the horizontal rotation, and your camera (the Daughter) only needs to look up and down It's the cleanest way to do it and prevents the code from becoming a tangled mess of quaternions
Try it, compile it, and go get some restāyou've earned it. Short and simple
everything i do stiffens up the horizontal axis. i want what i have vertically, horizontally too
the smoothness
I understand, you want the body's rotation to have that same smooth feel as the camera.
Look, to avoid a stiff feel, don't use Rotate directly. Create a targetRotation variable for the parent and use Quaternion.Slerp or Lerp in the Update, just like you did with the camera, but applied to the Player transform.
Basically
You calculate the desired body rotation along the Y axis.
You smooth the transition between the current rotation and that target rotation
This way, both axes will flow harmoniously Don't overthink it for today; your logic is already sólida you just need to smooth out the code. Time to rest, because tomorrow's code will be much easier to read!
š¤
are you using AI to answer their questions? because that is against the server rules
AI? I wish an AI could feel the pain of spending 10 hours debugging a rig at 3 AM. š¤ > The difference is that I learned this by breaking versions of Unity since before the Shader Graph existed. If my logic seems too clean to be human, take it as a compliment, but it's just accumulated experience. Short and simple
With all due respect, but this shows you lack a lot of knowledge.
š¤
at no point was the logic "too clean to be human". you speak like an AI with the bullshit empty platitudes and brown nosing that it is known for.
If you have a problem with how I help, open a ticket or escalate the complaint to the staff. š¤
Meanwhile, stop wasting time analyzing my English and get to studying, because it's obvious you need to. I have work to finish. Short and simple. š¤
If you like to be talked to
get to studying, because it's obvious you need to
seems like someone is a little insecure and is lashing out despite not having seen any indication of my skill level.
@sour fulcrum @twin pivot @rich adder ā¦ĶĶĶ_
don't tag people you're not in active conversation with
can i talk now
hey can anyone hlep me
Im new to unity and trying to make a forest with trees that span at random locations
how can i do this while ensuring the treess dont spawn too close together
@here
Take a look at an algorithm called Poisson Disk Sampling, it might help you with this problem.
thanks š
#šācode-of-conduct
-# and why would you try to ping almost 20,000 people anyway
sorry
if (heldObjectrigidBody != null)
{
Vector3 targetPosition = playerCamera.transform.position + (playerCamera.transform.forward.normalized * heldObjectDistance);
Vector3 targetDirectionForce = ( targetPosition - heldObjectrigidBody.transform.position ).normalized * strength;
heldObjectrigidBody.AddForce(targetDirectionForce, ForceMode.Force);
}
So this code works to keep a rigidbody in the general vicinity at the "targetPosition". But I'm having issues with the rigid body overshooting the target and bouncing back.
I know there is a way to fix this with some math, but I can't for the life of me remember what that math is.
it sounds like you want some kind of easing or damping
there's a ton of ways to achieve either - for example, a PID controller, smoothdamp, wronglerp (or the improved version for better results), a critically damped harmonic oscillator, etc
which one do I use?
Which one do you have?
I currently have the lower one selected, but I do not know if that is the correct one to use, or if theyre both correct
If you have them both installed it doesn't matter which one you use
I do have them both installed, does it really make no difference?
why would it
because to me they look like different versions
They are
but I can use both?
thanks!
Does anyone know how much more time (if any) will Visual Studio 2022 Professional be supported as an IDE for Unity 6 and the next Unity versions?
Why wouldn't it be supported by later version?
Well idk, cuz VS 2026 already exists, so, maybe 2022 won't be supported forever idk
It's just an Editor (VS) version. I would think that as long as Visual Studio itself remain backwards compatible (in regards to it's workload and backend), Unity would not differentiate between the versions.
Depends what you mean. An IDE for Unity is just a text editor with tools. The text editor part will always be supported - you can write Unity code in notepad if you're masochistic enough. But you're probably more concerned about Unity projects being able to use IntelliSense, do code highlighting etc. I don't see a good reason why they'd remove that capability that is already there, unless there is a major change to how things work.
hello
here is my story xD
i thinked about a colony game like as Stranded alien dawn
since last september im prompting on Chatgpt assets
im new in this game desing world xD im looking for tips maybe somebodi/es who can jump with me for this journey ^^
have a good one š im french btw ^^
most people here do not like chat gpt
this channel is for questions about programming, we don't have a channel for stories
not he good channel ok thank you
Hey does anyone know any good tutorials for Vr.
Wanna make a physics sandbox shooter. Any tips?
#š„½āvirtual-reality -> pinned messages
if (foh.FollowObjects != null)
{
Debug.Log(foh.FollowObjects.Count);
npc.targets.AddRange(foh.FollowObjects);
Debug.Log("Targets added");
}
im using this script to add one list to another. but its just not adding. the log gives proper count yet the list doesnt add at all. someone please help me out
you have the brackets now so that snippet is fine but just letting you know unlike languages such as python, c# does not functionally care about identing whatsoever, it's just a visual thing
perhaps debug.log foh.FollowObjects count?
if its empty it would be correctly adding nothing for example
-# that's kinda hard to parse, maybe add a comma in there
yet the list doesnt add at all.
how are you confirming that? have you tried loggingnpc.targets.Countbefore and after?
i can check through the inspector, npc.targets always just has one component which is the one which i put in manually
are you looking at the right instance then?
i can see through the inspector. there's clearly 3 components
yeah im a 100% sure
try Debug.Log("Added to npc list", npc); to make sure you're targeting the right object, and not for example a prefab
you could totally be right but your assuming your looking at the right object at the right point in time, to reduce the assumptions logging directly is a better strat
and again, do try logging npc.targets.Count
omg you're right
from the logs the list is added to the list of the prefab and not of the instance
i didnt even know that could happen
time to name those variables better
I am having this weird jittering effect in my game can someone please help me
both the pink bird and player are being translated
playerPositionerScript.TranslatePlayer(0.25f, 1f);
StartCoroutine(PlayerPositioner.MoveObjectX(transform, followPoint, 1f));
public void TranslatePlayer(float viewportX, float duration)
{
Vector3 viewportPoint = new Vector3(viewportX, 0.5f, GameManager.zDistance);
Vector3 worldPoint = mainCamera.ViewportToWorldPoint(viewportPoint);
StartCoroutine(MoveObjectX(gameObject.transform, worldPoint, duration));
}
// ? This function is only supposed to move object smoothly in x direction
// ! This function is supposed to let user control their y as they wish but is not functioning to do that
public static IEnumerator MoveObjectX(Transform obj, Vector3 targetPos, float duration)
{
Vector3 startPos = obj.position;
float elapsed = 0f;
while (elapsed < duration)
{
float t = elapsed / duration;
t = Mathf.SmoothStep(0f, 1f, t);
float newX = Mathf.Lerp(startPos.x, targetPos.x, t);
obj.position = new Vector3(
newX,
obj.position.y, // preserve current Y
obj.position.z // preserve current Z
);
elapsed += Time.deltaTime;
yield return null;
}
}
when the pink bird and player are being translated back the player is jittering
hence, challenge your assumptions. don't be 100% sure until you've actually checked
!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.
just new error now :(
sory
playerPositionerScript.TranslatePlayer(0.25f, 1f);
StartCoroutine(PlayerPositioner.MoveObjectX(transform, followPoint, 1f));
public void TranslatePlayer(float viewportX, float duration)
{
Vector3 viewportPoint = new Vector3(viewportX, 0.5f, GameManager.zDistance);
Vector3 worldPoint = mainCamera.ViewportToWorldPoint(viewportPoint);
StartCoroutine(MoveObjectX(gameObject.transform, worldPoint, duration));
}
// ? This function is only supposed to move object smoothly in x direction
// ! This function is supposed to let user control their y as they wish but is not functioning to do that
public static IEnumerator MoveObjectX(Transform obj, Vector3 targetPos, float duration)
{
Vector3 startPos = obj.position;
float elapsed = 0f;
while (elapsed < duration)
{
float t = elapsed / duration;
t = Mathf.SmoothStep(0f, 1f, t);
float newX = Mathf.Lerp(startPos.x, targetPos.x, t);
obj.position = new Vector3(
newX,
obj.position.y, // preserve current Y
obj.position.z // preserve current Z
);
elapsed += Time.deltaTime;
yield return null;
}
}
isn't that the same error you had like, a day or so ago
yeah yesterday night. today morning i didnt have that. now i fix the issue and here it is again
- is your camera moving or stationary?
- are you using a pixel perfect camera?
my camera is stationary
i haven't changed anything in camera it's just the default one
this time the targets are properly added, none of the instances is destroyed. yet that error
i suppose do some checking to make sure the foh is the object you think it is, and potentially also its FollowObjects elements
try adding a pixel perfect camera (and configure it properly)
umm actually the thing is only happing to the player and not to the pink bird
so it might not be camera fault
it is.. and i logged the count of the objects, im getting 3 which is correct
why is it saying it doesnt exist anymore when it is literally there
i see that you haven't logged a context in any of those logs
there's a reason i added the second argument npc here
should i try logging anything else ? i tried making the foh variable a public class because i was running the assignment code just once but still im getting the error
you should log a context and see if the object points to the object you think it does
yeah it does... foh points to the correct instance and so the does the npc variable
does the player have any other components, eg a rigidbody?
as in the npc? yes
ye
the up and down moments are happening with velocities
you haven't logged a context in any of the logs you've shown. have you done that and you just aren't showing it, or have you not done that at all
that was not for you
you should not be modifying the transform then, that will conflict with the rigidbody as it tries to control the transform.
once you have a rigidbody, do all the movement through that
šššš
ummm
ok thanks
i have... ROAD_STRAIGHT(Clone) and bomber are the context
mb
no, that's not how context works
it's a seperate argument
Debug.Log(message, context)
and once you have that, you can click the log message to see what actual object in unity the context is pointing to
did you not read this message at all #š»ācode-beginner message
