#💻┃code-beginner
1 messages · Page 400 of 1
Like, they are the base components for unity; you can download extra components from the store but they ate made by other guys
Yeah, they have like keywords, special words reserved for some premade methods and variables I suppose
this is 2 different lines right
It was weird to me that's all
They're not "special" or "reserved". There is a line of code in Unity that says "Loop over every game object, then every component on it. If it has a function named Update that returns void and has no parameters, call it"
It's just a normal function
You can freely call someBehaviour.Update() just like any other function
Reserved in the sense that I can't make a custom functions named "Update" because unity already has a meaning for that word
I mean, you certainly can
Especially if you make it an overload
You absolutely can. In fact, you always do. It's just that Unity will call that function every frame
You likely do not WANT to though, if you expect it to act differently
are the blanks all ToString?
That's the thing, it has special privileges then
Every Update is a custom function for that script. It's not calling anything. It gets called
If I wrote BizarroUpdate it wouldn't work the same
It's not special privileges. It's just that Unity calls it
That is what I meant by using reflection
no because its a different function not matching signature.
It checks the actual name of the method
Correct. But if you made a different script that scanned for functions named BizarroUpdate and ran them, you could do the same thing
It's nothing "special" that Unity does. It's a thing that anyone could do
But what's what I'm saying, nevermind
my whole game started rotating lol
But it does by default
It's an inherited member which you're overriding. It already has a defined a purpose, but in no different manner than how inheritance works in other classes
I eat my words - it's not inherited 😅
Like I don't have to setup anything for it to detect "update"
okay ill put it in an update field
Correct 🤷♂️
That is what an API is
Right, Unity has some messages that it will call. I sent you a link to every message function Unity uses and when it calls them
its just a Method from the Parent class
Yeah yeah I get it
but they're completely ordinary functions, that are called via reflection by a script that is run by Unity
i think i messed up one second
It's logic already made by monoBehavior
there is no logic in it
i filled out the blanks and it still didnt work
This is a common pattern that'll be found with many frameworks and libraries.
Or, in the case of OnCollisionEnter, rigidbody and collider
it just calls the C++ backend
int score = ScoreManager.instance.score.ToString();
displayText.text = Score.ToString();
There's no "ur-Update" function that everything's "inheriting" from. It's not defined anywhere. It's simply checking the name, and executing the function, whatever it does
i suppose I could in theory do a bizarroMonobehaviour script, copypaste the code and would also work
When si inherit from it
very close actually
this errors in the IDE
i also just made the score lowercase bcs thats what u suggested
ScoreManager.instance.score.ToString() means "ScoreManager's instance's score's String Value". int score = means "Create a variable that holds an integer, and set its value to"
Put together:
"Create a variable that holds an integer, and set its value to ScoreManager's instance's score's String Value"
Does it make sens to store a string value in a variable that can hold an integer?
https://gdl.space/hunejeduti.cpp this is my code as you can see its a pivot gun i literally just want the gun to move up around when i shoot it
but unfortunately when i try it doesnt work
okay so I combine int score = ScoreManager.instance.score.ToString()
i thought it was 2 lines
either works but pretty close
That's literally the line I just broke down for you
you need the scoretext to update every frame ?
its more for convenience purposes, this wouldnt fly inother codebases
let them cook
save us sanity
Let's say with boxcollider2d
no it goes in awake
well its good for them to at least somewhat know what Update is doing
Wdym, so it's just monoBehavior acting like a shortcut for stuff
okay it doesng go in awake
Awake runs once when object is created, Update runs every frame
make your decision
yea ig, at the endo f the day unity is still a c++ codebase and the tools are just a C# interface to their binaries
it works in awake, just only once. it wont update again
It's not. It's just that the code that scans for the function will scan any objects of type MonoBehaviour. There's no definition inside of MonoBehaviour that says "This thing has an Update function". There's code that says "If this thing is a MonoBehaviour, and it has a function called Update, call that function"
What do you have and what are the errors
if you have errors thats why it doesn't work
Pffff I'm not getting it, let me make up my mind...
we need to see what u wrote
Okay, so, first error: What's scoreManager
its my other script
and a class i made
that houses the public static ScoreManager instance
yes but that script doesn't know what it is
but i already have a public static score manager instance in my scoreManager script
so why do you have scoreManager still in there in UI script if you already have ScoreManager.instnace
Okay. Show it
did you save first of all
yes
why is it complaining scoreManagement.cs but your class is called ScoreManager
managment is the name of the file
you should keep your names the same as class with filename
ok
You said you are not a developer, right? How much handson experience do you have with coding? I feel like all of this would be very confusing in abstract, but make much more sense when actually implementing it.
I am simply not sure how to explain it in a way it makes sense. Other than repeating that these are magic methods and used via reflection.
Sorry
No that's ScoreManager I asked what scoreManager was
I know how to programm in csharp
i mean im junior but yeah
brb let me write a long message about what confuses me
public class ScoreManager
{
public static ScoreManager instance;
public int score;
}
how can i just add to the Z rotation value
you can add a Vector3 with the x and y values set to 0
thats not the scoreManager its complaining about
you dont need to set scoreManager's score. in fact scoreManager doesnt exist. only ScoreManager.instance
What is scoreManager
okay so nwo there are two scores
you can still recover if unity isnt opened again
You can recover it if you don't reopen unity right away
ok so now what is score
get rid of start completely
score doesnt exist because you havent defined it yet
what happen to text
you dont need score either
stop showing ScoreManager
ykw gimme a sec
we dont care about ScoreManager
oh lord
why is this defined in here..
public class ScoreManager
{
public static ScoreManager instance;
public int score;
}```
okay ill remove it and put it in the other script
who told you to put it
not a monobehaviour either
put it in seperate scripts
can you please stop and think for a moment..
dont touch anything on the ScoreManager everything was fine on how you had it
is it spoonfeeding if i make a whole video tutorial on this right now
No
You need ONLY 2 scripts. you got that part or not
OKAY
no "new script"
ok
if you're struggling with simple following instructions might wanna give another hobby a try
i put public class ScoreManager
{
public static ScoreManager instance;
public int score;
} in the displayScore script
Okay, I am going to say some pretty harsh things but you are going to need to hear it.
If you are incapable of basic logical reasoning, you will never be able to code anything at all. You need to actually think through what you are doing. These lines all have meaning. They say things. You need to be able to hold multiple statements and draw conclusions from them. This is not something we can teach. This is not something anyone can really teach. If you are incapable of logical reasoning, this is not the hobby you should be pursuing. You will not create any programs by randomly bashing words into various places until they stop yelling at you
dude what the hell
im sorry
im just very tired
im trying really hard
im really sorry
My dad used to say "Dont be sorry just do it correctly"
I don't intend to be mean, I just want to warn you
This seems like a failure to connect cause and effect
which is going to make this very very hard for you
this is just very rude
okay ykw besides the point
just being honest
in diisplay score I put
public class ScoreManager
{
public static ScoreManager instance;
public int score;
}
I'm just going to provide a solution as this is likely a guessing game that isn't really productive for the server channel cs private void Update() { scoreText.text = ScoreManager.instance.score.ToString(); }Which will likely not work properly if they do not have an appropriate Singleton object instance in the scene.
you can try hard but without the foundational knowledge you wont be able to get far. learn object oriented programming first and develop stuff with it. learn what static variables are, what types in c# are, and learn unity's quirks. what MonoBehaviour is, what Start, Awake, Update and LateUpdate do
this isn't a coding this at this point, you arent even following our instructions correctly
earlier you told me to remove it. and now I only need 2 scripts?
you're just guessing and writing stuff that dont' need to be written in code
I think the steps of operation may help? so Physx or Box2d checks the position of every collider every physics update.
If some overlap, it will tell unity.
Unity will iterate all monobehaviours with those colliders and check if conditions are right for the physics message to be sent. Then it sends the message to the methods providing data for you to use in your code. Because of course the only place you COULD use it is in your own code (ie, a MonoBehaviour)
you are very confusing
because of the way MonoBehaviour is, ScoreManager and displayScore must be in different files.
No, you just don't seem to be able to synthesize multiple statements into one conclusion
they are
and write something completely different than what was said or shown
"I need ScoreManager to exist" and "ScoreManager should not be in the same file as DisplayScore" should lead to the conclusion "ScoreManager should be in a different script" without having to be directly told that
and ScoreManager isnt a monobehaviour either, based on what you showed us. Because ScoreManager is not a monobehaviour, you couldnt set public static ScoreManager instance to the ScoreManager because there's no start function.
Because of that, theres a null reference. And thus your code didnt work out
That's not factoring in you having difficulty converting an int to a string.
https://docs.unity3d.com/ScriptReference/Collider2D.html
for example, here, this is a component, a collider. It has properties, and it has functions, something like
void Start()
{
mycollider = GetComponent<Collider2D>();
mycollider.enabled = false;
mycollider.enabled = true;
mycollider.IsTouching(mycollider);
}```
here it has functions exclusive to that component, like "Istouching" and it has properties/functions that are common through all components, like "enabled" (all ccomponents can be enabled/disabled)
My question is, why doesnt it have something like```mycollider.OnCollisionEnter();``` because if I put this I get an error.
I suppose many collider components have a common parent, component, called "collider" it seems, for what I'm seeing here on the docs. But my question remains, why cant I get the "check if it has collided" function directly from the collision component?
@summer stump
@polar acorn
where are you getting that from ?
dunno If I explained it right
Overall, you should understand that unity requires knowledge of object oriented programming, and the ability to search online for what you need to do
Because Collider2D does not have a function named OnCollisionEnter
That is not a member of that class
You would be CALLING a method doing that.
You want it to be called BY the physics engine though
it is a message function that is called by collisions
On collision enter isn't a public member
its the final thing
WE DID
no, you just told me to fill in blanks and after I did i was very close apparently
They wrote the whole damn class for you
"git good" would be too harsh. its more of "learn the foundations". you had difficulty converting an int to a string which is one of the first things taught in c#
thats whats even more frustrating we didnt even hide behind the bush or hint at it. We literally give you lines of code to copy
and you still copied wrong
oh i didnt see that
Well at least with Collider it seems to be a member?
https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
yeah I suppose it doesnt work because it doesnt have that function, but why doesnt it have it?
You were literally given the exact line of code to use multiple times and copied it wrong
Because what would that function even do
isnt that what we want?
this is in scoreManagment
No, definitely not
check if the collider has collided right?
What is scoreText
so whats what im not getting
You want to be informed that it happened, not check it yourself
The physics engine is checking it
That sounds like IsTouching which does exist
i fixed the errors
like, start, update, on collision enter... all of those are functions right?
yes
functions you make
Yes, and YOU are not calling them. Unity does
yeah I suppose
okay it works
they are called by unity. Not made by unity
They're more like event handlers
the way messages work is that youre calling a function by the function name. it quite literally looks for all objects with the function named "OnCollisionEnter`. you're not overriding a function. youre just hoping the physics engine finds your gameobject with the OnCollisionEnter function,
thus you need to define the OnCollisionEnter in your gameobject first.

this example doesnt define OnCollisionEnter yet so thts why it doesnt work
That would certainly be nice. And they are LIKE it. But it is reflection
yeah I get that unity is searching for a function of that name
thats what I dont get
let me think how to say it
the physics engine looks through all monobehaviours, checks if it has OnCollisionEnter, then acts upon it
OnCollisionEnter is a way of saying "Hey, physics engine, can you let me know when someone crashes into me? Thanks"
It wouldn't make sense for it to be a function you call on a collider
Defining OnCollisionEnter is like that!
Because you don't know when a collision happens
Not calling it. Just to be clear
Unity does
Unity needs to tell you when a collision happens. So you define a method that runs when Unity says "Hey, you hit this thing"
yeah I get that unity is checking the monobehaviour scripts and looking for those keywords and act uppon it. What I dont get is why cant oncollisionenter be exclusively inside the collision components
and not something outside of it
but you do, when the gameobject has another gameobject in an area right?
you only know about it because unity told you about it
or rather, the physics engine
Okay, and how would you know when that happens without asking the physics engine about it?
so it all falls down to the physics engine?
What is "in an area"?
You do not know that unless doing manual physics checks, or letting the physics engine do it for you
yes, physics is completely seperated from everything else
Yes
It is a completely separate engine
ok I think im starting to get it now
You absolutely can do the math yourself in update and keep track of what is intersecting with what. In which case, you don't need colliders at all
Honestly this doc confuses me. Even the examples are demonstrating MonoBehaviour.OnCollisionEnter instead of Collider.OnCollisionEnter
Collisions is physics
But, since you're using colliders, you probably want to know when that collider has collided
Yeah, I am super confused by it too
There is one for Rigidbody too
I dont think that page should exist lol
ok so because collision is physics and are complicated operations, is not enough to have a check inside a component, you need unity, the engine, to act and thats why iOnCollisionEnter has to be separated
the library unity uses is called PhysX. for physics engines the overall procedure is
- add a bunch of physics objects to a scene(cube, sphere, mesh)
- keep calling Physics.Simulate(delta) to update the positions of your physics objects
- keep changing the position of your GameObjects to the position of your physics objects
imagine how it confuses me
Just ignore it 😄
the physics is "sweeping through the area thats why it has to know about all objects
all the ones with colliders become part of that separate "physics scene"
Yes. That's the entry point to how you'd respond to physics. Imagine a mailman who runs letters between the physics engine and your script. You making a function OnCollisionEnter is kind of like setting up a mailbox for letters to be delivered to
Just because Unity did not choose to implement the API in that fashion. They totally could have exposed a public event on Collider that you could subscribe your own method to:
collider.OnCollide += MyCollisionHandler;
...but they didn't. They chose this reflection-based approach instead.
so basically when you do "oncollisionenter"iS the unity phisics engine what is managing all of that
I think when Unity started, C# didn't have event yet
and it can't be something outside of it, like a component
Yes, the physics engine is the one that calls those functions
at the end of the day you need a Collider for OnCollisionEnter to work. internally, defining OnCollisionEnter could just be a shortform of adding something to Collider.OnCollisionEnter
Unity uses PhysX to leverage the physics then it gives us the easy functions
we wont know what happens inside unity core
Ahhh that's really interesting. I hadn't considered that. The reflection always seemed strange to me, though I do appreciate it's convenience
There's a lot of technical baggage from Unity 1, which mostly used javascript, and later added C# support
wasn't it its own language and not real js ?
yea it was js-like
I dont understand then why something like box colliders or rigidbodys are optional components then if the operations are made by the physics, why arent the same as the "transform" like all components have?
Yeah, unityscript. But it used js syntax
You REALLY do not want all objects to be simulated by the physics engine
not everything needs a collider or rigidbody though
Because not everything needs to be physical
because for example sometimes I have components that I dont need them to be in a specific position in the map, something like a background song
But Collider does not have a member method called OnCollisionEnter. It's just wrong
why do they all have a transform component that you cant remove then?
An object might represent, for example, TurnManager, an object that knows whose turn it is and who's next and so on. This object doesn't really "exist" in a physical sense. It would not need a collider
what we code in C# versus what goes on in unity core in c++ is different
gameobjects cannot exist without transform
and vice versa
Because that is simply a position
maybe if you work in a corp that has unity source code youll get to see it all
How can a gameobject not have a position (and scale and rotation)
It is not physics
Because the Transform is more than just "where an object is", it also defines an object's parent, and creates a coordinate space for any of its own children
yeah but a component could not have a position and be "everywhere" sort to speak, like a background song
An object could define a coordinate space but not physically exist, such as the canvas
its in a physical world, so it needs to have position. Unity is Gameobject / component based
cant gameobjects exist without transforms in ECS?
Not really
I suppose its the basis of how unity made teh components
you can just avoid using it
Even if it was a thing on the c++ side, why would the C# scripting docs have that?
Canvas objects are massive so that their coordinate space is in pixels instead of meters, but they cannot have physics on them
for me I have a Manager gameobject that has every manager script
yeah but... feels off
unity things
a lot of gameobjects do it that way too
So, a canvas does have a scale and position, because it's important where other objects are in relation to it, but it's not a physical object that can collide or be moved by physics
its better than changing your background music in the project settings
bu thats my point, canvas, music, things that dont have a specific place in map, at least like other objects
I will stick to this
I just explained how a canvas does need to have a specific place and scale, because it's something other objects define their positions relative to
they are still contained on physical objects in the engine world (the components)
its easier to extend monobehaviour to do your things rather than add directly to engine code
But they DO have specific positions
you do not want to spend 12 hours compiling unity
so basically collisions, physics and stuff like that are handled by unity directly and thats why it is on monobehaviour instead of inside a component
The common patterns are:
- You iterate through every object, validate them and do what you've defined them to do
- You'd just define and subscribe them (the magic portion)
Unity (and many other frameworks and libraries) will likely opt for the second behavior as the first is less flexible (subscribe/unsubscribe), puts the burden on the person implementing/defining the function (manage-less) and requires the library to expose members. The purpose of events is to have users be able to subscribe/unsubscribe to stuff without knowing or being able to modify the stuff. The user shouldn't need to know or modify whatever's calling their code - decouples implementation.
monobehaviour is a component but better
yeah but they dont really need them as a concept I mean
They do. Because the camera and listener can move.
If the canvas does not move along with it, it will go out of view
more like a type of Component
I have this scene which works fine in the editor but when building I get this parsing error , I went to look at the file in code and it looks just fine at those lines
whenever i put oop in layman terms I address child objects as "but better"
I meant in a broad sense, like if you wanted a background music for everything, independently
monobehaviour comes from behaviour coming from component
Then it would have to be positioned at a static offset from the listener
differences between those? or is it not important?
not important just use monobehaviour
major differences
They probably implement stuff or give features you use in the derived classes that you aren't aware of.
come on @eager spindle @rich adder you cant just put those two comments together
Rigidbody is a Component but not a behavior iirc
theres big differences, but generally most people use MonoBehaviour
hence why it cannot be disabled
Generally speaking, Behaviour is for built-in components and MonoBehaviour is for custom components
will not think about it at the moment then
yea this has proved to be inconvenient to me at times
some days I just want to disable rigidbody
but no i have to set iskinematic
just I should know that everything comes from monobehaviour
like oncollisionenter, start, update
and that unity determines which one goes first
everything you want to make comes from monobehaviour, yes
you can turn simulation off in Rigidbody2D thats about it
I wonder why PhysX doesnt have that
How would this be applicable for Scriptable Objects then 🥹
another thing, would it be possible that components didnt have transform as their base? like if you wanted an ephemeral component like music
Turn off gravity and disable rb.detectCollisions should do it 🤔
And maybe make it kinematic
like I suppose itsa just how unity made things, im just asking if its possible
oh true. I usually make it kinematic, jus wondering why 2D one has a toggle and 3D we don't have a fancy toggle
dont confuse me please 😦
ScriptableObject inherits directly from UnityEngine.CoreModule.Object(not to be confused with System.Object).
MonoBehaviour inherits from Behaviour inherits from Component inherits from UnityEngine.CoreModule.Object
thats a tongue twister
They don't.. they just all have a property to access the Transform component.
Not really, no
all monobehaviour wants a gameobject. and all gameobject wants a transform. so no
Static classes on crank
Aye, so the dependency isn't with MB - my point.
yuh
oh yeah I suppose something like update is static
like how does unity detect which update goes first
from one gameobject or another
script execution order, otherwise theres no reliable way to tell
no no . Scriptable Objecect I meant are similar to how static class work but with unity benefits
you can go to Project Settings to change that
thats what I wanted to know thanks
you read my mind
You don't worry about that and likely will not be able to do anything about that without changing the priority.
yeah if you're messing with executions order your design is probably flawed
ok so
my savesystem needs to go first
but other than that nothing else
collider is an abstract class then?
yep
I just use Dependency injection for everything 🤷♂️ never need to worry about order of exec anymore
Why do you suggest that?
I don't believe so, no
how
because a collider doesnt have a shape, its children do though
and I suppose these were made as default by unity devs
so these are tied to the physics engine in the end
transform.eulerAngles += new Vector3(0,0, angle)
🥣
Abstract is a specific keyword
these are Unity's representation of the Physx version
well you cant do anything on a collider with no shape
What I see is that Collider is where On Collision Enter is defined.
Like if you decide to define an enum in your class.
abstract means that you cant instantiate that directly right? like "vehicle", you cant instantiate, you can have a car boat, bus, but not a "vehicle" alone
you can GetComponent<Collider> but unity will tell you its outdated
Be aware that you can still make classes that don't inherit from MonoBehaviour or anything. cs public class MyClass { }
POCO or "Plain old C# object"
You just can't attach them directly as components, but you can have a reference to them
do i add recoil and angle together?
yeah I suppose a collider must have a shape
you cant make a new collider since the constructor is probably protected, youll need to talk to the phys engine instead. which is what unity does when you add a collider component
your recoil is the angle
yeah I can make structs and such
what does it mean to add the recoil and angle together
is just that they wont have the unity things
like this "Gun.transform.eulerAngles += new Vector3(0, 0, Recoil);"?
yuh
well it unfortunately doesnt work
so here messages arent quite right functions
they are like "checkers"
did you mean to rotate the camera instead?
oh it does
That's true but probably not what he's questioning about as the image shown is of the On Collision Enter method #💻┃code-beginner message
Which implies that there's some misunderstanding about OOP (where a member lives etc)
theres a problem
its because the gun will always point to the mouse
i see it rotating for a millisecond
and I dont have to worry how the calling logic works because thats what unity is for, to manage that right?
are these all the messages unity has or are there some extra ones outside of monobehaviour?
Basically. You cannot work with it directly without the instance inheriting from it.
https://docs.unity3d.com/520/Documentation/ScriptReference/Collider.OnCollisionEnter.html
one example I found. even in legacy docs, OnCollisionEnter for Colliders dont have its own page
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
how can i approach this
you want the camera to rotate, so get the camera's transform and do the same
or do you just want the gun to be offset?
offset ig
the cursor will anyways be invisible
- keep track of a Vector3 that's your offset.
- after you rotate your gun in the direction of your player, rotate it again based on the offset
wait what so there is this link https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
and this link https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html
I suppose the collider one is residual
so maybe "OffSet = Gun.transform.eulerAngles + new Vector3(0, 0, Recoil);"
Yes, please just pretend that the first one does not exist
It's a common pattern and you'll only see more as you grow as a developer - most of the Unity Network libraries (not limited to this as well) will use said pattern.
i honestly think they might have been different functions at some point, got merged, but for "legacy purposes" they keep seperate docs for it
void FaceMouse()
{
Gun.transform.right = direction + OffSet;
}
its been > 10 years though
You'd just work with the docs
thats what confused me at the begginig because I read the ciollider link first and I was all confused
the function for the gun looking at the mouse
Yeah it doesn't help that the Collider one is the first one that pops up on google
so the "collider" class shouldnt have that function then. thats what I was refering to in the beggining XD like, why didnt they put oncollision into the collider and it seems like they did but they changed it
"unity things"
Make a class variable where you store the recoil.
Every frame after you set the gun's rotation, add this recoil vector to its rotation.
Even if you go all the way back to Unity 5.2 docs, it still demonstrates MonoBehaviour.OnCollisionEnter:
https://docs.unity3d.com/520/Documentation/ScriptReference/Collider.OnCollisionEnter.html
It's a weird decision from whoever documented it
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, 0.05f);
this casts the ray from the player position down but i'm worried if the distance is too small, also how do I use this to check if the player is colliding with the ground
You can use Debug.DrawRay to visualize the ray
I put this in the update?
Best to try Googling a tutorial and getting a working system first.
For the ground part, it's common to use the LayerMask parameter in Raycast where you pass the layers that you want to be checked. So the layers that "ground" objects use
But yeah, plenty of resources online about ground checks
FixedUpdate, unless you are using CharacterController?
yeah that's what i meant
Physics don't necessarily update between Updates, but they always do between FixedUpdates
'between' as in FixedUpdate always runs after a physics update?
maybe not after
but every 0.02 seconds
so updates can happen very frequently or very slowly, but fixedupdates happen every 0.02 seconds
FixedUpdate is called just before the physics update
Fixed Update will be called a certain amount of times regardless of how much time has elapsed. Do note that they aren't called immediately at the specified time but simply promises that they'll be called a bunch of times if there were say.. a ten second delay between the previous and current call to Update.
which is why deltatime is irrelevant in fixedupdate 👍
isn't this just after?
I often use FixedUpdate for AI too, since I don't want it to be dependent on framerate
Fixed Update -> internal physics update
FixedUpdate happens before, which is what I'm saying
Although I very very rarely have to think if it's "after" or "before"
Correct, unless you're just wanting to read the value or scale some value relative to timescale.
I'm currently trying to work out how to make an inventory system. I already have my grid of buttons so that's covered. That was the easy part though.
I'm trying to reason my way through this to figure out what I need to do to make the buttons functional though. Here's what I have so far:
Assign sprites and other info to items
Slots must be accessible in item script - probably with GetComponent right?
When item is obtained set button image to item sprite
Set value in button that indicates slot is filled
If a slot is filled make item fill the next slot instead
This isn't quite as simple as I had hoped for though and I'm concerned that my C#/Unity knowledge isn't going to cut it here. But will this general plan get me somewhere?
make an array with all the items? like a list of all the items in game?
im kind of confused i made a variable called recoil and added recoil
what I had in my inv manager is a List<Item>. Item is a ```class Item {
string name; Sprite icon; string description;
}
Maybe show your whole current script
(If you still have an issue?)
as for slots, you can have a list of slots, either instantiated at runtime(with getcomponent) or you can drag them all manually.
Otherwise pretty solid plan
idk how I feel about dragging in 27 slots
But it would probably be easier for my smooth brain to figure out. Ik I can already do that
Your inventory system should exist completely independent of UI, but maybe describe more of what you're doing. Why do you even have buttons in the first place?
```cs pleaseee
damn
Could probably use a Scriptable Object to define data for the Items where your objects (Items) in the scene would reference - if you're needing to simply store the data somewhere outside of the scene.
I currently know nothing about scriptable objects. Where would I go about learning about them? The docs felt kind of sparse to me.
Just lookup some stuff on 
There should be plenty of discussions or videos about them.
ScriptableObjects are generally used to make your own custom assets.
A lot of the unity settings assets are actually SO's too
you know how when you attach a script to a gameobject you can save data on that gameobject? by using SerializeField or public
imagine that but you make a object dedicated to storing data
They're useful if you need instances that are not deeply associated with game objects and the scene.
Besides being able to transfer data between scenes you can also make workflows for your artists and story writers that don't involve code
So I just make an object and put a bunch of scripts on them with information?
in theory you can make a prefab with your MonoBehaviour script, and change the data of the prefab directly. works the same way as having a ScriptableObject.
Thanks for this, I figured it out
"Transfer data between scenes" is definitely not the use case for SO here.
yea I don't really do that, I see a lot of tutorials quote it though
And those tutorials are dumb
I've seen it used in many ways, even as an "event relay" basically because the people didnt know how to properly setup events. It is simply a data container, you can try to turn it into more but theres usually better options
how do i paste short code snippets without pastebin?
triple backticks
```cs
yourCode.here()
```
Note that those are backticks, not apostraphes
how do i make a simple respawn point and check points system in my 2d sidescrolling platformer i can vc if it would help
it's a fun idea that falls apart the moment you need more than one of something
or when you try to store any state in the ScriptableObject and it happens to get unloaded
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TouchingDirections : MonoBehaviour
{
// Attributes
private CapsuleCollider2D col;
[SerializeField] private LayerMask platformLayerMask;
public bool isGrounded;
public bool touchingLeftWall;
public bool touchingRightWall;
// Methods
private void Awake() {
col = GetComponent<CapsuleCollider2D>();
}
private bool CheckCollision(Vector2 direction, float distance){
RaycastHit2D hit = Physics2D.Raycast(col.bounds.center, direction, distance, platformLayerMask);
Debug.DrawRay(col.bounds.center, direction * distance, hit.collider != null ? Color.green : Color.red);
return hit.collider != null;
}
private void FixedUpdate() {
isGrounded = CheckCollision(Vector2.down, col.bounds.extents.y + 0.01f);
touchingLeftWall = CheckCollision(Vector2.left, col.bounds.extents.x + 0.01f);
touchingRightWall = CheckCollision(Vector2.right, col.bounds.extents.x + 0.01f);
}
}
is this implementation the most efficient way?
Use transform position to those checkpoint's coords. That's how I would do it at least
can you give me an example im pretty new to unity
I am too. Just look up transform.position
and what about for detecting whern my player hits like the spikes or wtever
OnCollisionEnter2D and put a 2D collider on the spikes
Alright. Is there a better way to get components for all of these buttons other than copying and pasting this 27 times? GameObject.Find("Button1").GetComponent<Image>().sprite = newItem1;
Drag them in the inspector
Put them in an array
Image[]
Is there a way to set the dimensions of an object rather than it's scale?
To easily set everything to have the same dimensions
use a tilemap (make sure the PPU matches)
doing it this way is over convoluted
but either way you normally want the PPU to be correct that 1 box = 1 unity unit
also not a code question #💻┃unity-talk or #🖼️┃2d-tools
why not just use ToString?
What type is the date to start with? Many have tostring implementations
i just want date and time so i can store files
DateTime can easily read it back
Is it DateTime, or a string from a filename? Or what?
both. i want to save the timestamp as a string in a json as well as use it to save files with the date and time on them
you can easily just store it as a string with ToString() then remake the object with DateTime class
how can i remake it?
I am asking where the date is coming FROM
Are you just writing it? Or is a DateTime object from some api?
use Parse
oh no it would come from the datetime class i guess
i didnt know how to get the time
awesome, thanks
string dateString = "2024-06-26 14:30";
DateTime parsedDate = DateTime.Parse(dateString);
Debug.Log(parsedDate);```
indeed
although i guess it would be sorted kind of if you were grabbing them in file order?
btw list also has a Sort method which would work
oh awesome
okay, thanks!
im trying to save multiple replays now, until now i've just been reloading and loading the same file which is annoying if i want to look at multiple replays
like multiple files or 1 file
i want to make one new file for each replay. until now i'd only been able to watch the last match
easy enough to make
gotcha. makes sense
hey guys, im back. this time with a smaller issue. Im getting this error: input string is not the correct format. I think its due to the way im doing this invoke.
this wont be as bad
im more rested now lol
whats weird is that its a unity only error and not VScode
im using int.Parse too
Maybe show us the code
So you are passing a string into int.Parse that is not in the correct format, as the error says
is there a ToInt() like there is for ToString()?
int.Parse is pretty much that
What is this script doing anyway? Are you storing the score in a text...?
im sending the score to a script that sends it to a leaderboard
the name the player inputs
tbh i think i'll start this alll
over again, with making the code
because anything i have tried so far hasn't worked, and so far my issue seems to get worse
Well, your scoreText doesn't contain a valid integer that could be converted to from string.
You shouldn't store data in a text object anyway. It should be for displaying only
Well, if you don't know what to do no point starting over
Consider storing it in an actual int
Post code, send picture
hmm, well it is an input box
how do i post the code without sending it all as a very long list?
What is an input box?
I see a TMP_InputField which is an input field
its not on the input box
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Take a snippet. Post relevant part.
Lol
'''cs
Don't grab the score from the scoreText, grab it from an int variable instead
okay
i am so confused
@wooden socket Like I already told you here
And here
lemme change it rn
Read the Larhe code blocks section of the bot message above.
i just pass the value right?
Yes
lemme do that
I will let you do that
scoreText doesnt exist in the current context btw
Speaking of context, it would be helpful to see more than this one class you have written
why are you using the string from the text to get number...instead of just using the score from the ScoreManager instance
This is...the same class you linked earlier
true, lemme pass it
This, raise an event from this mysterious ScoreManager
What exactly are you trying to accomplish?
i just want to pass it
Pass what? To what? From what? Why?
i want to pass the score value to this script. its for a leaderboard
How is this score created in the first place?
scoreManager gets the score from stuff in gameplay
so did you do it?
Alright, good. The score is tracked in ScoreManager. THAT class would be more suited to contain the code in this "LeaderScore" class. Is this a singleplayer game you are trying to create a high score system for?
If so, score manager should handle this from start to finish. When your game reaches an end condition, the score manager should send the high score to whatever container is tracking high scores, be that a file, PlayerPrefs, etc.
On the other side, if you want to then display those high scores later, a Leaderboard class can retrieve that container and read scores from it to display.
Does this make sense to you?
yea, im just stuck at how to pass the value
its public and then like
scoreManager score?
having an absolutely agonizing time where using a dont destroy on load manager im trying to create a sprite on screen and it literally does not show up on screen when i instantiate the object. do i have to instantiate it as a child of the canvas or what? it says its instantiating but then the sprite itself doesnt show up
you access it the same way you have accessed it in the UI text display
looking to that now
nothing changes in c# how you access values in other objects
Actually, the ideal way would be to have an event fire when the score should increase, on whatever player object
i have that alreadyu
ykw lemme send scoreManager
So the score value can be private
do you not remember anything from our earlier conversation?
this entire time, you have assumed im really stupid. I am just learning. please stop being extremely rude, discouraging, and overall unhelpful
Alright presumably you are calling this function directly from somewhere else?
i LITERALLY said Im going to reference that script from earlier now
Method AddPoint()
its nothing to do with stupidity
more to do with attention to what others are telling you to help fix an issue, instead of ignoring it then do your own thing writing something else then complain when its broken
no memes #📖┃code-of-conduct
Oh yeah?
im not purposefully ignoring. I TOLD you i was overtired from working on this game for over 18 hours. You ALSO flat out told me to "pick up a new hobby" that isnt extremely disrespectful??
idk what yer yappin about I helped you multiple times, i said if you refused to learn maybe do another hobby if you just want spoon fed answers
(should i... use another channel?)
also, this type of passing of values IS NOT the same from what I can tell, as its in an invoke
Accesing values is done the same exact way
.
whatever you do do not turn the volume on this, long story essentially but i am literally just invoking a prefab and the sprite not showing up is driving me insane
it already says scoreText.text, but it SHOULD say scoreManager.score
would it be better for me to put this in general? its a weirdly trivial error
yeah i usualy dont at all. just thought it was funny since we helped this person for 3 hours earlier
I don't mind, it's just hypocritical
@wooden socket Did you do any C# beginner courses yet?
true true. just letting them know, i didnt say delete it or anything
Are you...a beginner?
well now the object reference is required for the non static field
because you're not accessing it from the instance?
i mean, no, but the error itself is kinda a novice error, hence here
You need to reference the instance
well im going to college for game design soon. im trying to get a head start by doing projects and taking classes
like, ive never had anything like this happen before so my immediate thought was. i am missing something trivial and im stupid
You did this is with the display text thats what Im saying , its nothing new here. The process is the same
You should really start with the basics. Like learning referencing, static classes, and much more
Well not static classes in this case but singletons
no because score manager is a singleton it doesnt need references
there is a static instance
the dreaded global state
i would strongly recommend following along with a tutorial like roll a ball @wooden socket
before jumping into a project solo with no experience
it has been suggested multiple times
fantastic
you can literally always come back to this when you have some knowledge of fundamentals
please just tell me this ONE small part of how to do this
this is the last error i have
The SpriteRenderer reference you have is currently empty in the inspector, is this intentional? Sorry I am having some trouble gathering what is happening in this video, Discord is kind of glitching it out for me
@rich adder what the hell is wrong with you fr
im just trying to learn and you are being a jerk
you been told how to do it multiple times..
but you're not thats the thing
I AM
remember earlier you said "i got this working now i go learn c#"
i want to learn how to do this so fucking badly man
If you were trying to learn you'd have actually made an effort to solve anything on your own instead of guessing randomly until we get frustrated enough to just write it for you
yet here we are
i told you man, ive been up for so long and im tired. theres no need to say "here we go again" and act like im some kind of fucking clown
its just discouraging and rude
apologies, which spriterenderer are you talking about? Like attached to one object
then stop trying and come back when you're capable of learning anything at all
fuck you man
thats really rude
This is a gigantic waste of everyone's time
IL_ARIA object -> Mon Data component -> Sprite field
If you are, by your own admission, unable to learn anything
why should we waste time trying to teach
ah. Give me a second
i dont know how to do this one specific thing
this one thing relates to what was explained to you earlier..
Or the previous one specific thing. Or the one specific thing before that. Or likely the next ten one specific things
i looked at the display text thing
and from what I can understand
and what you said I need to use a .
do know what the . does ?
but im asking what I put on the left and right ends of it
its the 's of code
I'm geniunly asking and not even trying to be an ass.
oh girl you can not be asking character by character help
ok so then why were you confused about how to access the int
so helpful and kind
score is already an int, why are you trying to parse to int
well, I want to make it a string
also you're not using the static instance
and when I do this
inside the earlier script you dont know how to make it string?
(Not using a static instance is technically correct)
Not with that syntax it's not
lel
no its not
🍿
dude what the fuck
We literally went over how to access the score from your singleton instance last time. You wrote it right then
just do that again
Hey I am all down to help you, but we gotta focus here and stop arguing
Stop swearing at people
then dont post a fucking popcorn emoji
If you're not actively participating in anything productive, please don't comment.
i have been asking for help and multiple times its been you guys just being rude
its very discouraging and unhelpful
Fair enough but I was previously helping this person and I am helping @olive fractal
You have, many times, been told exactly what to do
Make a thread then, and anyone who wants to sit through teaching the basics, can. Everyone else can choose to stay out of it.
You need to stop and learn the basics
im trying to
I always recommend these
https://www.w3schools.com/cs/index.php
And then
https://learn.unity.com/pathways
"I just need this one thing"
and at the same time, you being rude REALLY isnt helpful
yet we spoon fed you for 3 hours until it worked
I have not seen anyone being rude except you
i know you think im stupid and as @rich adder said "pick up another hobby"
I didn't start rude. I became rude after three hours of teaching you how to access a variable
@wooden socket what about this #💻┃code-beginner message
my only confusion is the parenthesis
biting the hand that feeds..
I also recommend this resource from microsoft on C#: https://dotnet.microsoft.com/en-us/learntocode
dude cmon
the error now is different
its about object referenes are required for the non static field
You really, truly need to just take a basics course.
Have you done the w3schools or microsoft courses that have been linked? What about the !learn course?
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
the error wont change if you don't do it properly 🤷♂️
This is not rude. It is all that will help
and at the top, I tried putting public scoreManager score and it didnt work
Well yeah, that won't work without assigning a reference
whats so complicated about copying what you did earlier
Also, score is a very misleading name for ScoreManager. Keep in mind that it is not the score itself. Just be careful
You are trying to declare a class reference without initializing it if that's what you've written
Did you assign this field in the inspector?
score isn't a static field so it needs to be accessed through an instance.
doing that now
the static instance exist
look the dam UI score..the syntax is there.
I DID
why isnt this screenshot working?
So, how do you acces score from there
is that the path ?
if (frameIndex == 1200)
{
string fileName = Application.dataPath + "/ReplayScreenshots/Replay" + DateTime.Now + ".png";
ScreenCapture.CaptureScreenshot(fileName);
_replay.screenshotFileLocation = fileName;
GameManager.Instance.SendNotification(MessageType.Info, "Screenshot taken");
}
this is how i've done it
invalid characters in path
ah
i dont know man
So, read the code you already did and check
it's right in front of you
you can just, like, read it
may have figured it out
changed it and it still doesnt work. is it because i havent created /replayscreenshots/ yet/
thats right you need to create folders before you try to save a file there
worth creating the directory first to see
i see. its just cus the unity recorder creates the folder automatically so i thought this would, too
I have a question about generating a graph for A* pathfinding in a 2D platformer.
My game world will not be represented purely by tiles. So Instead of having a "grid" of nodes and connections where a node is placed above each walkable tile in my scene, could I just generate nodes at the "start" and end of platforms? Like over their corners/vertices or something?
It seems by the sound of it...that the structure of your project is perhaps a little off. You should have a player object that does things. If it does a thing that earns a point, it should raise an event. This event should be listened to by the Score Manager class, where it will increment an integer. This integer can then be stored somewhere as a high score (file, playerprefs)
ykw im gonna be back later
why not ust use the 2D Navmesh tool
Can you describe the current structure, the current logic flow of your game
what some of you did was very rude. i didnt like that at all and was very discouraged. sorry for not understanding, but there is no need to be rude
everything everyone says is rude, are you 12?
A professor in college would perhaps roast you even worse for this, tbh
THIS ISNT RUDE???
and this isnt either??
ykw goodbye. im astonished at how unwelcoming this waas
Can you answer the question I asked that will assist your issue?
It took four hours to explain how to use ToString they are not prepared for events
Oh no it was very welcoming. The amount of time it took to explain basically anything far outstripped the "welcome" period
you didnt have to be dicks about it
you're the rude one tbh you're projecting
@wooden socket You finally fixed it, move on.
when i do the ScreenCapture.TakeScreenshot thing, the game freezes for a split second. is it possible to avoid this by putting it in a coroutine or async or something
And now go do your promise of learning C# basics before your next question.
i just dont appreciate the reacts and making fun. it hurts a lot
If you find yourself asking one, make a thread so we can avoid all this.
File system access will do this. It is possible to use an async method
I told you twice to make a thread, so you can deal with people only interested in holding your hand. You chose not to.
If you are referring to the built in navmesh tool that comes with Unity I believe it's only compatible with 3D? Unless you meant another tool
probably better off using the capture directly from the Graphics card like how RT does it
True
nah this one
https://github.com/h8man/NavMeshPlus
how can i do that? and what's RT?
@olive fractal did you fix your sprite issue?
Render Texture. just grab the texture basically and save that
Okay, updated, shorter video, and I'll try to explain the bug this time.
Once again, please turn off audio before watching this, I'm working with some buggy audio files that are kind of painful to hear.
So, I'm just trying to instantiate a Sprite on the screen, using one of my managers (it's dontdestroyonload). The object is initializing properly but for whatever reason, it doesn't seem to have a sprite inside of it?
No, but I have a way more concise video, where the thing mentioned earlier is fixed.
so i just take a sprite from the rendertexture or something and save that to the disk? as sniflheim said apparently its filesystem which makes it lag and not the screencapture?
Ehh it can also be Unity being slow about it, I like navarone's solution.
Can you do things like makedir from inside Unity? I've definitely never tried, lol
I use it with async too and have no hiccups 🤷♂️
i havent actually touched async before
only coroutines
no idea how it works
https://gist.github.com/unitycoder/9fbd682f7d250c016d6cc0d306290966
Possibly helpful?
you should have no hiccups anyway you should be able to save file during play np
might just be in the editor, then.
looks like it fits my bill exactly lol, thanks for showing me this!
yeah idk System.IO can be slow in general but it should not hiccup unity afaik.
Yes I realized the brain fart there
although this can't be avoided sometimes esp when dealing with UI
You can't use some event that uses Actions without using void 😛
😭
This object is a canvas renderer with no canvas parent
do you have to instantiate it as a child of the canvas?
Yes
Okay, where I kept getting tripped up was, just feeding it a transform works? Feels weird syntactically
if it's not too much to ask, what's the syntax?
Ah, thanks!
Object comma parent transform i think
turned out pretty well 😄 i tend to write a lot of code before testing anything, for better or for worse, which makes it more satisfying when it all works first try
(I'll get back to you guys in like five...)
oh this is really sexy UI, nice
lookin good!
Are you writing a fighter?
thanks!
im making a platform fighter rn, yeah
the past week has been making my replay system actually work to begin with
thanks!
Now you just gotta check if the videos turn out right when you watch 'em
yeah, i'm recording all the inputs when the game is playing and replaying them, basically resimulating the whole game. if one frame goes whack the entire thing blows up
Type mismatch with the Canvas, y'all... this is also a prefab I'm using, should I just findtype canvas and get its transform from there
you're accounting for rng, right
i've been spending a lot of time making my game very deterministic so the inputs work the same no matter what you use
Does the class that instantiates the prefab know about the canvas?
yes i've accounted for that, each replay saves the seed of randomness so any RNG plays out exactly the same
It sure doesn't, it's scene independent and when I tried to give it the Canvas's transform it gave me the type mistmatch
thanks to @swift crag's suggestions im getting very close 😄
Lets see some code
Right, this is a prefab...
public class EncounterManager : MonoBehaviour
{
[SerializeField] List<GameObject> monData;
public static EncounterManager instance = null; //Static instance of GameManager which allows it to be accessed by any other script.
public MonData enemy = null;
[SerializeField] Transform canvas;
void Awake()
{
//Check if instance already exists
if (instance == null)
//if not, set instance to this
instance = this;
//If instance already exists and it's not this:
else if (instance != this)
//Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
Destroy(gameObject);
//Sets this to not be destroyed when reloading scene
DontDestroyOnLoad(gameObject);
}
public void ChooseEncounter(){
enemy = null;
GameObject m = monData[Random.Range(0, monData.Count)];
MonData data = m.GetComponent<MonData>();
if (data != null && m != null)
{
enemy = data;
StartCoroutine(StartBattle(m,0.1f));
}
else
{
Debug.LogError("The selected game object does not have the specified script attached.");
}
}
private IEnumerator StartBattle(GameObject m, float delay){
yield return new WaitForSeconds(delay);
secondBattleStart(m);
}
public void secondBattleStart(GameObject m){
SoundManager.instance.efxSource.clip = enemy.cry;
SoundManager.instance.efxSource.Play ();
Instantiate(m, canvas);
}
}
And what exactly does the error say? You've got a console message?
No error, just that the image doesn't appear (see video)
You said it gave a type mismatch?
I at least know it IS instantiating, but there's clearly an image visible in the prefab and then it's not visible after 😐
I could be misunderstanding something important here, but I think the problem with this solution is in a platformer game context it would create a mesh where the whole scene (-any obstacles) is a big walkable mesh. So it would only work for flying enemies? That's why I came up with my original proposal of nodes on the "start" and "end" of platforms like this. (greatest diagram ever lmao)
Oh, right, if you attempt to attach the Canvas as the Transform, it literally just says type mismatch
Oh, don't do that
attach the gameobject that the canvas is on
it will pull the transform
What you're assigning is a transform
oh you're making platformer ? mb thought it was topdown..Gotcha yeah using node makes sense now
not the canvas component itself
ooooh
You can't assign a scene object to a prefab field
These things exist in different contexts
You'll need some way to find this canvas transform when you spawn the encounter manager
oh god, what's the workaround, then? Should I like
find_object_of_type<Canvas>()
parent = canvas
because theres only one canvas in scene ever
Yes, it's kind of...bad, but yeah
its certainly special. lets see if it cooks, haha
Why can't you have the encounter manager already in the scene?
Its all good thank you for the suggestions!
im really early in dev, so honestly, yeah, its not like im going to have to use it outside of here. ill just spawn one every time i change to the battle scene
wait i literally dont even have to, nvm
oh, don't do that, make it dontdestroyonload and make sure you use a "zero" scene
Singletons being created an destroyed for each scene will make hell for you later
or, just use the same battle scene for every battle and spawn what you need, but have the encounter manager already in there
yo I needa cook something up on unity (in the next 22h) for a college assignment, Ive never used unity before and I got no idea what tf im doin I just downloaded unity. Please someone tell me where to start 😭 🙏
Oh dear
check pin in this channel
yeah, i think thats what ill be going with X|
Im cooked bruh, If I dont get it in I dont get on to my next year 
It's great fun really
I needa make like a top down 2d racing game kinda thing I guess 🤔
I use a scene like that and literally spawn everything at runtime
do rollaball it will take less than 24 hours
fortunately its not that resource intensive because its literally a pokemon-like
make a Box that has rigidbody2d and disable gravity
now you got a car
lol
Nice I do like what I see in the video there very classic looking
haha, dont give me that much credit yet, its mainly derived from the unity roguelike tutorial
Yeah definitely have a battle scene with all the "scaffolding" already in place
its got some nice 2d movement. very smooth
then fill in the blanks with context for the battle
Anything that will be there every time should be in the scene
hey, I'm trying to make a shooter game but I can't firgue out how to make the ammo count on my HUD work, does anyone got some methods I can use?
Well, what have you tried?
I tried a bunch of different functions for getting the ammo count from my gun script to mu hud script but none of them have worked and I can't find any videos on it for the life of me that work
also that worked 🥲
thanks snif
Easiest way is to reference this "gun script" in the hud script
yeah, this should be easy as having an accessible variable, can we see the HUD script?
You bet lemme know if you need more help with that, kinda my specialty, building scenes up at runtime
Hey say I wanted to make something like this - https://youtu.be/vF9R7dhHJCw?si=HnbWRz3wHFSgFbpt
What's up guys !
In this video, we are going to make a car racing 2d game which we used to play in our childhood.
Download Game from Playstore: https://play.google.com/store/apps/details?id=com.SanitTech.StreetRacing2D
Road Sprite: https://sanittechcodes.blogspot.com/2022/08/street-runner-2d-in-unity.html
Playlist Link: https://www.youtube....
^ which one of these would I use 😭
how do I do that?
^ his different to mine in the video
so idk
Hud script should have something like public GunScript gunScript; near the top, inside the class braces, then assign this in the inspector. Make sense?
idk if I pick "universal 2d" or "2d (built in render pipeline)"
so I can just make a var?
and then in the code, hudText.text = gunScript.bulletVariable
Pretty much, yep
jeeze, ight thanks man 🙂
built in is fine
You should be able to follow the tutorial regardless. Those are render pipelines and dictate how the game is rendered under the hood. Not something you should be concerned with as a beginner
this isnt a coding question btw
my bad chronum 
also URP is prob overkill in 2D unless you need lights
i have an android project and when the resolution is 18:9 everything works well but when i set it to my phone resolution only one image gets weird, what is causing this and how can i fix it?
Alright I'm not crazy, lol
Make sure you've got anchors and pivots set right on that image component (assuming this is all UI canvas stuff?)
yeah its ui stuff
how do i find these anchors and pivots things
that you are talking about
Alright it doesn't say it's set to stretch or anything right?
someof my components are different
nope
so i have a camera following a falling ragdoll (the player) but the camera is shaking crazy because its following a falling ragdoll, anyway to get it to shake less? (ive tried using a empty follow object that follows the ragdoll and the cam follows that but same output 😦 )
screenshot the whole recttransform component
Use interpolation
Aha! See that blue cross arrow bit?
Says stretch on box axes