Ok so i have a 2 game objects, Object A & Object B
Object A is a player controlled character with quite a few scripts attached.
Object B is a trigger Zone
On Object A there are 2 animation sets,
1 Unarmed
2 Armed
So when i step over the trigger zone, i have the following:
function OnTriggerEnter (myTrigger : Collider) {
if(myTrigger.gameObject.name == "Player"){
GetComponent(Unarmed).enabled = false;
GetComponent(Armed).enabled = true;
}}
Now when i do a debug test to see if its detecting the collision all works well.
Basically the Armed script starts off inactive and when i touch the trigger zone i want it to disable and enable 2 scripts.
It doesn't seem to work, I see it as i need to somehow link scripts between 2 seperate prefabs or objects, How can i do this?
Thanks in Advance.
Ok say for example you have a player right and on this player you have 5 scripts, now in the game you also have 3 other players with 2 scripts. now you said if you step on the trigger you disable one script and enable the other. because i don't know if these scripts are all attached to your player i will still give you an answer that can help :
function OnTriigerEnter (hit: Collider) {
if(hit.gameObject.tag =="Player"){
// this will disable the script on the player
GameObject.Find("Player").GetComponent("put the script name here ").enabled = false;
// this will enable the script on the enemy
GameObject.Find("Enemy1").GetComponent("put the script name here ").enabled = true;
// this will enable the script on the enemy
GameObject.Find("Enemy2").GetComponent("put the script name here ").enabled = true;
}
}
Now basically all you need to do is tell the script what gameOject it should look for the script on and then which script is should enable and disable
As MC HALO said, we need to know what the referenced scripts are attached to. If they are not on the gameObject the script you posted is executing from - then that's what you're doing wrong. The script now searches the game object it's attached to for components it does not have.