Olá, estou com um problema que quando deixo meu controle (o stick analógico) centralizado, meu personagem vira pra cima em 90 graus e começa a atirar pra cima. Aqui estão as classes utilizadas
public class CharactersMovement : MonoBehaviour
{
private Rigidbody _rb;
public Vector3 direction { get; protected set; }
void Awake()
{
_rb = GetComponent<Rigidbody>();
}
public void Movement(float speed)
{
_rb.MovePosition(_rb.position + direction * Time.deltaTime * speed);
}
public void SetDirection(Vector2 direction)
{
this.direction = new Vector3(direction.x, 0, direction.y);
}
public void SetDirection(Vector3 direction)
{
this.direction = direction;
}
public void Rotation(Vector3 direction)
{
if (direction != Vector3.zero)
{
Quaternion newRot = Quaternion.LookRotation(direction);
_rb.MoveRotation(newRot);
}
}
}
public class PlayerMovement : CharactersMovement
{
public void PlayerMov()
{
Vector3 aimPosition = this.direction;
aimPosition.y = this.transform.position.y;
Rotation(aimPosition);
}
}