|
hey i was wondering if someone could help me i am new to scripting and think that my script should work but i have a problem that when i shoot my projectile prefab it hits the game object wich the script is atached to it gets destroyed but the game object the script is atached to dosent so its like projectile>hit game object>destroy projectile> then nothing when it should be projectile>hit game object>destroy projectile>destroy game object anyway hear is the script var Projectile = gameObject; //var Item = gameObject; function OnControllerColliderHit (hit : ControllerColliderHit) { Destroy (Projectile); Destroy (gameObject); }
(comments are locked)
|
|
According to your script, you are trying to set the projectile with the gameObject your script is attached too and you do that at initialization time, which you may not do. // This is not good: var Projectile = gameObject; gameObject with a lower case g, is always the instance of the game object your script is attached too. So you basically you are trying to tell the program to destroy the gameObject twice. It is more likely you want something like this:
(comments are locked)
|

Aren't you getting the following error in the console:
"ArgumentException: You are not allowed to call get_gameObject when declaring a variable."?
(CTRL + SHIFT + C to open the console if it is not)