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 /
This question was closed Jun 21, 2014 at 02:36 PM by Neel-Frost for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by Neel-Frost · Jun 12, 2014 at 04:28 PM · item pickupcollid

function OnCollissionEnter not working

I am trying to make a pickup script in which when the player collides with the object the object gets destroyed.But this does not seems to work.Please help.

var player : Transform; function OnCollissionEnter(info : Collision ) { if(info.gameObject.name == "player") { Destroy (gameObject); } }

Comment
Add comment · Show 1
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 legion_44 · Jun 12, 2014 at 04:35 PM 0
Share

Please use the code tag when writing code (the 101 010 button)

1 Reply

  • Sort: 
avatar image
3

Answer by tanoshimi · Jun 12, 2014 at 05:08 PM

It's OnCollisionEnter() <-- one "s"

Comment
Add comment · Show 4 · 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 Neel-Frost · Jun 15, 2014 at 03:56 PM 0
Share
 function OnCollisionEnter(info : Collision)
         {
         if(info.gameObject.tag == "player")
         {
         Destroy(gameObject, 1); 
         }
         }
 

this is the script.The script is still not working please help

avatar image tanoshimi · Jun 15, 2014 at 07:24 PM 1
Share

"Not working" is not a sufficient description for anyone to help you. What happens? Error message? Does the method get called at all? Does the player have a rigid body and collider component attached, and are they tagged "player"?

avatar image Kiwasi · Jun 15, 2014 at 07:27 PM 1
Share

Drop the info. Tags are case sensitive. $$anonymous$$ake sure the player is tagged properly. Also check there are colliders on both objects and a rigidbody on at least one of them.

avatar image Neel-Frost · Jun 17, 2014 at 06:01 AM 0
Share

thanks for replying but ins$$anonymous$$d of using OnCollisionEnter() i used OnControllerColliderHit(hit: ControllerColliderHit) and tagged the ammo box with box and now it works. Thanks for trying to help me.

Follow this Question

Answers Answers and Comments

23 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 avatar image avatar image

Related Questions

Use editor icons in game? 2 Answers

How to respawn items along with player 1 Answer

Check Colliders in X or Y axis separately 0 Answers

Trying to destoy an object can a transform be hardcoded? 2 Answers

Item collection in specific sequence. 2 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