void Update() { if (!enable) { return; } if (audioTimer > 0) { audioTimer -= Time.deltaTime; } if (diffAngle != 0) { print("1- c: " + curAngle + "d: " + diffAngle + ", p:" + progress); float distance = diffAngle * 3; diffAngle = 0; if (Mathf.Abs(distance) < 0.1) { return; } float pre = progress; progress += distance; progress = Mathf.Max(0, progress); progress = Mathf.Min(max2, progress); transform.Rotate(Vector3.right * distance); transform.position = Vector3.Lerp(startPos, endPos, progress / max2); if (pre < max2 && progress >= max2) { hl.lightErrorOff(); hl.lightOff(); } else if (pre == max2 && progress < max2) { hl.lightErrorOff(); hl.lightOn(Color.yellow); } else if (pre < max1 && progress >= max1) { hl.lightErrorOff(); hl.lightOn(Color.yellow); } else if (pre > 0 && progress == 0) { hl.lightErrorOff(); hl.lightOn(Color.green); snap.unlockTarget(); } else if (pre == 0 && progress > 0) { snap.lockTarget(); } print("2- c: " + curAngle + "d: " + diffAngle + ", p:" + progress); } }
void updateHL(float p) { if (p == 0 && progress != 0) { snap.highlighter.lightOff(); snap.highlighter.lightOn(Color.green); snap.unlockTarget(); } else if (progress == 0 && p != 0) { snap.highlighter.lightOff(); snap.lockTarget(); } else if (p == 0 && progress == 0) { snap.highlighter.lightOff(); snap.highlighter.lightOn(Color.green); } }