Hi,
I have a pubic variable in a script(Pend_ball.cs) which is attached to child of a gameobject which is again a child of blank gameobject:
Pend_ball.cs
…
speed = (transform.position - lastPosition).magnitude;
…
Now I want to access/print the value of “speed” in another script (KE.cs) which is also child of a blank gameObject:
KE.cs
public class KE : MonoBehaviour {
float ratio;
void Start(){
ratio = Time.deltaTime;
InvokeRepeating("ChangeScale",1f,1f);
}
void Update(){
float newVal = Mathf.Lerp(transform.localScale.y,speed,ratio);
transform.localScale = new Vector3(transform.localScale.x,newVal,transform.localScale.z);
}
}