Interacting with Objects and Code in Unity3D

  Рет қаралды 31,299

Jason Weimann (GameDev)

Jason Weimann (GameDev)

Күн бұрын

Пікірлер: 97
@thelastneenja
@thelastneenja 3 жыл бұрын
I've been teaching myself Unity and C# for the past 6 months and this video is a really good summary/review of all the foundational principles I've learned over that time. I like watching stuff that re-covers the basics like this, because the more ways you see and hear the same thing, the easier it becomes to internalize and it eventually becomes intuitive over time. Pay attention fellow newbies! This is good stuff.
@rashidfarhan6223
@rashidfarhan6223 3 жыл бұрын
this comment is pin worthy tbh.
@GamesPatron
@GamesPatron 3 жыл бұрын
@@rashidfarhan6223 Yes, yes it is.
@kehmesis
@kehmesis 3 жыл бұрын
While I didn't learn much, this video format/type is amazing. I wish I had found a similar video 5 years ago. I hope to see much more like these, great stuff!
@tylerquevedo
@tylerquevedo 3 жыл бұрын
The concept of referencing classes and caching references via Get Component took me nearly a year to learn because I couldn't find anyone explaining it well. I wish I had this video back then. Great content as always!
@Betruet
@Betruet 3 жыл бұрын
I know this is such great content. Its videos like these that save me so much time as a new person to programming. I just need clear explanations and I can understand concepts. Loving these videos
@rashidfarhan6223
@rashidfarhan6223 3 жыл бұрын
This is what every beginner unity dev should see!
@alicanted
@alicanted 3 жыл бұрын
I've been working in Unity for over a year now, and I truly love it. I can make basic, intermediate games now myself, but the level you are Jason... I hope one day...
@sannanch7564
@sannanch7564 3 жыл бұрын
Jason Brother it's my opinion that, if you make a playlist of C# use with unity and define every aspect of C# with unity from basic to advance then it will be very helpful for many people... Just my opinion 😘🥰😋
@dukemagus
@dukemagus 3 жыл бұрын
That's his paid course
@sannanch7564
@sannanch7564 3 жыл бұрын
@@bezoro-personal yup you are right and i am saying that for a complete beginner its very tough to find every aspect of c# use with unity so it will be very helpful for many people and there will be a complete palylist of this course..... and i think that it will be helpful for you also.... so let's see what's Jason decision
@this-is-gamedev
@this-is-gamedev 3 жыл бұрын
@@sannanch7564 Unity Learn has lots of C# resources as well :) all free.
@sannanch7564
@sannanch7564 3 жыл бұрын
@@this-is-gamedev ☺😊
@jmguillemette
@jmguillemette 3 жыл бұрын
Consider having a part 2 to this video where you show making ScriptableObjects that contain ActionEvents and these are used to invoke events on the characters without tightly coupling them together. :)
@Artmos
@Artmos 3 жыл бұрын
I second this. I would even take it a step further and look at existing frameworks. My preferred is Unity Atoms, combined with UniRx and a bit of modification it becomes really powerful.
@BazSupport
@BazSupport 3 жыл бұрын
Third this
@pRoFlT
@pRoFlT 3 жыл бұрын
I like this process. but I'm starting to see it get out of control when you have a lot of different events that need triggering. 10-20 SO's fine. but 100? Easy to hook up in editor but lots of clicking and managing all the SO's. makes it hard to follow what is happening in game. I'll keep playing with it. i like the SO's with events just not sure of large scale development with it yet. I even put together based abstract event class so i can create SO with any type and use UnityEvent setup inside editor. So when you raise event you pass the data with it. Would like to hear Jasons thoughts on events inside scriptible objects. i know he said he was looking at something like this. and Jason Storey warned him about large scale projects using this. but maybe JW found a way around this?
@jmguillemette
@jmguillemette 3 жыл бұрын
@@pRoFlT a single SO can support more than one event. :)
@this-is-gamedev
@this-is-gamedev 3 жыл бұрын
@@pRoFlT IMO, SO's with events is one of best ways to decouple components. But, it's true that on a larger project it can get out of hand. And usually, at this point it is a good idea to start documenting your code and architecture so that you can quickly look up how all those decoupled objects work together, who's broadcasting events, who's receiving them etc.
@badjano
@badjano 3 жыл бұрын
This video can leverage a junior developer into mid-level developer... nice bro, even for an experienced developer it´s nice to have some confirmation on code decisions. ;) I always felt like I shouldn´t use static variables too much, but it does come with a nice performance boost... Finding objects on Update gives me itches
@badjano
@badjano 3 жыл бұрын
@@bezoro-personal I think Rider from Jetbrains even warns you when you call some functions on update.
@TheJackal917
@TheJackal917 3 жыл бұрын
I like design of your room. Makes it pleasurable to watch videos.
@WatThaDeuce
@WatThaDeuce Жыл бұрын
I like this video format and I learned a thing or two, though, I'd like to see more intermediate-level demonstrations.
@supertenchoo4271
@supertenchoo4271 3 жыл бұрын
The Way you explain is mazing you are Unity Expert Thanks for the video...
@mesolagic
@mesolagic 3 жыл бұрын
Great tutorial! Most of the info seems great for beginners but I also learned some new things and the formatting is very clear and nice. Keep up the good work Jason!
@Choco-sk2gj
@Choco-sk2gj Жыл бұрын
Thank you Jason. Your videos are incredibly helpful
@juleswombat5309
@juleswombat5309 3 жыл бұрын
That was neat. I have been using Unity for 4 years, but only today learn't that I can double click upon Errors in the Unity console, to get to the line of code in my code editor.
@Ninakoru
@Ninakoru 3 жыл бұрын
Great format, straight to the point. Thanks for the effort.
@kubinelg3436
@kubinelg3436 3 жыл бұрын
Great video. Lot of awesome info. Would love to see video about setting up NavMeshAgent.
@jaredhead9503
@jaredhead9503 3 жыл бұрын
This is my favorite unity video
@GamerExA
@GamerExA 3 жыл бұрын
This is super informative video. Thank you
@supertenchoo4271
@supertenchoo4271 3 жыл бұрын
This is the Best Tutorial in 2021
@pirateguitarrr
@pirateguitarrr 3 жыл бұрын
This one was a gold mine for me, thanks.
@nGAGE0nline
@nGAGE0nline 3 жыл бұрын
Nice video. Perhaps could have added an example of using ScriptableObjects to reference prefabs, values etc, across multiple objects. Suggestion/request: You could do a video on the various ways to observe for changes, like the INotifyPropertyChanged interface, but then practical examples for Unity.
@Elenthiriel
@Elenthiriel 3 жыл бұрын
love you Jason Your tips just save me a lot a of pain, thank you for your free knowledge
@arcday4281
@arcday4281 3 жыл бұрын
Very useful video ! You have explained everything clearly !!!
@bertconnell
@bertconnell 3 жыл бұрын
Your content is amazing.
@TimmacTR
@TimmacTR 3 жыл бұрын
This was super useful. Favorited.
@AmNothi
@AmNothi 2 жыл бұрын
great format.
@adamgrey268
@adamgrey268 3 жыл бұрын
Great video. Well done. I enjoy this sort of video.
@DionGrimm
@DionGrimm 3 жыл бұрын
Nice refresher and learned new things as well!
@ChristopherRohde1
@ChristopherRohde1 2 жыл бұрын
Great video...very easy to follow! I'm probably necro-ing here (if thats a thing) but I'd love to see how TryGetComponent would fit into the array of ways to find objects/components. It's kind of self-explanatory, but wondering if there are scenarios where it's more useful than just checking if a component exists or if that is its only use case
@TheKr0ckeR
@TheKr0ckeR 3 жыл бұрын
That's incredible! I needed that and only 1 day before you uploaded it! :) I wonder how we click spesific object and only move it instead of using serializedfield? We will first click knight, then we will click where it needs to go and then only clicked knight will go there
@juliaalder2007
@juliaalder2007 3 жыл бұрын
Very good and clear explanations. Could you do a tutorial on interactions like this with the new input system? This would be so helpful! :)
@goldone01
@goldone01 3 жыл бұрын
Really great video. Only question I have is if you're not at risk of creating a bit of a monolithic structure if your "Knight" class is responsible to provide access to all the different components- e.g. movement, animation, sound, etc.
@justinanderson267
@justinanderson267 2 жыл бұрын
Wow, learning a lot from this video. Thanks++
@AndrewShestopalov
@AndrewShestopalov 2 жыл бұрын
How about implementing KnightManager/KnightController or example? Or both of them (depending of your needs). Manager responsible for creating, removing, pooling, giving references to existing knight, for example (GetKnightClosestToWorldPosiiton()) for example. Controller - controls knights. Knight itself knows nothing about anyone but himself. Manager/controller - the one who does all the job. Controlling of a knight(s) goes from only through the controller, that could be a static instance. Receiving commands from InputController then passing it to controller to do further ingame actions like select knight, deselect (if it was selected), move it, cheer, attack, etc. And at this point it does not matter who send commands to the controller, either player or AI. Overall I think it is a much more organized approach. Every component logically separated and doing only its job.
@oyaguni961
@oyaguni961 3 жыл бұрын
Thank you for the content, really informative! Appreciate it
@ddamindu
@ddamindu 3 жыл бұрын
Glad to see this video
@ACBros_06
@ACBros_06 Жыл бұрын
This vid is great . thanks very much
@Unity3dCollege
@Unity3dCollege Жыл бұрын
Glad it helped
@CleisonRodriguesComposer
@CleisonRodriguesComposer 3 жыл бұрын
You're the best! Thank you!
@BlueBirdgg
@BlueBirdgg 3 жыл бұрын
Great tutorial! Ty!
@KyranFindlater
@KyranFindlater 3 жыл бұрын
excellent video, thank you!
@random_precision_software
@random_precision_software 3 жыл бұрын
I'm always getting into trouble finding objects when issue prefabs. Great vIdeo btw!
@JohnK68
@JohnK68 2 жыл бұрын
Nice video well explained.
@tonywhite4476
@tonywhite4476 3 жыл бұрын
Very useful tutorial. Could you show how to access and play a particle effect using volume(decibels) or sound as input method. Also, should I make the particle emitter a child an empty game object ? Thanks and please do more like this one.
@Medal71
@Medal71 3 жыл бұрын
A huge thank you for this summary! Frankly, I had lost many things along the way ... p.S: Where can I post any ideas / suggestions to see them in your future videos if possible?
@Unity3dCollege
@Unity3dCollege 3 жыл бұрын
Here is always good
@Medal71
@Medal71 3 жыл бұрын
@@Unity3dCollege It would be interesting to see how manage an inventory (fps, survival, rpg etc.) with scriptable objects, instances and more. Frankly, I've always found a lot of confusion because of the mechanisms that are sometimes very complex! I very much hope that you could deepen this aspect. Thanks Jason!!
@betterlifeexe4378
@betterlifeexe4378 3 жыл бұрын
If your not building everything from scratch than your design is inevitably determined by your resources. I inherited navigation via transform targets from my ragdoll solution, which made integrating my 'AI' a headache. Special care needed to be taken with manual adjustments as well, as physics can get involved. In the end, my 'AI' turned into this hub that was significantly interdependent on many scripts, which made catching state exceptions a whole thing.... any general advice on dealing with this sort of problem?
@betterlifeexe4378
@betterlifeexe4378 3 жыл бұрын
I guess to give more definition to the problem, what do you do to effectively cope with inherited technical debt? Are there specific patterns for reducing interdependance between components that maybe is more readable than var myvar; TryGetComponent(out myvar); If(myVar != null) { finally use data - if (var from other component != null) { doTheThing(var or default);} else {Debug.Log("you broke it, check the state of the other component if it even exists") } else {Debug.log("that's right, doesn't even exist");} I hate this pattern.
@OtakuDYT
@OtakuDYT 3 жыл бұрын
Instead of the static approach, I'm switching over to a list that is within a ScripableObject, that way other items (that aren't knights) can reference the list without coupling. Hope this is a good thing to do? 🤔
@DanTheMann1218
@DanTheMann1218 3 жыл бұрын
ScriptableObjects are a great alternative to making public static properties and fields. They can exist outside of the scene (no messy “DontDestroyOnLoad” GameObjects) and even persist between sessions if you’d prefer.
@GGFTV
@GGFTV 3 жыл бұрын
At 4:26 Do you not have to assign the variable on line 6. So it would be written as [SerializeField] List _toggleObjects = new List(); If I don't do this, I get a null reference error often
@Unity3dCollege
@Unity3dCollege 3 жыл бұрын
If its serialized, it'll automatically create the instance and serialize it, but that won't happen until you go back into unity
@MegaStygian
@MegaStygian 3 жыл бұрын
what would be the best approach on let's say collectible items in the same interaction area. Let say the player is in range of more than one interactable objects what would your implement. I have this problem in my head i implemented something but i am not sure if it will work everytime
@Glu10Free_Waifu
@Glu10Free_Waifu 3 жыл бұрын
What I did was add those collectibles into a list of intractable when they are in range, then when player press intract, either intract with the first one or show them an option to choose which one...
@bdcampbell
@bdcampbell 3 жыл бұрын
In your example you are creating a new static list of Knights in every instance of the Knight class. Could you explain why it's OK to create a new list many times, even though the list exist only once in the game?
@pawciudev
@pawciudev 3 жыл бұрын
Wow, thanks for the trick (3:42). I was wondering if there is a way to do something like this :D
@hurin1576
@hurin1576 3 жыл бұрын
Thanks!
@zekiozdemir420
@zekiozdemir420 2 жыл бұрын
thank you
@sammiegardner2159
@sammiegardner2159 3 жыл бұрын
Hey Jason I just got the program unity and I trying to build an game similar to final fantasy tactics I need a little advice on what that package i should buy on unity app store because I'm no artist in I was wondering if I could use the character creator of rpg maker or something of that sort any advice is much appreciated
@Draekdude
@Draekdude 3 жыл бұрын
I've done a few Unity course and they always use arrays everywhere. I automatically converted most of them into Lists and then used LINQ. However, I heard there's a performance hit between Lists and Arrays. Is that something I should note? Or just ignore it due to function and readability?
@kissarmin7130
@kissarmin7130 3 жыл бұрын
Thanks
@Rovsau
@Rovsau 3 жыл бұрын
Hey, Jason! I'm curious about the performance difference between different ways of referencing objects and components. I always try to reference only the components that I need. Take this scenario: - I have a GameObject with 20 components, but I only need to reference 10; would it be better to cache the entire game object, or write 10 lines of code to get each component during the same code segment? Also - What do you think about the approach of placing scripts on Empty Parents, which reference other scene objects via GameObject.Find? I can imagine a point where an item has to be found again, and the following logic could cause unnecessary complexity, because it is initially cached in Awake - but is it any less performant than keeping scripts on their respective game objects?
@gammafoxtbg
@gammafoxtbg 3 жыл бұрын
For your first question, I'd re-examine why you need to reference all these components in the first place. Can the functionality you need from them be performed as a method in the reference object? That can decouple your code and keep your objects responsible for their own stuff (part of the Single Responsibility Principle of S.O.L.I.D.).
@Rovsau
@Rovsau 3 жыл бұрын
@@gammafoxtbg In this case the question is entirely theorietical. I do try to keep things as simple and segmented as possible. One reason why my question might not make sense, is because I am not that experienced yet. I've got a decent grasp on how to code C# and handle components in Unity, and learning stuff is easier at this point. What I always want to know, is what are the most and least performant ways of doing things. Like should I get a component in one script, and reference that component variable to my other scripts, or let them all cache the component individually?
@gammafoxtbg
@gammafoxtbg 3 жыл бұрын
@@Rovsau Caching everything would be a bit overkill and take up a lot of unnecessary lines if you've got multiple other scripts trying to access those components. As I kind of alluded to earlier, you'd be better off making methods inside the object in question to do these things itself, and call those methods instead.
@Rovsau
@Rovsau 3 жыл бұрын
@@gammafoxtbg Thanks :) Noted.
@rehankalhara759
@rehankalhara759 3 жыл бұрын
One like and one subscribe. Thank you Sir
@wavyemoji6375
@wavyemoji6375 3 жыл бұрын
Hey man is your agriculture course for beginners i write code in swift please let me know i want to make the decision to jump into game development. Thanks man appreciate you
@baerthe
@baerthe 3 жыл бұрын
D-did you add even more to the background? I'm scared this is becoming a fire hazard lmao
@Unity3dCollege
@Unity3dCollege 3 жыл бұрын
There's still space available l, I can still see some wall! :)
@alirana823
@alirana823 2 жыл бұрын
Hi sir hope you are doing well Sir I need to learn how to make some part in 2D game to across under water some enemy attack under water and then come out on ground. if you help I will be very thank full.
@ZacIRL
@ZacIRL 3 жыл бұрын
Honestly, why would you even show the FindObjectInScene Example? It's a horribly imperformant call. A roundabout way I access objects are through Singletons. Lets say a GameManager.Instance. The player and enemies add themselves in Awake() with PlayerList.Add(this) or EnemyList.Add(this). This way every script can access the Player/Enemy with GameManager.Instance.PlayerList[i] or GameManager.Instance.EnemyList[i]. I generally recommend this approach.
@Alperic27
@Alperic27 2 жыл бұрын
Teaching people to ‘make a knight class’ and hardcode the finderexample to a list of Knight is a profound disservice to them… and completely missing the philisophy of umity!!! 17:51 ‘the simplest is to make the knights remove themselves’ … and there goes teaching another bad thing to do… which leads to a unfathomable pile of spaghetti over time 19:10 … now onto ‘reverse spaghetti’ 23:54 … RTFM … TryGetComponent()
@Mr7Shane
@Mr7Shane 3 жыл бұрын
I thought the video was going to be about interacting with objects as a user, not developer.
@doismilho
@doismilho 3 жыл бұрын
Honestly. Things like tags where you have to use getcomponent midway through the game are options I tipically avoid for performance... I came here hoping for stuff more performant than findobject and stuff like it.. except for the static list, guess nothing really useful :(
@KyranFindlater
@KyranFindlater 3 жыл бұрын
you'll usually need to create and manage your own lists of entities/objects for things you are interested in, for example a big list of all units in an RTS game, and then filter/reduce the list by which team they are on, by selection area, etc. and you can build Maps using unique unit references (like a unit ID number created for each instance and is unique) for instant lookup of an object. But your architecture and the rest of your code needs to be built around those techniques. Every time a unit is spawned, it must add itself to the list or fire an event saying it was spawned, with a publisher-subscriber style event system, and your game lists can just see events as they occur and add the units to the list, rather than the unit itself knowing about/directly accessing the global unit list.
@guraysenova
@guraysenova 3 жыл бұрын
All the zooming in and out is quite disorienting.
@tylerak47
@tylerak47 2 жыл бұрын
#yawn
3 Interesting Ways Scriptable Objects can fix YOUR Unity3d project now!
24:29
Jason Weimann (GameDev)
Рет қаралды 87 М.
Это было очень близко...
00:10
Аришнев
Рет қаралды 7 МЛН
Wait for it 😂
00:19
ILYA BORZOV
Рет қаралды 11 МЛН
amazing#devil #lilith #funny #shorts
00:15
Devil Lilith
Рет қаралды 18 МЛН
Unity3D Mistakes I made that you should avoid
17:32
Jason Weimann (GameDev)
Рет қаралды 337 М.
I Wish I Had Known This Before I Started Unity Game Development...
11:11
The Attributes that [SaveTime] - Unity3D - GameDev
18:52
Jason Weimann (GameDev)
Рет қаралды 32 М.
5 ways to Reference GameObjects in Unity3D
11:49
Jason Weimann (GameDev)
Рет қаралды 133 М.
The 8 Game Code & Architecture Mistakes We ALL Make - Unity3D
25:45
Jason Weimann (GameDev)
Рет қаралды 123 М.
Why this SKILL will make all your code BETTER! #gamedev #unity3d
9:17
Jason Weimann (GameDev)
Рет қаралды 7 М.