I have visited many forums for this problem and I have searched lots of tutorials for this issue. Here's my code:
private void OnTriggerEnter(Collider collision)
{
GameObject collisionGameObject = collision.gameObject;
if (collisionGameObject.name == "playerBullet")
{
Debug.Log("damage taken");
TakeDamage(40);
}
}
I should be doing everything right, what went wrong?
Make sure of the following things:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.