Hi Guys,
Somehow, when the enemyLaser prefab hits the heroship, the heroship died.
But when the heroship knocks against other enemy ship(tag:enemy), nothing happens. They just passby each other, thats all.
Below is the script:
function OnTriggerEnter(enemy : Collider)
{
print(enemy.tag);
if (enemy.tag == "enemyLaser" || enemy.tag == "enemy")
{
Destroy(this.gameObject);
}
I did some print testing, I realize, the hero ship isn’t reacting to enemy ships at all.
below is the setting my prefab objects ( I put under code format so it’s easier to see):
My hero ship is rigidbody, IsKenmatic Off, IsTrigger Off
My laser is rigidbody, IsKenmatic Off, IsTrigger On
Enemy ship is rigidbody, IsKenmatic Off, IsTrigger off
Wave of enemy (the sub enemy ships, not the empty game object)
is rigidbody, IsKenmatic On, IsTrigger off
Be it is the enemy ship or wave of enemy, it just didn’t trigger at all. Any advice?
Thanks in advance!
You will not get any OnTriggerEnters for anything that has isTrigger = false - instead you will get OnCollisionEnter (which has a Collision as a parameter not a Collider - so watch for that).
For your ship to ship collisions:
function OnCollisionEnter(collision : Collision) {
if(collision.collider.gameObject.tag == "enemy") {
}
}
What kind of Colliders are you using? Two Mesh Colliders only see each other, if at least one of them is set to Convex.
Hi Guys,
Just to update,
For question (2), I couldn’t edit to remove it or new comment so I put as answer.
I understood it by reading the documentation, [http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html
][1]
[1]: http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html
scroll all the way, the matrix table is the guide all the issues.
My enemy ships (individual) aint’ moving because it’s off IsKinematic, if I turn on IsKinematic, it won’t react my heroship.
I did the same as I did with my wave of enemy ships,
- I created a prefab empty object,
added rigidbody, &
- attached the
enemyship to empty prefab, turn On IsKinematic
Now is working fine, I’m curious is there any other ways to do it?