MENU

Fun & Interesting

Object References in Unity - How to Communicate Between Scripts

Tarodev 126,171 3 years ago
Video Not Working? Fix It Now

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: https://www.patreon.com/tarodev ========= 🔔 SUBSCRIBE: https://bit.ly/3eqG1Z6 🗨️ DISCORD: https://discord.gg/tarodev ✅ MORE TUTORIALS: https://www.youtube.com/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

Comment