- Home /
Question by
HawkSP · Feb 24, 2018 at 05:12 PM ·
unity 5javascriptmeshcolliderenable and disable scriptmember
BCE0019 "enabled" is not a member of "Object"(On JavaScript Script)
Basically, I am making a psychology game and I want to make it so you can't collide with an object ahead of you until you collide with one before it. Therefore I want to turn off MeshCollider so they won't be able to collide before I want them to.
I am getting this Error: Assets/Objectives/Objective1.js(17,21): BCE0019: 'enabled' is not a member of 'Object'.
#pragma strict
private var objManager : ObjectiveManager;
var ob2;
function Start()
{
objManager = GameObject.Find("3rdPersonController").GetComponent(ObjectiveManager);
ob2 = GameObject.Find("Objective2").GetComponent(MeshCollider).enabled;
}
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
{
ob2.enabled = true;
Destroy(gameObject);
objManager.objective1 = true;
objManager.objective2 = false;
objManager.objective3 = false;
objManager.objective4 = false;
objManager.objective5 = false;
objManager.objective6 = false;
objManager.objective7 = false;
objManager.objective8 = false;
objManager.objective9 = false;
objManager.objective10 = false;
objManager.objective11 = false;
objManager.objective12 = false;
}
}
The "Objective2" is an object in my scene which I want to be turned on after the collision
Comment
Best Answer
Answer by HawkSP · Feb 24, 2018 at 05:38 PM
Nevermind FIXED: #pragma strict
private var objManager : ObjectiveManager;
private var ob3 : MeshCollider;
function Start()
{
objManager = GameObject.Find("3rdPersonController").GetComponent(ObjectiveManager);
ob3 = GameObject.Find("Objective3").GetComponent(MeshCollider);
}
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
{
ob3.enabled = true;
Destroy(gameObject);
objManager.objective1 = false;
objManager.objective2 = true;
objManager.objective3 = false;
objManager.objective4 = false;
objManager.objective5 = false;
objManager.objective6 = false;
objManager.objective7 = false;
objManager.objective8 = false;
objManager.objective9 = false;
objManager.objective10 = false;
objManager.objective11 = false;
objManager.objective12 = false;
}
}
Answer by ShadyProductions · Feb 24, 2018 at 05:23 PM
var ob2 : MeshCollider; //shouldn't it be this?