Unity Guide

Script communication in Unity | GetComponent

A quick guide about how to implement script communication in Unity using the GetComponent method

We can use [SerializeField] to test the amount of lives in the inspector.
A life will be subtracted every time the function is called and, if there’s less than 1, the player gets destroyed.
It’s important to verify that the component we get isn’t null to avoid a compile error when calling GetDamage.

A passionate computer technology engineer and Unity developer that is always looking to grow in every aspect of life :).