- Home /
Question by
dudedude123 · Jul 14, 2014 at 05:04 PM ·
c#errorvehicle
Entering/Exiting Vehicles
I have a error with the script.
if (Input.GetButtonDown("Vehicle")&& isPlayerVisible)
{
Debug.Log("Driving");
player.gameObject.SetActiveRecursively(false);
player.gameObject.active = false;
player.parent = exitpoint.transform;
player.transform.localPosition = Vector3(-1.5f, 0, 0);
exitpoint.parent = car.transform;
exitpoint.transform.localPosition = Vector3(-1.5f, 0, 0);
GameObject.Find("FireTruck").GetComponent<"FireTruck">().enabled=true;
PlayerCamera.enabled = false;
CarCamera.enabled = true;
}
else
{
if (Input.GetButtonDown("Vehicle"))
{
Debug.Log("Driving");
player.gameObject.SetActiveRecursively(true);
player.gameObject.active = true;
player.transform.parent = null;
exitpoint.parent = car.transform;
GameObject.Find("FireTruck").GetComponent<"FireTruck">().enabled=false;
PlayerCamera.enabled = true;
CarCamera.enabled = false;
}
}
The error says Invalid expression term')' ) expected. How do I fix this problem?
Comment
Answer by Landern · Jul 14, 2014 at 05:06 PM
You don't use strings in generic methods.
if (Input.GetButtonDown("Vehicle")&& isPlayerVisible)
{
Debug.Log("Driving");
player.gameObject.SetActiveRecursively(false);
player.gameObject.active = false;
player.parent = exitpoint.transform;
player.transform.localPosition = Vector3(-1.5f, 0, 0);
exitpoint.parent = car.transform;
exitpoint.transform.localPosition = Vector3(-1.5f, 0, 0);
GameObject.Find("FireTruck").GetComponent<FireTruck>().enabled=true;
PlayerCamera.enabled = false;
CarCamera.enabled = true;
}
else
{
if (Input.GetButtonDown("Vehicle"))
{
Debug.Log("Driving");
player.gameObject.SetActiveRecursively(true);
player.gameObject.active = true;
player.transform.parent = null;
exitpoint.parent = car.transform;
GameObject.Find("FireTruck").GetComponent<FireTruck>().enabled=false;
PlayerCamera.enabled = true;
CarCamera.enabled = false;
}
}
}
I really hope this is for c# and not for unityscript.
There's 2 more errors, EnterExitVehicle.FireTruck' is a
field' but its used like a `type' and UnityEngine.Vector3 is a 'type' but used like a variable
Your answer
![](https://koobas.hobune.stream/wayback/20220613154037im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Entering/Exiting Vehicles Part 2 1 Answer
Distribute terrain in zones 3 Answers
Choose Player UNet Problem with Client 0 Answers
GetComponents array in C# error ? 4 Answers