C# Polymorphism in Unity! - Intermediate Scripting Tutorial

preview_player
Показать описание
Watch this video in context on Unity Learn:

Polymorphism is the process by which a child class can be treated as an object of the parent class. In this video you will learn how to use Polymorphism, Upcasting, and Downcasting to create complex and dynamic functionality between related classes.
Рекомендации по теме
Комментарии
Автор

I feel like these things are rather simple, but they're done differently than beginner classes. This is chaotic. Just decide if you're going to explain that on humanoids, colliders or on basic ParentClass and ChildClass. And if you go with the last one, tell us why would we ever need it.

jamqdlaty
Автор

Really enjoying these videos.
Some really good, concise descriptions of things (at least at a high level of the concept).
Nice!

muzboz
Автор

2:49 Idk if this is different in C#, but in Java you definitely want to check if what you're casting into is actually an instance of you're trying to cast it into, otherwise you're gonna run into nasty errors. In general downcasting is something you want to avoid in your code structures. Also you frame this as a Unity guide, but this is really just a general OOP guide lol.

MrPatrickbuit
Автор

Good in the beginning but failed in the end to describe why you would upcast an object.

patriknordberg
Автор

Great video!
However...how does that work within Unity? objects and game objects is the same thing?
I do understand the theory of inheritance and polymorphism, but have no clue of how to use it in Unity. Yet.

Is there a good video of how to use inheritance and polymorphism within Unity in an actual project?
Thanks

aldgardmusic
Автор

Now i understand how my getcomponent on parent class was automatically getting all child classes derived from it. I feel sily now

thevd
Автор

meh, very confusing use of two examples. why not stick with orcs and goblins instead of throwing parentClass and childClass in the mix?

Fanaimi
Автор

why cant i understand inheritence even after dot procedure help me!!

operationalhumanbeing