@dmitriimerc1less

Ошибка CS1503: Argument 1: cannot convert from 'float' to 'UnityEngine.Vector2'?

using System;
using UnityEngine;
using UnityEngine.InputSystem;

namespace platformer
{

    public class HeroInput : MonoBehaviour
    {
    
        [SerializeField] private Hero _hero;

        private HeroInputAction _inputActions;

        private void Awake()
        {
        _inputActions = new HeroInputAction();
        _inputActions.Hero.HorizontalMovement.performed += OnHorizontalMovement;
        _inputActions.Hero.HorizontalMovement.canceled += OnHorizontalMovement;

        _inputActions.Hero.SaySomething.performed += OnSaySomething;
        }

        private void OnEnable() 
        {
        _inputActions.Enable();
        }
        
    

        private void OnHorizontalMovement(InputAction.CallbackContext context )
        {
        var direction = context.ReadValue<float>();
        _hero.SetDirection(direction);
        
        }

        private void OnSaySomething(InputAction.CallbackContext context)
        {
          
        _hero.SaySomething();
        
        }   
    }
}
  • Вопрос задан
  • 300 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы