Hi there,
I’m creating a video game right now. It’s a 3d ball scroller, and I want it so that once I pick up something (a bar of soap in this case), my ball texture changes. This is already done, but I also want it to be that once my texture is changed, I’ll be able to destroy another game object.
So lets say I picked up the soap bar, and then I can destroy a virus simply by rolling over it, but ONLY if I have picked up the soap bar.
Right now, it always destroys the virus, no matter nor I’ve picked up the soap bar or not.
My scripts are:
The soap bar:
#pragma strict
var coinEffect : Transform;
var coinValue = 1;
var Soap : Texture2D;
var TheBall : Transform;
function OnTriggerEnter (info : Collider)
{
if (info.tag == "Player")
{
GameMaster.currentScore += coinValue;
var effect = Instantiate(coinEffect, transform.position, transform.rotation);
Destroy(effect.gameObject, 3);
Destroy(gameObject);
TheBall.renderer.material.mainTexture = Soap;
}
}
The virus:
#pragma strict
var coinValue = 1;
var TheBall : Transform;
function OnTriggerEnter (info : Collider) {
if (info.tag == "Player")
{
GameMaster.currentScore += coinValue;
var effect = Instantiate(coinEffect, transform.position, transform.rotation);
Destroy(effect.gameObject, 3);
Destroy(gameObject);
}
}
So what do I have to add to make it so that I can only destroy the virus once I have picked up the soap?