- Home /
Question by
SIxBORG · Jun 04, 2013 at 05:31 PM ·
javascriptraycastvarhealth
how do i access an int var in a javascript and -= it from another javascript
ok so, i have my first script that keeps track of the enemies health and kills it when its health is less than 1. Then i have another ray cast shooting script that when it hits a rigid body, it minuses 1 from that enemies health. i need lots of help on this, ive been searching for days for an answer. thanks!
Comment
Answer by Graham-Dunnett · Jun 04, 2013 at 05:33 PM
Really??? You didn't search very hard:
To access it from another script you need to use the name of the script followed by a dot and the global variable name.
print(TheScriptName.someGlobal);
TheScriptName.someGlobal = 10;
Your answer
![](https://koobas.hobune.stream/wayback/20220613103519im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Raycasting2D please help 1 Answer
Healthscript not working 1 Answer
Enemy Health With Raycast Not Working 1 Answer
Save Player Health and stats 1 Answer