I’m new to unity and trying to make a little game.
I have a conveyor belt with spawning cubes and I’m able to make a cube visible (cube.active = true) on my forklift when I touch a cube with it.
What I’m trying to do is that when my forklift touches a particle object (fire) the cube then deactivates.
I’ve tried it with different objects and the only time it deactivates is when I make the forklift touch a cube.
static var itemAttached = false;
var carbonCubes : GameObject;
var copperCubes : GameObject;
var goldCubes : GameObject;
carbonCubes.active = false;
copperCubes.active = false;
goldCubes.active = false;
function OnCollisionEnter(hit : Collision){
if(hit.gameObject.name == 'Gold(Clone)' && itemAttached == false){
itemAttached = true;
goldCubes.active = true;
}
if(hit.gameObject.name == 'Carbon(Clone)' && itemAttached == false){
itemAttached = true;
carbonCubes.active = true;
}
if(hit.gameObject.name == 'Copper(Clone)' && itemAttached == false){
itemAttached = true;
copperCubes.active = true;
}
if(hit.gameObject.name == 'Flames2' && itemAttached == true){
itemAttached = false;
goldCubes.active = false;
copperCubes.active = false;
carbonCubes.active = false;
}
}