kokos12
Мастер
(1330)
8 месяцев назад
Попробуй так:
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float movingSpeed = 10f;
private PlayerInputActions playerInputActions;
private Rigidbody2D rb;
private void Awake()
{
rb = GetComponent<Rigidbody2D();
playerInputActions = new PlayerInputActions();
playerInputActions.Player.Enable();
}
private Vector2 GetMovementVector()
{
Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>();
return inputVector;
}
private void FixedUpdate()
{
Vector2 inputVector = GetMovementVector();
// Применяем движение к Rigidbody2D
rb.velocity = inputVector * movingSpeed;
}
}
[SerializeField] private float movingSpeed = 10f;
private PlayeInputActsion playerInputActions;
private Rigidbody2D rb;
private void Awake() {
rb = GetComponent<Rigidbody2D>();
playerInputActions = new PlayeInputActsion();
playerInputActions.Enable();
}
private Vector2 GetMovementVector() {
Vector2 inputVector = PlayeInputActsion Player.Move.ReadValue<Vector2>();
return inputVector
;
}
private void FixedUpdate()
{
Vector2 inputVector = GetMovementVector();
}