So im trying to change a variable in another script by touching a cube. Current setup
Each with their own scri
The first thing to make this shorter (and eventually faster) would be to store this: gameObject.GetComponent
on Start()
in a private variable (you should avoid calling GetComponent on a frequent basis if you can avoid it).
For the Health variable, a way of avoiding GetComponent
calls could be caching: you create a Dictionary
and read from that as soon as this gameobject collided once