Assets\ControlEnemy.cs(5,7): error CS0116: A namespace cannot directly contain members such as fields or methods
NullReferenceException: Object reference not set to an instance of an object UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.FindClassAndNamespace (System.String className, System.String source, System.Boolean acceptStruct) (at :0) UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.FindNamespace (System.String sourceCode, System.String className, System.Boolean acceptStruct, System.String[] defines) (at :0) Rethrow as IllegalNamespaceParsing: Searching for classname: 'ControlEnemy' caused error in CSharpNameParser UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.FindNamespace (System.String sourceCode, System.String className, System.Boolean acceptStruct, System.String[] defines) (at :0) UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.GetClassAndNamespace (System.String sourceCode, System.String className, System.String& outClassName, System.String& outNamespace, System.String[] defines) (at :0) UnityEditor.Scripting.Compilers.CSharpLanguage.GetClassAndNamespace (System.String filePath, System.String definedSymbols, System.String& outClassName, System.String& outNamespace) (at :0) UnityEditor.Scripting.ScriptCompilers.GetClassAndNamespace (System.String file, System.String definedSymbols, System.String& outClassName, System.String& outNamespace) (at :0)
Assets\ControlEnemy.cs(5,7): error CS0116: A namespace cannot directly contain members such as fields or methods
meu codigo:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void FixedUpdate()
{
GetComponent<Rigidbody>().MovePosition
(GetComponent<Rigidbody>().position +
Myriah.transform.position);
}
public class ControlEnemy : MonoBehaviour {
public GameObject Myriah;
public float Velocidade = 5;
void Start () {
}
void Update () {
}
void FixedUpdate()
{
Vector3 direcao = Myriah.transform.position - transform.position;
GetComponent<Rigidbody>().MovePosition
(GetComponent<Rigidbody>().position +
direcao.normalized * Velocidade * Time.deltaTime);
}
}