Accessing a transform variable for it's position.

I have a script on a game object that needs to scale and rotate based on information from another script. I have set up all my necessary variables and am trying to debug. I am getting an error that RootHandler is not a member of UnityEngine.GameObject. I understand what that means but I can’t figure out how to access my locator variable from the other object. I’ve posted the whole script as it is quite short.

#pragma strict
var rootHandler: RootHandler;
var rootCounter: rootCounter;
var rot: float;
var currentCount: int = rootCounter.count;
var lastCount: int = rootCounter.count - 1;
var currentLocator: GameObject;
var lastLocator: GameObject;
var currentRootName: String;
currentRootName = currentCount.ToString();
var lastRootName: String;
lastRootName = lastCount.ToString();

function Start () {

}

function Update () {
currentLocator = GameObject.Find(currentRootName);
lastLocator = GameObject.Find(lastRootName);
Debug.Log(currentLocator.RootHandler.locator);
Debug.Log(rootHandler.transform.position);
Debug.LogWarning(Vector3.Angle(rootHandler.locator.position, rootHandler.transform.position));
}

The error is on line 21. RootHandler is the script in which the variable locator can be found.

Thanks for your help!

Use GetComponent.

–Eric

Like Debug.Log(GetComponent(currentLocator.RootHandler.locator); ?

I receive the same error.

not exactly sure what you are trying to do but…

dont do all that finding every frame
assign your object that has the script called RootHanldler into the inspector slot.

var rootHandler : RootHandler ;

function Start () {

 
lastLocator = GameObject.Find(lastRootName);
}

 

function Update () {

//currentLocator = GameObject.Find(currentRootName);

//lastLocator = GameObject.Find(lastRootName);

Debug.Log(rootHandler.locator);

Debug.Log(rootHandler.gameObject.transform.position);

Debug.LogWarning(Vector3.Angle(rootHandler.locator.position, rootHandler.transform.position));

}

I figured out the problem, I should not be using the locator variable from the other script. I simply assign the current and last locators, then check their positions.

Nope; see the example on the page I linked to.

Seems to be a mutant combination of both…call it Javasharp. :wink:

–Eric

sorry, yeah updated my reply. its JavaScript