i am very new to unity2d and i was watching tutorials on how to make a scrolling background and i copied this code and for some reason i get error cs1002 and i dont know what the problem is iv ben trying to find out for the past 2 hours i cant do it so maybe someone can help me.
Here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class backgroundscroller : MonoBehaviour
{
private BoxCollider2D boxcollider;
private rigidbody2D rb;
private float width;
private float speed = -3f;
// use this for initialization
void Start()
{
boxcollider = getcomponent();
rb = getcomponent();
width = boxcollider.size.x
rb.velocity = new vector2(speed, 0)
}
// Update is called once per frame
void Update()
{
if (transform.position.x<-width)
{
reposition();
}
}
private void reposition()
{
vector2 vector = new vector2(width * 2f, 0);
transform.position = (vector2)transform.position + vector;
}
}
CS1002 is a missing semicolon.
Please use code tags when showing code as its very hard to read otherwise Using code tags properly
You have a few problems with your script.
They are easy to spot if you put them into a code editor such as Visual Studio
The red lines indicate potential problems. Mouse over them for more details.
Code is case sensitive so you need to make sure to capitalize the classes, for example rigibody2D should be Rigidbody2D.