Hi just need a little help with this error. I have had it before due to the incorrect number of brackets and have thus been able to sort it but this time I have the correct number of opening and closing brackets but its still coming up.
The origin of this script is from this tutorial RTS Tutorial - Part 6 and these errors have come at the end of part 6.
Assets/Player/UserInput.cs(130,41): error CS1525: Unexpected symbol `}’
using UnityEngine;
using System.Collections;
using RTS;
public class UserInput : MonoBehaviour {
private Player player;
// Use this for initialization
void Start ()
{
player = transform.root.GetComponent< Player >();
}
// Update is called once per frame
void Update ()
{
if(player.human)
MoveCamera ();
RotateCamera ();
MouseActivity ();
}
private void MoveCamera ()
{
float xpos = Input.mousePosition.x;
float ypos = Input.mousePosition.y;
Vector3 movement = new Vector3 (0, 0, 0);
//horizontal camera movement
if (xpos >= 0 && xpos < ResourceManager.ScrollWidth)
{
movement.x -= ResourceManager.ScrollSpeed;
} else if (xpos <= Screen.width && xpos > Screen.width - ResourceManager.ScrollWidth)
{
movement.x += ResourceManager.ScrollSpeed;
}
//vertical camera movement
if (ypos >= 0 && ypos < ResourceManager.ScrollWidth)
{
movement.z -= ResourceManager.ScrollSpeed;
}
else if (ypos <= Screen.height && ypos > Screen.height - ResourceManager.ScrollWidth)
{
movement.z += ResourceManager.ScrollSpeed;
}
//make sure movement is in the direction the camera is pointing
//but ignore the vertical tilt of the camera to get sensible scrolling
movement = Camera.main.transform.TransformDirection (movement);
movement.y = 0;
//away from ground movement
movement.y -= ResourceManager.ScrollSpeed * Input.GetAxis ("Mouse ScrollWheel");
//calculate desired camera position based on received input
Vector3 origin = Camera.main.transform.position;
Vector3 destination = origin;
destination.x += movement.x;
destination.y += movement.y;
destination.z += movement.z;
//limit away from ground movement to be between a minimum and maximum distance
if (destination.y > ResourceManager.MaxCameraHeight)
{
destination.y = ResourceManager.MaxCameraHeight;
}
else if (destination.y < ResourceManager.MinCameraHeight)
{
destination.y = ResourceManager.MinCameraHeight;
}
//if a change in position is detected perform the necessary update
if (destination != origin) {
Camera.main.transform.position = Vector3.MoveTowards (origin, destination, Time.deltaTime * ResourceManager.ScrollSpeed);
}
}
private void RotateCamera ()
{
Vector3 origin = Camera.main.transform.eulerAngles;
Vector3 destination = origin;
//detect rotation amount if ALT is being held and the Right mouse button is down
if ((Input.GetKey (KeyCode.LeftAlt) || Input.GetKey (KeyCode.RightAlt)) && Input.GetMouseButton (1)) {
destination.x -= Input.GetAxis ("Mouse Y") * ResourceManager.RotateAmount;
destination.y += Input.GetAxis ("Mouse X") * ResourceManager.RotateAmount;
}
//if a change in position is detected perform the necessary update
if (destination != origin) {
Camera.main.transform.eulerAngles = Vector3.MoveTowards (origin, destination, Time.deltaTime * ResourceManager.RotateSpeed);
}
}
private Vector3 FindHitPoint() {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit))
return hit.point;
return ResourceManager.InvalidPosition;
}
private void MouseActivity()
{
if (Input.GetMouseButtonDown (0)) LeftMouseClick();
else if (Input.GetMouseButtonDown(1)) RightMouseClick();
}
private void LeftMouseClick() {
if (player.hud.MouseInBounds ()) {
GameObject hitObject = FindHitObject ();
Vector3 hitPoint = FindHitPoint ();
if (hitObject && hitPoint != ResourceManager.InvalidPosition) {
if (player.SelectedObject)
player.SelectedObject.MouseClick (hitObject, hitPoint, player);
else if (hitObject.name != "Ground") {
WorldObject worldObject = hitObject.transform.root.GetComponent< WorldObject > ();
if (worldObject) {
//we already know the player has no selected object
player.SelectedObject = worldObject;
worldObject.SetSelection (true);
player.hud.GetPlayingArea()
}
}
}
}
}
private void RightMouseClick(){
if (player.hud.MouseInBounds () && !Input.GetKey (KeyCode.LeftAlt) && player.SelectedObject) {
player.SelectedObject.SetSelection (false);
player.SelectedObject = null;
player.hud.GetPlayingArea()
}
}
private GameObject FindHitObject() {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit))
return hit.collider.gameObject;
return null;
}
}