|
How would I perform a check to see if an instantiated object (like a bullet) were to hit an other game object (like an enemy)? I am new to this sorry if this question is noobie Thanks in advance
(comments are locked)
|
|
You probably want to use tags on the objects you want the collision to interact with, and then check the tag of the object you hit, like this: Thanks mate :) working awesomely
Jan 06 '11 at 07:55 PM
AtomicMarine
function OnCollisionEnter(collision : Collision) { Destroy(gameObject); if (collision.gameObject.tag == "Enemy1"){ } } oops had to modify code alil for on collision enter function above is final code
Jan 06 '11 at 08:04 PM
AtomicMarine
hmm... CompareTag does the same thing as that, except it is a little more optimized and is suggested that you use it. http://unity3d.com/support/documentation/ScriptReference/Component.CompareTag.html
Jan 06 '11 at 08:52 PM
PrimeDerektive
oh dang, it does, my bad, thanks changed it now
Jan 06 '11 at 09:12 PM
AtomicMarine
(comments are locked)
|
