- Home /
Cannot fix error anyone have any suggestions
error CS1525: Unexpected symbol `{'
line 59 is marked with double star **
using UnityEngine;
using System.Collections;
public class TP_Camera : MonoBehaviour
{
public static TP_Camera Instance;
public Transform TargetLookAt;
public float Distance = 5f;
public float DistanceMin = 3f;
public float DistanceMax = 10f;
public float X_MouseSensitivity = 5f;
public float Y_MouseSensitivity = 5f;
public float MouseWheelSensitivity = 5f;
public float Y_MinLimit = -40f;
public float Y_MaxLimit = 80f;
private float mouseX = 0f;
private float mouseY = 0f;
private float startDistance = 0f;
private float desiredDistance = 0f;
void Awake()
{
Instance = this;
}
void Start ()
{
Distance = Mathf.Clamp(Distance, DistanceMin, DistanceMax);
startDistance = Distance;
Reset();
}
void LateUpdate ()
{
if (TargetLookAt == null)
return;
HandlePlayerInput();
CalcuateDesiredPosition();
UpdatePosition();
}
void HandlePlayerInput()
{
var deadZone = 0.1f;
if (Input.GetMouseButton(1))
{
// The RMB is down get mouse Axis input
mouseX += Input.GetAxis("Mouse X") *X_MouseSensitivity;
mouseY -= Input.GetAxis("Mouse Y") *Y_MouseSensitivity;
}
// This is where we will limit mouseY
if (Input.GetAxis("Mouse ScrollWheel") < -deadZone || (Input.GetAxis("Mouse ScrollWheel") > deadZone)
{
desiredDistance = Mathf.Clamp(Distance - Input.GetAxis("Mouse ScrollWheel") * MouseWheelSensitivity, DistanceMin, DistanceMax);
} (** THIS LINE)
}
void CalcuateDesiredPosition()
{
}
void UpdatePosition()
{
}
public void Reset()
{
mouseX = 0;
mouseY = 10;
Distance = startDistance;
desiredDistance = Distance;
}
public static void UseExistingOrCreateNewMainCamera()
{
GameObject tempCamera;
GameObject targetLookAt;
TP_Camera myCamera;
if (Camera.mainCamera != null)
{
tempCamera = Camera.mainCamera.gameObject;
}
else
{
tempCamera = new GameObject("Main Camera");
tempCamera.AddComponent("Camera");
tempCamera.tag = "MainCamera";
}
tempCamera.AddComponent("TP_Camera");
myCamera = tempCamera.GetComponent("TP_Camera") as TP_Camera;
targetLookAt = GameObject.Find("targetLookAt") as GameObject;
if (targetLookAt == null)
{
targetLookAt = new GameObject("targetLootAt");
targetLookAt.transform.position = Vector3.zero;
}
myCamera.TargetLookAt = targetLookAt.transform;
}
}
looks like the 3D Buzz tutorial =]
Unfortunately it is very hard to read this without the code being formatted. But the method HandlePlayerInput seems fine? except for the spelling of $$anonymous$$ouse ScrollWheel (note : scroll , not scrool) =]
Please edit your answer, by highlighting all the code, then click the '10101' button at the top. Then it will be much easier to read, and a better chance for you to get an answer.
What section/video is this from (where are you up to)?
Answer by DaveA · Jul 11, 2012 at 12:35 AM
You need to format this, but that error almost always means a mis-matched set of { } so make sure those all match up. If you use MonoDevelop, it highlights the matching one if you click on it, and/or use Ctrl-B to jump to match. If it jumps somewhere you don't expect, you are on track to finding the problem.
Your answer
Follow this Question
Related Questions
Ending my game 3 Answers
Error BCE0018 0 Answers
Need Help Understanding Script! (Javascript) 1 Answer
need help, with greater than statment 1 Answer
Error in script 1 Answer