#💻┃code-beginner
1 messages · Page 673 of 1
It is absolutely impossible for myRigidBody to have worked. The only answer here is that you saw it seemingly work because it didn't compile any changes you had made prior to changing it. As you said, no point arguing these facts.
Then maybe I pressed play too early??
But as you're configuring your IDE currently, these things shouldn't be able to happen again since it'll get auto corrected/underlined.
Yes, maybe you did.
It could be any number of reasons that aren't "that it worked with different spelling", which is absolutely impossible.
Thank goodness, can actually autofill some of it instead of typing everything
I have a habit of breaking things the moment I even look at em, unity was having some compile errors the moment I started it up, figured that could've been related
Hello everone! I'm a professional Roblox developer looking to try, and hopefully move forward to Unity. I'm struggling to start, and have been looking for good example games to take a look and experiment with. Could you guys recommend any? I done some research, and i'm trying to find one with dependency injection, and UI Toolkit, as these concepts were my go-to's when developing on the Roblox engine. Thanks!
check the pinned messages in this channel
I've loooked through them, although it's not what i'm looking for. I rather learn using an existing project, rather than using guides or tutorials.
i would recommend recreating some simple famous games like flappy bird or temple runner but it seems like you are more focusing on asset development than game dev
since you said roblox development and ui
This might be what i was looking for!
also, i've seen a lot of paradigms recommended; ECS, DI, etc.. which is the most popular? As in, which one should i take a look into first?
favorite animator tutorial for 3D sprite render?
im kind of lost in that unity gives me no errors but the game doesn't do anything different with my new script either.
sorry but what is 3D sprite render?
anyone know what causing this flickering behavior?
any code to provide?
hi, wondering why i cant drag my sprites into the sprites folder?
change Multiple to Single
there are many possibilites, but maybe u can try look at the rigidbody2D setup if ur movement system uses one, ie: interpolate
Try moving the camera in LateUpdate(). Maybe show some code of how you move the objects and camera.
it just made the sprite disappear and it still cant be dragged
restart unity, sounds really weird
i want to code a enemy attacks pattern, could someone explain me when to use cooldown, timer or wait for seconds?
which one does interrupt the flow but doesn´t allow a 2nd flow to come after the first
so that the flow is only going through once
how you implement the cooldown is up to you, you can use a Coroutine(Wait for Seconds) you can use the Update method with a timer or something similar
and is it the timer or is it the cooldown which lets multiple flows go through at once?
also i tried a little bit with wait for seconds but the flow get´s completely cutted even tho i did use the coroutine at the beginning
100% on me tho because i lack the understanding of flow and right conenctions and utilization
so to explain it simple, wait for second just executes code after a certain amount of time.
when i switched the wait for seconds to timer and it worked exactly how i did think it would
i used wait for seonds in other comamnds and it worked well
but yeah, i only have the problem of the flow not getting prioritized correctly, i only have a very little experience with unity so far
if i could understand time stops better it would be quite helpful
i think the fact that as you said you have only little experience explains it
yeah 😅 only 2 weeks ago i got the gist of how to do things more alone without guidance or tutorials
try rubber duck debugging first mate
are there any 3d boss battle tutorials? more spesifically and first person or third person like in elden ring bosses
can someone help me.
ive been trying to an a oncollisionenter code thing to my script, but no matter what it wont trigger
this is it
is this 2D or 3D? Do you have:
- a rigidbody (or rigidbody2D) on at least one of the objects?
- a collider (or collider2D) on both of them?
- any collision layers set?
- "IsTrigger" disabled for both colliders?
I am using unity 2d. I have a 2d box collider on all objects, and they also both have a rigidbody 2d
is trigger is not checked also
ah then it needs to be
void OnCollisionEnter2D (Collision2D collision)
{
}```
no problem 😁
🎉
it's an easy thing to miss when you're just getting started, but eventually all of this will come naturally!
Dumb question but whats the keycode for left mouse button
Mouse0
here's the docs also
for no further confusion
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/KeyCode.html
Its gonna take me 9 years to read this all so im just gonna look at it whenever i get confused on what something does
just scroll down
well
all the keycode are there
for now i dont need to know any other keycodes
so i'll just wait till i need to know keycodes for it
Aight im like really new to unity, trying to get some basic movement set up (which I have managed to do) but I got this problem with my character just sticking to walls when I jump up against them. I know its a problem with how I'm calculating movement on a slope ect. but I just have no clue how id fix it.
I can send the code file if needed, ik it will be a really simple fix like changing a single value or something. Did also follow a tutorial for it aswell.
is this in 3d? With a character controller or rigidbody?
are you using any physics materials?
probably should have specified yeah lmao, 3D charactercontrol and no im not using any phyusics material im pretty sure. all the physics and friction is all calculated and set in the character controller file
can you send the character controller then, please? 🙂
void Update()
{
float dist = Vector3.Distance(MainObj.transform.position, Player.transform.position);
Debug.Log($"Dist is {dist}, rad is {rad1}, pos is {KeyObj.transform.position} ");
if (dist < rad1 && Input.GetKeyDown(KeyCode.E))
{
if (KeyObj != null)
{
StartCoroutine(MoveKeyDown());
}
}
}
IEnumerator MoveKeyDown()
{
KeyObj.transform.position = Vector3.MoveTowards(
KeyObj.transform.position,
TargetKeyObjPos.transform.position,
speed * Time.deltaTime
);
yield return null;
}
so i wrote this
to try to move a key down until it reaches the targetkeyobjpos
but it only moves an inch everytime i click
like its at 6.00 Y level
and i click E and it goes to 5.99 or 5.98
and stops
(and then if i click it again it goes down more )
Quick question, what's the difference between Delta time and fixed Delta time
delta time:
- time in seconds it took to complete the last frame
- used for smooth frame rate movement and animations in update and other stuff
- reason why is frame rates can vary so multiplying by delta time effectively makes movement consistent
fixed delta time:
- the fixed time between calls to fixedupdate() usually i think its like a .02 seconds (50 times per second)
- used for physics calculations and updates in fixedupdate()
- physics sims run at fixed intervals for stability and other stuff
if (Input.GetKey(KeyCode.D))
{
gameObject.transform.position = new Vector3(speed * Time.deltaTime, 0) + gameObject.transform.position;
}
else if (Input.GetKey(KeyCode.A))
{
gameObject.transform.position = new Vector3(-speed * Time.deltaTime, 0) + gameObject.transform.position;
}
}```
is my usage here good?
Delta Time becomes the same value as Fixed Delta Time in FixedUpdate()
this is put in normal update
ur usage of
new Vector3(speed * Time.deltaTime, 0) is missing the Z component, also the Y component should remain the same (im assuming 3d space)
anyone can tell me how i can make a grenade in vr?
dude theres hundreds of tutorials
2d space lol
not for vr
oh idrk
yea
maybe
im not a 2d guy
i think it is better to move it in fixedupdate tho
only if ur using rigidbody2d
else its okay
na i am using normal transform movement
if (Input.GetKey(KeyCode.D))
{
gameObject.transform.position = new Vector2(speed * Time.deltaTime + gameObject.transform.position.x, transform.position.y) ;
}
else if (Input.GetKey(KeyCode.A))
{
gameObject.transform.position = new Vector2(-speed * Time.deltaTime+ gameObject.transform.position.x, transform.position.y);
}
}```
i did
idk what i was thinking lol
While it works, it's not ideal because it's not framerate independent.
Better to save the current Inputs in Update() and then use them in FixedUpdate()
its fine
hey, can u try to help m with my issue/
how to?
Your Coroutine isn't really a Coroutine, you yield return at the end but nothing comes after it. Depending on what you want to do call the Coroutine again at the end or turn the whole thing into a loop
if (Input.GetKey(KeyCode.D))
{
gameObject.transform.position = new Vector2(speed * Time.deltaTime + gameObject.transform.position.x, transform.position.y);
}
if (Input.GetKey(KeyCode.A))
{
gameObject.transform.position = new Vector2(-speed * Time.deltaTime + gameObject.transform.position.x, transform.position.y);
}
if (Input.GetKey(KeyCode.W))
{
gameObject.transform.position = new Vector2(transform.position.x ,speed * Time.deltaTime + gameObject.transform.position.y);
}
if (Input.GetKey(KeyCode.S))
{
gameObject.transform.position = new Vector2(transform.position.x ,-speed * Time.deltaTime + gameObject.transform.position.y);
}
}```
quick question, why when i move in 2 directions i get more speed
private float input;
void Update()
{
if (Input.GetKey(KeyCode.D))
{ input = 1; }
else if (Input.GetKey(KeyCode.A))
{ input = -1; }
else input = 0;
}
void FixedUpdate()
{
transform.position = new Vector2(input * speed * Time.FixedDeltaTime, 0);
}``` Something like that
if u move in 2 directions at the same time, you combine 2 speed vectors.
i figured a way to fix it
You want the player to click once and it keeps going down until it reaches the target, correct?
ooo
yes, but what is happening (issue) is when i click once, it goes down by a little bit, then if i click again it goes a bit more etc
make a variable when you click it equals to 1, and it wont go down to 0 until it reaches the destination
i feel like you overthought it cuz i could just use a bool value for that probably*
or if its a point and click movement, save the click vector, and keep reducing the current location of the object with the saved vector, and it wont stop until it all equals 0
IEnumerator MoveKeyDown()
{
while(Vector3.Distance(KeyObj.transform.position, TargetKeyObjPos.transform.position) > 0.1f)
{
KeyObj.transform.position = Vector3.MoveTowards(KeyObj.transform.position, TargetKeyObjPos.transform.position, speed * TIme.deltaTime);
yield return null;
}
}```
bruh who took the continous play bottom from youtube
what'd ya change?
and how is it gonna affect the script
it's a while loop now that "runs" every frame until the distance between KeyObj and TargetKeyObjPos is smaller than 0.1f
ah i couldve read too lol
also can i ask one more thing
how do i add a glowing item indicator
or like a pointlight thats rlly bright
to an object
as far as i know shaders
so what can i do to make that
ive never used shaders, they too complicated
prebuilt ones arent
so how do i make a pointlight/indicator for an item
in any way
idk how to access shaders in a script, but it would be like if the item is hovered by the mouse, shader example activates
eh i just installed prebuilt psx shaders
cuz im making a psx style game
suprisingly they are very good
i can try smth with that
psx? what is that lol
playstation
playstation 1
the graphics in ps1 games used to be up to 256x256 and no texture filtering
so everything was real pixelated in said games, leading to a new genre of videogames (mostly horror) in 2024-2025 called "psx retro" or smth like that
oh those streamers horror games
ya
where they scream hella for no reason
ya
mine isnt gonna be the uh
screamer type
its gonna be the psychological type/puzzle type
where it takes about 5 hours to complete 50% of the game stuck in one room
what the hell is incorrect in here
the moment i wrote this line every other vector2 went nuts
my patience would never
if you change Vector2 to UnityEngine.Vector2 does it work?
you've had a new using added automatically.. you need to remove it
have you got class Vector2 or struct Vector2 anywhere else in your code?
got them here
ayeo any idea how to make an item indicator?
i specifically wanna add some sort of image (like a glow) to a gameobject
if u dont want to deal with shaders why not create a light that focuses on it?
like a spotlight
when i delete fixed update, the vector2s go to normal
ohh if u want a glow or an outline its probably gonna need to be an outline shader
good luck finding one that works well enough for u
issue is not at all shaders, as i already have preset shaders
do all your opening curly braces { have a closing }?
hover over the Vector2 and see what the thing says
yes
nah i was thinking of adding an image to the gameobject and applying my psx shader (which would make the image follow the plrs cam like a billboard gui type of thing) can i do that?
so remove the second one (System..) from the top
or specify which vector2
at the top of your script, delete using System.Numerics
it looks like your code editor has added that for you lol
like UnityEngine.Vector2
how the hell was it even added
probably automatically when you hit enter on an autocomplete suggestion
when you typed Vector2.. you selected the one from the wrong namespace in the autocomplete
Visual Studio/Visual Studio Code/Jetbrains Rider all have functionality to automatically add using statements from autocomplete
or that ^
too many cooks now 😂 I'll drop out lmao
oh
@rocky canyon
sorry
wrong ping
u good
anyway can i do smth like thast
add an image to it
u meaning like an OnScreen Indicator?
ya, an image can be an indicator lol
yeas
i will add a glow image to the miage
and apply a shader
i can show u kinda what i mean
u can simulate glow.. with a transparent image.. if u wanted.. is this 2d or 3d?
3d
this ws the first thing that came to mind
yes, my shaders will do the transparent stuff
i can show u a reference, one min
thread this non-code chat !
a lighter item with a glow effect like this
and/ or move it to #💻┃unity-talk
ahh yes! this belongs in one of the Graphics channels
shall we move?
yes..
alr where
probably #archived-shaders
While using Cinemachine Freelook Camera, i want to be able to also pan the camera by specific hotkeys. However if i access the cinemachinInputAxisController and modify the InputValue of the X axis the camera seems to stay the same. Any clues how could i do that? ( in the editor the value changes but the camera does not seem to move)
{
gameObject.transform.position = new Vector2(inputx *speed * Time.fixedDeltaTime + gameObject.transform.position.x, inputy * speed * Time.fixedDeltaTime + transform.position.y );
}```
this feels so clanky anytips to smoothen it
Don't use teleport-based movement?
what to use then, i hate rigidbodys too buggy
Rigidbodies, but you use them right
Neva 🔥
Then suffer
they are pain to deal with and configure
Seems more like a lack of experience issue.
btw - you don't need to do gameObject.transform .. you can just do transform
yeah ik, its just a muscle memory
if i didnt lack experience i wouldnt be asking in beginner lol
unity treats objects with colliders as static unless they have a rigidbody - so you really do want a rigidbody if the object is gonna move 😅
so i do the rigidbody.addForce or wut
nah you can just directly set rigidbody.velocity
or linearVelocity in unity 6+
so ```cs
void FixedUpdate()
{
rbody.linearVelocity = new Vector2 (inputx * speed, inputy * speed);
}
Hi, does anyone have youtube tutorial for 2d top down 4 direction sword/meele tutorial?
Or just use movePosition which is teleportation but less jank because it's the physics engine doing it
I figured thank you
Man I love the unity community lol, full of kind people
anything you think of, brackeys have made
Brackeys you say. I'll check it, thanks.
you probably don't actually need a tutorial - for any feature like this, try breaking it up. You can probably do each individual bit, or google it/ask here! e.g.
- when the player presses the attack button
- get the current input direction
- play the sword swing animation for that direction
- check collisions while the sword swing animation is playing. For this, you'd usually enable a collider during certain frames of the animation, and disable it when it's done! (You can do this in the animation clip)
rigy.velocity = new Vector2(inputx *speed , 0 );
@clear juniper
so the body started falling hella slow
set the gravity scale to 0 on the rigidbody 🙂
Alright, thanks so much.
i want it to fall normally, not to stop falling
ah I see - then rigy.velocity = new Vector2(inputx *speed , rigy.velocity.y );
another question, which is why i hate rigidbodies, how do i stop the clamping when i go against a wall
what do you mean by that?
when you hit a wall, do you want to bounce off, slide along the wall, or stop completely
or just go through it
clamping probably isnt the word you want here. i assume you just want to put a frictionless physics material on the rigidbody.
its when the object stops completely when i apply force opposing the direction
ah yeah that's probably the issue! In your project create a new physics material 2d, and set the friction to 0
ohhhhh I see
okay, in that case you might want to use forces then
or use SmoothDamp, one sec
like this
you also dont have to use a rigidbody. its not the only way to have non "clanky" movement. your initial code was directly modifying the position in FixedUpdate rather than Update, so it was always updating at 50 times per second rather than once per frame.
yes do what i said above with the frictionless physics material
that is friction
that's a frictionless material, do this 🙂
how do i make a friction material 2d, only the 3d one is showing up
this is a code channel. but look in the 2d submenu
it's also called a Physics Material not a Friction Material
ik its physics material lol
ik its a code channel, but one thing lead to another regarding a code
which version of unity?
it's in here for me
after you've done that you might want to smooth the horizontal motion, it'll feel nicer to play 😂
[SerializeField] private float smoothTime = 0.3f; // change this to make it start moving faster/slower. Lower = reaches max speed faster
private float _smoothVelocity;
void FixedUpdate()
{
// your other code
rigy.velocity = new Vector2 (
Mathf.SmoothDamp(rigy.velocity.x, inputx * speed, ref _smoothVelocity, smoothTime),
0
);
}```
that would be the "2d submenu" i told them to check and it's there regardless of which version of unity they are using
yeah screenshots are helpful though 😉
i mean, in this case not really. if someone cannot figure it out by being informed they need to look in the 2d submenu and a screenshot of the 2d submenu is required for them to figure it out, then they perhaps need to get their eyes checked or learn to read
im guilty of screenshotting everything 😦 .. im trying to calm down lol
its not that personal g
then why are you taking that information personally?
you did
did you find it? 🙂
yes thanks to you
actually i did not, i simply informed them how their screenshot was unnecessary. you went out of your way to specifically ping me about how "iTs nOT pErSoNAl"
seems like you took it personal enough to get raged
just because someone provides information does not mean it is a personal attack on you. you can drop the nonsense now and move on
Hey folks,
I am trying to make a simple endless runner and as part of that I want to Instantiate new "Ground" and destroy old "Ground" depending on the player position. The game already starts a single instance of gameobject "Ground". I have set up 2 different Trigger colliders, 1 for spawning new Ground and another for destroying old Ground.
The player starts between the destroy trigger and spawn trigger so the flow is : Player moves forward=> new ground spawns => once the player reaches new ground => destroy trigger will destroy the old Ground.
The first new Ground spawns as expected and the First old Ground destroys as expected.
Problem=> When the 2nd new Ground tries to Spawn, because the old Ground was destroyed, The spawnPoint transform which is a child object of the Ground prefab, doesnt exist EVEN THOUGH one clone of Ground ALWAYS EXIST.
Initially I was trying to get the Ground Object by name and since this issue I modified by using tag since the tag Respawn always exist in the scene, but still the issue persists
Appreciate any help on this
The spawnPoint transform which is a child object of the Ground prefab, doesnt exist EVEN THOUGH one clone of Ground ALWAYS EXIST
this is irrelevant, if you are referencing an object that is being destroyed then the reference will not automatically change to a different object when that object is destroyed, it will still point to the destroyed object. So because yourspawnPointvariable points to the object that is in the scene, when that object is destroyed thenspawnPointwill point to a destroyed object
you should instead refer to a prefab for the ground object, and on that prefab have a component that can reference its own "Spawn Point" child so that your spawner object can get that reference more easily from the instantiated objects
this will also eliminate the usages of the Find method and the GetChild with the magic number to clean up the code and (very very slightly) improve performance
OMG I see it now after you pointed out. So basically, currently I am using the spawn point vector from the ground that would be destroyed before the new ground can spawn so it throws error. But If I were to have the spawn point value of each ground on itself, this could be avoided.
I am thinking I could keep adding the z coordinate with the length of the ground piece to get the coordinate when the new ground is created. Hopefully this will work.
Thanks a lot @slender nymph, I was cracking my head for a while on this😅 🫡
can someone assist me on this: I have ads being initialized and the banner being loaded in a different Awake method. However I see in the console that adsAreInitialized and bannerLoaded are set to true after going through this while loop but the ShowBannerAd() is never invoked. What am I doing wrong?
here are logs for context
If the Instance is initialized in Awake and this is loaded in another scripts Awake, then you have a race condition. There is no guarantee one Awake will be called before the other . . .
i am still trying to figure out what the yield return will do in that while loop
i think ur logic might be flawed..
Sorry i should clarify that this while loop is in a mthod that is called during the Start Method not the Awake method
u want to wait while BOTH are false correct?
correct
well the moment either of those become true.. the while loop exits
It returns to the caller and waits for one second before continue (ultimately exiting) the while loop . . .
even if the other is still false
or wait..
while (!adsAreInitialized || !bannerLoaded) i was thinking.. but my brain aint braining just yet
Yeah should be a OR here I think
its like pausing until while loop is done
(checking every 1 second)
Wait no, brain is not working
lmao!! same bro
I hate these conditions lmao
"Proceed if both are loaded"
if (a && b)
// proceed
So invert, !a || !b
right?
but wouldn´t it spam the yield return unneceserally
In propositional logic and Boolean algebra, De Morgan's laws, also known as De Morgan's theorem, are a pair of transformation rules that are both valid rules of inference. They are named after Augustus De Morgan, a 19th-century British mathematician. The rules allow the expression of conjunctions and disjunctions purely in terms of each other vi...
It would wait until one or both are true.
ohhh yea ur right
didn't see the full context above, but the IDE should have options to invert conditions already
thats where my brain was broken
&& waits until both are true
Yeah you can use the "Invert if" IDE code fix if you don't want to think too much haha
while (!(adsAreInitialized && bannerLoaded))
That also works
phew, i was waiting for a "well, no.." lol
conditionals like that confuse me
Hey so my doors are interactable, And they have a bool variable, I'm however slamming the doors shut during events by tweening them from other scripts, Now the issue is, Once I have slammed it, It's still in the 'closed' state so you have to click on it twice to open it again, Is there a way I can change this variable/bool from another script?
Especially when both operands have a different individual state lmao
Go and invert a if (a && !b) for me, if you're never done it it's not easy
make a reference if its public, or use a public method (better way)
feels like the IQ tests i had back in grade-school for the "Gifted Program"
demorgan is a blessing and a curse
im just learning of de morgan
public bool isOpen = false yeah it's public
But yeah what I do is just write the condition "normally" and use the "invert conditional" feature of the code editor lmao
demorgan also works for sets, (A & B)' = A' | B'
[SerializeField] Storagedoor sg; // assign the script via inspector then you can acces it
@high summit
eg
[SerializeField] StorageDoor storageDoor;
public void SetStorageDoor(bool open) {
storageDoor.isOpen = open;
}```
this not a typo?
whats A'
the negation/complement of A (A prime)
lmfao!
this all falls under "discrete mathematics" if you wanted to look further. honestly a lot of it might just fly over your head if you're not looking at a structured course. you also might not use any of it.
if ur tweening them via another script.. just grab its reference and use a public function to call alongside it after tween..
ResetDoorState();
thats a normal occurance for me.. i still like reading into stuff (i retain what i can).. and atleast im exposed to things i cant
will do bawsi!
the way i think of it is "AND" is the opposite of "OR", and de morgan is just distributing the negation to the operator as well (not just the operands)
AND being the opposite of OR does kinda make sense, if you've ever touched making logic gates from scratch
negating the output of OR gives NOR
negating the inputs of OR gives NAND
negating both gives AND
and these are abstract definitions of AND/OR, they apply to
- logic gates AND/OR
- boolean algebra AND/OR
- set intersection/union
unfortunately does not apply to mult/add in the reals - you'd be surprised how many things map from mult/add to and/or
im learning embedded systems and electronics.. and it fascinates me at teh overlap we have in
conditionals in programming language.. and logic gates on circuitry
coding is all just data w/ (yes and notrue and false, on and off) in the simplest of senses
It's like on equations when you have inequality a < b and at some point (I don't remember when) it can flip to a > instead
When you make an operation on it
if you negate both sides (by multiplying/dividing a negative number in)
Yeah that
🧮
2 < 5
-2 > -5
i might be against the grain here but i dont think its all that useful for you to look into discrete maths too much unless you have other work involving this stuff (doubtful). You could definitely look into the "laws of boolean algebra". There are more laws you can find online, a lot of them are very obvious.
out of all the laws, there are probably 3 that aren't completely obvious
ya, i'll skim it.. i like knowing of things.. as much as i do understanding them..
addition and subtraction move the number line around, that doesn't change the relative position of the 2 values you check
multiplication and division are scaling the number line - when you multiply or divide by a positive number, that keeps the relative position the same, just the distance changes
but if you multiply or divide by a negative number, that flips the number line, so the relative positions swap
i try to draw game-ideas and mechanics from everything .. soo possibly something unique in there that might get my brain spinning
every code beginner: "damn i joined the wrong unity channel"
advanced maths is beginner code obviously
I would definitely recommend looking into discrete mathematics if you intend to play Minecraft. That's where I learned it all. Restone Torch is a NOT operator and that's all that's required for turing-completeness because that's one hell of a gate
i mean if theres anything a beginner should really hone their skills about its conditionals imo
esp since beginner code is 50% conditionals
lol
I guess the graph theory part of discrete maths could be useful too in unity. anything else im not sure you'd be able to use
ive already fallen into a boolean algebra rabbit hole
discrete maths will have to wait a sec
sounds like some pure math stuff would interest you, like properties of operands/relations
imo if you get that kind of primitive understanding you can generalize it to a lot of things
i learned like 12 separate rules for differentiation in calculus even though it can be summarized in 4
- distribution over addition
- multiplication rule
- power rule
- chain rule
ngl.. i feel i know alot more about maths than ur average person... but i still find myself asking myself things like this for example.. i had this thought:
someone was talking about Interest.. and how much u would accumulate after X amount of years. with it compounding..
well i had an interesting thought.. (i can totally do that math in a forloop in unity in just a couple of seconds)
but if i were want to do that using mathmatics.. and a simple equation.. im completely lost..
so i went searching and found the equation.. and compared it to teh for loop i had written.. and it just didn't seem to sync up in my mind..
things like that ^ are always rattling off in the back of my brain
i def need to learn more about the rule of powers
ngl.
the power rule in calculus is kinda a specific thing, separate from rules of exponentiation in general
ohhh.. see TIL 🫠
any specific resources u might have handy? if not its fine.. i'll just jot down the keywords and go crazy a little later
the power rule in calculus is d/dx x^n = nx^(n-1)
i tend to just dive into wikipedia, it has very detailed information for these topics
its probably because you learned it for school/uni and then didnt have to apply it anywhere else. I did a math minor also so like calc 3, 3rd/4th year linear algebra, and some other course. This is more than most cs students because you're supposed to only do basic calc 1 and 2, then early lin alg. I was good too getting A or A+ except in one lin alg class.
Today, i couldnt tell you shit about how to do basic calculus
I do still think if you're going to look into these kind of things, you aren't going to use most of it. my suggestion for anything unity related still would just be boolean logic and graph theory. Calculus/pure math doesn't fall into discrete maths
ya ur right.. soo many times im like "that sounds sooo familiar" and realize ive learned it before..
but just lost it
ya, boolean logic will be my topic of choice for a bit 👍
making a notesheet of what I think i know first.. and then we'll do a deeper dive and see where it takes me 💪
appreciate ur cautions
{
rigy.AddForce(new Vector2(0,jumpforce));
}
is this an ideal way to jump?
why
in one frame that ain't gonna do much
with 200 force it does
probably want Impulse mode
use the correct forcemode and you can also use a reasonable amount of force instead of an unnecessarily high amount
thats why even at such high number it probably barely does
ik how to use keycodes and vectors lol, just not force mode, thanks for ur help tho
the forcemode script is unreadable for a rookie
i was trying to read it before uve sent it
use Impulse, it should be what you are looking for
it´s literally one line of code, what is so unreadable
? the forcemode script is almost 200 lines
the example code just shows the different forcemodes, you don't have to copy them all
actually i agree on that. the documentation for the ForceMode is kind of messy and not beginner friendly
reminds me of the microsoft docs
Because it's an example, not something for you to plant directly into your project without looking at
ik, i just couldnt find the wanted line
i kept screwing around with it till i found out how
got more similar pics???
its literally the second parameter of AddForce, its just an enum already defaulted to ForceMode.Force
i use bing and bing is annoying as hell
i did
(vector2.up * jumpforce, forcemode.impulse)
close
do you work without intellisense?
your IDE should have told you that there are a few code errors
its fine except for capitalization..
i just wrote this here, its different with capitalizations in code lol
Debug.DrawRay(transform.position, Vector2.down * lenght, Color.red);
why isnt this drawing a debugray
do you have gizmos enabled
yes
then it is, assuming that line of code is running
sorry lemme do it
also large blocks of code should be shared via a paste site, not just dumped directly into discord 👇 !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.
it doesnt work
where is this line of code placed anyway, you have to give more context
its in update
show the full code
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.UIElements;
public class Movement : MonoBehaviour
{
public int speed;
public int usage;
public int inputx;
public int inputy;
public int jumpforce;
public int lenght;
Rigidbody2D rigy;
// Start is called before the first frame update
void Start()
{
rigy = gameObject.GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
Debug.DrawRay(transform.position, Vector2.down * lenght, Color.red);
if (Input.GetKey(KeyCode.D))
{
inputx = 1;
}
else if (Input.GetKey(KeyCode.A))
{
inputx = -1;
}
else
{
inputx = 0;
}
rigy.velocity = new Vector2(inputx * speed, rigy.velocity.y);
if (Input.GetKeyDown("space"))
{
rigy.AddForce(Vector2.up * jumpforce, ForceMode2D.Impulse);
}
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down * lenght);
if (hit)
{
Debug.Log(hit.transform.name);
}
}
}
for the hit, it prints the original name
how to share large code blocks was still visible yet you decided to dump the whole thing here anyway
i literally did the cs thing
yes, which is not how you share a large block of code
Large Code tells you about sharing code in links..
which link? there is more than 1 there..
first one i clicked
if only there were 3 others you could choose from
** tries one **
"well i guess the others are broken too"
A tool for sharing your source code with the world!
did you give length a value in the inspector?
yes
anyway, if you are absolutely certain you have gizmos enabled and you have looked in the scene view and still don't see the line, then you need to check the variables you are using for the drawray call
i gave variaty of small/large numbers
screenshot what you see then
show your scene gizmos are enabled (no crop screenshot entire view)
including the inspector with the value of the lenght variable
you dont have gizmos in game view
gizmos is not enabled in your game view window
brh
Can you show a screenshot of the scene view with this object selected? Actually, the whole unity window, with the inspector open and visible as well
this is why i also said to check the scene view
well Scene Gismos and Game View gizmos are not the same option.
weeeeeeeelllllllll, thats on me
if your PC is powerful enough you can also put scene view and game view side by side if you don't need to tab back n forth
then yeah gizmos in Game View, dont forget to turn it off when not needed cause that could also effect your performance in editor
Why is is that when i run, it will show the first debug log, but not the second debug log? In addition, it will not display the Ad so it seems that nothing after that yield is being invoked.
presumably whatever is starting this coroutine is being deactivated or destroyed
I have it set up that the method goes when the BanneIsLoaded Event is triggered.
The coroutine will stop running if:
- The object it's running on is deactivated or destroyed
- StopCoroutine was used to stop it
- It may also not return here in a reasonable time if time scale is set to a low number or zero
or it hasn't been started with StartCoroutine
they said they can see the first debug tho
If you just call the function it'll run until the first yield
it shouldn't. it shouldn't actually run any of that code until MoveNext is called on the returned IEnumerator
running to the first yield was a common misconception
That's interesting, I guess I was thinking about the lines running before the execution continues in the calling method
hi there, i'm making a game and i want to make the spear bounce of the walls, but only works on the wall at the top, does anyone have a hint on why it's doing this, here's the code as well
public class SpearTrajectory : MonoBehaviour
{
private Vector2 _surfaceNormal;
private Rigidbody2D _rb;
private Vector2 _direction;
private float _speed;
[SerializeField]
LayerMask _layerMask;
void Start()
{
_rb = GetComponent<Rigidbody2D>();
_direction = _rb.totalForce.normalized;
_speed = _rb.totalForce.magnitude;
}
// Update is called once per frame
void FixedUpdate()
{
//Debug.Log(_direction);
RaycastHit2D hit = Physics2D.Raycast(transform.position, _direction, 1f, _layerMask);
if (hit)
{
_direction =Vector2.Reflect(_direction, hit.normal);
_rb.AddRelativeForce(_direction * _speed);
//transform.up = _direction;
}
}
void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawRay(transform.position, _direction);
}
}
yeah i need to do more research on CoROutine. it seems like it never does what I think it should do but I am following what it says in teh Unity DOC so i am even more confused
show where you start the coroutine
or, better yet, show all of the code related to that object
u can use tags for the wanted wall
they are all in the same layer, are tags better?
you can keep the layermask, but you have to specify the bouncy wall with a tag yes
looks like your collider only covers the tip of the spear, make sure to cover it completely., you can view the collider in the inspector.@safe vale
no, their suggestion is pointless. the issue is the direction of the raycast
or rather, the origin of the raycast being at the tip of the spear and the spear not rotating
okay im seeing, so right now im using a line, maybe a sphere?
yep a circle should
that's not quite going to do what you think it does
ah shucks
And is this object ever disabled or destroyed?
nope, i checked every single object just in case
Do you do any mucking with timescale?
that was not directed towards you.
but yes, check what digi is suggesting. also consider putting a log in OnDisable to make sure it isn't being disabled
yup it didn't
yo
try shooting the spear towrads the top box then instantly move the rotation of ur player away
wait doesnt work
just try drawing gizmos and see
I am not even sure how to do that. I changed the float value in the yield from 1f, to 2f, to 5f, to just 5 and nothing seems to work.
You don't have any code that pauses the game or anything?
Two things to diagnose it:
- Log
Time.timeScalebefore the yield - Add
void OnDisable() => Debug.Log("Coroutine object disabled")somewhere in your script
See if the timescale is 0 or if this object is being disabled/destroyed
OOOOOH thats was it. but now i have to figure out where i pause it
the time scale was indeed 0
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Time-unscaledTime.html not sure if its helpful but this variable doesn't rely on Time.timeScale
appreciate this, i might need this becasue I have a timer in the main game but I realized I paused the Timer in the Menu Screen.
i use it to log playtime.. same concept
WHY does my interface return "null"???
I do a null check if(IMyInstanceType != null)
and it enters the if statement when the instance is NULL!!!!!!
when I ask Visual Studio what the value of the instance is, it says it is "null" <- literally as if in a string
so it's not null
Unity can have nulls that aren't nulls. An object slated for destruction but not cleaned up will exist, but == null will return true
Is the object that implements the interface a UnityObject such as a MonoBehaviour or is it an ordinary C# class?
Normal equality check works
Should work then, if anything, it'd be skipping the != null check when it shouldn't be
Usually in that case the code runs twice, once with a destroyed object and once with a non-destroyed object so it looks like it skips the check
it's not skipping the check, it's ENTERING the statement when it IS null
sorry I'm not yelling I'm talking as I type haha
That's what skipping the check means
you can use WaitForSecondsRealtime instead of WaitForSeconds so it doesn't rely on timeScale
ah ok, skipping the check for me usually means it doesn't enter a statement block
Do this and show what it prints:
Debug.Log("Checking " + IMyInstanceType);
if(IMyInstanceType != null) {
Debug.Log(IMyInstanceType + " is not null");
}
else {
Debug.Log(IMyInstanceType + " is null");
}
"skipping the check" generally means "the check isn't doing what i want it to do"
what you're referring to would be skipping the block or not passing the check
anybody know why the text legacy wont display what i write?
not without more info, no. we aren't psychic
i really dont understand whats wrong, no matter what i type in the textbox it wont apear
im using unity 2d btw
oh, not a code issue
That isn't a code question but the box is probably too small
well, shouldve seen that coming
then where should i ask this question?
okay thanks
this prints null is not null
ah, that's one way of looking at it. I interpret "skipping the check" as literally skipping the block or not passing the check as you stated
Wait is it literally a type and not an instance?
if you hover over the ==/!= where you compare the object, does it show UnityEngine.Object.operator == or something else
when I hover over the comparison, it shows the instance as literally "null" in strings <<<<<<<
the object in question _myObject is an instance of an interface IMyInterface that is implemented by MyClass : MonoBehaviour, IMyInterface
it's the same problem the guy in the forums was having
so probably not null, probably unity's fake null, given that you can apparently access props of the object
(that's not what i asked you to hover over though btw)
So my fix is literally just casting the instance as a UnityEngine.Object and that seems to do a correct comparison
probably yeah
i guess you could make your interface an abstract class that extends MonoBehaviour
not sure if that's a common fix
The null string is definitely a destroyed object
why is my text not adding 250 when ScoreAdd = true
Because you didn't write any code that would add 250?
yeah I Did
looks like ScoreAdd is false
and once you fix that you will need to grapple with the fact that your code doesn't add anything, it overwrites a string with another string.
can anybody link me a simple movement script?
i just need to move around a capsule primitive and have it feel decent
my existing movement script feels teerible, accelerates too slow, deceleration feels jank
1 . Use GetAxisRaw not GetAxis
2. increase the movementSpeed variable
3. increase the deceleration variable
what does getAxisRaw do?
ah i see
mm still feels like it accelerates too slowly, maximum speed is too high, deceleration logic is just bad (it also decreases fall speed)
for deceleration affecting the vertical you would need to fix that line to only affect horizontal velocity (i.e. factor the y out first, then apply it, then put y back in)
as for too slow accel and too high max speed you would increase the force even more and then make your deceleration proportional to the velocity or add a hard cap
mhm but i figured i'td be simpler to just borrow a movement script from the internet, i have little knowledge on how to make 3d movement feel good
plus my friends wanted to have the ability to jump despite the fact the final product will likely not have jumping
sort of like how real drag works
This may be surprising to hear but writing and especially tuning your movement to feel good is not easy
expect it to take time
not surprising at all, so many games struggle with it
it's for a minigame so having some simple configurable properties is ideal
it might help to think about how running works in real life. When you are at a dead stop it's very easy to apply a very large force to your body and get moving quickly. But once you are moving, it becomes more difficult.
mhm but realistic movement isnt necessarily what i want
A strictly realistic movement script would take that into account - applying a high force when you kick off the start and tapering off if you're triyng to continue to move in the same direction, while also allowing a very high "braking" force, since that's easy
Yeah i understand
I'm just talkjing about the forces that need to be applied if you want somewhat reasonable feeling movement
you need high forces to feel "responsive"
but then limitations on infinite acceleration in one direction
mhm, maybe even something like an impulse from the get go
hm, why cant i invoke an action with multiple variables?
ah duh i forgot you have to declare actions
what does the error say
i corrected it already, it was expecting <int>, had to add bool in there
How do i do somekind of checklist where I complete a task and a display in front ticks the task I've done. Also what is it called exactly?
that's basically just a quest system. create some data structure that defines the quest: what needs to be completed in code, a property for the description, and an event. possibly even some id to save/load it's state
then when you add the quest to the task list your UI just gets the description and subscribes to some completed event. when the conditions for the quest are met you fire off that completed event and the UI puts a tick to indicate it is complete
guys i need help with coding something
i want to make it so when you shoot you bounce backwards
would like it if you can make the knockback easily editable
if you can help please send me a dm or reply
Nobody is making anything for you, here.
aww man really?
Yes absolutely
needed help so though this sever would help
If your definition of help is a free handout, then this server is not for you.
welp sorry then
hm, can i not set a variable's value on declaration?
it always seems to be false, and i commented out the logic that tried to change it
the variable is serialized which means whatever value is set in the inspector will be the one applied when this object is created at runtime
ah weird
that's kind of the entire point of serializing it
think how weird it would be if the value you set in the inspector was arbitrarily ignored 😵💫
and also setting a variable's value on declaration is not really the best thing to do
truue
i want to create a serializefield variable that lets you select one of three options from a dropdown
how would i do that? an enum?
enum yep
mmkay research time
hmm, how do i make it visible in editor?
adding serialize field here just made nothing show up in the editor, but no errors
Well adding serialize field to a public isn't going to do anything extra, it should show up in the inspector as enums are serializable so it's strange it doesn't, if you plan on using SerializeField though, make the variable private (It's a better practice too as public means any script can access it, and this usually isn't what is wanted, look into access modifiers for more information about this)
Specifically here: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers
(Not related to your question btw, just a tip)
For your question, could you show the full !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.
hmm odd, but yeah making it private did work
not sure why it didnt show when it was public
so seems like no need
No clue, as far as I know should still serialize
I would assume you just didn't reload
And changing that reloaded it
You probably had a compile error or didn't save or didn't refresh or something along those lines
prehaps
uh what do i put in line 98 to end the method without returning a variable?
also if i have the method call itself again, will it still return the selectedInt to the method that called it?
you have to return an int
mhm but i want this logic to repeat until it selects an int that isnt the lastselectedvalue
you might want more than one function involved here
for what purpose?
if you want this to be recursive then you need to return pickTileValue(); rather than just calling the method again
but i agree with batby, you probably want to split that logic up a bit
this kinda thing has two goals
pick a random value until you get one that isn't the last one
pick a random value
validate that value
might be cleaner to have one function that just picks randomly and returns the result regardless and another in charge of using that function to find a new "valid" one
ohh i see
the range of values is small enough that i dont need another method in this case
anyway, problem solved
doing a tutorial from only 3 years ago, has the whole thing really changed that much? the velocity changed to linear velocity (albeit basically making the process easier) and things like getkey have also changed it seems
the whole tutorial has been more or less me troubleshooting the problems because it seems like the terms changed
you can still use the old input system if you'd like, you can even do both now if you want!
i'd like to use both
it'd be nice to have access to both at the same time without much error so i can follow different tutorials from different times while i learn how to use this thing
It should just work by default? do you get an error when you try to?
yeah, if (Input.GetKey(KeyCode.Space) == true) get's an error that says i have switched to active input handling
ok hold on
so it won't let me press spacebar
i figured i could just switch but that would mean writing down the whole velocity thing underneath it differently, and i quite like how it looks now
unless there's an easier way to press spacebar
yeah so what you can do is: ProjectSettings->Player->OtherSettings->Configuration->ActiveInputHandling and set it to both
takes a second to find it once you've gone to other settings lol
i found it rather quickly
it's restarting now
theorhetically the first game i make takes less than an hour to make, unfortuntely for the tutorial i'm a bit of a cloud head so it's going to take at minimum, 3 hours
hey it works, thanks!
np 😄
learning about variables, this is one of the biggest reasons i picked up unity in the first place, this isn't productive text, i just love the idea of being able to make my own controls for the games
i'm like- fangirling out because i love this idea so much
lmao wdym
being able to make a slider to adjust the variable of something is such a cool idea to me, especially since you can do it in game and adjust to how you see fit
maybe i'm just being a nerd
nah I get what you mean lol
i'd absolutely love to use this when making scripts for items, their values being interchangable, can use this to make all sorts of things right off the bat
when I was first starting out the idea that I could make my own variable that could be accessed by MY CLASSES was so cool to me
so I kinda get it
example, if i wanted to make an item that applies statis effects, like bleed or critical chance, i can adjust the variable in which that happens with that specific weapon, can create a sort of 'base script' that i can copy and paste for each item so i don't have to make them individually
i haven't programmed before this, but for some reason there's a familiar feeling of having to make each thing individually, and i don't know where it comes from
maybe it's just that i like the idea of creating my own scripts and reusing them because i made them myself
do you know about the Range property for variables?
so if I wanted a variable that could be from 1, 100 I can do
[Range(1f, 100f)]
public float someNumber = 25f;
I get a nice little slider in the inspector
ooh
that's cute
does the range come with the slider? is that what makes it a slider?
yeah, the Range adds the slider in the inspector, but it can't be seen in game view, it's like changing a variable normally in the inspector, just now you have a slider to go with it!
lmaoo
i hope you know what you've done
Yes https://docs.unity3d.com/6000.1/Documentation/ScriptReference/RangeAttribute.html
When this attribute is used, the float or int will be shown as a slider in the Inspector instead of the default number field.
i love sliders
lmao, that's not all, you can even add graphs, too
huh
i'm sure i'll find it in a tutorial somewhere
that's less fun, i like discovering things from tutorials or other people
fair enough
but now this has me wondering what the final product of the first project will look
because i totally expect it to be a linear one weapon game, but i also get carried away
and this seems like something i'll get carried away doing
whatcha working on?
ever heard of kingsfield?
no 😭
it's a first person dungeon crawler for the ps1 and ps2, made by fromsoftware, WAYYY before dark souls
Could you guys take this to DMs?
oh my bad
No problem!
my b!
BTW if you want this to work better then why not just keep a collection of possible tiles and explicitly filter out the last value? What you have now is very slow. I assume yo don't call this frequently but I don't know your project
If the main goal is to get unique tiles then you could also shuffle the collection and drop them in a queue which you pick from. If the queue is empty then shuffle it again
thats what i already have elsewhere mhm
this logic is to make sure the last value doesnt match the first value of the next set
hmm, if thats faster then maybe that makes more sense, didnt think filtering was an option
but this is just a prototype, and it doesnt run often enough for a noticable (or any?) lag spike so its fine for this
but ill make a mental note
If you want true randomization then just make a Queue of an initial capacity of 4 (assuming it's always 4) and then Shuffle and fill the queue when its length is 0 (which means on initial check and every 4th check since it would be empty again)
I've got this code for a spawner that spawns enemies, but the enemies seem to be spawning on top of each other (or somewhere in some kind of invisible radius) and that destroys the previous spawned enemies, kinda annoying since it can stop them from getting to the player in time
is there a way to fix it or get around this issue?
I'm not exactly sure, I'm trying to make a top down game with an infinite wave of zombies, so anything but this, I guess
well this is a code channel
you don't really have a code problem here
you want to change the way the game works
oh, I thought it was a code problem
code does what its told
you have more of a game design problem here
perhaps look at similar games and figure out what they are doing for that kinda spawning system and what your game isn't
and think about how you want to change the code in order to make that happen
alright, thanks for the help, appreciate it
if you figure out what is "wrong" and what you want to change but aren't sure how to actually implement that via code thats when you are more than welcome to come here
this will lead to a bias fyi
the size of the range of values doesn't really change whether or not you need another method - it's just about logic flow
Enemies spawn on top of each other because you don't specific a spawn position
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Object.Instantiate.html
Instantiate can take a position as an argument, you can look at the examples here for better implementation
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Internal.InputUnsafeUtility.GetAxis (System.String axisName) (at <8464a637132d4cf7b07958f4016932b9>:0)
UnityEngine.Input.GetAxis (System.String axisName) (at <8464a637132d4cf7b07958f4016932b9>:0)
CarMovement.Update () (at Assets/Scripts/CarMovement.cs:22)
anyone know how to fix this i just downloaded new unity am usng old input system commands i think it probably added new input system automatically
what do i do
how do i find player settngs
At the top menu bar, there's the Edit menu. Inside you'll find Project Settings. In it, you'll find Player tab
Thanks bro
scroll in that, you'll find input handling
both should be fine. I use Rider
VS > VSC
hi, is there anyway to change which scene is opened at unity editor startup?
Yes, close the editor with the scene you want open
It will open whichever you had open last
ye i know it, but i want a way to change it
this isn't a code question, if you want to ask more.. move to #💻┃unity-talk
You'd have to write an editor plugin if you have some custom behavior you want
Open a different one
i see, actually, i was caught into a very strange scenario, my unity stuck at start up in Entites's runtimeContentSystem update literally forever, and i cant think about anything peculiar i did other than opening a specific scene before last quit, so i would like to find some help about it
what is the difference of vector 2 and Vector 3?
This is like the most Googleable question, ever
as it says, vector2 has 2 float, 3 has 3
well, theres some other differences like the methods being different in each
Vector2 has no cross product
That always says if i google it but I dont know the meaning or what it does to my gameobject
its numbers
its really about how you use them that matters, a Vector2 lets you create a 2D vector, a Vector3 lets you create a 3D vector
well... mostly we use vector refer to a position or a direction in 2/3D space, but for themselves they are just grouped floats, you could use them for whatever you want
Could any1 help me, where do I make so I see this, because I have script for attack and it says and I think its something from like refference he made
post your code, not the youtubers
I want a good resource that help teach me C# for Unity and game design/programming in general. If anyone has good resources i'd much appreciate it if you can send them
But I dont know how to code I am just using youtube tutorials
well either you have code, so we need to see that, or you don't have code, and you don't need this channel
i assume that error didnt come from the youtube video?
I have code but I dont have something linked that everyone says if I dont ahve they wont help
ok
!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
cool
text editor < ide, change my mind
But also
"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: 188
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-06-10
Have fun never making anything, ever
😭
@sour fulcrum
You should probably actually follow the tutorial
😭
This entire section is nonsense
That's just now how you write a function
You have a tutorial to follow, follow it
it is just one line that is wrong in this specific case though
Yeah ik
Or just look at the way you've defined other functions in this very file and do that
I want a good resource that help teach me C# for Unity and game design/programming in general. If anyone has good resources i'd much appreciate it if you can send any resources I can use
Yeah and
!learn and the resources in the pins
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yep, that's correct
Its not working
It is working, if you do it right
Like I dont have Collider2d nowhere and he doesnt either
He has boxcollider2d and so do I
but you didnt write what he wrote
He didnt write it
Which is why I added you to the counter
ohhh
He wrote Ontrigger and then selected from options
@polar acorn its the autocomplete
just write it out manually
yup you did post that
write out what he wrote
or didnt write
theres no magic embedded in his words he just did the shortcut to write it out faster
When I use Microsoft Learn and do C# which one do I press? If so do I need to know all of it for Unity. If not then which ones are the most needed sections? (Sorry if i'm asking a lot of questions)
This is what it says
post code
what does the youtube video have
Check out this reference for a bunch of links . . .
You had red underlines below your errors what happened
Did you un-configure your IDE
follow what the youtuber writes
float indeed does not have that method, you want Time instead
It’s delta time is a property of time not float
And you should initialize time until Meele
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
i use vs code because vs makes my pc slow
Your errors should be underlined
but both work
not in the context of what they are learning
Thank you, I also found this website called w3Schools.com, I was wondering if it's also good?
well, its quality varies.
my previous opinion was that it was too hand-holdy, it was good for beginners but then it didn't let you really improve past that stage, but im not sure if that opinion is outdated
i'd recommend just using official resources when available
Well I am a beginner, I have some Java experience. I just don't know what to do on official sources. Like do I do the "C# Learning plans"?
Again i'm sorry if i'm asking too many questions
Edit -> Project Settings -> Player -> Active Input Handling
It looks like you are trying to read Input using the UnityEngine.Input class, but you have switched Active Input Handling to Input System in Player Settings.
there's also !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Is there a way to cancel reloading domain or at least to save my project while it is reloading? If there is no way to save it then I will have to crash my project I assume
@wintry quarry
yep, you found it
Which one
What is that?
either one other than the one you're on
official learning materials from unity, there's over 750 hours worth of different courses there
Is there a way to disable filtering on grass on Terrain?
no a code question. #⛰️┃terrain-3d
oh, I am sorry 😅
none of the links are final or lock the others
try going through them to see which one fits what you want to see
The one you want to use
is it bad to use the new input system package?
of course not
it's preferred
Oh, scrolled up, saw the errors
it's just harder to use for beginners
that person got those errors because they have code using the old system but their project was set to use the new system
I'm very new but I think I've pretty mch learned it, and its very useful
overwhelming until you realize its as easy as cs if (Keyboard.current.spaceKey.wasPressedThisFrame) { //jump } if (Input.GetKeyDown(KeyCode.Space)) { //jump }
is that not old?
top is new, bottom is old
just showing how easy it could be
but the main benefits is event based so you don't have to poll, action maps, rebinds etc..
ye ive wrote this so far
although the JumpEventListner is just setting acceleartion that allows player to move vertically
If you use the Generate C# class option you can use Type-Safe actions skipping this string search bs
im sure there are better ways but im just trying stuff out
you could also use serialized references on the actions
and drag them all into the player? is that preferable?
idk about preferable, i'm just saying it's possible
prefer whatever makes it easier for you
just know there are options that you could not do in old Input class
does anyone know how to fix an issue if i turned on mesh collider on the player, but the player still falls through the ground?
no. because there isn't enough information there..
also this is a coding channel
Using a Mesh collider on a player object sounds pretty suspicious
sorry, still a newbie, don't know where to ask 😄
#💻┃unity-talk show inspector for the player, ground etc..
is there a way to change this setting of a particle system in code? not seeing anything obvious. i need it to use unscaled in certain situations and scaled in others
useUnscaledTime?
oh wait i was looking at the wrong thing
oh i was looking at the right thing? 🫠
maybe.not sure why it shows up as an enum dropdown maybe there is another ? or justa custom inspector ? dunno
GUIBoolAsPopup 👀
!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 #854851968446365696
u can just drop the question here
if someone know they can help
btw no collab/job posting
its not allowed
hello got a bit of probuilder 6 issues is this channel alright to ask?
did you read the description of the channel ?
kk well i need help adding the int number of a variable in a script into another script so i can use the variable and convert the int into text
x = x + y;
string s = x.ToString();```
ty ill see if it works
one problem is that a bool from the other script also needs to be met to add the set number to the text
This is what ive done but yeah..
"but yeah.." is not descriptive. what isn't working
you can use &&
ty ill focus on my vocabulary
how about instead of being a smart ass, you actually say what isn't working
mb..
i need help adding the int number of a variable in a script into another script so i can use the variable and convert the int into text
again, what is not working with what you've shown.
Adding things is done with the+ operator
The Int Alien Value Isnt being set as the text
then are you sure you've referenced the correct object?
I helped you with this yesterday
You ignored me
And have made no progress
im rlly sorry i had to sleep
i asked too late and im still in school
Man I should really learn how the new input system works 
I pointed out that ScoreAdd is clearly false
So of course your code will not do anything
it gets set to true in this IEnumerator
it will run if the "Alien" Gets Hit And Thats In The DamageTaken() Trigger
thats my bad
If you want help, show all of your code
Alien just dies after taking any damage? thats crazy
And do some basic debugging
Sorry.
!code not screenshots
📃 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.
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
they even said, no screenshots..
ik but it wont let me do text
using System.Collections;
using UnityEngine;
using UnityEngine.Rendering;
public class AlienHeath : MonoBehaviour
{
Animator animator;
public int Health;
public bool ScoreAdd;
public int AlienValue;
void Start()
{
animator = GetComponent<Animator>();
ScoreAdd = false;
}
void Update()
{
if (Health == 0)
{
animator.SetBool("IsDamaged", true);
StartCoroutine(DamageTaken());
}
if (Health > 0)
{
animator.SetBool("IsDamaged", false);
}
}
private void OnTriggerEnter(Collider other)
{
Health = Health - 1;
}
private IEnumerator DamageTaken()
{
ScoreAdd = true;
yield return new WaitForSeconds(1);
Destroy(gameObject);
}
}
lord
is that better?
reading must be hard
read this bot embed, specifically the part about large code blocks
take your time, don't just ignore it
ok so having all your logic in Update is gonna be an issue
you can't really link it with anything else and you'll be starting the coroutine every frame you're dead - which doesn't happen to be an issue in this specific case, but it's not great
Oh
heres the other code if that helps
what is even the point of that delay anyway?
Destroy(gameObject); already has a float parameter for Time until destroy
so that an animation plays for 1 second and then gets destroyed
you can do Destroy(gameObject, 1f); btw
though should make a isDead bool so you dont keep calling
if (Health == 0 && !isDead)
{
isDead = true;
animator.SetBool("IsDamaged", true);
Destroy(gameObject, 1);
ScoreAdd = true;
}```