• 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 Envy · Feb 08, 2010 at 04:53 PM · physicsgraphics

Pickup Doesn't Pick up

I created a different look for the example FPS's health pickup Prefab out of basic transformed shapes from the Game object menu. I didn't want it to animate, i just wanted it to act like a regular object, so i added a rigidbody and a capsule collider. It works pretty well when just laying around, but when I apply the script, it uses the collider I made for something, and it automatically clicks "is Trigger" on that collider. I added another collider to a different part of the pickup ( a different shape ), but now its really hard to actually pick up. It seems to work sometimes when i drop it on the FPS Walker Preset's head, but I need it to be accesible from all angles and trajectories and everything. So does the pickup script use the actual object or the collider to determine when the player gets the health, or what is the problem with my approach?

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

3 Replies

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

Answer by e-bonneville · Apr 19, 2010 at 07:34 PM

Do what Skjalg said, except with one slight change that makes all the difference - make the new collider trigger the parent of your pickup. That way, when it's deleted, it kills the children - the pickup part.

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 user-1794 · Apr 28, 2010 at 02:06 AM 0
Share

THAN$$anonymous$$S! super helpful.

avatar image
0

Answer by Skjalg · Feb 08, 2010 at 05:10 PM

You need to have the collider (so it collides with the world) attached to the rigidbody. Then you make a child object and attach the pickup script there, which then creates a new collider (trigger), now make this trigger-collider bigger than the parents world-collider and it should work.

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 Envy · Feb 09, 2010 at 12:35 AM 0
Share

Your method leaves the parent object intact after usage. I also tried putting an empty gameobject as the parent and put the script there and it failed.

avatar image
0

Answer by GeneralGadd · May 03, 2010 at 09:48 PM

If it is just a pickup your after what I did is add a box collider to an object and added this script to the player not the object:-

    function OnControllerColliderHit(hit:ControllerColliderHit)
    {   
        if(hit.gameObject.tag == "key")
        {   
            Debug.Log("You picked up the key!");
            Destroy(hit.gameObject);
}

if you want it to unlock somehthing add this to the bottom

    var key : boolean = true; 
     audio.clip = keySound;
        audio.Play();
level_block = GameObject.Find("PortalBlock");
Destroy(level_block.gameObject);  
    }
    }

Comment
Add comment · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

GetPixel() returns only one value 2 Answers

Countdown little help...! 1 Answer

Is this a problem of unity 3 or i am doing something wrong. 1 Answer

Game build works fine in Android but is jittery in iPhone. 0 Answers

Collect some coins for Points 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