0
\$\begingroup\$

(UPTADE) I am developing a 2D Topdown Rpg Game. I have a problem with trigger colliders. I have button which make active an object and ı use it like Hitbox when i press button ı destroy enemy if it is touching hitbox but there is a problem about something. When i press button enemy is destroyed if only enemy is moving when it stop i cant destroy it

How can I fix this?

This is my hitbox's destroy script

 private void OnTriggerEnter2D(Collider2D other)
    {

        if (other.tag == "Enemy")
        {
            Destroy(other.gameObject);
        }
    }
```
\$\endgroup\$
8
  • \$\begingroup\$ Can you describe what specific symptoms you mean by "not work" and "work"? \$\endgroup\$
    – DMGregory
    Mar 10, 2021 at 15:01
  • \$\begingroup\$ I tried to fix the grammar in your post. But for some cases I had to guess a bit because I wasn't really sure what you meant. Can you please read my edit and tell me if I understood everything correctly? \$\endgroup\$
    – Philipp
    Mar 10, 2021 at 15:03
  • \$\begingroup\$ I have Hitboxes for 4 way left right up and down. Normally when i press attack i destroy enemy but İf enemy touches my Players collider . My hitbox cant destroy enemy Sorry about my English \$\endgroup\$
    – Wallroad
    Mar 10, 2021 at 15:07
  • \$\begingroup\$ Sounds like you should show us your attack code and the configuration of these objects in your scene/inspector. \$\endgroup\$
    – DMGregory
    Mar 10, 2021 at 17:51
  • \$\begingroup\$ how can i send video? I have 2 short video. It explain what my problem is. \$\endgroup\$
    – Wallroad
    Mar 10, 2021 at 19:01

1 Answer 1

0
\$\begingroup\$

I fixed it. If anyone come across with same problem just add animation to collider because if you dont do that your collider wont be triggered

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .