Loading video...

Video Failed to Load

Go Home

Reusable Interaction System in Unity in Under 60 🫳🗡️😎 #unitytips #unity3d

15,933 views • 2 years ago •via X (Twitter)

10 Comments

Hura's profile picture
Hura2 years ago

Don't forget to cast your interface to UnityEngine.Object when checking for null. If not, you'll have some crazy moments 👀. The video doesn't do null checks so it doesn't apply but it's nice to know 🙏

Sunny Valley Studio's profile picture
Sunny Valley Studio2 years ago

Thanks for sharing 👍

Distracted Coder's profile picture
Distracted Coder2 years ago

Hah I usually use SendMessage for stuff like this. Good to know there’s a better way

Sunny Valley Studio's profile picture
Sunny Valley Studio2 years ago

Yeah c# is staticly typed so I would recommend using interfaces. On the other hand if you work in Godot in GDScript (dynamic language) sending messages is a default way. It is super cool but the tradeoff is there is no error checking done by the compiler.

Mobius Dev-Tech's profile picture
Mobius Dev-Tech2 years ago

This is an example of abstraction right? It's quite powerful thanks for sharing.

Sunny Valley Studio's profile picture
Sunny Valley Studio2 years ago

Technically i believe it is an example of implementing polymorphism through interface implementation. You do abstract out the concept of "interactable" object by defining a common method (interface) to be called.

Alex Ameye's profile picture
Alex Ameye2 years ago

Nice! How are the selection outlines rendered? Extruding the vertices?

Sunny Valley Studio's profile picture
Sunny Valley Studio2 years ago

I explain it here 🙂

ozn1911's profile picture
ozn19112 years ago

pls tell me how did you quickly add the function there

Mahima Singh's profile picture
Mahima Singh2 years ago

Thanks for sharing! I’ll give this a try

Related Videos