Hey guys this script does not work propperly cn you help me?
its attached to a sphere that simulates a force Shield. and my idea was to get the forseshield ony able to see when its been hit by my machine gun script wich is attachted to my space ship
function Awake (){
gameObject.renderer.enabled = false;
}
function Update () {
}
function OnTriggerEnter (hit : Renderer)
{
GameObject.FindGameObjectWithTag("Shield");
hit.gameObject.renderer.enabled = true;
}
instead of enabling and disabling the renderer why don’t you alpha fade the material? but to go back to your question the problem is your running the FindGameObjectWithTag but it doesn’t have a pointer or variable to store the results. Try this approach instead:
//Add this to your projectile gameobject. Add a Collider and Rigidbody to it and check isTrigger
function OnTriggerEnter ( hit : Collider)
{
if(hit.tag == "Shield") hit.gameObject.renderer.enabled = true;
Debug.Log(this+" Collider hit: "+hit);
}