I got a problem with my character’s collision: nothing happen when he get hit by the enemy’s bullets (trigger or not). When a bullet hit him, he don’t loss from his health, I checked many times if I add a tag to the bullets and if all the bullets are triggers.
This it part of my character’s code:
function OnTriggerEnter ( hit : Collider)
{
//pick ups
//works perfect
if (hit.gameObject.tag == "bombPick")
{
bombAmmo += 5;
Destroy(hit.gameObject);
}
if (hit.gameObject.tag == "telePick")
{
teleAmmo += 4;
Destroy(hit.gameObject);
}
if (hit.gameObject.tag == "rocketPick")
{
rocketAmmo += 2;
Destroy(hit.gameObject);
}
if (hit.gameObject.tag == "healthCapsule")
{
if (healthBarDisplay <= 0.6)
{
healthBarDisplay += 0.4;
Destroy(hit.gameObject);
}
else
{
healthBarDisplay = 1;
Destroy(hit.gameObject);
}
}
//enemy hits
//don't works
if (hit.gameObject.tag == "STBullet")
{
gotHit = true;
healthBarDisplay -= 0.07;
yield WaitForSeconds (5.0);
gotHit = false;
}
if (hit.gameObject.tag == "LIBullet")
{
gotHit = true;
healthBarDisplay -= 0.15;
yield WaitForSeconds (5.0);
gotHit = false;
}
if (hit.gameObject.tag == "RHBullet")
{
gotHit = true;
healthBarDisplay -= 0.1;
yield WaitForSeconds (5.0);
gotHit = false;
}
if (hit.gameObject.tag == "SPBullet")
{
gotHit = true;
healthBarDisplay -= 0.16;
yield WaitForSeconds (5.0);
gotHit = false;
}
if (hit.gameObject.tag == "SPDrop")
{
gotHit = true;
healthBarDisplay -= 0.2;
yield WaitForSeconds (5.0);
gotHit = false;
}
if (hit.gameObject.tag == "BEBullet")
{
gotHit = true;
healthBarDisplay -= 0.2;
yield WaitForSeconds (5.0);
gotHit = false;
}
}
If you think it because I loss too low health so I can’t see I lost - you wrong, 100% of the health is 1, so 10% is 0.1.
Another problem with the character collision: I made an ice that should break when something collide with it (if it the character, enemy or something thet fall on it).
When my character collide with it, it don’t break and it only with my character!
This is the ice’s code:
function OnCollisionStay ( collision : Collision)
{
print(collision);
Destroy(gameObject, 0.5);
}
How I make my character have a collision with the bullets and the ice?? My character have CharacterController and Capsule Collider that I added to try solve the problem, and it didn’t helped…
Sorry for poor english.