void LateUpdate() { if (!inUse) { ballText.text = "[R] Reset Ball"; if (Input.GetKeyDown(KeyCode.R)) { ball.transform.position = ballPos.position; } Vector3 dir = _controller.velocity.normalized; Debug.DrawRay(_controller.transform.position, dir, Color.red); v = Mathf.Abs(v) == 0 ? 0 : v > 0 ? 1 : -1; h = Mathf.Abs(h) == 0 ? 0 : h > 0 ? 1 : -1; float angle = h == 0 ? 0 : v == 0 ? h * 90 : h * v * 45; if (angle != _angle) { _angle = angle; _timeCount = Time.deltaTime; } Armature.Rotate(Vector3.forward, angle); Quaternion grot = Armature.rotation; Armature.rotation = Quaternion.Lerp(_srot, grot, _timeCount); if (Quaternion.Angle(Armature.rotation, grot) != 0) { _timeCount += Time.deltaTime * 1f; } _srot = Armature.rotation; RaycastHit hit; if (Physics.Raycast(Armature.position, mainCamera.transform.forward, out hit)) { Debug.DrawRay(Armature.position, this.transform.forward); IUsable iu = hit.collider.transform.GetComponent <IUsable>(); if (iu != null) { text.text = iu.MessageToUse(); if (Input.GetKeyDown(KeyCode.E)) { text.text = iu.MessageOnUse(); iu.StartUsing(this.gameObject); } } else { iu = hit.transform.GetComponent <IUsable>(); if (iu != null) { text.text = iu.MessageToUse(); if (Input.GetKeyDown(KeyCode.E)) { text.text = iu.MessageOnUse(); iu.StartUsing(this.gameObject); } } else { text.text = ""; } } } } else { ballText.text = ""; _srot = Armature.rotation; } if (stick.stick != null) { switch (stick.ss) { case (GolfStick.StickState.Car): stick.stick.transform.position = stick.caringPos.position; stick.stick.transform.rotation = stick.caringPos.rotation; break; case (GolfStick.StickState.Swing): stick.stick.transform.position = stick.swingingPos.position; stick.stick.transform.rotation = stick.swingingPos.rotation; break; case (GolfStick.StickState.Walk): stick.stick.transform.position = stick.walkingPos.position; stick.stick.transform.rotation = stick.walkingPos.rotation; break; } } }