The question is answered, right answer was accepted
error CS0101: The namespace `global::' already contains a definition for `ActivateTrigger'
Simply put- Im very new to the whole scripting and unity engine, anyways Im trying to modify the original ActivateTrigger code so that when my first person controller enters a box collider, it should turn on a light (but for whatever reason, this original code is not working at all and i cannot find a solution.) I have followed all the instructions but for whatever reason the light is just not turning on or its not recognizing a collider/first person controller entering the trigger zone(the box collider), (honestly i have no idea at this point) And I realize i have more than one problem at the moment My question is 1. I am getting the above error code CS0101 at 3,14 and I honestly have no clue what it means or to do.
2. If anyone could possibly fix the last part of the script for me in a way so that as soon as the first person controller enters the zone, it will activate the trigger/light (or atleast if anyone can show me how) - (61,37): error CS8025: Parsing error
using UnityEngine;
public class ActivateTrigger : MonoBehaviour {
public enum Mode {
Trigger = 0, // Just broadcast the action on to the target
Replace = 1, // replace target with source
Activate = 2, // Activate the target GameObject
Enable = 3, // Enable a component
Animate = 4, // Start animation on target
Deactivate= 5 // Decativate target GameObject
}
/// The action to accomplish
public Mode action = Mode.Activate;
/// The game object to affect. If none, the trigger work on this game object
public Object target;
public GameObject source;
public int triggerCount = 1;///
public bool repeatTrigger = false;
void DoActivateTrigger () {
triggerCount--;
if (triggerCount == 0 || repeatTrigger) {
Object currentTarget = target != null ? target : gameObject;
Behaviour targetBehaviour = currentTarget as Behaviour;
GameObject targetGameObject = currentTarget as GameObject;
if (targetBehaviour != null)
targetGameObject = targetBehaviour.gameObject;
switch (action) {
case Mode.Trigger:
targetGameObject.BroadcastMessage ("DoActivateTrigger");
break;
case Mode.Replace:
if (source != null) {
Object.Instantiate (source, targetGameObject.transform.position, targetGameObject.transform.rotation);
DestroyObject (targetGameObject);
}
break;
case Mode.Activate:
targetGameObject.SetActive(true);
break;
case Mode.Enable:
if (targetBehaviour != null)
targetBehaviour.enabled = true;
break;
case Mode.Animate:
targetGameObject.animation.Play ();
break;
case Mode.Deactivate:
targetGameObject.SetActive(false);
break;
}
}
}
void OnTriggerEnter (Trigger Collider) {
if(Trigger.gameObject.name == "First Person Controller"){
DoActivateTrigger ();
when I try to play my game (rollaball) this pops up and I do not know what it means, I am very new to the game. Assets/Scripts/CameraAngle.cs(3,14): error CS0101: The namespace global::' already contains a definition for
CameraController' Help
Answer by aldonaletto · Dec 28, 2013 at 03:52 AM
Apparently, you've forgot to close the curly braces in the OnTriggerEnter function:
void OnTriggerEnter (Trigger Collider) {
if(Trigger.gameObject.name == "First Person Controller"){
DoActivateTrigger ();
}
}
About the global error: you can't have two scripts with the same name in your project. If there is another ActivateTrigger script anywhere in Assets or any of its folders, delete, rename or move it outside Assets.
When i used that script it comes up with a 63,1 parsing error, and the global error, THAN$$anonymous$$ YOU, finally an answer that actually made sense, I dont fully understand it though, I had it named to something completely different (TriggerZoneScript) and in a different folder (although that folder was in the General Scripts folder) and it still had the global error, but i made a folder in the Assets folder itself, put it in there, and now the global error is gone, and the parsing error... I had actually had those curly braces there before, but that very same parsing error im having now came up, so I had removed them. I apologize I have just become flustered
Answer by Strozean · Aug 18, 2016 at 09:49 PM
@aldonaletto I am doing the Roll a Ball tutorial and in it you create a script called Camera Controller and I got the 'global::' error. Referring to your answer, I found something called CameraController Import Settings and I can't delete it. Besides this, there are no other files with the name 'Camera Controller' and the error is still there.
If you have a question, then create one. You asked a question as an answer to a 3 year old post.
There are two script files in your project with the same class name (ActivateTrigger)