void Update() { if (transform.localRotation.y >= 0) { if (transform.position.x <= maxX) { exerciser.DynamicDirectionChange(new Vector3(Mathf.Abs(transform.localRotation.y) * 15, 0, 0)); } else { exerciser.DynamicDirectionChange(new Vector3(0, 0, 0)); } } if (transform.localRotation.y <= 0) { if (transform.position.x >= minX) { exerciser.DynamicDirectionChange(new Vector3(-Mathf.Abs(transform.localRotation.y) * 15, 0, 0)); } else { exerciser.DynamicDirectionChange(new Vector3(0, 0, 0)); } } }