- Home /
getting a float value from another script
hi all i sort of have 2 questions here, im building a score sytsem much like the one found in angry birds (1, 2 or 3 stars) fist off im trying to get a float value from another script (float parCount = X;) but not sure how to call it?
secondly i wish to make an if statement to say something like if ball goes in hole, get float value and display number of stars depending on number of shots taken.
thsi is the script ive got so far for when the ball goes in the hole but im not sure how to turn this into an if statement.
any ideas would be great
using UnityEngine;
using System.Collections;
public class Hole_TouchDestroy : MonoBehaviour {
void OnTriggerEnter(Collider other) {
Destroy(other.gameObject);
}
}
Comment
Best Answer
Answer by Magnomous · Aug 04, 2013 at 03:10 PM
You can make your float as "static" and then call it from another script like this: floatScriptName.NameOfVariable = someValue;
Your answer
![](https://koobas.hobune.stream/wayback/20220613111523im_/https://answers.unity.com/themes/thub/images/avi.jpg)