|
var health = 10; var TakeDamage : boolean; function OnTiggerEnter(other : Collider){ if(other.tag == "Player"){ TakeDamage = true; } }
(comments are locked)
|
|
The function is OnTriggerEnter not OnTiggerEnter unless you are referring to the children's comic character!
+1
Jul 04 '12 at 11:20 AM
Bunny83
(comments are locked)
|
Please use code formating (select the code text and click the 1010101 button) when posting, as well as a copy of the error message in the future. You still have the Tigger thingy so it won't do. Also, does work. The compiler will cast the variable to the appropriate type.
Jul 04 '12 at 05:48 AM
fafase
Yup, updated just now. And yes it is valid. Without the #pragma strict. I usually get error on those. Credit goes to Mike
Jul 04 '12 at 05:51 AM
Linus
No, you don't get an error with In this cases the compiler can determine the type from the value you're assign to it, but that doesn only work when you assign a value at variable declaration. This will type the variable dynamicly: Avoid dynamically typed variables. They are slow and can cause strange errors at runtime. The compiler can't detect such errors since the type isn't known at compile time.
Jul 04 '12 at 11:19 AM
Bunny83
(comments are locked)
|

MIght need some clue as to what isn't working... You have two colliders I presume - at least one set to isTrigger = true and one of them having a rigidbody...
I answered var health : int = 10; but due to low karma my answer did not show up
What should the script do? Should it only set TakeDamage to true? Or should it also decrease the health?