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 TheTb0 · Feb 08, 2013 at 02:37 PM · collisioncollisiondetection

Collision not being detected?

I have had a problem with a collision detection that is meant to cause a few events to take place, but the collision itself is not being registered so the events are not being triggered.

this is the first code for the first collision (of 2):

”

var Collectible2 : GameObject; var GUI1 : GUIText;

function OnCollisionEnter( collision : Collision ) { if ( collision.gameObject.Name == “Graphics” ) { Debug.Log( “Collision: Detected (Graphics)” ); Destroy( gameObject.Find(“Collectable1″) ); transform.GUI1.Text( “Well Done!” ); yield WaitForSeconds(5); Collectible2.MeshRenderer.Enabled = true; Collectible2.Collectible2Script.Enabled = true; Collectible2.ParticleRenderer.Enabled = true; transform.GUI1.Text( “Now Find The Second Collectible >:D” ); yield WaitForSeconds(5); transform.GUI1.Text( “” ); } } ”

and this is the second (Not sure if this one isn’t working as that code is meant to set it off):

”

var EndGame : String;

function OnCollisionEnter(EndGameCollision : Collision) { if(EndGameCollision.gameObject.name == “Graphics”) { Application.LoadLevel(EndGame); Debug.Log(“Collision: Detected (Graphics)”); } } ”

I also originally had all of the script on one document:

”

var readynow : boolean = true; var seconds : float = 5; var gui : GUIText; var nextlevel : String; var collectible1 : GameObject; var collectible2 : GameObject; var Spawnpoint : GameObject;

function OnCollisionEnter(Collectible : Collision) { if(Collectible.gameObject.name == “floor2″) { Debug.Log(“Collision: Detected”); } if(Collectible.gameObject.name == collectible1) { Debug.Log(“Collision: Detected”); destroy(); create(); GUIdisplay(); if(Collectible.gameObject.name == collectible2) { Debug.Log(“Collision: Detected”); destroy2(); } } }

function destroy() { readynow=false; Destroy(gameObject.Find.collectible1); yield WaitForSeconds(seconds); Destroy(gameObject.Find.Spawnpoint); } function create() { readynow=false; Instantiate(gameObject.Find.collectible2, Spawnpoint.position, Spawnpoint.rotation);

} function GUIdisplay() { transform.gui.Text(“Well Done! Now Find The Second Collectable”); } function destroy2() { readynow=false; Destroy(gameObject.Find.collectible2); Application.LoadLevel(nextlevel); } ”

but I don’t need that one analysing, just the other two (albeit more efficient, I am a beginner so I should probably just stay with the other two)

So, what can I do to fix these problems?

thanks, Tim

Comment
Add comment · Show 2
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 Landern · Feb 08, 2013 at 02:39 PM 0
Share

edit your post, highlight each portion that is your code/script and clicky the 101010 button, you can't read(don't want to try) that up there.

avatar image GC1983 · Feb 08, 2013 at 06:05 PM 0
Share

Try OnTriggerEnter() ins$$anonymous$$d.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DeBunked · Feb 08, 2013 at 05:57 PM

Make sure one of the colliding objects has a rigid body attached to it.

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 GC1983 · Feb 08, 2013 at 06:04 PM 0
Share

Rigidbody has nothing to do with collision issues. Rigidbody is for physics.

avatar image DeBunked · Feb 08, 2013 at 06:57 PM 0
Share

Rigidbodies do play a part in several forms of collisions, especially ones that make use of PhysX.

http://docs.unity3d.com/Documentation/Components/class-$$anonymous$$eshCollider.html (table at the bottom for further reference)

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

12 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

Related Questions

Getting sprites to stop going through one another? 1 Answer

Collision Enter one of the objects ? 1 Answer

Obstacle avoidance 1 Answer

Collision detection for sprite 1 Answer

How does Unity detect collision? 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