Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Как починить код для движения персонажа в визуал студио

Евгений Жуков Ученик (107), открыт 1 неделю назад
{
[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();

}
1 ответ
kokos12 Мастер (1257) 1 неделю назад
Попробуй так:
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;
}
}
Евгений ЖуковУченик (107) 1 неделю назад
все равно ругается
Евгений ЖуковУченик (107) 1 неделю назад
мои ошибки он определил вот так
kokos12 Мастер (1257) Евгений Жуков, у тебя Playe написано а не PlayerInputActions
Евгений ЖуковУченик (107) 1 неделю назад
поменял но так же как будто ошибки
kokos12 Мастер (1257) Евгений Жуков, using UnityEngine; using UnityEngine.InputSystem; 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.Enable(); } private Vector2 GetMovementVector() { Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>(); return inputVector; } private void FixedUpdate() { Vector2 inputVector = GetMovementVector(); rb.velocity = inputVector * movingSpeed; } }
Евгений ЖуковУченик (107) 1 неделю назад
не-а, вообще в никакую
Евгений ЖуковУченик (107) 1 неделю назад
он тупо говорит об ошибках компилятора и все
Похожие вопросы