Question by
TvattSvampen · Jul 16, 2018 at 09:27 PM ·
textconsole errorsprintconsole.log
Text isnt printing to console!
Hey guys! when i'm colliding with a cube its supposed to say in console but nothing shows up i have the cube tagged NPC This is my code
private GameObject triggeringNpc;
private bool triggering;
void Update()
{
if (triggering)
{
print("Player is Triggering with " + triggeringNpc);
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "NPC")
{
triggering = true;
triggeringNpc = other.gameObject;
}
}
void OnTriggerExit(Collider other)
{
if (other.tag == "NPC")
{
triggering = false;
triggeringNpc = null;
}
}`
Comment
private GameObject triggeringNpc;
private bool triggering;
void Update()
{
if (triggering)
{
print("Player is Triggering with " + triggeringNpc);
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "NPC")
{
triggering = true;
triggeringNpc = other.gameObject;
}
}
void OnTriggerExit(Collider other)
{
if (other.tag == "NPC")
{
triggering = false;
triggeringNpc = null;
}
}
Best Answer
Answer by TvattSvampen · Jul 17, 2018 at 07:30 PM
I feel very Dumb i accidenlty changed the name of the script.. If any one has preoblem remamber to chek if the script has the right name.