I was wondering how do I call the damage parameter from this script from another script? I’m fairly new so this may be a noobie question to some but any answers would be very helpful, Thank you!
var health : float;
function Start ()
{
health = 100;
}
function Update ()
{
}
function TakingDamage(damage : float)
{
health = health -= damage;
}
Take a look at this: http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
It describes how to access other components/scripts as well as other game objects
If you need to get it from another script there are many ways. Assuming you really meant the parameter, and not just the variable (though similar ways apply):
- Store in a static variable, then you can call it from another script.
- Get a reference to the script, and store the last parameter, then access it with reference.
- Boardcast the parameter.
- Make the function static
We need more details to give an exact answer to what you can do, to get the best result. Are you sure you mean the parameter, and not just the variable?