Parsing error

Hi there.

I’m new to coding and starting at basic commands.
This script i’m having trouble with.

using UnityEngine;
using System.Collections;

public class bob : MonoBehaviour {
function Start () {
}
function Update ()
{
if (Input.GetButtonDown(“Jump”))
{
transform.position.x += " 1.0 ";
}
}

But it keeps coming up with ‘error CS8025: Parsing error’ for the last }.
What am I doing wrong! Cause this sort of thing I think should be basic and I’m having trouble, which bugs the hell out of me :rage:

Matt

You are missing a } at the end

public class bob : MonoBehaviour {
    function Start () {
    }
    function Update () {
        if (Input.GetButtonDown("Jump")) {
            transform.position.x += " 1.0 ";
        } // Missing the } at the end of Update()
}  // It should be between these comments

Thanks for the reply.
Still getting the error message on the last line. Copied and pasted your bit of code too and still coming up with that red wavie line.
I attracted the script to the main camera, to move away from a cube. That’s all i’m doing. And the script is in c#.

Matt

You’re mixing JS syntax and C# syntax. You don’t declare methods using the function keyword in C#.

public class bob : MonoBehaviour
{
    void Start() {}
    void Update() {}
    // etc etc
}

Thanks. I am watching a some lad on youtube and i tried to convert the java to c#.

Matt

I didn’t even realize the mixing. Haha
Also your line

transform.position.x += " 1.0 ";

Will not work cause you can’t convert a string to a float.
And cause position.x is a return, and you cant set it that way
try making position to a new vector3

transform.position = new Vector3(transform.position.x + 1, transform.position.y, transform.position.z);

Thanks both of you for replying. Sorted it with your help and moving the camera on the x axis :slight_smile: