using UnityEngine;
using System.Collections;
public class Cube : MonoBehaviour
{
float xPos;
public float movementSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
xPos =Input.GetAxis("Horizontal")* movementSpeed;
transform.Translate(xPos,0,0);
if(transform.position.x>5)
{
transform.position=new Vector3(5,transform.position.y,transform.position.z);
}
You are missing two ‘}’ at the end of the file…one to close off the Update() method, and one to close off the class:
using UnityEngine;
using System.Collections;
public class Cube : MonoBehaviour
{
float xPos;
public float movementSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
xPos =Input.GetAxis("Horizontal")* movementSpeed;
transform.Translate(xPos,0,0);
if(transform.position.x>5)
{
transform.position=new Vector3(5,transform.position.y,transform.position.z);
}
}
}