Search Unity

  1. Unity 2019.2 is now released.
    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:
    4,714
  3. Timelog

    Timelog

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