HI there im trying to disable a script on another game object as the title suggests I know theres a few good functions for this I just can’t seem to figure out why the code does not work
var hanging = false;
//on collision
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == "Ledge")
{
transform.parent.GetComponent("PlatformerController").enabled = false;
hanging = true;
}
}
function Update(){
if (Input.GetButtonDown ("Jump") hanging == true ) {
hanging = false;
// GetComponent("Ledge").enabled = false;
transform.parent.GetComponent("PlatformerController").enabled = true;
transform.position += Vector3.up * 3;
}
}
I’ve also tried making a Transform variable assiging the parent object, if I apply this version on the same gameobject I want to disable the script on it works fine but not when its applied to its child object (which is just a box collider with the script)
var hanging = false;
var player :Transform;
//on collision
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == "Ledge")
{
player.GetComponent("PlatformerController").enabled = false;
hanging = true;
}
}
function Update(){
if (Input.GetButtonDown ("Jump") hanging == true ) {
hanging = false;
// GetComponent("Ledge").enabled = false;
player.GetComponent("PlatformerController").enabled = true;
transform.position += Vector3.up * 3;
}
}
Thanks for any help.