I am trying to change a boolean in a different script On collision here is the code:
var script : Bullet;
function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.tag == "Weapon1"){
script.gun1 = true;
script.gun2 = false;
Debug.Log("cgfbkml");
}
if(collision.gameObject.tag == "Weapon2"){
script.gun1 = false;
script.gun2 = true;
Debug.Log("cgfbkml");
}
}
When i collide with the object i get the error message, the script i am getting the Boolean from is
var bulletSpawn1 : Transform;
var bulletSpawn2 : Transform;
var gun1 : boolean = true;
var gun2 : boolean = false;
function Update () {
GunsAndBullets();
}
function GunsAndBullets(){
if(gun1 == true gun2 == false){
if(Input.GetKeyDown(KeyCode.Mouse0)){
Instantiate(bulletSpawn1,transform.position, transform.rotation);
}
}
if(gun2 == true gun1 == false){
if(Input.GetKey(KeyCode.Mouse0)){
Instantiate(bulletSpawn2,transform.position, transform.rotation);
}
}
}
Any solutions thanks.