Learn INTERFACES in 5 minutes | Unity
HTML-код
- Опубликовано: 27 июн 2023
- Learn how to use interfaces in this quick Unity tutorial.
In this example, we will use the IInteractable interface to interact with any object that implements that interface.
✅ Get my courses with discount:
👉 Unity 2D Master: www.udemy.com/course/unity2dm...
👉 Unity Mobile Course: www.udemy.com/course/unitymob...
👉 Unity Input System with Rebinding: www.udemy.com/course/unity-in...
👍 Save your time and learn Unity faster
-------------------------------------------------------
🔔 Subscribe for more awesome content:
🔴 / @rootgames
-------------------------------------------------------
🟡 Support this channel through donations
Any amount means a lot and will help grow the channel:
👉 PayPal: www.paypal.com/paypalme/rootg...
-------------------------------------------------------
Social Networks:
⭐ Instagram: / rootgamesofficial
⭐ Twitter: / rootgamescro
⭐ TikTok: www.tiktok.com/@rootgamesoffi...
⭐ Facebook: / root-games-10337038860...
-------------------------------------------------------
#unity #interface #interfaces #unitytutorial
Once you learn Interfaces and Events, life gets a lot simpler and your code WAY cleaner. Get scriptable objects in there too and you can remove a lot of your dependencies.
True facts 👍🏻
Please that sounds very useful. Please consider make a tut of how. Thanks
Totally agree. I use SO as middle man for my events and it work great!
Straight to the point, concise & informative! Brilliant explanation!!
Thank you! 😉
I went through your tutorials and it was so helpful that I decided to buy your course to support you.
Thank you very much! I really appreciate it ❤️
I really like your videos. This video is short but very useful. Awesome!
Thank you! Glad you like them, more to come!
ISubscribe. You got me.
really cool !! Very useful ! Thanks
Thanks Spinola!
Good! But it’s better to place OnTrigger event inside player
Yes, you also do that! 😉
It is indeed a way to do it, but what about going the other way around? You could put the OnTriggerEnter and Exit only once onto the player. When its in range of a trigger, set a bool _canInteract to true and _interactable = other.GetComponent(); (Set back to false and null in exit).
Yes you also do it like that. Just note that then you lose some flexibility, because your collider for detecting interactables is always the same (on the player). In the way shown in the video, you can customize the colliders for each object as you wish/need.
@@RootGames Oh no forgot to say the collider trigger is still on the objects. The main difference is instead of each objects getting the player component and sending their IInteractable to the player, the player get it itself.
Can you make a tutorial for ground enemy chase trigger?
I'm in the middle of creating a new course. Did you watch my flying enemy tutorial? It may give you an idea of how to do it.
quee bien
Thank you! 😉
why doesn't my vs code report an error when not implementing the interface? should I type it down for each class?🥲