Hello everyone,
Im running into an issue with my code.
I want the InTheCar bool to become true when you are in the trigger and press E.
For so far this function is doing nothing for me.
Thanks so much for looking into this.
public bool InTheCar = false;
void OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Debug.Log("Enter Car");
if (Input.GetKey(KeyCode.E))
{
InTheCar = true;
other.transform.SetParent(this.transform);
}
if (Input.GetKey(KeyCode.E) && InTheCar == true)
{
other.transform.SetParent(this.transform, false);
InTheCar = false;
}
if (InTheCar == true)
{
other.GetComponent<Movement>().enabled = false;
}
else
{
other.GetComponent<Movement>().enabled = true;
}
}
}
void OnTriggerExit(Collider other)
{
Debug.Log("No Car Nearby");
}