- Home /
Question by
CaptaoMiller · Jul 20, 2013 at 05:55 PM ·
c#errorparser
Error cs8025 script (parser error) How i can fix this?
using UnityEngine; using System.Collections;
public class LanternaSlender : MonoBehaviour {
public Light spotLightFL;
private Ray rayToInteract;
private RaycastHit hitInteract;
public float rangeInteract;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.F)){
spotLightFL.enabled = !spotLightFL.enabled;
if(Input.GetMouseButtonDown(0)){
rayToInteract = Camera.main.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(rayToInteract, out hitInteract, rangeInteract)){
if(hitInteract.collider.tag = "InteractObject"){
Destroy(hitInteract.collider.gameObject);
}
}
}
Comment
Answer by Cerbion_ · Jul 20, 2013 at 06:19 PM
The answer is quite simple: You're missing a ton of those curvy brackets: '}'
here you go:
public Light spotLightFL;
private Ray rayToInteract;
private RaycastHit hitInteract;
public float rangeInteract;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if(Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.F))
{
spotLightFL.enabled = !spotLightFL.enabled;
}
if(Input.GetMouseButtonDown(0))
{
rayToInteract = Camera.main.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
}
if(Physics.Raycast(rayToInteract, out hitInteract, rangeInteract))
{
if(hitInteract.collider.tag = "InteractObject")
{
Destroy(hitInteract.collider.gameObject);
}
}
}
Tip: always try to make your code clean and structured and those problems disappear all by themselves :)