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 zac 1 · Dec 13, 2010 at 10:16 PM · objectdestroy

destroy object collision problem

I have a mouse script where to drag the object A...

var screenSpace;

var offset;

function OnMouseDown(){ //translate the cubes position from the world to Screen Point screenSpace = Camera.main.WorldToScreenPoint(transform.position);

 //calculate any difference between the cubes world position and the mouses Screen position converted to a world point  
 offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x,Input.mousePosition.y, screenSpace.z));

}

/ OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse. OnMouseDrag is called every frame while the mouse is down. /

function OnMouseDrag () { //keep track of the mouse position var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);

 //convert the screen mouse position to world point and adjust with offset
 var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;

 //update the position of the object in the world
 transform.position = curPosition;

}

THen I apply the destroy script to object B..

function OnTriggerEnter(hit:Collider){
    if(hit.gameObject.tag=="cube"){
        Destroy(gameObject);
    }
}

Object A have collision Object B is mark isTrigger

when I drag the Object A to object B.. Object B does not destroy.. How can I fix it?Blockquote

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

1 Reply

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

Answer by skovacs1 · Dec 13, 2010 at 10:32 PM

OnTriggerEnter is not being fired. From the docs:

Note that trigger events are only sent if one of the colliders also has a rigid body attached.

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 zac 1 · Dec 14, 2010 at 02:44 AM 0
Share

Thanks~! it works perfect by just adding rigid body..

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

No one has followed this question yet.

Related Questions

Destroying specific clone object while not destroying others on screen 5 Answers

Object won't instantiate at parents position(solved) 2 Answers

Destroy Object during animation 2 Answers

Why Can't I Destroy This Object? 4 Answers

Destroying the original object destroys all its clones? 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