- Home /
Question by
narthur157 · Dec 06, 2012 at 03:11 AM ·
javascriptarrayclassscope
Scope of variables: .NET arrays (UnityScript)
I'm getting an error when I try to access arrays of a class from another script. I have a script with a class definition which includes some float arrays. I want to grab my elements from idealObject.forces and idealObject.velocities in another script.
var idealObj :idealObject = new idealObject();
var forceX :float;
function Update() {
forceX = idealObj.forces[0];
}
class idealObject extends System.ValueType {
var mass : float;
var forces : float[];
var velocities : float[];
public function idealObject() {
var x = new float[3]
x[0] = 0;
x[1] = 0;
x[2] = 0;
forces = x;
velocities = x;
}
You get "forces is not a member of 'idealObject'"
Comment