🔍Did you know these differences? Which one do you prefer to use? 🌍Get my Complete Courses! ✅ unitycodemonkey.com/courses 🎮Get the Polygon Heist pack cmonkey.co/synty_heist_gameobjectvstransform 🔴RELATED VIDEOS🔴 Why you should NOT make everything PUBLIC! th-cam.com/video/pD27YuJG3L8/w-d-xo.html Learn Unity in 17 MINUTES! th-cam.com/video/E6A4WvsDeLE/w-d-xo.html Awesome Inventory Tetris System! (Resident Evil 4, Escape from Tarkov) th-cam.com/video/fxaDBE71UHA/w-d-xo.html Awesome House Building System! (Castle, Hut, Mansion, City, Village) th-cam.com/video/Cdcn6uK9gPo/w-d-xo.html I Made a Factory Game in 20 HOURS! th-cam.com/video/88cIVR4KI_Q/w-d-xo.html
Extra tip. You can reference any script that inherits from MonoBehaviour, and use it in the Instantiate. In this case the GameObject/Trasnform is created as usual, but what is returned is the instance of the component used in teh reference, saving a GetComponent in case you just need to access the script. (Very common to intantiate new rows of a grid in the UI)
This is actually really helpful for me! I’ve relatively new to Unity, and I’ve always wondered what the difference is, and if one is better. Thanks for making this!!
You could still access the transform when instancing the object as a GameObject with: Transform instance = Instanciate(prefab).transform; Personally I prefer to instanciate prefabs as gameobjects as that feels like the more logical approach (in most of my personal use cases), but I like that you really go deep into explaining the nittygritty details about such abstract topics! Good video as always!
A game object is the base class for any object that can be manipulated in a scene, its transform stores that objects position, rotation and scale in its local space.
3:20 Thanks for going into the pros and cons when using one over the other. So in the end it is just a thing of convenience depending on what you are most likely to do with an object.
I already knew this. but, I like hearing your explanations because you do them so well and sometimes I get helpful tips that I've missed. Plus, it's always good to return to basics every once in a while, just to let it sink in...
to instantiate an object at a certain position/rotation, there is an overload of Instantiate() that does it all in one call. it's actually slower (i.e. extra code/CPU cycles) to set the position/rotation/parent on the returned transform.
I tend to think of GameObject as a container that holds various components, while a Transform is a component that contains position, rotation, and scale data. In the case of a Rect Transform, it'll also contain anchor point data.
Pretty obvious, but I like to make the field/reference relevant to it's main function so I know what I'm using it for at a quick glance. E.G If I'm moving something I use a Transform, if I'm instantiating something or need to use it's components, I use a GameObject.
I understood both Transform and GameObject and personally I prefer GameObject simply because I like to visualize in my head that it's an object and not just "something" that has x,y,z stuff. I know it can go back and forth by accessing the properties / object etc but I just like it better in my head xD
they both are the opposite of what you need! 1. if you declare gameObjects you'll need their transforms. 2. if you declare Transforms you'll need the gameObjects. it's a balancing of memory and performance. it'll take some time to get the component data from an object, but it takes up memorie to store that data.
It's not that the data gets stored at the time of retrieval. Once an object is initialized - it's stored in RAM. Then it's a matter of referencing it. Of course CPU will grab a chunk and store in a cache as well. So I think it would cache all about the object regardless which particular component you look for. But tbh that all probably won't matter to you as a dev. Also C# is not like Javascript, it doesn't suffer the property lookup slowdown. It compiles, and at run has the memory addresses on hand (pointers behind the scenes).
The differences in 2 lines Game Object: Any and every asset inside and representable by the hierarchy. Transform: A component who is found inside every Game Object which represents shape, size and rotation. My problem is that they should rename Game Object to something else such as "Asset Object" because saying "Game Object" is not friendly to a newbie while calling it something like "Object Container" would not only be understandable for newbies but also explain its primary function.
Coming from the KitchenChaos tutorial, awesome video BTW. My thought though, if we want to stick with the self explanatory principle of writing code, shouldn't we always use GameObject for any object in the game, and Transform for any transform of an object in the game? This way there's less confusion when reading code, regardless of author and regardless of time/version of game engine when the code is written.
I guess in theory for someone who is not familiar with how Unity works then yes GameObject would make more sense. But you quickly learn that GameObjects and Transforms are connected, so as long as you have that knowledge I feel that using Transform is just as readable while making it easier to use (access position directly for example)
I've made a ton of controllers, depends heavily on exactly what you're looking for Platformer controller unitycodemonkey.com/video.php?v=DEGEEZmfTT0 Top Down Controller unitycodemonkey.com/video.php?v=Bf_5qIt9Gr8 Modular Controller unitycodemonkey.com/video.php?v=mJRc9kLxFSk First and Third Person unitycodemonkey.com/video.php?v=jXz5b_9z0Bc Third Person Shooter unitycodemonkey.com/video.php?v=FbM4CkqtOuA
So we can create a Scriptable Object -> Use Transform to reference a prefab -> get component of that prefab referenced in the Scriptable object ? (idk if my question make sense tho lol)
Hmm sure, you can make a scriptable object with a transform/prefab reference. Then in a script reference that scriptable object and access the transform/prefab reference
Yes you can do it, personally I tend to separate them for better readability. However performance isn't really a valid concern in that example, if you're ever doing something where you need to optimize setting the position, then you have much much bigger problems since Instantiate has 100x the cost of setting position.
Wait, can I just use a component as the datatype and then I can only insert a GameObject with the Component of that type? Like, transform is the component but what if I only want CharacterController for the field, i.e. only GameObjects with my CharacterController Code Component Would that work?
Indeed, you can use any behavior class as the prefab class and you'll get a direct reference to that component when instantiating. Extremely useful in certain cases.
Yes, do it that way. You can even chunk your controller script into separate parts like Input, Movement, Abilities, States, Animation States, then add all of those as monobehaviors to an object and reference those components in another script which will bring everything together. But this is just one of the approaches.
Yup! If there's a specific script you want to immediately grab from whatever object you're instantiating you can use that type. Although personally I'm not a fan of doing that, I find it causes confusion in the code, I prefer to instantiate the Transform prefab, then GetComponent for whatever else I need
@@CodeMonkeyUnity Maybe GameDev is just build differently. I do Unity on the side for fun, I'm a regular old C# Dev by day and for me it feels like just putting an Object as a reference, something you usually wouldn't do, it's either a direct class or depending on context even better, an interface. A field of type object would probably never pass any Quality Gate let alone a Pull Request where I work(ed) So I was always skeptical of using the gameObject type. I mean, sometimes it might make sense? But usually I have something specifically in mind with that field. Like a reference to the projectile you shoot. I'd rather use a Projectile reference, or rather an IProjectile.
@@TheThursty100 I am using type as well. I can follow it better back. With GetComponent I need to make sure the Component is attached. But if I have already a reference to the component I know the prefab has this component otherwise I couldn't assign it in the inspector.
Heh not quite yet, still trying to recover from the past 5 month "sprint", although for my next big project I might do a Steam game instead, haven't published one in 3 years!
2 ปีที่แล้ว
@@CodeMonkeyUnity I confess that I’ve missed your regular weekly videos.
Can you please do a video on how to lock a player controller to an X, Z spline? What I am saying is - would like to be able to have a 2.5D side scroller that can go through 3D space. Simplest example of what I mean would be a giant cylinder with platforms on its sides, and a player that can move left and right (around cylinder) and jump platforms up/down. A more complex example is something like Sonic Rivals on PSP. How I am imagining implementation could go - splines that a character can get locked onto when reaching a trigger. With some splines controlling X and Z axis only, and others may also have some Y effect. Also I wonder if there can be a soft lock to a spline, like a range of movement in the axis that a controller can move on its own before it gets corrected by a spline.
Hmm if you rotate the spline you can just modify your player transform.up to always match the spline normal vector. That way you can move and rotate the spline and the player will always have its feet on the spline. It's kind of how I rotated the Scout probe to land in any surface in the Outer Wilds video unitycodemonkey.com/video.php?v=67WObFrWpRg
I have on question, I saw a video where they got the name of the game object by typing 'transform.name' I do no tunderstand as to why this works considering there is not name within transform, why not type 'gameObject.name'? Sry I am new to unity
Both are exactly the same, transform.name or gameObject.name gives you the same data. Like I mentioned in this video they are pretty interchangeable, Unity has tons of things like that to make it easier to use, you can access the data with either of them.
ahh yes after mastering DOTS with your tutorials it is finally the time to learn about gameObjects and Transforms. jk! there are many beginner tutorials but only few are good ones in the long term.
Depends on your definition of "good", there's no set number of things you need to learn, it's all about being able to bring your vision to life, if you can do that then you're "good"
@@Dark-jn4hr I've been programming for almost 25 years, using Unity for almost 10. But it's not like you wait that amount of time and suddenly you're good, it's a constant slow improvement.
Isn’t it just when you create a transform reference, it’s calling the base class constructor which is a game object so you always get a game object behind the scenes so to speak.
What do you mean? A game object always has to have a transform, you can't remove it Maybe you just mean you closed the inspector window? Go to Window - Inspector
Depends on many many factors. How many models are you going to have on screen at once? 1? 1000? How many other things are on screen? What are your platform targets? Low end devices? So yes it may be normal or it may be too much, depends on the scenario.
I know every game object have transform in unity the same happen in many other game engines as well. However I personally I don't understand why that is the case. I mean I understand wean you have mesh, point light, you need to have transform. However the are many code's and system that the transformer it besicly useless. For in my game I have system called Player manager this don't need any transform system however the have transform because unity forshing eny game object to have one. One other example is the music. In my game the music 🎶 it's 2D sounds that means no matter wear you are on the map you hired the sound 🔊 why wean shomene use component that doesn't effect by transom the have to forshing to be inside game object that it have transom I really don't understand that. One other thing I didn't know you able to use instead for transom.
Yup technically you don't need it, the engine could very well be designed in a different way. In fact in Unity DOTS you can absolutely have just an Entity (similar to a Game Object) without any Transform component, it's just an entity that exists but has no concept of world position.
To be honest, this seems like bad design. If there's a GameObject called GameManager which must be active in the scene, it shouldn't have a position, rotation or scale. I think the entity relationship between the two should be GameObject(0, 1) HAS (1) Transform
In DOTS/ECS you can indeed have an Entity without any components, so no Transform, no data attached to it. However with regular Game Objects, they always exist in the world so they must have a Transform
meh I hate when youtube tutorials learn bad practises, I wasted a lot of time because of videos like that at the beggining of my gamedev journey. How to make it much better ? Spawner should NEVER set the positions, spawner can have refs to the spawnpoints but never set positions. When you make a spawner like in this video by referencing [SerializeField] private Transform _moneyPrefab then its SUUUPER easy to drop bad prefab into slot (because all objs have transform) - instead you should make a class Money.cs and add it to the prefab. In spawner reference [SerializeField] private Money _moneyPrefab - this way you can drop to the prefab slot on the spawner ONLY objects with Money.cs script on them. Money.cs should have class InitializeMoney(Transform spawnPosition); - spawner after instantiating it should pick the spawnPosition and pass it into Money.cs InitializeMoney() function and Money.cs should set position for itself.
and btw you should almost never instantiate in Update() on button click - get familiar with object pooler and instantiate objects in loading phase of your gameloop... but thats whole another topic - but would be nice to mention that - me in 2016 would really appreciate that.
I disagree, there's nothing wrong with spawning and then moving that object. I just did it recently in my TBS course for making all the Grid Object Debug objects, they are instantiated then moved to their correct position. Nothing wrong with that approach. Also personally I dislike Instantiating a specific component, Instantiate is creating an object, it makes sense to me to create the base object then use GetComponent for whatever you want to do with it.
@@CodeMonkeyUnity yep instantiating creates objects but referencing prefabs by component that is vital for this object minimize mistakes possibility. Spawner should spawn - nothing more. When project gets bigger then this money object will do more stuff (setting amount of money, changing mesh based on amount, registering oncollect event etc.) and then you will need InitMoney() anyway and you know where to look for anything related to the money object. If you make all initialization in one place but position setting will be somewhere else then you creates problems for future self.
Why not just do new Transform prefabTransform = Instantiate (prefab).transform ? I prefer like this, because if you want to reference any other component and what you have is the transform you have to go tranformPrefab.gameobject.Getcomponent... And it's just an extra step every time.
🔍Did you know these differences? Which one do you prefer to use?
🌍Get my Complete Courses! ✅ unitycodemonkey.com/courses
🎮Get the Polygon Heist pack cmonkey.co/synty_heist_gameobjectvstransform
🔴RELATED VIDEOS🔴
Why you should NOT make everything PUBLIC! th-cam.com/video/pD27YuJG3L8/w-d-xo.html
Learn Unity in 17 MINUTES! th-cam.com/video/E6A4WvsDeLE/w-d-xo.html
Awesome Inventory Tetris System! (Resident Evil 4, Escape from Tarkov) th-cam.com/video/fxaDBE71UHA/w-d-xo.html
Awesome House Building System! (Castle, Hut, Mansion, City, Village) th-cam.com/video/Cdcn6uK9gPo/w-d-xo.html
I Made a Factory Game in 20 HOURS! th-cam.com/video/88cIVR4KI_Q/w-d-xo.html
Extra tip. You can reference any script that inherits from MonoBehaviour, and use it in the Instantiate. In this case the GameObject/Trasnform is created as usual, but what is returned is the instance of the component used in teh reference, saving a GetComponent in case you just need to access the script. (Very common to intantiate new rows of a grid in the UI)
This is actually really helpful for me! I’ve relatively new to Unity, and I’ve always wondered what the difference is, and if one is better. Thanks for making this!!
I'm glad you found the video helpful! Thanks!
You could still access the transform when instancing the object as a GameObject with:
Transform instance = Instanciate(prefab).transform;
Personally I prefer to instanciate prefabs as gameobjects as that feels like the more logical approach (in most of my personal use cases), but I like that you really go deep into explaining the nittygritty details about such abstract topics! Good video as always!
A game object is the base class for any object that can be manipulated in a scene, its transform stores that objects position, rotation and scale in its local space.
this is the real explanation i was looking for
3:20 Thanks for going into the pros and cons when using one over the other.
So in the end it is just a thing of convenience depending on what you are most likely to do with an object.
its not a thing of convenience, GameObject.
I already knew this. but, I like hearing your explanations because you do them so well and sometimes I get helpful tips that I've missed. Plus, it's always good to return to basics every once in a while, just to let it sink in...
to instantiate an object at a certain position/rotation, there is an overload of Instantiate() that does it all in one call. it's actually slower (i.e. extra code/CPU cycles) to set the position/rotation/parent on the returned transform.
nice video even for experienced users because we can learn in deepth about casual stuff in unity, thanks as always
I'm multimedia engineer and developer whit Quest 3 and I forget this xD. Tnks Bro!
I am confused about this concept using transform or gameobject different times, this video was completely clean and understandable, thanks for this!
I'm glad the video helped! Thanks!
For my sanity I prefer GameObjects. It just makes it more clear to me what's going on.
Thanks for saving my mental health! I was so frustrating about this .transform/Transform things.
heh yup this can be a bit tricky at first, I'm glad the video helped! Thanks!
I already knew this, but came to confirm. Great video as always
Of all your videos, this one has definitely the most mentions of "transform" and "gameobjects" per minute ;P
so helpful, thanks for the rundown
I tend to think of GameObject as a container that holds various components, while a Transform is a component that contains position, rotation, and scale data. In the case of a Rect Transform, it'll also contain anchor point data.
you clear my confusion! thanks for making this video!
Pretty obvious, but I like to make the field/reference relevant to it's main function so I know what I'm using it for at a quick glance. E.G If I'm moving something I use a Transform, if I'm instantiating something or need to use it's components, I use a GameObject.
I understood both Transform and GameObject and personally I prefer GameObject simply because I like to visualize in my head that it's an object and not just "something" that has x,y,z stuff. I know it can go back and forth by accessing the properties / object etc but I just like it better in my head xD
Good, but (IMHO) I will be add the specific related to foreach (Transform child in transform) ;
Oh yup that's another good one, cycling through children
they both are the opposite of what you need!
1. if you declare gameObjects you'll need their transforms.
2. if you declare Transforms you'll need the gameObjects.
it's a balancing of memory and performance.
it'll take some time to get the component data from an object, but it takes up memorie to store that data.
It's not that the data gets stored at the time of retrieval. Once an object is initialized - it's stored in RAM. Then it's a matter of referencing it. Of course CPU will grab a chunk and store in a cache as well. So I think it would cache all about the object regardless which particular component you look for. But tbh that all probably won't matter to you as a dev. Also C# is not like Javascript, it doesn't suffer the property lookup slowdown. It compiles, and at run has the memory addresses on hand (pointers behind the scenes).
THANKS!
Super helpful man .... love it. Thanks!
The differences in 2 lines
Game Object: Any and every asset inside and representable by the hierarchy.
Transform: A component who is found inside every Game Object which represents shape, size and rotation.
My problem is that they should rename Game Object to something else such as "Asset Object" because saying "Game Object" is not friendly to a newbie while calling it something like "Object Container" would not only be understandable for newbies but also explain its primary function.
good video - but i would like to understand what they are, not just that they're different and how to fetch each other. keep it up!
GameObject is the base object in Unity. Transform is a component storing position, rotation, scale, parent
I do godot, but your vids are always fun
thanks for the video sir. 😀
Solved my doubt which existing many years, I used to think transform is found in scenes, however, gameobject is found in memory for gameobjtect itself
Thank you so much buddy:)
Coming from the KitchenChaos tutorial, awesome video BTW. My thought though, if we want to stick with the self explanatory principle of writing code, shouldn't we always use GameObject for any object in the game, and Transform for any transform of an object in the game? This way there's less confusion when reading code, regardless of author and regardless of time/version of game engine when the code is written.
I guess in theory for someone who is not familiar with how Unity works then yes GameObject would make more sense.
But you quickly learn that GameObjects and Transforms are connected, so as long as you have that knowledge I feel that using Transform is just as readable while making it easier to use (access position directly for example)
Thanks!
Thanks for the super thanks!
amazing tutorial thanks alot
I'm glad you found it helpful!
Thanks man you are wonderful
Can you make video on all basics codes for making a game [ like moving, jumping, teleport etc. Codes ] ? Just simple not too much advanced : )
i think Brackey’s has that
I've made a ton of controllers, depends heavily on exactly what you're looking for
Platformer controller unitycodemonkey.com/video.php?v=DEGEEZmfTT0
Top Down Controller unitycodemonkey.com/video.php?v=Bf_5qIt9Gr8
Modular Controller unitycodemonkey.com/video.php?v=mJRc9kLxFSk
First and Third Person unitycodemonkey.com/video.php?v=jXz5b_9z0Bc
Third Person Shooter unitycodemonkey.com/video.php?v=FbM4CkqtOuA
So we can create a Scriptable Object -> Use Transform to reference a prefab -> get component of that prefab referenced in the Scriptable object ? (idk if my question make sense tho lol)
Hmm sure, you can make a scriptable object with a transform/prefab reference. Then in a script reference that scriptable object and access the transform/prefab reference
3:30 you know that passing position, rotation and parent directly to Instantiate function is much more efficient, right?
Yes you can do it, personally I tend to separate them for better readability.
However performance isn't really a valid concern in that example, if you're ever doing something where you need to optimize setting the position, then you have much much bigger problems since Instantiate has 100x the cost of setting position.
oh thanks
Pretty much, personally I tend to use Transform most of the time
love your vids, are you thinking of doing more dev reacts in the future? those videos have me hooked on your courses
I'm currently working on a How It's Made on V Rising, been playing it and the Sunlight system is pretty interesting
Thanks Code Monkey!
I try to use a Script the prefab is using as the prefabs type
I think there are only a few rarely occurring cases where gameObject is needed, especially if pooling is present.
I always thought of it as - GameObjects are containers for components that require a component of type Transform.
Container for components, that's a nice way to think about it!
Wait, can I just use a component as the datatype and then I can only insert a GameObject with the Component of that type?
Like, transform is the component but what if I only want CharacterController for the field, i.e. only GameObjects with my CharacterController Code Component
Would that work?
Indeed, you can use any behavior class as the prefab class and you'll get a direct reference to that component when instantiating. Extremely useful in certain cases.
Yes, do it that way. You can even chunk your controller script into separate parts like Input, Movement, Abilities, States, Animation States, then add all of those as monobehaviors to an object and reference those components in another script which will bring everything together. But this is just one of the approaches.
Yup! If there's a specific script you want to immediately grab from whatever object you're instantiating you can use that type.
Although personally I'm not a fan of doing that, I find it causes confusion in the code, I prefer to instantiate the Transform prefab, then GetComponent for whatever else I need
@@CodeMonkeyUnity Maybe GameDev is just build differently. I do Unity on the side for fun, I'm a regular old C# Dev by day and for me it feels like just putting an Object as a reference, something you usually wouldn't do, it's either a direct class or depending on context even better, an interface. A field of type object would probably never pass any Quality Gate let alone a Pull Request where I work(ed)
So I was always skeptical of using the gameObject type.
I mean, sometimes it might make sense? But usually I have something specifically in mind with that field. Like a reference to the projectile you shoot. I'd rather use a Projectile reference, or rather an IProjectile.
@@TheThursty100 I am using type as well. I can follow it better back. With GetComponent I need to make sure the Component is attached. But if I have already a reference to the component I know the prefab has this component otherwise I couldn't assign it in the inspector.
I hope you are already planning the next course 🙂
Heh not quite yet, still trying to recover from the past 5 month "sprint", although for my next big project I might do a Steam game instead, haven't published one in 3 years!
@@CodeMonkeyUnity I confess that I’ve missed your regular weekly videos.
Can you please do a video on how to lock a player controller to an X, Z spline?
What I am saying is - would like to be able to have a 2.5D side scroller that can go through 3D space.
Simplest example of what I mean would be a giant cylinder with platforms on its sides, and a player that can move left and right (around cylinder) and jump platforms up/down.
A more complex example is something like Sonic Rivals on PSP.
How I am imagining implementation could go - splines that a character can get locked onto when reaching a trigger. With some splines controlling X and Z axis only, and others may also have some Y effect. Also I wonder if there can be a soft lock to a spline, like a range of movement in the axis that a controller can move on its own before it gets corrected by a spline.
Hmm if you rotate the spline you can just modify your player transform.up to always match the spline normal vector. That way you can move and rotate the spline and the player will always have its feet on the spline.
It's kind of how I rotated the Scout probe to land in any surface in the Outer Wilds video unitycodemonkey.com/video.php?v=67WObFrWpRg
I have on question, I saw a video where they got the name of the game object by typing 'transform.name' I do no tunderstand as to why this works considering there is not name within transform, why not type 'gameObject.name'? Sry I am new to unity
Both are exactly the same, transform.name or gameObject.name gives you the same data. Like I mentioned in this video they are pretty interchangeable, Unity has tons of things like that to make it easier to use, you can access the data with either of them.
ahh yes after mastering DOTS with your tutorials
it is finally the time to learn about gameObjects and Transforms.
jk! there are many beginner tutorials but only few are good ones in the long term.
Why you don't use dark theme for visual studio, it would be much easier to watch your videos at night.
Because dark mode burns my eyes sorry, with I could tailor the video to what each person likes to watch but that's not possible
How much time to become a good game developer for beginners?
Depends on your definition of "good", there's no set number of things you need to learn, it's all about being able to bring your vision to life, if you can do that then you're "good"
I am doing this over 10 years still learning new things lol
@@CodeMonkeyUnity i mean like you. How much time it take to be like you cause you are my inspiration💜
@@Dark-jn4hr I've been programming for almost 25 years, using Unity for almost 10. But it's not like you wait that amount of time and suddenly you're good, it's a constant slow improvement.
Isn’t it just when you create a transform reference, it’s calling the base class constructor which is a game object so you always get a game object behind the scenes so to speak.
yea this is what I was wondering too.
What is this IDE? Visual Studio?
Yup Visual Studio Community 2017
@@CodeMonkeyUnity thx!
My transform is gone and idk what to do?
What do you mean? A game object always has to have a transform, you can't remove it
Maybe you just mean you closed the inspector window? Go to Window - Inspector
@@CodeMonkeyUnity ok👌
Not every gameobject has a Transform. Some can have RectTransforms, etc
Idk why you would reference prefabs with Transform, just seems terrible
RectTransform extends Transform, so they share the same type
hi , i have a question . I downloaded 3d model from "Punishing: Gray Raven" and it has 42000 polygons . Is that normal for mobile game ?
Depends on many many factors. How many models are you going to have on screen at once? 1? 1000? How many other things are on screen? What are your platform targets? Low end devices?
So yes it may be normal or it may be too much, depends on the scenario.
@@CodeMonkeyUnity thank you
I know every game object have transform in unity the same happen in many other game engines as well.
However I personally I don't understand why that is the case.
I mean I understand wean you have mesh, point light, you need to have transform.
However the are many code's and system that the transformer it besicly useless.
For in my game I have system called Player manager this don't need any transform system however the have transform because unity forshing eny game object to have one.
One other example is the music.
In my game the music 🎶 it's 2D sounds that means no matter wear you are on the map you hired the sound 🔊 why wean shomene use component that doesn't effect by transom the have to forshing to be inside game object that it have transom I really don't understand that.
One other thing I didn't know you able to use instead for transom.
Yup technically you don't need it, the engine could very well be designed in a different way.
In fact in Unity DOTS you can absolutely have just an Entity (similar to a Game Object) without any Transform component, it's just an entity that exists but has no concept of world position.
First!!! (Again 🙂)
as an experienced programmer but not with unity, these tutorials are so verbose, useful but veeeery verbose veeeeeeeeeeeeeeeeeeeeery
What part of the video did you feel was unnecessary? It's one of my shortest videos ever, just 6 minutes
Ur verbose leave my monkey alone
Make more for noobs
I definitely would like to make more beginner focused tutorials
Bro shout out pls
Wow I really real stupid now ...... thanks code monkey lol
heh don't feel study, game dev is a lifelong learning journey! I'm learning something new every day!
To be honest, this seems like bad design. If there's a GameObject called GameManager which must be active in the scene, it shouldn't have a position, rotation or scale. I think the entity relationship between the two should be GameObject(0, 1) HAS (1) Transform
In DOTS/ECS you can indeed have an Entity without any components, so no Transform, no data attached to it.
However with regular Game Objects, they always exist in the world so they must have a Transform
meh I hate when youtube tutorials learn bad practises, I wasted a lot of time because of videos like that at the beggining of my gamedev journey.
How to make it much better ?
Spawner should NEVER set the positions, spawner can have refs to the spawnpoints but never set positions. When you make a spawner like in this video by referencing [SerializeField] private Transform _moneyPrefab then its SUUUPER easy to drop bad prefab into slot (because all objs have transform) - instead you should make a class Money.cs and add it to the prefab. In spawner reference [SerializeField] private Money _moneyPrefab - this way you can drop to the prefab slot on the spawner ONLY objects with Money.cs script on them.
Money.cs should have class InitializeMoney(Transform spawnPosition); - spawner after instantiating it should pick the spawnPosition and pass it into Money.cs InitializeMoney() function and Money.cs should set position for itself.
and btw you should almost never instantiate in Update() on button click - get familiar with object pooler and instantiate objects in loading phase of your gameloop... but thats whole another topic - but would be nice to mention that - me in 2016 would really appreciate that.
I disagree, there's nothing wrong with spawning and then moving that object. I just did it recently in my TBS course for making all the Grid Object Debug objects, they are instantiated then moved to their correct position. Nothing wrong with that approach.
Also personally I dislike Instantiating a specific component, Instantiate is creating an object, it makes sense to me to create the base object then use GetComponent for whatever you want to do with it.
@@CodeMonkeyUnity yep instantiating creates objects but referencing prefabs by component that is vital for this object minimize mistakes possibility.
Spawner should spawn - nothing more. When project gets bigger then this money object will do more stuff (setting amount of money, changing mesh based on amount, registering oncollect event etc.) and then you will need InitMoney() anyway and you know where to look for anything related to the money object. If you make all initialization in one place but position setting will be somewhere else then you creates problems for future self.
Why not just do
new Transform prefabTransform = Instantiate (prefab).transform
?
I prefer like this, because if you want to reference any other component and what you have is the transform you have to go tranformPrefab.gameobject.Getcomponent...
And it's just an extra step every time.
You can do GetComponent directly on a transform, no need to go through the Game Object
@@CodeMonkeyUnity Oh. you are right. Thought you couldn't for some reason. haha
Thanks.