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 :).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store