#💻┃code-beginner
1 messages · Page 680 of 1
may as well use a lambda since you wouldn't have to unsubscribe in that scenario
yeah i was basically just debating between that and the separate message
i love syntax sugar..
i don't remember why i used the message, i don't think there's any practical difference (in this case where it's just for checking exiting playmode)
i try to stay away from things that look good.. but make me second glance.. or think too much
you would if you were subscribing to this event when testing in the editor and you have domain reload disabled
edge-cases!! Ftw
ah, i haven't touched on disabling domain reload so i didn't even consider that lol
boxfriends comment was met with "you're already thinking like a pro" 😊
well i mean... in something like js it's not even syntax sugar, it's just a normal feature lol
i should probably look into the domain reload thing
is domain reload required after a recompile, regardless of that setting?
gotcha
Where I can learn much things to get better in Programming in Unity? I'm looking for very good tutorials becasue I watched a lot of tutorials and 99% of them are about things I already know like: Variables, GameObjects, Colliders, Collision Detections, ScriptableObjects, Tags, AI, etc.
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
!docs
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
Is this tutorial good?
I only want learn programming
yes, the pathways are a good place to learn how to use the engine
I already know how to navigate in Engine
I know how to make Animations, Cutscenes, just the everything in interface
Thanks for help, you are insanely good person
!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.
quick rundown: @brave idol says that his GameManager gets destroyed as soon as he starts the game
DontDestroyOnLoad(this); may need to be changed to DontDestroyOnLoad(this.gameObject);
i kinda figured the gameobject would also remain if u DDOL the component its attached to.. but just to be certain u could change it real quick
alright will try that
With this structure, will it be fine going forward if I attach the Rigidbody2D to the Hull component? The hull script will contain the movement type information and code, and I'm not sure if I'll need to make it feel the information to the root, or if it'll be fine to let the Hull object hold the sprite and necessary colliders
I think it'll be fine with my current understanding but I don't want to learn that some property of collisions will make everything harder in a few hours or days
if the rigidbody is on Hull then only hull will be affected by physics. you need the rigidbody on the root object if you want it all to move as one piece with physics
Understood, thank you!
In a third person 2D birds view RPG, should one make every room its own scene?
Or should you instead write some room switcher
probably a better idea to just switch to different locations within the same scene
yep
also allows for far more freedom
means i can make bigger rooms and make the camera track to a certain limit
thank you
seems about average of what u'd see while building a controller.
looking good
if (_timeLeft > 0 && useAction.IsPressed())
{
_rb.AddForce(0, 1.5f, 0, ForceMode.Acceleration);
_timeLeft -= Time.deltaTime;
_particleSystem.Play();
}
if (!useAction.IsPressed())
{
_particleSystem.Stop();
}
can someone tell me why its not working???
📃 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.
its not playing
private void Update()
{
if (_playerScript.IsGrounded && _timeLeft <= 2.5f)
{
_timeLeft += Time.deltaTime * 2;
}
if (_timeLeft > 0 && useAction.IsPressed())
{
_rb.AddForce(0, 1.5f, 0, ForceMode.Acceleration);
_timeLeft -= Time.deltaTime;
_particleSystem.Play();
}
if (!useAction.IsPressed())
{
_particleSystem.Stop();
}
}
Are you ever letting go of the useAction button
yes
you're playing the particle system every frame
that will reset it
every frame
i tried doing it it didnt work
It stops when you release the button
"tried not doing it" is really vague
yes
there are many ways to write incorrect code. I wouldn't be surprised if you found two of them
How did you actually do it in that case
i mean i tried
maybe you didn't do it properly
private void Update()
{
if (_playerScript.IsGrounded && _timeLeft <= 2.5f)
{
_timeLeft += Time.deltaTime * 2;
}
if (_timeLeft > 0 && useAction.IsPressed())
{
_rb.AddForce(0, 1.5f, 0, ForceMode.Acceleration);
_timeLeft -= Time.deltaTime;
if (!_particleSystem.isPlaying)
{
_particleSystem.Play();
}
}
if (!useAction.IsPressed() && _particleSystem.isPlaying)
{
_particleSystem.Stop();
}
}
thats how i did it
Okay, next step is to log when you start playing and log when you stop. Also please read the !code thing
📃 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.
there arent
and what were the results
why would the presence of a boxcollider2d on an object affect the amount addTorque has on it?
I fixed my bug where one nearly identical vehicle had a completely different turn rate, but I have zero idea why that would be the case
Colliding with something
that it is
wait so its a problem with the particles
the one without a collider turned slower and there was nothing on the field to collide with, I haven't gotten to that part yet
If it's logging "Play" when you expect it to, and it's logging "Stop" when you expect it to, then the code is working
The shape of the object affects its moment of inertia
Like real objects
And the colliders define the shape
Ohhhh so the one with a collider had more inertia, which meant the drag force affected it less
OHHHH IM STUPID ASS HELL
the position of the particles was above the player
im sry for wasting ur time
thx for help
Not precisely inertia. _moment of inertia _ which is sort of a rotational equivalent
Thank you to Arbor Scientific for letting me borrow their Rotational Inertia Demonstrator to … uh … demonstrate rotational inertia. Want Lecture Notes? https://www.flippingphysics.com/rotational-inertia-demo.html This is an AP Physics 1 Topic.
0:00 Intro
0:22 The Rotational Inertia Demonstrator
0:58 Rotational Inertia
1:40 Demonstration #1
...
I made this script for my enemy to deal dmg to my player's health, but the health variable isn't decreasing
Did you try logging Health.currentHealth instead of just the word "hit"
and is damage set
yea, but the health variable on the player isn't decreasing
just tried that, didn' really change anything
Did you reference the health variable?
What GameObject is Health attached to?
Like did u put the script into that slot
It wasn't supposed to change anything it was supposed to show you something
What did it print
the Player
Health.currentHealth
ye
Yes, what does it print
and did it go down
wait, no, I could only put the Player prefab into the slot
you were supposed to print the variable, not as a string
cool so it's decreasing the health of the prefab, not of the actual player
drag the actual player into the slot
or is this a prefab where you can't do that?
you were supposed to log the value, not the words
I'm not sure how to do that
alright, gimme a sec
both the enemy and player are prefabs, won't let me do player normally
are you instantiating the enemy at runtime?
so it is going down - the issue is that it's a different counter than the one you're expecting, since you assigned the prefab
Yes, we've established now that you're changing the CurrentHealth of the prefab
ohhh, I see
@simple hawk answer this
I think? this is the code I used for it
instantiating means to create a copy of a gameObject right?
You'll need to set the Health variable on the object you instantiate. Instantiate returns a reference to the object it creates
ok, make a Health field on the spawner and have it give that to the enemy when you instantiate it
though there are some.. other problems with the code
Better idea: If this thing collides with the player, why not just get the Health component of the thing you hit
instantiating is creating a new object, in specific to Unity Instantiate method it clones and creates a new copy
you're starting a coroutine every frame, and thus it will always be spawning
just use a single coroutine from Start or something and do a loop
ohh
I am extremely noob at coding, I'm planning to actually learn (from the start) what everything actually means, so what's a loop?
thnx
I'm confused, do you mean get the player's health component? that's the only thing that has health
Get the Health component from the object that gets hit. The thing you're checking the tag of
It's best to start learning C# basics before jumping into Unity, I did the opposite and it was very difficult to wrap my head around it.
agreed, I'm understanding just now how confusing it all is, planning to start learning after college ends
wait, I might be stupid, could this be why the code isn't working?
what do you mean by "this" exactly
should've highlighted, I'm referring to the part at the bottom
you aren't even setting currentHealth here
could that be it?
Well, it's public so it's set in the inspector
What about it
according to your above code, you're using a trigger
that message won't even run - as evidenced by the lack of a log
Which part and how so? What's it doing or not doing that it isn't?
public int currentHealth = 3;
I thought maybe the two scripts would conflict with each other
yeah, but in all likelyhood it should be set to maxHealth on Start
this doesn't change anything
In what way?
This object has a function that runs when this object collides with a solid object. The other script you showed has a function that runs when that object collides with a non-solid object
If you aren't getting any messages in the console it could be due to a variety of things. First off, is a collision really happening? Are the two objects pushing each other etc. Second, does the other object have the tag "zombie" (case sensitive)? Third, well this should've been first but I'm too busy/lazy to edit this, are you certain this is a 2d environment or 3d (both use their own physics system)?
ok, I might be incredibly stupid if this is the case: but, since the enemy's dmg script damages the prefab's health variable.. could the problem be that the prefab doesn't have a 2D collider?
Are you expecting this thing to collide with an object that doesn't exist
the problem is that the enemy's dmg script damages the prefab's health variable
Have two objects in the scene. Both must have 2d colliders (non-trigger). One must have a rigidbody. Put the damage script on the object with the rigidbody component. The object without the rigidbody component should be tagged "zombie".
I managed to fix it by making the player's collider not a trigger, not sure what that did exactly, but now it can't attack
are you on a 5 minute deadline or something
This is now causing the function on health to run
you should probably step back and do a proper unity tutorial instead of guessing and checking everything
true, I think I'm just going to get this feature working (or not) and then just focus on doing actual tutorials
yea, ur probs right, I'm going to leave it here, set up the itch page and focus on tutorials
thnx for the help guys, and sorry for the trouble
you don't have to put it entirely down
Hi , how to fix rb.velocity //(-velocity-) is dashed out and only have linearlyvelocity and angularvelocity for 2D
just- figure out what you're doing instead of doing random stuff until it works
velocity was replaced by linearVelocity in unity 6
use one of those
I do want to make a main menu, but besides that, I'm probs going to leave it and focus on tutorials, to prevent future headaches
So the default Unity.engine is using Linearvelocity now?
yes
it's the same thing, just a rename to make it clearer what it is for
Thanks
why the inerted sprite went missing when play?
Probably because something in code is changing it
havnt add script yet
Animator could also change it
yes the animator cause it
Hey guys, this is my first time making a top down 2d roguelike and i'm running into a rotation issue with my polygon collider.
From these 2 images you can see that it starts out positioned right in front of the character, but after moving in a direction, my calculation is supposed to rotate the z value according to the users last input. However, when i rotate the parent objects z value to say 90 degrees, it throws my collider far away from my character. Does anyone know how I might be able to fix this to have it stay right in front of the character after rotating?
Here's the code snippet that makes the calculation as well:
{
Vector2 moveDirection = Vector2.zero;
if (Input.GetKey(KeyCode.W)) moveDirection.y += 1;
if (Input.GetKey(KeyCode.S)) moveDirection.y -= 1;
if (Input.GetKey(KeyCode.D)) moveDirection.x += 1;
if (Input.GetKey(KeyCode.A)) moveDirection.x -= 1;
if (moveDirection != Vector2.zero)
{
moveDirection.Normalize();
transform.Translate(moveDirection * moveSpeed * Time.deltaTime);
animator.SetBool("isMoving", true);
lastMoveDirection = moveDirection;
Vector3 aim = Vector3.left * lastMoveDirection.x + Vector3.down * lastMoveDirection.y;
Aim.rotation = Quaternion.LookRotation(Vector3.forward, aim);
}
else
{
animator.SetBool("isMoving", false);
}
}```
Im getting an error that says "Can't add script behaviour 'Player'. The script needs to derive from MonoBehaviour!" but the internet says this script should work; whats wrong with it?
using UnityEngine;
public class Player : MonoBehaviour
{
private Vector3 direction
public float gravity = -9.8f;
}
where is that error being said
when I try to add the script to the inspector window it comes up with the error message
is that script saved
looks like it yeah
I rarely use my pc so I might just be an idiot tho
right click the script in Project view -> Reimport
actually nvm
your script didn't save/compile cause you have compile errors
ermm ```cs
private Vector3 direction
public float gravity = -9.8f;```
look at console window you most likely have the error there since your IDE might not be configured
hey, in a 2d plataform space how i can make a npc detect my player pos but with "lag". I mean, for now my rifle enemies know where the player pos is and shoot at it, very good. But now for the bosses and such, maybe a railcannon, i want it to know where the player was once, not where it is right now, so the player can dodge it
this is how i can detect the player
{
distancia = objetivo.position.x - transform.position.x;
distanciaAbsoluta = Mathf.Abs(distancia);
}```
this is how i can shoot at it
```protected void dispararBalas(GameObject balas, Transform balasPos, float firingspeed, float bulletspeed, float angulo)
{
GameObject nuevoProyectil = Instantiate(balas, balasPos.position, Quaternion.identity);
Vector3 direccion = (objetivo.position - balasPos.position).normalized;
Rigidbody2D rb = nuevoProyectil.GetComponent<Rigidbody2D>();
Vector3 direccionAngulo = Quaternion.Euler(0, 0, angulo) * direccion;
if (rb != null)
{
rb.linearVelocity = direccionAngulo * bulletspeed;
}
}```
store the vector3 position , clear it with a new one after a certain amount of delay
... how?
sorry for my noobness ;-;
wdym "how" ?
certainly by now you know how to store some info ?
use a variable
ahh, you mean that
idk i thought store was another thing
you mean putting the player pos inside a value
and use that value
yes thats one way to store info for later usage
oooooooh ofc, in a non-updating way
how often you update is. up to you
also can be done based on distance moved by player etc
huh
hey nav, how good are you with rotating colliders...
what does that even mean?
yeah like Vector2.Distance or something
here
from this view is hard to tell where the origins even are, the scene view with gizmos showing much more useful than a gameview
1 sec
change it from Center mode to Pivot real quick
screenshot again after
Center mode strikes again
because when you use Center mode you're not seeing the true origin point so you may be further than shown when you moved it around
just reset the transform on AIm
and adjust from there
might need to reset pos the melee thing too.
btw shouldn't that be a trigger?
you're probably right, and yes it should be but for early testing purposes i left it on to make sure it was there
huh..where is the gizmo for player at compared to its sprite
you're right there again... i just didn't implement it in the code...
the code might be okay, its always best to fix these gizmos / pivots first to make sure the rotation will be accurate
you're a LIFESAVER! i adjusted the 2 objects and now it works perfectly
tysm i was stuck all day <3

also should i stick to developing in pivot mode?
i'm new to game development with a coding background and want to know best practices going forward
yeah I rarely find use in Center mode unless you're rotating a group of objects together around a point in Scene view
Kinda weird for unity putting that as default as it messes people up a lot if you're not aware of it in the beginning, esp in code where transform.position doesnt match for example
DUDE IK
i was bug fixing all day
and this shit didn't make aaaany sense to me
bashing my head into a wall
haha yeah it used to trip me up to in the beginning for position
do you have any sources that has more of these useful tips for new developers other than youtube or stack overflow?
we used to have a #unitytips channel which sadly got closed down..it had cool little tricks but yeah most things are trial and error, maybe some in the !docs or sometimes YT vids will do a compiled list of " x useful things to know in unity"
some favorite channels that had good content were official Unity channel, Jason Weiman, LLamma academy
and some stuff on !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
noted! tysm
Hey,
For some reason I have a stack overflow and I don't understand why 🤔 Does anyone know why please ?
Code : https://paste.mod.gg/axkjjlvsorml/0
A tool for sharing your source code with the world!
(Once I click on a mine, I want to reveal where all the mines were before restarting the game 5 sec later.)
https://learn.microsoft.com/en-us/dotnet/core/diagnostics/debug-stackoverflow?tabs=windows
read on what a stack overflow is. i dont see why its listing line 87 specifically but it does also say line 82 which is when you load the current scene again. you should use the debugger here to see whats exactly happening
You need to scroll down in that stack trace to see where the infinite recursion is happening.
Hi, I am trying to use the localization package and can't figure out how to listen for changes from a function.
I got this:
private void HandleNameTMPChanged()
{
if (_nameLocalizeStringEvent)
_nameLocalizeStringEvent.OnUpdateString.RemoveListener(UpdateNameText);
_nameLocalizeStringEvent =
_nameTMP?.gameObject.GetOrAddComponent<LocalizeStringEvent>();
if (_nameLocalizeStringEvent)
_nameLocalizeStringEvent.OnUpdateString.AddListener(UpdateNameText);
Debug.Log(_nameLocalizeStringEvent);
}
And Debug.Log shows that it's not null, however, I don't see my method added in the inspector nor does it execute.
What is going on?
just a heads up that you shouldn't use ? to null check unity objects, it has inconsistent results due to reasons
Ok, my bad, I think that the event listener is added but I don't know how to trigger the change when I edit the component like this:
_nameLocalizeStringEvent.StringReference = ItemManager.SelectedItem?.LocalizedString;
_nameLocalizeStringEvent.RefreshString();
This sometimes works, it's very inconsistent tho.
when you add a listener, it doesnt populate in this list you see in inspector
the docs seem to have a decently thorough example
https://docs.unity3d.com/Packages/com.unity.localization@1.5/api/UnityEngine.Localization.Components.LocalizeStringEvent.html
I debug logged so I know for a fact LocalizedString is not null here and this gets executed when it should
They appear to be using the .RefreshString method, that's what I am doing aswell, am I missing something?
I added this Debug.Log() right above the refresh and I can see it being called, however, the name just doesn't update:
Debug.Log(_nameLocalizeStringEvent.StringReference);
I am honestly beyond confused :/
if anyone is able to help, please @ me, thanks in advance!
ok, I genuinely have 0 clue what happened but it seems to be fixed out of nowhere, I literally just walked away from my pc and it's working now 😭
and it's not working again, I just give up at this point, again, if someone could happen to have a clue as to what's going on please @ me, I would highly appreciate it :/
Last message, I hope, I think I figured it out.
You gotta do it like this:
_nameLocalizeStringEvent.StringReference
.SetReference(ls.TableReference, ls.TableEntryReference);
ls.RefreshString();
_nameLocalizeStringEvent.RefreshString();
You can't use _nameLocalizeStringEvent.StringReference = ls; instead of SetReference.
This is so odd, especially considering the fact the setter for StringReference is public, but whatever.
Hopefully it stays at this and I never encounter this issue again...
I'm making these rabbits move by themselves with simple ai, but their idle animations dive into this, then dive back up to normal when they run. Disabling root motion stopped them from diving down, but it altered their movement and made them slow
i will also add they float in game mode but don't in scene mode
Can someone teach me c# in unity?
That isn’t really something people can do for free
maybe watch some youtube tutorials?
See the pinned post, there are plenty of tutorials.
I highly suggest you learn C# basics before touching Unity in any way.
I don't necessarily agree, Unity is especially a good starting point for using C# in my opinion (and even more if the end goal is to master Unity).
It really depends on your experience but the majority of people getting into C# and Unity have no prior experience with programming. You really shoot yourself in the foot by combining them, especially given Unity's horrible implementation of C#
Especially since they ask for both C# basics and Unity, you really should get used to the syntax first. That's also why the pinned post has the Intro to C# link
Long term it's faster and less frustrating than taking them both at the same time
Oh okay, yeah if there is absolutely no prior programming experience maybe it's questionnable as you say
I still believe that if you have a correct approach, you may begin with Unity to learn C#, I think you can to pretty simple things with it, like if you have an input, you just move a transform, or even play with forces with rigidbodies pretty intuitively (well at first not really, but you learn fast).
I'm kind of suprised the pin doesn't include any interactive beginner tutorials
the microsoft beginner guide is super extensive but it's quite offputting for a complete beginner imo
Also I'm curious, @burnt vapor why do you think Unity implements the C# language horribly?
i'd also be curious if the answer contains alternative solutions
Various conventions and hacks to make the language work is enough reason to put it to the side and learn C# the right way
Bugs with constructors in Unity, bugs with any type of null-coalescing or null-conditional operators that work in an unintended way on game objects in comparison to comparing to null directly
I wish unity just expose a way to use c++
Then we won’t have to jump interop hoops
It's years and years of bad ideas and the fact they supported UnityScript or whatever it was called which just made it worse
how would you solve the constructor support?
i don't think those two make it a "horrible" implementation
I don't solve it, Unity should have made it work from the start
You don't find it horrible that a very normal C# implementation doesn't work in Unity?
Fair point for the null-related thing, but at the same time, i understand the design
Do you know what issue constructors have in Unity?
I know MonoBehaviours are designed to completely avoid them because of there fundemental design
It really isn't. Overriding null on gameobjects to indicate they are destroyed. Why did they choose to do this over a normal property?
wont a majority of checks be (if object == null || object.IsDestroyed) then
object?.IsDestroyed? Not sure what you mean
I guess it's a way to reduce verbosity? But I get that it's not really great because this object itself is not null and can hide the real memory management
oh fair
Overriding null is horrible, you don't expect it to check if something is destroyed. You expect the reference to be gone
for 90% of people they do not care about that difference and the other 10% are nerds who know whats going on entirely
whats wrong with constructors
You must use the Instantiate function instead, maybe this is because some requirement about unity can't fit in the constructor in some way? I don't have the knowledge for this
They can be called multiple times due to the way they work with Monobehaviours
Would you prefer another function getting run immediately on creation regardless of active state?
to be honest it would feel a little weird of monobehaviour constructors worked period
Why would this be weird?
I think that in the end, they made this design choice (null overriding) because of clarity.
Imagine having object?.IsDestroyed called to check if the object exists: it makes perfect sense alright, but it can be tricky for beginners to understand that it's not about a object being destroyed, but its mere existence at all.
So I understand why they chose to keep it "simple" by just having object == null which is more likely to be understand as "we have a valid object" than object?.IsDestroyed
Enforcing the gameobject would feel very out of place in how constructors should work, no?
Curious what a preferable solution would be using c# constructors and enforcing the design descision that all monobehaviours must exist in the context of a gameobject
Yeah having the reference just be removed would be really useful, but maybe they can't do that because of some internal requirement we don't know?
i want to enable preview features in my project so i can use some functions that i cant use before
which file should i modify?
What kind of preview features? And what makes you think that modifying the cs project is gonna help with that?
in C#14 theres a new features called extension method?
but it needs to "enable preview features"
and when i google how to enable it, i saw some article saying modify the csproj helps, maybe i will look into it more lol
Unity only supports C# 9 according to the docs.
And csproj are only used for intellisense. Modifying these files might help in the ide, but the code wouldn't compile anyway.
ty 👍
extension methods are supported just fine though
Are you talking about making a static method with an argument, but the first argument can be considered as the object to call the function on?
like :
// In some .cs file
static class ExtensionThing
{
public static void DoSomething(this YourObjectType yourObject)
{
// Do something with yourObject
}
}
// Somewhere in your project
// ..
YourObjectType instanceOfObject = new();
instanceOfObject.DoSomething(); // Allowed because the ExtensionThing class is STATIC, and the function has the first parameter marked as "THIS".
ExtensionThing.DoSomething(instanceOfObject); // Also allowed, since it's the default behaviour
// ..
in that case, it is supported
Ah, extension methods are not C# 14 though
More on this article, a certain syntax is indeed only for C#14, but you don't really need it.
now this is a code from someone
that "extension" is a new thing right?
Yes this syntax is only for C#14 or newer
but you can basically do the same with the "old" syntax, which is what I send as code above
nice i gonna try it , ty 👍
AFAIK Unity overwrites anything done in the csproj so the answer is that you can't
You might be able to add a Directory.Build.props file to your project and place it in there. It will take effect over all csproj files and Unity won't modify it
Considering how ancient Unity's langversion is it would still be nice to have if you can at least bump it to 13
So I made a spherical planet and I want my player to walk on the planet while staying aligned and always upright relative to the center of the sphere. I already made simple gravity using rb.AddForce() but I still need a way to always have the player perpendicular to the sphere's surface. I looked on youtube but the only tutorial I found basically just told me to download his code and didn't show how it worked. Any help is appreciated!
the gravity script is on the planet and it references the player rigidbody. In case that matters
edit: here's the gravity script since it might be helpful
public class Gravity : MonoBehaviour
{
public Rigidbody[] rigidBodies;
public GameObject planet;
private Vector3 gravityDirection;
public float gravityStrength = 1f;
void FixedUpdate()
{
foreach (Rigidbody rb in rigidBodies)
{
gravityDirection = rb.transform.position - planet.transform.position;
rb.AddForce(gravityDirection * -gravityStrength);
}
}
}
Hi all,
So, I'm having a weird raycast issue and can't seem to see what's going wrong.
I'm generating a world in a tile pattern and need to add a spawn point to each 'chunk'. Everything is working, but the raycast I have on the spawnPoint object is 'missing' the terrain collider (It's hits it, but the hit.point y axis is very wrong, it's way lower than it should be). My layer mask etc. is all correctly assigned, and the terrain collider does work because I can walk around on the islands (manually moving of the character to test)
So, I'm a little bit baffled.
The debug is spitting out a hit.point position as 0, 3.27f, 0, which given the hit point is actually around 200 is confusing.
Here is the full script.....
https://hastebin.com/share/ifomumatah.csharp
and here's just the SpawnPointGeneration part.
GameObject newSpawnPoint = new GameObject();
newSpawnPoint.name = newIsland.name + " Spawn Point";
newSpawnPoint.transform.parent = newIsland.transform;
newSpawnPoint.transform.localPosition = new Vector3(0, 500, 0);
RaycastHit hit;
Vector3 raycastOrigin = new Vector3(newSpawnPoint.transform.position.x, newSpawnPoint.transform.position.y, newSpawnPoint.transform.position.z);
if (Physics.Raycast(raycastOrigin, newSpawnPoint.transform.TransformDirection(Vector3.down), out hit, Mathf.Infinity, layerMask))
{
Debug.Log("Hit Ground @ "+hit.point);
newSpawnPoint.transform.position = new Vector3(hit.point.x+0.5f, hit.point.y+1, hit.point.z+0.5f);
}
else
{
Debug.Log("Did Not hit Ground");
}
dataManager.spawnPoints.Add(newSpawnPoint);
Anybody see or have any ideas as to what's happening? Cause I just can't see it 😕
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
after messing with it, i give up, if old version still able to do what i wanted then i will let it go
Try the props file I mentioned
u need a plugin called csprojmodifier to import .props file and a csc.rsp file under asset folder right?
if that plugin is not necessary i can try it again👍
when i google it , the article said i should install csprojmodifier and import .props files from there
but if u install that plugin , it will have conflict with unuty.test-runner , i havent used that so idk what that is
@eternal needle
Hey guys, so I have a script that tells me when a button is selected or deselected. Let me say I'm using keyboard navigation so keep that in mind. I also have a system where if the player doesn't meet the KhronsAmount, the button will be locked(thisButton.interactable = false;).
My problem is that when I'm CURRENTLY on the button and want to lock the button so the player cant press it, the keyboard navigation stops working. I checked and its deselecting the button but somehow its still selected.
If I lock the button while on another button, its fine. I want to also be able to lock it when currently on it.
https://pastecode.io/s/rn7shapg
do you still have a question here after reading the stack trace? it should be pretty clear as to whats happening
Yup as I still don't understand how to fix it
is it because I didn't clear the Coroutine first before creating a new one ?
you have infinite recursion between OnTileClicked, OnGameOver, and RevealTile
when you look at the stack trace it tells you exactly whats happening. first thing to note you subscribe to the action (this isnt an event)
OnTileClickedEvent += OnTileClicked
in OnTileClicked you call neighbour.RevealTile();. In RevealTile() you invoke the action GameManager.OnTileClickedEvent?.Invoke(this);. Repeat
Go in reverse from the top of your stack trace down. Whats line 82 of GameManager.cs? What's line 101? What's line 144 of Tile.cs?
when you click on a mine, you game over.
when you game over, you click on all tiles, meaning you click on a mine
actually i got the order wrong since OnGameOver is the one calling RevealTile as well, which invokes the event too
so this is like double infinite recursion
So do I remove the event invoking in "RevealTile()" ?
thats for you to decide on how to fix this. im looking at this error purely from the code. i dont know how your OnTileClicked or RevealTile function needs to work
no matter what you do, you just have to remove this infinite chain of methods calling each other
maybe that means RevealTile shouldnt invoke the action. Maybe GameManagers OnTileClicked shouldnt reveal a tile under certain scenarios
the only thing I notice here is that you seemingly have this visitedNeighbours hashset which you dont use, and a tile.Visited property that never is set.
maybe you forgot to finish writing the logic for not infinitely checking over neighbour tiles. Maybe ai hallucinated if you used ai here
just curious when u do the "directory.build.prop" file u havent installed any of the plugins? just place it directly to rootpath?
Dumb question but do i have to rename a class in my script if i rename the script
also unrelated but should i update visual studio whenever it gives me the option to update?
As of Unity 6, no. If you're on an earlier version of Unity, yes.
As long as there's only one class in the file
Well good thing im using unity 6 i guess cause im probably going to be renaming scripts a lot
Hi I am trying to check when my cutscene video ends. I tried using a simple example code and find myself running into an error with the CheckOver function I made, and the loopPointReached? Any suggestions as to what could be wrong?
using UnityEngine;
using UnityEngine.Video;
public class VideoPlayer : MonoBehaviour
{
[SerializeField]
VideoPlayer video;
void Start() {
video.loopPointReached += CheckOver;
}
void CheckOver(VideoPlayer vp)
{
print("Video Is Over");
}
}
you have to put it in update
start only happens when the script is made if im correct, update happens every frame
idk if thats the only issue but thats the only thing that i would personally know
i have a custom class that i want to assign to GameObjects in the inspector (using a [SerializeField]). I'm assuming this is possible i just don't know how to actually put the data in. My custom class has the tag [System.Serializable], so i just need to work out how to put the data into here -- "Price" should take my custom class. If you need more info please ask
at the end i gonna make my own extension method like this
Read the error. You dont need to add in update as the other person said because that's not how event subscriptions work
i didn't even know they were using event subscriptions or what an event subscription is 👍
but wait how would it work if its in start and not update
atleast from what i know that code would never work unless its in update
Maybe use a scriptable object? What are you trying to solve here.
With your current setup, any serializable fields under your custom class will show already on the component. You dont drag anything in
Sorry to interrupt the convo but some help here would be amazing. Thanks. #💻┃code-beginner message
Read up on events and it'll be clear. Its hard to answer without just explaining the entirety of what an event or delegate is
ok
Because it's a subscription to an event. Putting it in update would break things horribly
because every frame it'd add another copy of the function to that event
idk what an event is thats the problem
😭
Your issue is that this class is named VideoPlayer. And it doesn't have any events named loopPointReached
Then look it up
someone already told me to
i was trying to read on it but you pinged me
Its built in from what I can see on the docs
There is a built in class named VideoPlayer, but that's not the one they're using here
They're using this one
You would need some way for these planets to tell your characters what planet its even on, or what direction "down" is now. The logic of aligning to the planets surface is the same as if you were just on a flat surface, except you just change the direction of your physics cast
It's a single planet that the player will be on the entire game, which hopefully makes things easier
Its the same thing still, the player needs to just know what direction down is
They can calculate that by having a reference to the planet they're on
okay ik this is dumb but google doesn't understand my question, does < check if something is under the second value or above the second value
I tried this bit of code
rb.rotation = Quaternion.Slerp(rb.rotation, targetRotation, 100);```
from an old Sebastian Lague video but my player kept spazzing out and spinning wildly so not sure what was going on there
Did you have basic math at school?
The quaternion multiplication looks backwards there
yes obviously but i genuinly don't remember cause genuinly who uses them bro 😭
< is Less Than (search 'boolean operators')
thank you 😭
which part?
the only part there where you multiply two quaternions. i think it should be
rb.rotation * Quaternion.FromToRotation(rigidBodyVector, gravityVector)
The alligator eats the bigger number
erm actually i was told it was a crocodile
LMAO. I was literally just about to type that's how I was taught at school
C# doesn't care about the commutative property of multiplication?
Yup good job looks nice
who says? math is a math thing, not a c# thing. the order matters for quaternions
oh interesting
I fixed that part but my player still spins extremely fast as soon as I press play. This is the only active script in the scene. Any idea what could be wrong?
public class Gravity : MonoBehaviour
{
public Rigidbody[] rigidBodies;
public GameObject planet;
private Vector3 gravityVector;
private Vector3 rigidBodyVector;
public float gravityStrength = 1f;
void FixedUpdate()
{
foreach (Rigidbody rb in rigidBodies)
{
gravityVector = (rb.transform.position - planet.transform.position).normalized;
rigidBodyVector = (rb.transform.eulerAngles).normalized;
rb.AddForce(gravityVector * -gravityStrength);
Quaternion targetRotation = rb.rotation * Quaternion.FromToRotation(rigidBodyVector, gravityVector);
rb.rotation = Quaternion.Slerp(rb.rotation, targetRotation, 100);
}
}
}
Well, you're passing a value of 100 to the Slerp, which means it's way more than 1.0 which means you could just replace that line with rb.rotation = targetRotation
hmm ok
thats definitely interesting if that was directly from a Sebastian Lague video, i have doubts about that being the final code he wrote.
though maybe you also want to do this logic on the player directly? otherwise everything with a rb is going to try and align itself like this
I tried 0.5 but it gives the same result
because you're not using Slerp as it should be used, you cant just plug in random values
sebastian had 50 as the last arguement of slerp but other than that it's the same
keep in mind this was an 11 year old tutorial
Can you link it
50 has never been a valid third parameter for slerp
A tutorial on creating a Faux Gravity system in Unity. This allows your characters to walk on planets without falling off. (As seen in Mario Galaxy)
Download planet model: https://copy.com/O8C1lWLNFUOuqfJe/Planet.blend?download=1
Download Unity project: https://copy.com/13VfW36IP8eiBmCe/Faux Gravity Example?download=1
he shows the Quaternion.Slerp part at 10:28
he's multiplying by Time.deltaTime, which is usually a very small value
even that is technically wrong to do but should work ok
https://unity.huh.how/lerp/wrong-lerp
Applying lerp so that it produces smooth, imperfect movement towards a target value.
"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: 189
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-19
lemme switch to the Update method and see what happens
you dont need to swap to Update though
Time.deltaTime in FixedUpdate turns it into Time.fixedDeltaTime
You would still want to use FixedDeltaTime to get the value in seconds each time step takes
It still isn't the best way to do this, in a more modern tutorial he'd be using RotateTowards
and it still spins lol
But Slerp's third parameter is a percentile value for how much of the way between the first two parameters you want. 0 means first parameter. 1 means second. 0.5 means halfway between the two
looks like I need to go back to the drawing board 
Problem solved 🤔 Thanks 🙏
- I don't have the stack overflow anymore and all the mines reveal correctly but right now I have this error that appeared once (the second try it didn't appear, third try it appears again when I clicked on a mine)
- also my game revealing neighbors that are 0 and their surroundings don't work anymore as you can see with those empty revealed tiles 🤔
https://paste.mod.gg/lqldofmnpdos/0
A tool for sharing your source code with the world!
You should probably pick one of the Unity servers and stick to it so you don't end up getting multiple people doing the same answers since they're not seeing each other's messages
I tried to redo it with RotateTowards just by memory from other projects but I must be overlooking something simple because my player still spins in place and changing the max angle in the RotateTowards argument just changes how fast it spins. I'm very sorry but I can't think of what could be wrong.
foreach (Rigidbody rb in rigidBodies)
{
gravityVector = (rb.transform.position - planet.transform.position).normalized;
rigidBodyVector = (rb.transform.eulerAngles).normalized;
rb.AddForce(gravityVector * -gravityStrength);
Quaternion currentRotation = rb.transform.rotation;
Quaternion targetRotation = rb.rotation * Quaternion.FromToRotation(rigidBodyVector, gravityVector);
rb.rotation = Quaternion.RotateTowards(currentRotation, targetRotation, 1);
}
Try using Debug.DrawRay to see what direction your gravityVector and rigidBodyVector are pointing
hmm the gravityVector and rigidBodyVector rays appear to both be pointing the same direction as each other at all times and every few seconds the rays jump to another rotation randomly
sorry nvm
So that sounds like a problem. gravityVector is obviously supposed to be pointing in the direction of gravity, but what's rigidBodyVector supposed to represent?
accidently put rigidbodyvector as both rays 🤦♂️
my apologies
ok the gravityvector ray is constantly pointing at the center of the planet which is good
well I have it set to rigidBodyVector = (rb.transform.eulerAngles).normalized; and it's supposed to represent the direction the player is facing so I can rotate the player and get the rigidbodyvector to be in the same direction as the gravity vector
all to get the player to always face feet down on the sphere
So, it's a direction vector, why are you trying to get it from an orientation?
Those aren't the same thing
lol uh that's not good I didn't notice
Consider an object with euler angles of 0, 180, 0, that's going to be facing backwards, but the normalized value of that is 0, 1, 0 which is straight up
If you want the direction the object is facing, use transform.forward
var listEvents = events.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
foreach (var x in listEvents)
{
Debug.Log(x.FieldType.ToString());
if (x.FieldType == typeof(System.Action))
{
GameEvents.TryAdd(x.Name, (System.Action)x.GetValue(x));
}
Why does this array come up empty? If put something like string instead of System.Action, it does find them
do I need to normalize that?
oh it's already normalized got it
Probably doesn't have any fields of type System.Action then
Ye but it does though
What do the logs say?
here type says x.FieldType is System.String ?
how do I figure out what to put as the max angle for Quaternion.RotateTowards()?
Now the player vector is pointing out the front of the body (it's a cube) but the whole player character is still spazzing out
How much do you want it to rotate in one frame
Oh nevermind I'm supposed to use GetEvents() instead of GetFields()
Okay, so does it ever print System.Action?
You're printing the type of every field
I don't know what I'm even doing here, just messing around
I want it to rotate fairly quickly but lemme try a few numbers rq
was it perhaps an action with params
I'm still running into the same issue when I put it in update. I did also try making the loopPointReaced var into a Action<VideoPlayer> variable but didn't work?
Do not put it in update. Read the other people's responses to your post, this is further from correct
Go back to what you had before, then read my other reply to you
Your video variable, what thing are you trying to reference with that? What object?
the guy said put it in start
and he's smarter so
yeah
I made transition between three animation. The problem is character stucks at jumping anim when transition goes from run to jump. Whenever, I stop instead switch to idle staying on jump anim.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
its a bit complicated
you're probably still "running" when you run and jump, so the transition won't be taken since you're requiring it to be isRunning == false
also, #🏃┃animation for future reference
This is what I have now. Idk if you can see in this video but the green debug ray is the gravity vector and the red debug ray is the player vector (ik, poor color choice). It's still not correctly rotating itself upright and I have no idea why.
here is the current code again:
foreach (Rigidbody rb in rigidBodies)
{
gravityVector = (rb.transform.position - planet.transform.position).normalized;
rigidBodyVector = rb.transform.up;
Debug.DrawRay(rb.transform.position, gravityVector, Color.green);
Debug.DrawRay(rb.transform.position, rigidBodyVector, Color.red);
rb.AddForce(gravityVector * -gravityStrength);
Quaternion currentRotation = rb.transform.rotation;
Quaternion targetRotation = rb.rotation * Quaternion.FromToRotation(rigidBodyVector, gravityVector);
rb.transform.rotation = Quaternion.RotateTowards(currentRotation, targetRotation, rotationSpeed * Time.fixedDeltaTime);
}
rotationSpeed is currently set to 5
Goofy ahh rigid bodys😭🙏
2025 people using their phones to record a computer monitor instead of video screen capture 
I was lazy
And my mic is kinda trash
yeah yea nothing new in this generation
what does mic have anything to do with screen recording a video lol
Oh yeah right
also pressing 1 Key in OBS is hardly any more work than hitting recording on a phone lol strange times
I think microsoft even has their own crap with WinKey + G to record
how do i get in bro
well as the error says
save your project somewhere else, dont use system folders
Windows is case sensitive ?
ok
yeah i see that error for the first time
but fr tho, windows weird as hell
not by default. this is because of something they've changed theirself
ahh that makes sense
it can also be set per-directory so they probably just need to make the project somewhere else, likely where ever the rest of their projects are would work
isn't it based on the file system, rather than the operating system
I'm completely stuck so if someone could help me that would be nice. For context I want to make my player to constantly rotate to stay upright (perpendicular to the sphere's surface).
not completely sure but this might be helpful for you https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Quaternion.FromToRotation.html @vocal wharf
i remember i made something similar to what you have but i am not sure if it was this method i used, been a very long time
I read the doc already but I have no idea what could be wrong
the new snipping tool even has recording now, even prompts u when u press PrntScreen 🙌
the only positive thing out of 11 it seems lol
Ladies and gentlemen what the heck
I just created the project and it gave me an error
this is a new project, almost blank. i just created 2 sprites
i'm running unity hub in arch linux
everytime i click to run, i get that "errors need to be fixed before compiling" message, but there's nothing on the console, absolutely nothing
yea, thats b/c the console wont work.. b/c the game wont even go into playmode
u have to fix "compile" errors before you'll get runtime errors
can you show the project window w/ all the files in it?
there's only a default scene and a input map, nothing else
if its a completely empty project i'd try to make a new one..
u shoudnt have compile errors in an empty project 🤔
try a different template maybe
it's the BIRP 2D default in unity 6 LTS, btw
it might have something to do with the fact you're running it on an unsupported distro, who knows what could possibly have gone wrong during installation
guess it can be that too
i have already used unity on this distro before without errors, it should be something with the version or smt
anyway, i'm gonna try to create a new project and see what happens
ya i thinking its installation / ur pc setup and not an actual unity problem
2D Birp opens fine in unity6 LTS just checked for ya
also try earlier version of unity
yup
could be a mix of not official supported distro + newer version not ported properly for linux in general
true true..
it'll help marginally.. new projects just take a while
mechanical are only good for long time storage
after the first start-up sequential ones will be much quicker
i got like 4 HDDs i just found by the house 3 years ago
os dependent too
my 2014 macbook would create in 30 secs
on my windows machine ssd nvme + ryzen 7 would take at least 2-3 mins
ive had more SSDs die on me than i can count
just need at least 1 ssd 😛
I have a HDD 5400 rpms that still runs GTA5 lol
smt about 500gb should be fine
i managed to run Resident Evil 4 remake without SSDs XD
haha 500 gig is "warm-up"
basically OS and apps you work with often that use disk
laughs in Adobe cache
guess my SSD will be only for windows and unity, linux is fine on HDD
ohhh nooo.. my heavy drive is getting on up there
i have windows 11 + arch linux dual booted on my PC, but while arch takes 2min to boot, windows takes like 15
12 FRICKIN TB???
what are you trynna store? the sins of the humankind? damn
just unity projects bro 😄
yeah SteamOS is my main priority so i use linux
handhelds are definitive proof that the same hardware you get better performance and battery life with a linux based machine instead of windows 11 ARM version no less. win
they just need a bigger marketshare so these dam big techs would actually shift priority
i'd like if unity gave more support to linux. i mean, it exists, but isnt the same thing
i got a game i'm making on godot but recently i wanted to do it multiplayer, so i'm getting it into unity, (godot's multiplayer didnt cooked enough)
i have 3 years xp on unity but after some trauma i quitted game dev and i'm getting back rn
i feel dumb because i forgot too much stuff about C# 😄
ehh its normal to forget if you don't do it daily or close to that
thats why theres google, unity docs, and stackoverflow 😉
ya a quick lookup it comes back anyway, its usually not totally forgotten
if u cant find ur solution by using those 3.. it probably isn't possible..
we'll have to learn more about physics first
the microsoft docs for c# is pretty decent
is it more common to have a scene-manager its own component?
or have the game-manager be in charge of that as well?
im torn 🪚
I got managers everywhere so I prefer the former
just lives alongside the gamemanager?
which i assume is like in control of the game-state
yeah my game manager manages the other managers typically they react with events
ahh fudge!! brb pc is crashing out
I basically use this pattern I guess
https://refactoring.guru/design-patterns/mediator
what the heck
ill look after restart 🧡 thxx
good luck
leak eating ram ? 😮
ya, i figured 16gig would be way enough
oh 16gb..damm
ive only got 3 projects open
bro wtf
but thats actually a smaller number than ususally so yea something is leaking
WHAT
running 3 unitys now is more hefty then 3 2019/2020 unitys
bro's trying to fry an egg on the CPU

meh, i'm not gonna complain, i got an i3-3240, a RX550 and 12gb ram DDR3
the most expensive thing in my setup is my 180hz monitor i guess
don't even know how unity runs on that potato
i've seen worse to be considered a potato
someone using onboard gpu for example and 8gb ram
i bet its that "pro" project, since it was basically an asset dump for the better of 2 years
thats cause you never saw my laptop
it's an galaxy book go (4gb ram, snapdragon7c gen 2 ARM)
just realized we should probably make a thread or sum
going offtopic from code
FOR REAL
how come ive never heard of a mediator pattern 🤔
its actually probably something ive used or seen used and didnt know it had a name
tbh most of these patterns I was doing without knowing a name to it
hey i just stumbled upon unity, can anyone recommend a good yt tutorial playlist to get started with? i only found really old ones
you guys wanna make a thread on #💻┃unity-talk?
check pins
i STRONGLY recommend "Code Monkey"
eh I think for a beginner code monkey is a bit much
meh, fr
his code is confusing as hell sometimes and you yell at the screen "WHY"
also the cringe earlier videos where he uses his own UTILS you have to download from his sketchy site lol
i started with "Crie Seus Jogos" that is a brazilian channel yk? the guy talk to you like he is teaching a dog, impossible to not learn
I started with earlier vids of Jason Wiemann they were pretty solid
if he ever decides to edit out his Mechanical keyboard rather than emphasize it i'll consider watching his coding stuff
until then i'll just check out his Monthly asset list/review vids
ya, jason weimann was who i gravitated to... him and sebastian lague
actually tbh, those were the only two household names i used to learn almost everything i needed to know..
yah those are the good OGs
seb is more of devlog now so he doesnt always show the complete code but gives nice inspirations
ahh yea i do use this design pattern.. well i'l be darn knee slaps
yeah its pretty common once you see it in action. The real world analogy for it is perfect
that + observer pattern (just events lol)
but mine is a level above the game manager..
so it'll get its info from teh game manager to know whether or not to call functions in the game manager..
which at first kinda put me off from using it
but im sure theres another little workflow trick i dont know about to remedy that.. or make it make more sense i just havent discovered it yet
what exactly is supposed to do with it ?
also its kinda how i got my "References" object set up
the actual manager was getting too big and knowing about too many things
so i subdivided the data type stuff
also i don't typically make 1 giant mediator for many things (or you're back to GM monoliths), I more or so categorize them, also a bit of chain of responsibility parts
semi offtopic but this reminds me how much i wish we had built in readonly fields because some of these i wish i could view but not depend on inspector drag and drop injection for
Debug Mode 😛
it's pretty easy to just write your own ReadOnly attribute and property drawer
Unity is just lazy esp if there are assets for it
i used to use naughty attributes so i had alot more read-only fields and stuff
imagine how easy it would be for unity to make something like Naughty or Odin
but something about it broke my frame rate a while back and i couldn't save the project
so since then i wont install naughty
i just write my own attributes
like these cute little icons 😊
serialize a dictionary or lay off staff
unity: 🤔
" how else would we bring in these new AI features "
priorities mannn
heya, i have a ''random'' question!
using public variables for ''universal'' things, such as object speed and such, is a bad idea right, so it is usually private, and at max a [serialized field], but what if i want certain objects to have these variables tempered with? like buffs, debuffs n such.
would doing a private generic variable (private float moveSpeed; for example) for every entity that has it.
but then doing a public specific variable (public float playerMoveSpeed; for example) and then set playerMoveSpeed = moveSpeed;
would it work? cuz that way i can change this public variable to for example:
playerMoveSpeed = moveSpeed * SpeedBoost
using another script, would that work? is that dumb? is that unstable?
create a method that interacts with those variables, and/or use structs for example to group data
so the real kinda answer for this is c# properties but in general the idea is you want a public facing way to try and set the value, and let that function decide if the incoming value is ok to be used
the issue with public fields directly is any random stranger and give it any random value
your fine having a stranger do it but you need to check if the value is ok
yeah public fields can really trip your future self or another person working on it
im still a super beginner so i dont have the knowledge baggage to know better ways, im sorry for that, i will take a look into learning those things to see if i comprehend it tho!, this was the way i thought about based on what i know (super super beginner)
yeah, thats why i thought making the base speed, base attack n such, be private, would somewhat help
yeah no stress, you know what functions are right?
properties / functions generally the best way so you can put things like notifications of values changed and stuff like that
i use an SO with all my player data (default values).. and then it'll read em and assign em all to a local version of that variable.. (those i can modify as i wish all i want in the inspector, runtime or w/e) when the game restarts my default values are still intact
if i want to keep a modified value or something ill just jot it down
maybe superficially, i understand it as ''block of data that does a certain task'' but it may be too broad to serve as an answer, or even be straight up wrong
your not wrong in thats what they do but a function in the context of programming conversations is literally just a
void MyFunction()
{
stuffs
}
yeah, learned that doing a function to flip the character on the X axis, in that case, void Flip()
functions and methods are generally interchangeable but functions are usually the "doing something" that function on their own, methods are associated with objects
just so i get it as a direct answer, was the thing i described wrong?, or just not optimal/has a specific problem?
i couldnt find it when i tried searching about this method
int currentHealth;
public int Health
{
get => currentHealth;
set
{
// Clamp value between 0 and maxHealth
currentHealth = Mathf.Clamp(value, 0, maxHealth);
// Check for death
if (currentHealth == 0)
Debug.Log("💀 Player Died");
}
}
public void Damage(int amount)
{
Health -= amount;
}
public void Heal(int amount)
{
Health += amount;
}```
so whats a property do? is it a function?
probably dont need to hit the property off the bat
there is no built in method for flip, for example you'd code that in yourself
they do have a flip bool on sprite renderer and such, but the method usually something you write
i just lookin around for some use-cases that make me stop and refactor my code b/c i can't go without properties a minute longer 😅
property i still didnt learned, im sorry, what i can imagine is that it ''reads'' functions/manages them in some way? like add a property to adress X and Y functions in some way ? but at this point id be guessing
b/c ngl, ive neglected them for a long time now
yeh, thats what i meant! im sorry, i wrote the function
public class MyClass : MonoBehaviour
{
[SerializeField] private int currentHealth;
[SerializeField] private int maxHealth;
public int GetCurrentHealth()
{
return (currentHealth);
}
public void SetCurrentHealth(int newHealthValue)
{
if (newHealthValue > 0 && newHealthValue < maxHealth)
currentHealth = newHealthValue;
}
}
@idle grove so this is a very basic example of what you would ideally want to do instead of having the field be public directly
don't worry about using properties specifically for now they are just a convient way to merge functions and fields, ignore them
thats what i meant with learning it, i learned how to do a function, and named it flip, to use on the player movement
the idea with this code is that you can control what the value can actually be set to when strangers try to tamper with it
slap a OnHealthChanged Action<int> and you're golden
this way if others want to react when it changes its easy to do
A Property is a way to use a pair of functions as if it were a variable. You define a function that runs when you get the variable, and one that runs when you set the variable. It runs the setter when it's before a = and the getter when it's not
Or as nav said previously, you also get to know when it does get tampared with, in case you need to run code in reaction to the change
im slowly getting it
thanks people
i still have to get more of the basics to fully get it, but atleast it doesnt feel like magic
idk if this is a psycho comparison but imagine that
a public field is like a gold bar teleporting into a bank vault
a public function is like someone actually walking into the vault and putting the bar in there
so if you did
public int Health {get; private set;}
can only be read from outside but not allowed set from outside..
the way i think of it now is
you can use OnValidate() method to check if a variable ur entering into the inspector is a valid one..
but that only works in edit mode..
you can use a property to check if a variable either you entered or a script tried to set is a valid one..
and that works at Runtime
and.. theres all kinda cool things u can do with the getter and the setter.. making one public one private.. as nav just said and so on
[field: SerializeField] public thingo myVar {get; private set; } is my bread and butter 😄
im crazy but I always give it a private field / backing field
never looked back 🤣
asking for pure curiosity, this is from what type of project that you're doing ?
that will be a little nicer in c# 14 eventually
public int Value => myValue;
[SerializeField] private int myValue; //or no serializefiled sometimes```
its just a first person controller
oh ok
public string Message
{
get;
set => field = value ?? throw new ArgumentNullException(nameof(value));
}
14 lets you do this 😄
i like using headers and stuff to keep me organized
and easy to see things at a glance
if all ur values start at 0 u cant mess any of them up 🫠
i feel like this overestimates one's ability
using structs for this is annoying in unity we cannot assign default values..this is the shit that irks about old C#
u can create a new one w/ defaults cant u?
You can put it in a method but old c# didnt allow assign default value to initializer like you can in class so you do start with all 0s / default values
public struct Data{
public int speed = 10; // unity cries
}```
i mean you can do something like this though, no?
public X x = new("default");
[Serializable] public struct X { public X(string n) { this.n = n; } public string n; }
oh ya, i just do all the logic in one class
got my structure at the bottom and the default ones at the top
ya. i supposes you can use the constructor ? found it annoying that you need to assign all fields by default lol
ah. you can do spawn's thing with the bracket init though
assign all these values immediately without using functions or i will KILL MYSELF
i think i may be borderline dyslexic
that was sooo hard for me to read
my codegolf blood is showing
i wish i could read it better
i tend to just... ignore the existance of newlines when doing small tests like that yeah lmao
yeah took a couple passes to read lol
i love army acronyms and i wish i could code using more acroynms 😈
hey aren't colliders supposed to use green lines
typically yea
so my monitor just decided to pull an optical illusion on me i suppose
the boxcolliders i had looked like they had green horizontal lines and white vertical lines
zoomed screenshot/other monitor showed consistent green
any chance you have two gizmos lines drawing the same place and the load order sometimes flickers?
no, i think it (gpu/monitor, idk) decided the line was too thin and actually did just make it white
honestly so valid
ok so guys i read this C# crash course, do you think that's enough tp start making basic games or should i do more
that's not a very answerable question
- depends on what you mean by "basic"
- make sure you also understand it, not just that you read it
- you'll also need to learn unity apis and messages
- you'll also need to learn how to use the unity editor, how to work with gameobjects, and how to manage the assets
- you won't remember all of it, make sure you can find what you need if you have to go back to check
that being said - sure, you can start making stuff, but don't do "learning" and "making" as separate steps
learn as you go too, via tutorials, via guides, via docs, etc
I am trying to make a crafting interface in my survival game and used a scroll view for it. But when you select the scroll bar with your mouse and use it you can controll it with w and s, how can i remove this
try setting Navigation on the ScrollBars to None
that worked, thanks
Use GetAxisRaw instead, as GetAxis smoothes out your inputs from 0 to 1 and back
The effect is that, because you normalize the vector made for these inputs, it'll keep going until your inputs are both exactly 0, which takes a second or so with GetAxis
thanks
it didnt work...
!code pls
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
You still need to normalize the vector in order to go the same speed diagonally, idk why you removed that part
I'm still having problems with my game 🤦♂️. I want my player to be constantly upright relative to the sphere so that the feet are on the sphere no matter the position on the sphere. I've gone through so many tutorials and docs and this is what I have so far. The player is locked to what seems like global "uprightness" if that's a word. It's not rotating with the curve of the sphere, only staying vertical. Even after rotating the player using the editor during play mode, it just snaps back upright. I've used debug raycasts for the different vectors and gravity is pointing at the center of the sphere as it should but the player vector is locked upright. Any help is appreciated.
public class Gravity : MonoBehaviour
{
public Rigidbody[] rigidBodies;
public GameObject planet;
private Vector3 gravityVector;
private Vector3 rigidBodyVector;
public float gravityStrength = 1f;
public float rotationSpeed = 10f;
void FixedUpdate()
{
foreach (Rigidbody rb in rigidBodies)
{
gravityVector = (rb.transform.position - planet.transform.position).normalized;
rigidBodyVector = rb.transform.up;
Debug.DrawRay(rb.transform.position, gravityVector, Color.green);
Debug.DrawRay(rb.transform.position, rigidBodyVector, Color.blue);
rb.AddForce(gravityVector * -gravityStrength);
Quaternion currentRotation = transform.rotation;
Quaternion targetRotation = rb.rotation * Quaternion.FromToRotation(rigidBodyVector, gravityVector);
rb.transform.rotation = Quaternion.RotateTowards(currentRotation, targetRotation, rotationSpeed * Time.fixedDeltaTime);
}
}
}
{
float moveX = Input.GetAxisRaw("Horizontal"); //A / D movement or left / right
float moveZ = Input.GetAxisRaw("Vertical"); // W / S movement or Up / Down
Vector3 move = new Vector3(moveX, 0f, moveZ).normalized * moveSpeed;
//move the player
Vector3 velocity = new Vector3(move.x, rb.linearVelocity.y, move.z);
rb.linearVelocity = velocity;
}
}
How about having a rectangle in the sphere that faces the player and having the players rotation be the rectangles rotation
I mean that kinda defeats the purpose because if I can get a rectangle to face my player then I can get my player to face the sphere
you get it to work?
im making a flying script instead
why are interfaces stored in the transform of a GameObject?
what do you mean by that?
for example when you get a class from a gameObject you do gameObject.GetComponent<MyClass>(); but for interfaces you do gameObject.transform.GetComponent<IMyInterface>();
interfaces are not "stored" anywhere. and using GetComponent to find a component with a specific interface works exactly the same as finding a specific component class
(it's not stored period as you mentioned but in the context of how the question is phrased it is "stored" on the component that implements it)
oh so it's just gameObject.GetComponent<IMyInterface>();?
oh yeah the transform getcomponent just is a quality of life pointer to that iirc
since the transform <-> gameobject relationship is mandatory there's a couple functions that are provided in both
GameObject and Component both have a GetComponent method that works pretty much exactly the same. which is why you don't ever need to specifically access an object's gameObject or transform property to call GetComponent, you can call GetComponent directly on that object (assuming the object in question is a GameObject or Component)
Thanks for the help (kinda just excited with how easy interfaces make things happen)
oh yeah interfaces can be really nice
since you can try and get just that seperate chunk of functionality without caring about whatever else is there
regret skimming over it last time, would've made things so much easier
just makes using them now more rewarding 😄
they can be easy to over-use in some cases though but just takes abit of practice to figure out when and when not to use em
interfaces with constrained generics can get psycho fast lol
how do you even read that? I have enough problems with nested code lol
i poke at it until the red goes away
absolute nightmare fuel
I have no idea where else to ask this, but for some reason the origin point for my player is wayyyy off in the distance from where its supposed to be due to the UI being parented under the player, issue is that I need the origin point to be proper since im trying to get the camera to look at something
so is there a way I can fix this? I'm trying to use Quaternion.LookRotation since it allows me to use Lerping
make sure your tool handle is set to Pivot not Center so it shows on the actual origin point of the object selected and doesn't approximate a center based on the object and its children
Ah that fixed it very quickly, thanks
well in the editor I mean
there is definitely an issue with my code, but im not quite sure what 🤔
well for starters you are lerping incorrectly
https://unity.huh.how/lerp/wrong-lerp
see this to understand how lerp is supposed to work: https://unity.huh.how/lerp/overview
you are also using LookRotation almost entirely incorrectly
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Quaternion.LookRotation.html
it expects a direction as the first parameter not a position, and you are passing Vector3.forward as the up direction
Ohhhhhhhhhhhh, I thought it worked as a way of retrieving a rotational value, so i was using it in substitution to Transform.LookAt
since I needed to smooth the camera's rotation rather than having it immediately snap
no, if you just want the target's forward direction then use target.transform.forward.
otherwise direction is (endPosition - startPosition)
Thanks! that fixed it
Question. I want to use other models since mixamo isn’t letting me install non in place models I need.
Where can I get something similar that will work just as well?
this is a code channel
hey, for make a cast for detect the floor, wich shape is best in 2d, a square or a circle?
i forgot, thanks
can someone help me with this strange bug?
Pause the game whenit happens and select one of those bricks. Where is located in your hierarchy, is it a child of something like the player/camera?
yeah, most of the bricks are linked to the player, so how to ffix?
Don't put them as a child of the player? I mean, that would be the obvious answer here.
You clearly succeeded in doing that with half your bricks already.
Anyone please ☝️
I fixed t he error, right now the only issue left is those surrounding 0 tiles that don't reveal themselves 😬
it was accident
So select the bricks, drag them out of your player in the hierarchy.
ok
ok so guys i'm making a super simple platformer to learn unity because i haven't really used it before
and i'm trying to add a script for player movement and i have absolutely no idea what to do
i assume i need to learn some unity code things?
Well, yes, Unity isn't going to do it for you.
You can start with the !learn tutorials.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
thank you
I'm making these rabbits move by themselves with simple ai, but their idle animations dive into this, then dive back up to normal when they run. Disabling root motion stopped them from diving down, but it altered their movement and made them slow
i will also add they float in game mode but don't in scene mode
This is a code channel
If you think the issue is related to !code, please share it
📃 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.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class AI_Movement : MonoBehaviour
{
Animator animator;
public float moveSpeed = 0.2f;
Vector3 stopPosition;
float walkTime;
public float walkCounter;
float waitTime;
public float waitCounter;
int WalkDirection;
public bool isWalking;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
//So that all the prefabs don't move/stop at the same time
walkTime = Random.Range(3, 6);
waitTime = Random.Range(5, 7);
waitCounter = waitTime;
walkCounter = walkTime;
ChooseDirection();
}
// Update is called once per frame
void Update()
{
if (isWalking)
{
animator.SetBool("isRunning", true);
walkCounter -= Time.deltaTime;
switch (WalkDirection)
{
case 0:
transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
break;
case 1:
transform.localRotation = Quaternion.Euler(0f, 90, 0f);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
break;
case 2:
transform.localRotation = Quaternion.Euler(0f, -90, 0f);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
break;
case 3:
transform.localRotation = Quaternion.Euler(0f, 180, 0f);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
break;
}
if (walkCounter <= 0)
{
stopPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z);
isWalking = false;
//stop movement
transform.position = stopPosition;
animator.SetBool("isRunning", false);
//reset the waitCounter
waitCounter = waitTime;
}
}
else
{
waitCounter -= Time.deltaTime;
if (waitCounter <= 0)
{
ChooseDirection();
}
}
}
public void ChooseDirection()
{
WalkDirection = Random.Range(0, 4);
isWalking = true;
walkCounter = walkTime;
}
}```
i dont know if it's my code or something else, i'm asking in here just in case but if it's not code related i'll ask in another channel too
i fixed it by freezing x and y rotation
I've been stuck on this problem for days so any help would be nice. I'm trying to get all rigidbodies in the array to stand upright relative to the curve of the sphere (planet) and rotate to be perpendicular to the sphere no matter their position on the sphere. I've read all kinds of docs and tutorials and I feel like this should work but it permanantly locks the rigidbody (player) to global vertical and it doesn't even let me rotate the player on its Y axis (basically making so I can't turn side to side). Any ideas what's wrong?
public class Gravity : MonoBehaviour
{
public Rigidbody[] rigidBodies;
public GameObject planet;
private Vector3 gravityVector;
private Vector3 rigidBodyVector;
public float gravityStrength = 1f;
public float rotationSpeed = 10f;
void FixedUpdate()
{
foreach (Rigidbody rb in rigidBodies)
{
gravityVector = (rb.transform.position - planet.transform.position).normalized;
rigidBodyVector = rb.transform.up;
Debug.DrawRay(rb.transform.position, gravityVector, Color.green);
Debug.DrawRay(rb.transform.position, rigidBodyVector, Color.blue);
rb.AddForce(gravityVector * -gravityStrength);
Quaternion currentRotation = transform.rotation;
Quaternion targetRotation = rb.rotation * Quaternion.FromToRotation(rigidBodyVector, gravityVector);
rb.transform.rotation = Quaternion.RotateTowards(currentRotation, targetRotation, rotationSpeed * Time.fixedDeltaTime);
}
}
}
this is the gravity/rotation script that's on the planet object
first off:
Quaternion currentRotation = transform.rotation;```
This is confusing. Why are you using the planet's rotation as the "current" rotation
shouldn't that just be rb.rotation?
oh shoot yes thanks for pointing that out
I missed that
This also looks backwards:
gravityVector = (rb.transform.position - planet.transform.position).normalized;```
As you would expect gravity to point at the center of the planet, not the other way around, although you appear to be adjusting for that in your other code with the -gravityStrength
hmm ok
ok I fixed those things and now the player aligns to the sphere but the player object is still spazzing out and can't be rotated by the movement script
here's the player movement script in case that's helpful https://hastebin.com/share/satokuhezi.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I mean yeah you have two different scripts trying to control the rotation of the object
they are going to conflict
Also this code:
transform.Rotate(transform.rotation.x, mouseX * mouseXSens * Time.deltaTime, transform.rotation.z);```
is very very wrong
oh?
This is what you want:
transform.Rotate(0, mouseX * mouseXSens0, 0);```
hmm ok
transform.rotation is a quaternion, you don't want to access individual members
- Tiem.deltaTime should not be used with mouse input
- transform.Rotate is relative, you would not put the current rotation in there
- .rotation is a quaternion yeah
Guys do you think Chat GPT is right about this one? My concern is, linear velocity should be towards Y axis. I'm so beginner at game development and coding so maybe I horribly missed something
Here's the script im using:
using UnityEngine
public class PlayerMovement : MonoBehavoir
{
[SerializeField] private float speed;
[SerializeField] private float jumpHeight;
[SerializeField] private float dashSpeed;
private Rigidbody2D body;
private void Awake()
{
body = GetComponent<Rigidbody2D>();
Unity Messag sage 10 references
private void Update()
Float horizontalInput Input.GetAxis("Horizontal");
body. LinearVelocity = new Vector2(horizontalInput speed, body. LinearVelocity.y);
// making the player flip when moving Lef-Right
if (horizontalInput > 0.01F)
transform. localScale = new Vector3(6.5f, 1.25f, 0.5f);
else if (horizontalInput < -0.014)
transform.localScale = new Vector3(-0.5f, 1.25f, 0.5f);
// Jumping Input
if (Input.GetKey(KeyCode. Space))
body. LinearVelocity = new Vector2(body. LinearVelocity.y, jumpHeight);
// Crouching Input
if (Input.GetKey(KeyCode.S))
else
transform. localScale = new Vector3(0.5f, 0.5f, 0.5f);
transform.localScale new Vector3(0.5f, 1.25f, 0.5f);
if (Input.GetKey(KeyCode.5))
else
GameObject.Find("Player").GetComponent<Renderer>().material.color = new Color(1, 0.64765a8f, 0);
GameObject.Find("Player").GetComponent<Renderer>().material.color = new Color(8.88856554, 8.8962266, 0);
// Dashing Input
if (Input.GetKey(KeyCode. LeftShift)) body. LinearVelocity= new Vector2(bedy. LinearVelocity.x, dashSpeed);```
there were many things wrong with that
Chat GPT is right
yeah just don't put those 2 words in the same sentence
Yes ChatGPT is correct
in this case
you can also just do body.velocityY = jumpHeight;
chatgpt is not fully correct
although jumpHeight is an innacurate name for what that variable is doing
I cant open discord on pc now
Long story
linearVelocity is not from visual scripting, it is the new name for velocity
discord has a web version.
oh yeah I didn't notice that part
there's no way it compiles
I know about the "linearVelocity" part
incorrect syntax, misspelt props, incorrect casing, invalid identifiers
How?
setting y velocity to 5 doesn't mean you will reach a height of 5
It's not a force
it's the velocity you are setting
it means you will start moving upwards at 5 meters per second. You will then follow a parabolic curve eventually landing back on the ground.
it's more of an impulse that doesn't care about mass
the height you reach will not be 5 meters
Note:
The result of applying a force is to change the velocity of an object
you are doing the same thing a force does, but skipping actually using a force
surely it's possible to get this game idea to work though right?
of course
everything is possible
I just don't know where to start
Dude i just looked this word up and i found out it means "speed" or something like that
Im not native english speaker btw
velocity is a speed with a direction
Actually there're so much problems with this scripts but let's just focus on jumping for now
a starting velocity of 5 with a gravity of 10 will reach a height of 1.25
you can't. you have to fix the script before you can do anything
What i meant with problems I meant gameplay problems like the script itself has no errors
did you retype the script
ah well that makes sense since you said you didn't have discord on pc
yeah don't do that, ever
Any typo in the script is actually google lens fault not mine
it is your fault by using google lens lmao
you created 21 errors by doing that
just copy and paste the script
don't retype code or errors when sharing them, period
Ye I will absolutely my ethernet issue is solved
Anyways there's something I wanna understand
1-"linearVelocity.y" needs to be changed to "... .x" cool but shouldnt it be the Y axis? Like you're jumping vertically through the Y axis
you want to change the y axis, you want to preserve the x axis
the first part of the vector is the x velocity
you are creating a number here, which will be the new velocity of the object:
(x, y)
what you want is:
(current x velocity, new jumpy y velocity)
what you had before was:
(current y velocity, new jumpy y velocity)
Which makes no sense and now you're making the object move sideways at the speed it was moving up/down at.
Alright i got it now
Gonna test it then im gonna go back here to ask about the other issues
I need someone patient
take a screen recording, not a recording of a screen
i don´t know what is more annoying, the recording of the screen with a mobile phone or that the screen is upside down
use mp4 so it embeds on discord
presumably because you're using GetKey so you set the vertical velocity every frame space is held down
use GetKeyDown to trigger only on the frame it's pressed
Alriiiight
Now i have problem with crouching
When i press S the player gets slightly above the ground then drops down
Here's the script
!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.
public class EnterCommand : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI commandField;
private Dictionary<string, Action> _commands;
private void Start()
{
_commands = new Dictionary<string, Action>()
{
{ "test", Test }
};
}
public void CommandEntered()
{
String command = commandField.text.Trim().ToLower();
if (_commands.ContainsKey(command))
{
_commands[command].Invoke();
}
else
{
Debug.Log($"There`s no command named: {command}");
}
}
private void Test()
{
Debug.Log("test");
}
}
can someone tell me why its displaying that there is no command names test
is commandField perhaps part of a TMP InputField? if so this might be the u200b character causing issues
yes
ohhh
that would make sense
ITS WORKING
UR THE BEST
THX A LOT
guys i need help with the canvas gameobject
how do i get rid of these white lines
ok, what's the issue
thats at the very bottom left corner of ur screen
ull only see the edge of that number
in the scene view or the gameview?
both
thats ur screen, u dont want to get rid of it
i usually Hide the canvas components
how
the line is also in the game view?
yes
any suspicion at all what it could be from?
ya thats the canvas
note that gizmos like the canvas bounds are only ever shown in the editor. it should also not even be possible to see that in the game view considering it would be bordering the screen
can u even hide that? i never knew u could
that small rectangle is your camera. the big one is the canvas because it is a screen space overlay canvas
same here
okay so how do i get rid of those two lines or atleast how do i hide them
you don't need to