- Home /
Make a script look for something an an other script
Hi, I have two script one is to do with if you fall and the other one is player health I want the fall script to add 1 to the death count
Thanks
Answer by ThermalFusion · Sep 06, 2012 at 08:24 PM
can you give a better example please that reference didnt help much
It's right at the bottom of that page. var otherScript: OtherScript = GetComponent(OtherScript); Then you can access any public variable that component has. otherScript.deathCount += 1;
The script that i want to acess is called Health.js is this right var Health: Health = GetComponent(Health); and Health.playerDeaths += 1();
var health : Health = GetComponent(Health); health.playerDeaths += 1;
This ONLY works if the scripts are on the same GameObject.
There not one is on the player one is on a object in the scene
Your answer
Follow this Question
Related Questions
Fall Death 1 Answer
Help with InstantDeath Collider Script? 1 Answer
Line Renderer Collision Detection. 2 Answers
What is wrong with my text changing script? 1 Answer
2D Movement Problems 2 Answers