have an error that i don't know how to fix
hello everyone i have a problem that i don't know how to fix as i'm new to coding. the script is a enter car script that i'v tried to convert to an enter a boat script and i almost have it besides this error
Assets/EnterBoat.js(21,53): BCE0044: expecting ), found '='.
this is the script i'm using
pragma strict
var playerInVehicle = false; var playerInRange = false;
var test : boolean = false;
var Char : GameObject; var Car : GameObject; var Cam : Camera;
var CamTarget1 : Transform; var CamTarget2 : Transform;
function Awake(){
Car.GetComponent(DW_BoatController).enabled = false;
}
function Start (){ if (Car.GetComponent(DW_BoatController).enabled = false; }
function Update (){ if (playerInVehicle == true){
}
else if (playerInVehicle == false){
}
Controls();
} function OnTriggerStay(other : Collider){
if (other.tag == "Player"){
playerInRange = true;
}
}
function OnTriggerExit(other : Collider){
if (other.tag == "Player"){
playerInRange = false;
}
}
function Controls(){
if (playerInRange == true){
if (Input.GetKeyDown("f")){
if (playerInVehicle == false){
playerInVehicle = true;
Char.active = false;
Char.transform.parent = gameObject.transform;
Car.GetComponent(DW_BoatController).enabled = true;
}
else if (playerInVehicle == true && Car.GetComponent(DW_BoatController).currentSpeed <= 0.5 && Car.GetComponent(DW_BoatController).currentSpeed >= -0.5){
playerInVehicle = false;
Car.GetComponent(DW_BoatController).enabled = false;
Char.active = true;
Char.transform.parent = null;
Char.transform.position.y += 0.04;
Char.transform.rotation.x = 0.00;
Char.transform.rotation.y = Car.transform.rotation.y;
Char.transform.rotation.z = 0.00;
}
}
}
}
Answer by Jessespike · Aug 22, 2016 at 05:25 PM
Take a look at Start()
function Start (){ if (Car.GetComponent(DW_BoatController).enabled = false; }
Properly formatted code makes these kind of errors more obvious to spot
function Start ()
{
if (Car.GetComponent(DW_BoatController).enabled = false;
}
The if-statement is incomplete and you're trying to set enable at the sametime. Try this:
function Start ()
{
if (Car.GetComponent(DW_BoatController))
{
Car.GetComponent(DW_BoatController).enabled = false;
}
}
Also when sharing code on Unity Answers, be sure to format the code with the 101/010 button, or else others will be less inclined to help.
thank you so much for your help and i'll remember to format the code next time
Your answer
![](https://koobas.hobune.stream/wayback/20220612091330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
BasicFPS controller "Can not be loaded" 0 Answers
RuntimeAnimatorController not loading from script 4 Answers
thirdpersoncontroller multiplayer animations 0 Answers
Moving on the XZ plane 0 Answers
change game character/controller when inside box - RFPSP 1 Answer