Question by
mohannedkandil · Jan 12, 2020 at 10:45 PM ·
inputgamepadinput.getaxis
Can't get any value from ReadValue vector 2 (New Input System)
I want to get the values of the PS4 left stick part, but I am getting (0,0) while in the input debugger the joystick is working fine. So any help to make it work?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
//using System.IO.Ports;
public class FireTester : MonoBehaviour
{
[SerializeField] private Controls _controls;
//SerialPort sp = new SerialPort("COM3",9600);
Vector2 move; // for x and y axis in the joystick
void Awake()
{
_controls = new Controls();
_controls.Ship.Fire.performed += ctx => Shoot();
_controls.Ship.Move.performed += ctx => move = ctx.ReadValue<Vector2>();
_controls.Ship.Move.canceled += ctx => move = Vector2.zero; // if no vlaue in the joystick
//Debug.Log("I'am alive");
}
void Update()
{
Vector2 m = new Vector2(move.x,move.y) * Time.deltaTime;
Debug.Log(m); // print the full vector
}
void Shoot()
{
Debug.Log("Hello");
}
void OnEnable()
{
//_controls.Ship.Fire.performed += HandleFire;
_controls.Ship.Fire.Enable();
}
void OnDisable()
{
//_controls.Ship.Fire.performed -= HandleFire;
_controls.Ship.Fire.Disable();
}
}
Comment