i keep getting this error, can you help?

im new, and i tried the roll a ball tutorial project. However, whenever i put in the CameraController script it gives me an error message saying that there is a “compiler error” in the script and it cannot be used, i have tried everything; even copy/pasting the script under the video but still no luck. does anyone have any tips?

You can’t be going around putting scripts on objects if a compiler error exists in the project. If you want help, you need to provide the details of the error and copy/paste the script that the error is referring to. Use code tags please.

Open up the console by double clicking the error message. This will give you a list of errors. Fix the first one, then recompile. Repeat this process until no more errors remain.

Focusing on the first error is good practice as many beginner errors, like parsing error or unexpected symbol, can confuse the compiler and make the rest of the error log meaningless.

here’s my code:
using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

public GameObject Player;

private Vector3 offset

Start () {
offset = transform.position - Player.transform.position;
}

void LateUpdate () {
transform.position = Player.transform.position + offset;
}
}

and the error im getting is:
Assets/Scripts/CameraController.cs(10,9): error CS1520: Class, struct or interface method must have a return type

Start (){
Should be
void Start (){

Also: code tags!

1 Like

could someone help me with mine,i’m rying to get my sprite to move
it is

using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
public float maxspeed = 10f;
bool facingright = true
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void FixedUpdate(
float move = input.GetAxis(“Horizontal”);
Rigidbody2D.velocity = new Vector2(move* maxspeed, Rigidbody2D.velocity.y);
else if ( move > 0 &&!facingright
Flip();
void flip()
FacingRight = !FacingRight
vector3 thescale = Transform.LocalScale;
thescale.x* =-1;
transform.localScale = thescale;
) {
}
}