Hello.
I would like to get some advice. How to make player control smoother? I know my animations are bad. But, I’m talking about the code now, maybe something can be improved here
gracefulunderstatedanteater
private void Move()
{
// Player's inputs
//float horizontalInput = Input.GetAxisRaw("Horizontal");
//float verticalInput = Input.GetAxisRaw("Vertical");
float horizontalInput = joystick.Horizontal;
float verticalInput = joystick.Vertical;
Vector3 inputs = new Vector3(horizontalInput, 0, verticalInput);
Vector3 movement = inputs.normalized * Time.deltaTime * speed;
//Reset moves
if (horizontalInput == 0.0f && verticalInput == 0.0f)
{
animator.SetBool("LeftMove", false);
animator.SetBool("RightMove", false);
animator.SetBool("ForwardMove", false);
animator.SetBool("BackMove", false);
}
//Left Move
if (horizontalInput == -1.0f && verticalInput == 0.0f)
{
animator.SetBool("LeftMove", true);
animator.SetBool("RightMove", false);
animator.SetBool("ForwardMove", false);
animator.SetBool("BackMove", false);
}
//Right Move
if (horizontalInput == 1.0f && verticalInput == 0.0f)
{
animator.SetBool("RightMove", true);
animator.SetBool("LeftMove", false);
animator.SetBool("ForwardMove", false);
animator.SetBool("BackMove", false);
}
//Forward Move
if (horizontalInput == 0.0f && verticalInput == 1.0f)
{
animator.SetBool("ForwardMove", true);
animator.SetBool("BackMove", false);
animator.SetBool("LeftMove", false);
animator.SetBool("RightMove", false);
}
//Back Move
if (horizontalInput == 0.0f && verticalInput == -1.0f)
{
animator.SetBool("BackMove", true);
animator.SetBool("ForwardMove", false);
animator.SetBool("LeftMove", false);
animator.SetBool("RightMove", false);
}
player.Move(movement);
}
public void Look()
{
transform.LookAt(enemy.transform.position, Vector3.up);
}