I am making a game where the player has to pick up chemicals and craft them. How would I make a script that would, on collision, delete the gameobject, and add to a global var?
This is what I have (includes the crafting script)
on the player
static var onumber : int = 10;
static var hnumber : int = 10;
var water : int = 10;
var HP : int = 10; //HP stands for Hydrogen Peroxide
function Update(){
if(Input.GetKeyDown(KeyCode.Z)){
if(onumber > 0){
if(hnumber > 1){
onumber -= 1;
hnumber -= 2;
water += 1;
}
}
}
if(Input.GetKeyDown(KeyCode.X)){
if(onumber > 1){
if(hnumber > 1){
onumber -= 2;
hnumber -= 2;
HP += 1;
}
}
}
if(Input.GetKeyDown(KeyCode.I)){
onumber += 1;
}
if(Input.GetKeyDown(KeyCode.O)){
hnumber += 1;
}
}
and on the chemical (dropped)
static var onumber;
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.tag == "Player"){
onumber += 1;
Destroy(collision.gameObject);
}
}
what did I do wrong?
-Thanks, this is REALLY urgent!!!
I need this done by tomorrow!!!