A
A
ALTech12020-05-11 14:55:14
Unity
ALTech1, 2020-05-11 14:55:14

How to set player turn time?

There is such a script for the movement of the player. The player moves normally, but turns very sharply. Help how can I set the rotation time in this script?

public class Player : MonoBehaviour
{
    public float speedMove;
    public float gravityForce;
    private Vector3 moveVector;

    private Jostic joystick;
    void Start()
    {
        joystick = GameObject.FindGameObjectWithTag("Joystick").GetComponent<Jostic>();
    }

    // Update is called once per frame
    void Update()
    {
        CharterMove();
    }
    private void CharterMove()
    {
        moveVector = Vector3.zero;
        moveVector.x = -joystick.Vertical() * speedMove;
        moveVector.z = -joystick.Horizontal() * speedMove;


        if (Vector3.Angle(Vector3.forward, moveVector) > 5f || Vector3.Angle(Vector3.forward, moveVector) == 0.0f)
        {
            Vector3 direct = Vector3.RotateTowards(transform.forward, -moveVector, speedMove*100000, 0f);
            transform.rotation = Quaternion.LookRotation(direct);
        }
        

        GetComponent<CharacterController>().Move(moveVector * Time.deltaTime);
    }

}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question