void Start() { crank = GetComponentInParent <OkuuFireCrank>(); canMove = true; float rotations = crank.rotations; reach = 360 * rotations; Vector3 crankPoint = MainCameraSingleton.instance.WorldToScreenPoint(crank.transform.position); Vector3 handlePoint = MainCameraSingleton.instance.WorldToScreenPoint(transform.position); // Calculate angle of the handle from the crank. Vector2 offset = new Vector2(handlePoint.x - crankPoint.x, handlePoint.y - crankPoint.y); float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg; if (angle < 0) { angle = (180 - Mathf.Abs(angle)) + 180; } minAngle = angle; cranker.SetStartAngle(angle); // Calculate max cumulative angle maxAngle = minAngle + reach; crankSound = GetComponent <AudioSource>(); crankSound.Pause(); MoveMechanism(); ShowArrow(gauge.GetTargetOffset()); }
void Start() { this.crank = this.GetComponentInParent <OkuuFireCrank>(); this.canMove = true; float rotations = this.crank.rotations; this.reach = 360 * rotations; Vector3 crankPoint = Camera.main.WorldToScreenPoint(this.crank.transform.position); Vector3 handlePoint = Camera.main.WorldToScreenPoint(this.transform.position); // Calculate angle of the handle from the crank. Vector2 offset = new Vector2(handlePoint.x - crankPoint.x, handlePoint.y - crankPoint.y); float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg; if (angle < 0) { angle = (180 - Mathf.Abs(angle)) + 180; } this.minAngle = angle; this.cranker.SetStartAngle(angle); // Calculate max cumulative angle this.maxAngle = this.minAngle + reach; }