Hi, I’m making some test on new input system and I discoverd that when I try to get the first click of mouse or of a touch the Vector position is 0. However next clicks return a non 0 Vector.
Here it my configurations:
- Windows 10
- Unity 2021.3.01f
- Input System 1.3
- Game Run in Simulator Window
The controls asset (PlayerControls.inputactions) is configured as follows:
The code is the following:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputManager : MonoBehaviourSingletonPersistent<InputManager>
{
PlayerControls playerControls;
Vector2 initialPosition;
private void OnEnable()
{
playerControls.Enable();
}
private void OnDisable()
{
playerControls.Disable();
}
public override void Awake()
{
base.Awake();
playerControls = new PlayerControls();
}
// Start is called before the first frame update
void Start()
{
playerControls.Player.Click.performed += _ => SetInitialPosition();
}
// Update is called once per frame
void Update()
{
Vector2 pos = playerControls.Player.CameraMove.ReadValue<Vector2>();
}
void SetInitialPosition()
{
initialPosition = playerControls.Player.CameraMove.ReadValue<Vector2>();
print(initialPosition);
}
}
Thanks.