- Home /
Parser error for code...
I'm trying to make a gravity switch function but i keep getting this at line 14. Unexpected symbol ` (expecting bla bla). Here is my code.
using UnityEngine;
using System.Collections;
public class GravitySwitch : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
function OnMouseDown () {
Physics.gravity = Vector3 (0, 1.0, 0);
}
function OnMouseUp () {
Physics.gravity = Vector3 (0, -1.0, 0);
}
}
In general when you're posting about an error, you should put the actual text of the error, to help us identify the problem. (although, in this case, @zentiu is correct)
Answer by Zentiu · Feb 26, 2014 at 06:07 PM
info is plenty for now but in the future if you have an error.. make sure you give us the entire error.
now for your problem:
try this
void Update ()
{ //if left mousebutton is pressed.
if(Input.GetMouseButtonDown (0))
{
Physics.gravity = Vector3 (0, 1.0, 0);
}
// if left mousebutton is released.
if(Input.GetMouseButtonUp (0))
{
Physics.gravity = Vector3 (0, -1.0, 0);
}
}
ah, I wasn't paying attention to the code.. I deleted my answer. Well done.
sorry, didn't see your answer.. I was to busy fighting my new keyboard trying to enter this code :S
oh no, $$anonymous$$e was quite wrong. I didn't see notice the extra function calls
Still dosen't help... I get the same error : Assets/Standard Assets/Image Effects (Pro Only)/gravityswitch.cs(20,9): error CS8025: Parsing error
what is line 20 in your actual code?
Also for the record, that's a different error.