- Home /
Question by
Andy54 · Mar 21, 2012 at 12:01 PM ·
javascriptguitransform.positioninheritance
Help with inheritance to show GUI
I have an object, and I am trying to get its transform.position from one script attached to it into another script that controls the GUI. Tried using get/set method and called that function in the GUI script but to no avail.
I'm trying to get the position of a projectile to appear on screen. I already have a transform.rotation for an object that the GUI script is attached to showing on screen.
Problem is the position of the projectile is not so easily accessible, hence I am trying to use inheritance.
Any help would be appreciated, thank you!
Comment
Answer by DaveA · Mar 22, 2012 at 12:37 AM
Not seeing your code, you shouldn't need get/set nor inheritance. However you are getting transform.rotation, it's the same, transform.position.
Guessing:
public Transform xform; // you set this in code or drag in Inspector
void OnGUI()
{
// set up box1 and box2 in Start
GUI.Label (box1, xform.rotation.ToString());
GUI.Label (box2, xform.position.ToString());
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613065355im_/https://answers.unity.com/themes/thub/images/avi.jpg)