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 AtomicMarine · Dec 16, 2011 at 09:17 PM · collisiontriggerobjectcollide

Objects Touching?

I'm currently struggling with checking if two objects are touching but didn't collide this is because for a certain sword swing I am moving the position of the sword forward rapidly meaning it doesn't actual collide with the enemy but has it's position in the enemy so that they are touching. when i move the character the enemy dies but not when both are stationary and the player attacks?

How can I check that two objects are touching but didn't collide?

The code I'm currently using, it works when the enemy or the player is moving and the sword is swung but if both the enemy and player are standing still the script doesn't destroy the object

here is the code

 function OnCollisionStay (collision : Collision) {
     if (collision.gameObject.tag == "RedEnemy"){
         
     Destroy(collision.gameObject);
     }
 }


EDIT I noticed that a lot of people view this question with presumably the same problem? If that is the case I would like to inform the community that I ended up using a system where I got the distance between the players and enemies to figure out weather they were touching or not as this system is much more reliable than Unity Collision system (which has its place to work). I have since stopped working not his project so can provide no other feedback to it.

Comment
Add comment · Show 4
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 4illeen · Dec 16, 2011 at 09:24 PM 0
Share

So you say that collision works when you move your character? $$anonymous$$aybe you should change collision to trigger (it can be checked on colliders) and if OnTriggerEnter doesn't work, maybe OnTriggerStay/OnCollisionStay? But then you'd need to make some checks so that the enemy dies only once

avatar image AtomicMarine · Dec 16, 2011 at 09:39 PM 0
Share

I tried trigger enter >.< didn't work am going to experiment with CollisionStay

avatar image 4illeen · Dec 16, 2011 at 09:41 PM 0
Share

can you post your code? It's going to be easier to check what's wrong

avatar image AtomicMarine · Dec 17, 2011 at 12:40 PM 0
Share

Posted the code above ^^ thanks for your time eh

1 Reply

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

Answer by Montraydavis · Oct 30, 2012 at 04:32 PM

 if (collision.gameObject.tag == "RedEnemy"){
 
     Destroy(collision.gameObject);
 }

should be. . . .

 if (collision.collider.tag == "RedEnemy"){
 
     Destroy(collision.gameObject);
 }
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 AtomicMarine · Oct 30, 2012 at 04:33 PM 0
Share

Thanks :)!

avatar image Montraydavis · Oct 30, 2012 at 04:36 PM 0
Share

You are very welcome! I am glad that this has solved your issue :)

Thanks for supporting Unity3D

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

6 People are following this question.

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

Related Questions

how to make a script when u collide with an object it disappears 3 Answers

collision with objects, physics 1 Answer

2D game object trigger 1 Answer

Detecting another object collision from another object script (2D) 0 Answers

How can I make a sound deploy after colliding with a certain object (or terrain)? 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