function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == “EnemyHit”)
{
health.LIVES -=1;
Debug.Log(“Ramt”);
}
}
The things that it does not trigger the Collider.
The object there have the tag EnemyHit, is a Prefab there beening instantiate.
I have tried with
hit.Prefab.tag
hit.Clone.tag
But it doesn’t help
They litteraly touching each other, so i dont get it why i doesn’t trigger.
I have used the Debug.Log command to see if it trigger but it does not.
are you sure the object ur colliding with has that tag?
does on of the colliders have a rigidbody?
The other object needs a Collider as well.
Both of them got Box Collider and RigidBody
Does it matter that the gravity is off?
Collision should still work regardless of Gravity settings…
You can get the same effect using Triggers… That’s what I used for my FalloutDeath script, if the player walks into that (invisible) object, it’s a instant respawn after the screen fades.
function OnTriggerEnter (other:Collider)
{
//collision code
if(other.gameObject.tag == "Player"){
Debug.Log("OOPS: Player fell into the void!");
}else{
// Not the player? Kill it!
Debug.Log("OOPS: Object fell into the void. We don't give a s**t about it, so destroy it.");
Destroy(other.gameObject);
}
}
You should have some luck with that snippet. Make the box collider a trigger for this to work.
HandsomPatt
Coburn64
Thanks for your help, i have found the solution.
Instead of using
function OnControllerColliderHit(hit : ControllerColliderHit)
i have used
function OnCollisionEnter(collision : Collision)
Since the 2 objecter is going though each other.
thanks for the help
—===!!!T.O.P.I.C I.S. C.L.O.S.E.D S.O.L.U.T.I.O.N H.A.V.E B.E.E.N F.O.U.N.D!!!===—