- Home /
new input system catches inputs too early
Hello. I'm a newbie and I'm trying to recreate Flappy Bird. I'm using new input system for input handling. My game has no main menu and intended to start once the player taps the screen. To achieve this, I set body type of rigidbody of the bird to static and I change it to dynamic once there is an input. However, what I actually get is if the player taps when my splash screen occurs, the game starts immediately after the splash screen and doesn't wait for an input. The same happens in Unity Editor (version is 2020.3.32f1) if I click inside the "Game" window after clicking the "Play" button but before the game actually starts (and the "Play" button turns blue) - the game starts immediately and console shows that there was an input. Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
public class controlScript : MonoBehaviour
{
public InputAction buttonJump;
public void Start()
{
buttonJump = new InputAction(
type: InputActionType.Button,
binding: "*/{primaryAction}",
interactions: "press(behavior=1)");
buttonJump.Enable();
}
public void Update()
{
if(buttonJump.triggered)
{
Debug.Log("Jump.triggered");
Jump();
}
}
public void Jump()
{
Debug.Log("Jump");
}
}
Thank you in advise
Answer by AnyhowAnywhere · Mar 27 at 08:34 PM
Apparently it is some kind of a bug? This question is pretty much like mine and the fix proposed by its author did the trick for me. Thank you, @McAden