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 Persona · Jun 20, 2010 at 08:10 PM · collisionparticles

Use OnCollision to trigger particle activation

I'm trying to set up a script where upon contact with the player, a crystal will start to emit particles. However, it seems like nothing is happening when they collide. Is there something wrong with this script I wrote?

function OnCollisionEnter( collision : Collision ){
if (collision.gameObject.tag == "Player"){
particleEmitter.enabled = true;
Score.Crystal ++;
}
}
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
2
Best Answer

Answer by BoredKoi · Jun 21, 2010 at 06:16 PM

There is nothing "wrong" with the script you wrote. There are, however, obviously issues with the how the Game Objects are interacting when you run your game.

The console print idea is valid enough for debugging within the current Unity iPhone product. I would start with something simpler, however:

function OnCollisionEnter( collision : Collision )
{
    print(collision.gameObject.name);
}

If you are seeing no Collision messages, then you are (most likely) missing a Rigidbody for one of the two colliding objects.

Box Collider Script Reference

Check the matrix at the bottom -- that will tell you how Collision and Trigger messages are generated.

Lastly, once you get past that issue, make sure to disable or otherwise remove print / Debug.Log messages from your final release product. They are unkind to performance.

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 Persona · Jun 21, 2010 at 07:17 PM 0
Share

Thanks for the answers, I'll try them now

avatar image
0

Answer by AnaRhisT · Jun 20, 2010 at 08:17 PM

arrange ur scripts, be smart, put prints! Does it print on collision?

function OnCollisionEnter( collision : Collision ){
if (collision.gameObject.tag == "Player"){
  print("There's a collision");
 }
}
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 Peter G · Jun 20, 2010 at 09:07 PM 0
Share

This is not so much an answer but a suggested technique for finding the answer.

avatar image AnaRhisT · Jun 20, 2010 at 09:52 PM 0
Share

Exactly. I don't need to feed him with a spoon, but to show him how to eat. people who de-reped me why don't u show ur answers?

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Pong game collision problems 1 Answer

World particles collider scriptable? 1 Answer

How do I detect world particle collisions in Unity4.0? 0 Answers

Keep particles to defined area, destroy on 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