I don’t know much about Android specifics on Unity, but I do know it must use different policies than the PC build. This works fine on the PC, but when I use the same code for an Android project, I get nothing but errors.
function Awake () {
segements[0] = GameObject.FindWithTag ("Player Hand").transform;
for (x=1;x<segements.length;x++) {
var joint = segements[x].GetComponent ("ConfigurableJoint");
segements[x].position = segements[0].position;
}
segements[1].GetComponent ("ConfigurableJoint").connectedBody = segements[0].rigidbody;
for (x=1;x<segements.length;x++) {
joint = segements[x].GetComponent ("ConfigurableJoint");
segements[x].position = segements[0].position + Vector3(0,joint.linearLimit.limit * x,0);
}
}
function Update () {
stringLength += Input.GetAxis ("StringAdjust")*0.2;
stringLength = Mathf.Clamp (stringLength,0.5,30);
string.SetVertexCount (res);
for (var i : float =0;i<res;i++) {
string.SetPosition (i,CubicBezier (i/(res-1),segements[0].position,segements[1].position,segements[2].position,segements[3].position));
}
for (x=1;x<segements.length;x++) {
segements[x].GetComponent ("ConfigurableJoint").linearLimit.limit = stringLength/(segements.length-1);
}
}
static function CubicBezier (t : float,p0 : Vector3,p1 : Vector3,p2 : Vector3,p3 : Vector3) {
t = Clamp01 (t);
t2 = 1-t;
return Pow(t2,3) * p0 + 3 * Pow(t2,2) * t * p1 + 3 * t2 * Pow(t,2) * p2 + Pow(t,3) * p3; //Returns f raised to power p//
}
The specific errors I get are “Unknown Identifier ‘x’” and “Unknown Identifier ‘t2’”
I have the import UnityEngine.Mathf; that is required for the PC and Webplayer usinf Mathf.POW, so is there a different import for Android? Am I missing something, or does Unity need XML or LUA typecasting? I would doubt that or theoretically this wouldn’t be “crossPlatform”.
Let me guess: Androids are really bad at math…
Thank you in advance.