Hi, im new to unity, and made my first script to open a lock door in a game im making recreating Half-Life, Code (csharp): function Update () { Time.time = 6; var translation = Time.deltaTime * 3.6; Right lock transform.Translate (-0.2566914, 1.129246, translation); var translation = Time.deltaTime * -3.6 Left lock transform.Translate (-0.260433, 1.103976, translation); Time.time = 2; var translation = Time.deltaTime * 3.6; Top door transform.Translate (0.1311612, 1.930578, translation); var translation = Time.deltaTime * -3.6 Bottom door transform.Translate (0.1311612, 0.03431386, translation); } but when i try to add it to the prefab, the console says: Assets/Standard Assets/Scripts/Door open.js(6,14): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 6) Assets/Standard Assets/Scripts/Door open.js(6,19): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 6) Assets/Standard Assets/Scripts/Door open.js(7,48): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 7) Assets/Standard Assets/Scripts/Door open.js(8,13): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 8) Assets/Standard Assets/Scripts/Door open.js(8,18): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 8) Assets/Standard Assets/Scripts/Door open.js(11,12): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 11) Assets/Standard Assets/Scripts/Door open.js(11,17): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 11) Assets/Standard Assets/Scripts/Door open.js(12,48): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 12) Assets/Standard Assets/Scripts/Door open.js(13,15): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 13) Assets/Standard Assets/Scripts/Door open.js(13,20): UCE0001: ';' expected. Insert a semicolon at the end. (Filename: Assets/Standard Assets/Scripts/Door open.js Line: 13) as you see, i do have a simicolin at the end of the lines! What do i do? :?
What's with those "Right lock ", "Left lock " etc? That doesn't look like correct syntax to me. In JavaScript, whitespace is ignored and elements separated by comma (lists, parameters) or dots (objects). Also, two lines are really missing the semicolon at the end. Sometimes, errors at one place can cause errors at other places so it's best to fix them one by one.
There's an error: Time.time is read only so you can't assign it a value. To make a control to the time passed you need to use: Code (csharp): float startTime; void Start () { startTime = Time.time; } // Start void Update () { float passedTime = Time.time - startTime; } // Update but note that these instructions and also Time.deltaTime are Time.timeScale pending so if you change the timeScale (for example reducing it to emphatize a situation) also the time passed is "scaled" so your animation will be slower. Now I have to ask you something: what are "Right lock transform", "Left lock transform", "Top door transform" and "Bottom door transform"? If they are variable you CANNOT name them with space so maybe you meant, for example "LeftLockTransform" if this is a var of Transform type or "LeftLock.transform" if it is a variable of GameObject type. Try to fix your code and then we can go on !!!
You probably already caught this but on the off chance you are still having an issue with it. At the end of two of your lines you are missing semicolons. Toss a semicolon and the end and with the changes suggested by Apache you should be good to go.