Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by shraa1 · May 09, 2014 at 05:05 PM · rigidbodyontriggerenter

Issues with collision detection

i have 2 objects... one is named Block and the other is Hole... The block has 4 child empty objects that have box colliders with custom sizes, according to need... The hole object has a rigidbody, with gravity=false, and a box collider with isTrigger=true... for each child object in the BLOCK object, there is a code for movement when mouse is clicked on it... When the block enters the hole object, it does not trigger the OnTriggerEnter function... what do i do?

using UnityEngine; using System.Collections;

public class StopBlockMovement : MonoBehaviour {

     // Use this for initialization
     void Start(){}
     
     // Update is called once per frame
     void Update()
     {
     }
 
     void OnTriggerEnter(Collider other)
     {
         Debug.Log("a");
     }

I tried this on script on both items does not show collision...

script for movement in the child empty objects is:

     bool pressed=false;
 
     // Use this for initialization
     void Start(){}
     
     // Update is called once per frame
     void Update()
     {
         if(pressed==true)
         {
             transform.parent.Translate(Vector3.down*Time.deltaTime*2);
         }
         if(transform.parent.position.y<-6.5)
         {
             Destroy(transform.parent.gameObject);
         }
     }
 
     void OnMouseDown()
     {
         pressed = true;
     }
 
Comment
Add comment
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

2 Replies

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

Answer by shraa1 · May 12, 2014 at 02:46 PM

actually i got it answered myself... i just added rigid-bodies to the child objects... and the first script in each child... thanx for the help, though :)

Comment
Add comment · 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
0

Answer by VIPINSIRWANI · May 09, 2014 at 05:27 PM

First you should give the tag to other object and after that Once try with this Code may it will help you

 void OnTriggerEnter(Collider cldr)
   {
     if(cldr.gameObject.tag == "whatever you gave" )
      {
 
         Debug.Log("Trigger Enter is Working");
      }
   }
Comment
Add comment · 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

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

21 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

Related Questions

OnTriggerEnter not firing if rigidbody is on its side 0 Answers

Can't get trigger to work 1 Answer

Point of contact on other object in OnTriggerEnter 1 Answer

Problem with OnTriggerEnter not triggering 1 Answer

Does an asleep rigidbody mess with the OnTriggerEnter function? 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