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 /
  • Help Room /
avatar image
0
Question by AHAKuo · Mar 13, 2020 at 12:46 PM · 2d2d gameunity 2dboxcollider2d

Why isn't my BoxCollider2D doing anything?

I'm trying to make a speech bubble appear when you approach the tutorial board.

alt text

The bubble is there and it has its animation states "Appear" and "Disappear"

Appear is called OnTriggerEnter2D

Disappear is called OnTriggerExit2D

The collider is on the parent, tutorial board alt text

The animator and script is on the bubble itself Can't add more images due to rules.

This is the script I have attached to the bubble, the conditions script.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Conditions : MonoBehaviour
 {
 
     private Animator bubblecondition;
     private BoxCollider2D boxCollider;
 
     // Start is called before the first frame update
     private void Awake()
     {
         bubblecondition = this.GetComponent<Animator>();
         bubblecondition.Play("Disappear", 0, 1f);
     }
     void Start()
     {
         //bubblecondition.SetBool("Here", false);
         boxCollider = this.GetComponentInParent<BoxCollider2D>();
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 
     public void OnTriggerEnter2D(Collider2D other)
     {
         if (other.tag == "Player")
         {
             bubblecondition.Play("Appear", 0, 0f);
         }
         else
         {
             return;
         }
     }
 
     public void OnTriggerExit2D(Collider2D other)
     {
         if (other.tag == "Player")
         {
             bubblecondition.Play("Disappear", 0, 0f);
         }
         else
         {
             return;
         }
     }
 }


What am I doing wrong? I spent an hour trying to know why. I even tried to have the console write a message on collision but it's just dead. Help me see my mistake :)

annotation-2020-03-13-154005.png (319.5 kB)
annotation-2020-03-13-154005.png (319.5 kB)
Comment
Add comment · Show 1
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 AHAKuo · Mar 13, 2020 at 12:53 PM 0
Share

Also, before you ask, every other item (collectible) in the game works well. The player has a rigidbody component. Everything else that has a collider is working well.

It's just this one collider.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by AHAKuo · Mar 13, 2020 at 02:47 PM

SOLVED

I simply put the conditions script on the board itself and referenced the collider as private BoxCollider2D directly. This fixed it oddly. Don't know exactly why that was happening.

Comment
Add comment · Show 2 · 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 streeetwalker · Mar 13, 2020 at 03:03 PM 1
Share

you beat me to it! Trigger finger is faster than the submit finger ;-)

avatar image AHAKuo streeetwalker · Mar 13, 2020 at 08:36 PM 0
Share

lmao. All good. Actually, your comment helped me understand it. $$anonymous$$y fix was arbitrary and I didn't even know why it worked xD

avatar image
0

Answer by streeetwalker · Mar 13, 2020 at 03:00 PM

Hi @AHAKuo, It looks like that If this script is on the Bubble, trigger is never going to fire because the object with the trigger collider is it's parent object.

Not sure what you are trying to do with this:

boxCollider = this.GetComponentInParent();

but that does not make the parent object own the OnTrigger statements in this script. I'm guessing bubble does not have a trigger collider, nor would it work because (I gather) it's inactive.

Put this script on the Tutorial Board. Then OnTrigger will catch the collision events.

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 AHAKuo · Mar 13, 2020 at 08:35 PM 0
Share

Thank you so much for making me understand it! It makes sense now. God, I must've spent 2 hours actually. Waste of time

Thanks a lot. This is new information for me ^^

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

346 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 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 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

Virtual controller and fire bullet shot in 2D 0 Answers

how to make my 2d top down character face the direction of the cursor 1 Answer

Problem with tracking multiple object with multitouch 0 Answers

How do I turn off the previous object? 1 Answer

how can I make my bubbles created by this wave spawner move as it is preset in its movement script, because now it only creates them in their respective spawn point, but it doesn't move to the end point. 0 Answers


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