Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unexpected symbol Var

Discussion in 'Scripting' started by Ckiss, Feb 6, 2017.

  1. Ckiss

    Ckiss

    Joined:
    Nov 28, 2016
    Posts:
    1
    My thread keeps saying Unexpected symbol Var and i cant figure out how to fix it please help.

    here is my thread.

    //Smothlyopena door
    var smooth = 2.0;
    var DoorOpenAngle = 90.0;
    private var open : boolean;
    private var enter : boolean;

    private var defaultRot : Vector3;
    private var openRot : Vector3;

    function Start(){
    defaultRot = transform.eulerAngles;
    openRot = new Vector3 (defaultRot.x, defaultRot.y + DoorOpenAngle, defaultRot.z);
    }

    //Main function
    function Update (){
    if(open){
    //Open door
    transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth);
    }else{
    //Close door
    transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth);
    }

    if(Input.GetKeyDown("f") && enter){
    open = !open;
    }
    }

    function OnGUI(){
    if(enter){
    GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), "Press'F'toopenthedoor");
    }
    }

    //ActivatetheMainfunctionwhenplayerisnearthe door
    function OnTriggerEnter (other : Collider){
    if (other.gameObject.tag == "Player") {
    enter = true;
    }
    }

    //DeactivatetheMainfunctionwhenplayerisgoawayfrom door
    function OnTriggerExit (other : Collider){
    if (other.gameObject.tag == "Player") {
    enter = false;
    }
    }
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
  3. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Can you post the exact error you get? It should contain a line number.