void RotateToTargetAngle()
        {
            Angle           = AngleCalculator.GetAngle(this.transform.forward.x, this.transform.forward.z);
            AngleDifference = (targetAngle.Angle - Angle);

            if (Mathf.Abs(AngleDifference) > 180f)
            {
                if (AngleDifference < 0f)
                {
                    AngleDifference = (360f + AngleDifference);
                }
                else if (AngleDifference > 0f)
                {
                    AngleDifference = (360f - AngleDifference) * -1f;
                }
            }

            rbody.maxAngularVelocity = MaxTorque;

            Torque = AngleDifference * TorqueMultiplier.Evaluate(Mathf.Abs(AngleDifference) / 180f) * 20f;
            rbody.AddTorque(Vector3.up * Torque, ForceMode.VelocityChange);
            rbody.AddTorque(Vector3.up * -rbody.angularVelocity.y, ForceMode.VelocityChange);

            ShowTorque.transform.position = this.transform.position + (Vector3.up * Torque);
        }
Пример #2
0
        private void Update()
        {
            if (Input.GetMouseButton(0))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                RaycastHit hit = new RaycastHit();

                if (Physics.Raycast(ray, out hit))
                {
                    Debug.DrawLine(hit.point, control.transform.position, Color.red);
                    targetDirection   = hit.point - control.transform.position;
                    targetAngle.Angle = AngleCalculator.GetAngle(targetDirection.x, targetDirection.z);
                }
            }
        }
Пример #3
0
        private void Update()
        {
            if (Input.GetMouseButton(0))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                RaycastHit hit = new RaycastHit();

                if (Physics.Raycast(ray, out hit))
                {
                    Debug.DrawLine(hit.point, control.transform.position, Color.red);
                    targetDirection = hit.point - control.transform.position;
                    float targetAngle = AngleCalculator.GetAngle(targetDirection.x, targetDirection.z);
                    control.subcomponentProcessor.SetFloatDic[SetPlayerFloat.TARGET_ROTATION_ANGLE](targetAngle);
                }
            }
        }