private void Rotate() { int index = ((int)RotateState + 1) % 4; RotateState = (ERotateState)index; ResetSprite(); }
//============================================================= /// <summary> /// 遠心力を加える /// </summary> private void AddCentifugalForce(ERotateState rotateState, bool isFront) { int num = isFront ? 1 : -1; switch (rotateState) { case ERotateState.InX: if ((prevRotatePos.y - NearPillar.transform.position.y) > 0) { _rigidbody.velocity = rotateSpeed * centrifugalForce * num * Vector3.up; } else { _rigidbody.velocity = rotateSpeed * centrifugalForce * num * Vector3.down; } break; case ERotateState.InY: if ((prevRotatePos.x - NearPillar.transform.position.x) > 0) { _rigidbody.velocity = rotateSpeed * centrifugalForce * num * Vector3.right; } else { _rigidbody.velocity = rotateSpeed * centrifugalForce * num * Vector3.left; } break; case ERotateState.InZ: float x = (transform.position.x - NearPillar.transform.position.x); float y = (transform.position.y - NearPillar.transform.position.y); _rigidbody.velocity = rotateSpeed * centrifugalForce * new Vector3(x, y, 0).normalized; break; } }
private void OnTriggerExit(Collider other) { if (other.tag == "RotateAreaX" || other.tag == "RotateAreaY" || other.tag == "RotateAreaZ") { if (NearPillar) { NearPillar.transform.parent.GetComponent <Pillar>().IsIndicate = false; } NearPillar = null; RotateState = ERotateState.None; } }
private void OnTriggerStay(Collider other) { if (RotateState == ERotateState.None) { if (other.tag == "RotateAreaX") { RotateState = ERotateState.InX; NearPillar = other.gameObject; } if (other.tag == "RotateAreaY") { RotateState = ERotateState.InY; NearPillar = other.gameObject; } if (other.tag == "RotateAreaZ") { RotateState = ERotateState.InZ; NearPillar = other.gameObject; } } }