Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 17, 2020 at 04:22 PM by Vandal16.
avatar image
0
Question by Vandal16 · May 13, 2020 at 03:36 PM · 2d gamehealth

Enemy Boss doesn't take damage.

I have a problem with my enemy boss. When I shoot at him I deal no damage to him. When I shoot at my other enemy (not a boss :P) he recieves the damage. On the boss I have attached Rigidbody2D (which is set to Kinematic) a Circle and Box Collider2D(is Trigger off), I have this script attached to the boss:

using UnityEngine;

public class BossHealthTEST : MonoBehaviour { public int health; //<- Type health amount here

 public GameObject deathEffect;

 public void TakeDamage(int damage)
 {
     health -= damage;

     if (health <= 0)
     {
         Die();
     }
 }

 void Die()
 {
     Instantiate(deathEffect, transform.position, Quaternion.identity);
     Destroy(gameObject);
 }

}

And this is the script for my other enemy that takes the damage when I shoot at him. Honestly Iam a newbie that's why I ask for help with this simple script ... :P

using UnityEngine;

public class Enemy : MonoBehaviour { public int health = 100;

 public GameObject deathEffect;
 
 public void TakeDamage (int damage)
 {
     health -= damage;

     if (health <= 0)
     {
         Die();
     }
 }
 
 void Die()
 {
     Instantiate(deathEffect, transform.position, Quaternion.identity);
     Destroy(gameObject);
 }     

}

Comment
Add comment · Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Morphosys · May 13, 2020 at 04:41 PM 1
Share

Quick question @Vandal16 : are you modifying the health inside your inspector before pressing play ?

avatar image Vandal16 Morphosys · May 13, 2020 at 05:04 PM 0
Share

Yes but earlier I went with "public int health = 100;" and it also did not helped.

avatar image Eudauminiac · May 13, 2020 at 05:52 PM 0
Share

It sounds like it is a trigger issue. Is the triggering/collision setup identically on the boss and non-boss?

avatar image Vandal16 Eudauminiac · May 13, 2020 at 06:01 PM 0
Share

I think yes ;/

avatar image Eudauminiac Vandal16 · May 13, 2020 at 06:05 PM 0
Share

It is all I can think of. Perhaps share screenshot of RigidBody and Collider setup of both entities?

Show more comments
avatar image Snepple · May 13, 2020 at 06:34 PM 0
Share

Where are you calling the TakeDamage()function from? $$anonymous$$ay we see what's supposed to be triggering the function?

avatar image Vandal16 Snepple · May 13, 2020 at 06:49 PM 0
Share

I am searching it in my scripts but i can't find it. $$anonymous$$aybe I've never created that one and that may be the problem ? But it is weird I have the TakeDamage() function in my other enemy too and it works fine...

2 Replies

  • Sort: 
avatar image
0

Answer by DisuraRandunu · May 14, 2020 at 09:30 AM

I think it's because of the kinematic. There should be a non-kinematic rigidbody for Colliders to work

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vandal16 · May 14, 2020 at 02:31 PM 0
Share

If you mean by that the "Body type" like Dynamic,Static i tried them all.

avatar image
0

Answer by DisuraRandunu · May 13, 2020 at 04:41 PM

@Vandal16 Even if the above answer doesn't help and you have some value in health, then the issue is about the boss being kinematic. Colliders doesn't work in non-kinematic rigidbody i think..

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vandal16 · May 13, 2020 at 05:05 PM 0
Share

Sadly it doesn't work. I tried also with dynamic,static etc. different settings in the colliders,rigidbody and none helped...

Follow this Question

Answers Answers and Comments

164 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Drag and release 2 Answers

What resolution to make retro pixel game to scale up to HD? 1 Answer

Issue with swapping Player sprite when health lowers - Not sure how to fix 1 Answer

health decrease only once and stop player movement 1 Answer

How To Save Health Between Scenes 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges