I am getting this error and I don’t know why! Can someone please help? Thanks in advance! Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SwordBehaviour : MonoBehaviour
{
public GameObject player;
public PlayerBehaviour script;
// Start is called before the first frame update
void Start()
{
script = player.GetComponent();
}
// Update is called once per frame
void Update()
The line that apparently has the error-> {
private float nerp = 90 * script.dir - 90;
transform.eulerAngles = new Vector3(0,nerp,0);
}
}
Use code tags - it makes it easier to follow code, preserves spacing/etc, and shows line numbers.
The problem is your declaration of “nerp”. Local variables (variables inside a function) aren’t private or public. So the compiler sees “private”, assumes “oh we must be outside of the function now”, and tells you it didn’t find a } there because that’s what should be between a function and outside of the function.
1 Like
Thank you very much! It worked and fixed all of my errors.:)![]()