- Home /
This question was
closed Aug 19, 2014 at 05:46 PM by
fafase for the following reason:
Answered many times already
Question by
wegaz · Aug 19, 2014 at 05:44 PM ·
javascriptobjectvariableinteract
Changing variables of other scrips and objects
Hello I have got 2 different objects and scripts.
At my PortalDetection.js script, when the player enters to the red portal I need to change team variable in my character.js as red. I have got if statement but idk how to change a variable which is at other script.
PortalDetection.js script:
#pragma strict
var RedTeleport : Transform;
function OnTriggerEnter (Trigger : Collider)
{
if (Trigger.gameObject.tag == "RedPortal")
{
this.transform.position = RedTeleport.position;
Debug.Log("Spawning As RedTeam Soldier");
}
}
Character.js script:
#pragma strict
var pName : String = "Esporta";
var pHealth : int = 100;
var pMoney : int = 500;
var pLevel : int = 1;
var pTeam : String = "None";
function Update ()
{
if (pHealth <= 0)
{
KillPlayer();
}
}
function KillPlayer()
{
Destroy (gameObject);
}
Comment
Follow this Question
Related Questions
gameObject.active Find 1 Answer
Setting a variable to an instantiated object. 1 Answer
Walking Sound Script not working properly (JavaScript) 1 Answer
How to stop a prefab from changing a variable 0 Answers
Gun Script Help 2 Answers