- Home /
Error in Code
The error code is : Assets/_CompletedAssets/Scripts/Enemy/EnemyMovement.cs(4,14): error CS0101: The namespace global::' already contains a definition for
EnemyMovement'
using UnityEngine;
using System.Collections;
public class EnemyMovement : MonoBehaviour
{
Transform player;
//PlayerHealth playerHealth;
//EnemyHealth enemyHealth;
NavMeshAgent nav;
void Awake ()
{
player = GameObject.FindGameObjectWithTag ("Player").transform;
//playerHealth = player.GetComponent <PlayerHealth> ();
//enemyHealth = GetComponent <EnemyHealth> ();
nav = GetComponent <NavMeshAgent> ();
}
void Update ()
{
//if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
//{
nav.SetDestination (player.position);
//}
//else
//{
// nav.enabled = false;
//}
}
}
Comment
Answer by tanoshimi · Jun 28, 2015 at 07:38 AM
So, you have two scripts called EnemyMovement in your project. Rename one of them.
Or use a namespace such as
using UnityEngine;
namespace $$anonymous$$yNamespace
{
public class Enemy$$anonymous$$ovement : $$anonymous$$onoBehaviour
{
// ...
}
}
Then, to call your class,
$$anonymous$$yNamespace.Enemy$$anonymous$$ovement enemy$$anonymous$$ovementComponent = GetComponent<$$anonymous$$yNamespace.Enemy$$anonymous$$ovement>();