I’m trying to stop input when the player has crashed.
why is my boolean always true in update?
heres my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarInputHandler : MonoBehaviour
{
//Components
TopDownCarController topDownCarController;
public StartLight startLight;
public bool canDrive = false;
//Awake is called when the script instance is being loaded.
void Awake()
{
topDownCarController = GetComponent<TopDownCarController>();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame and is frame dependent
void Update()
{
print(canDrive);
if (startLight.raceStarted && canDrive)
{
Vector2 inputVector = Vector2.zero;
//Get input from Unity's input system.
inputVector.x = SimpleInput.GetAxis("Horizontal");
inputVector.y = SimpleInput.GetAxis("Vertical");
//Send the input to the car controller.
topDownCarController.SetInputVector(inputVector);
}
}
}