- Home /
please need a littlebit of help with a ForceShield
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;
}
Answer by Ermarrero · Apr 07, 2014 at 01:10 AM
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);
}
Your answer
Follow this Question
Related Questions
physical force feedback 0 Answers
Make UI elements invisible 4 Answers
Can you use renderer.enabled on array members ? 3 Answers
Unity 2019.4.9f1 - Toggle Show/Hide Gameobject with one keystroke. 1 Answer