Object References in Unity - How to Communicate Between Scripts

Опубликовано: 17 Февраль 2025
на канале: Tarodev
122,691
5.7k

PSA: The "Unit" class is a simple class I created to represent a unit in my game. It's NOT an inbuilt class. Sorry for the confusion.

As a new dev, keeping references to game objects you need can be a little confusing. Learn how to store game objects for later use as well as allowing external scripts access to your goodies.

Instead of trying to find an object, shift your thought pattern a little and ask "should I already know where this object is?".

❤️ Become a Tarobro on Patreon:   / tarodev  

=========

🔔 SUBSCRIBE: https://bit.ly/3eqG1Z6
🗨️ DISCORD:   / discord  
✅ MORE TUTORIALS:    / tarodev  


0:50 - Find Methods
1:45 - GameObject from Instantiate
2:33 - Component from Instantiate
3:49 - Multiple Components
4:59 - Static Instance
5:42 - Public Access Modifier
8:08 - Constructors
9:20 - MonoBehaviour "Constructor" (Init)
11:00 - OnCollision
11:50 - TryGetComponent
12:41 - GetComponent
13:03 - SendMessage
13:35 - Closing