Hello! Thanks for taking a look!
So the unity console spits out error BCE0005: Unknown identifier on every call of x and t2
i have no clue as to why is this is, as the code was running well when testing in desktop mode, i switch to Ios and this.
Any help would be greatly appreciated and an explanation of why this is happening would really help me out.
import UnityEngine.Mathf;
var segements : Transform[];
var res : int = 5;
var string : LineRenderer;
var stringLength : float = 4;
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;
}
Not sure bit i think i just lost my reply so is this is a duplicate then sorry Thanks for the help Graham, for anyone else that my see this, I had to use static var x : int; static var t2: float; but everything is working perfectly now ! I had a read up on #pragma strict i see the error of my ways, Thanks again for the pro tips Graham!
– BitHag