Aliright I made a script which when the player hits it it turns something off and another when it hits turns it back on here is the script. (Both similar just false/true is different
using UnityEngine;
using System.Collections;
public class BuildingExitEnterFalse : MonoBehaviour {
public GameObject BuildingTop;
public GameObject Player;
void OnTriggerEnter(Collider other)
{
if(Player)
{
BuildingTop.SetActiveRecursively(false);
}
}
}
It works as it should but if my player shoots and the bullets hit the collider it occurs which is VERY bad. I tired this but it didnt work
using UnityEngine;
using System.Collections;
public class BuildingExitEnterFalse : MonoBehaviour {
public GameObject BuildingTop;
public GameObject Player;
public GameObject PistolBullet;
void OnTriggerEnter(Collider other)
{
if(Player)
{
BuildingTop.SetActiveRecursively(false);
}
if(PistolBullet)
{
Destroy(PistolBullet);
}
}
}
Any suggestions?
And if this helps here is the script that spawns the bullet
void PistolShoot ()
{
tempVector = Quaternion.AngleAxis(8f, Vector3.up) * inputRotation;
tempVector = (transform.position + (tempVector.normalized * 0.8f));
GameObject objCreatedPistolBullet = (GameObject) Instantiate(ptrScriptVariable.objPistolBullet, tempVector, Quaternion.LookRotation(inputRotation) ); // create a bullet, and rotate it based on the vector inputRotation
Physics.IgnoreCollision(objCreatedPistolBullet.collider, collider);
VariableScript.pistolammo -= 1;
print("ammo is now: "+VariableScript.pistolammo);
GameObject.Find("g_Ammocounter").guiText.text = ""+VariableScript.pistolammo;
}