Recently I just set the boundries but when I go to test I get this error at the very start that says a namespace cannot directly contain members such as fields or methods. Any soluition to this problem. I have seen people mention about changing the class but I am not sure. Part of me is guessing that in Unity 5 you dont need to serialize the boundries since they already showed up before I entered the serializable code
using UnityEngine;
using System.Collections;
[System.Serializable}
public class Boundary
{
public float xMin, xMax, zMin, zMax;
}
public class PlayerController : MonoBehaviour
{
public float speed;
public Boundary boundary;
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
GetComponent<Rigidbody>().velocity = movement * speed;
GetComponent<Rigidbody> ().position = new Vector3
(
Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)
);
}
}