- Home /
Question by
JimRoot · Nov 15, 2013 at 07:01 PM ·
javascripterroreof
expecting EOF, found 'else'.
Hey folks!
I'am having a problem with the following script:
var car : Transform;
var player : Transform;
var exitPoint : Transform;
var doorTriggerLeft : Transform;
var isPlayerVisible : boolean;
function Update()
{
var screenRay : Ray= Camera.main.ScreenPointToRay(Input.mousePosition);
var rayhit : RaycastHit;
if(Physics.Raycast(screenRay, rayhit));
if(rayhit.collider.tag == "doorTriggerLeft");
}
Debug.Log("Driving");
{
player.gameObject.SetActiveRecursively(false);
player.gameObject.active = false;
player.parent = exitPoint.transform;
player.transform.localPosition = Vector3(-1.5,0,0);
exitPoint.parent = car.transform;
exitPoint.transform.localPosition = Vector3(-0.3,1.5,-0.65);
GameObject.Find("Car").GetComponent("CarControl").enabled=true;
}
else
{
if (Input.GetKeyUp("r"))
{
Debug.Log("Walking");
player.gameObject.SetActiveRecursively(true);
player.gameObject.active = true;
player.transform.parent = null;
exitPoint.parent = car.transform;
GameObject.Find("Car").GetComponent("CarControl").enabled=false;
}
}
}
function OnTriggerEnter(Player : Collider)
{
Debug.Log("Trigger Enter");
isPlayerVisible = true;
}
function OnTriggerExit(Player : Collider)
{
Debug.Log("Trigger Exit");
isPlayerVisible = false;
}
unity gives me the following error:
Assets/Standard Assets/Scripts/Car entering & exiting.js(28,1): BCE0044: expecting EOF, found 'else'.
could you maybe help me with that and show me where i can find the error? i know EOF means end of field and usually he excepting or missing a { or } but in my opinion everything is right :/
Comment
Answer by Eric5h5 · Nov 15, 2013 at 07:14 PM
You should really indent code properly so you can see where the incorrect { } are. Also you're putting ; after if statements, which is wrong. If statements work like this:
if (something) {
do something else
}
Answer by cmpgk1024 · Nov 15, 2013 at 07:13 PM
You are missing a }
at the end, to match the opening brace after function Update(){
.
Your answer
![](https://koobas.hobune.stream/wayback/20220613121958im_/https://answers.unity.com/themes/thub/images/avi.jpg)