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 Sep 02, 2013 at 05:38 AM by Fattie for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by FlammingFart · Mar 08, 2013 at 05:12 PM · parentingpickup

looting an item

how about a looting script or parenting an object to the player.. ex. you have an object in front of you then when you step on it, something will appear on the screen then when you press F you can have the object..

the "something will appear on the screen" is just an option i can do that. the main question is how can you have that object?

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

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by LightSource · Mar 08, 2013 at 10:23 PM

Updated:

 var loot : GameObject;
 var near : boolean = false
     
 function OnCollisionEnter (loot : player) {
     
 Debug.Log("You are stepping on an object, press F to pick it up");
 
 near = true;
 
 }
 
 function OnCollisionExit (loot : player) {
 
 near = false;
 
 }
 
 function Update {
 
 if (Input.GetKeyDown ("F") && near == true) {
     
 //Do stuff
     
 }
 }
     
 
Comment
Add comment · Show 14 · 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 FlammingFart · Mar 24, 2013 at 02:37 PM 0
Share

what do you mean my "Do stuff?"

avatar image Tim-A · Mar 24, 2013 at 02:39 PM 0
Share

They mean that you have to put in what it's going to do. What do you want to have happen when you're standing on it.

avatar image MadJohny · Mar 24, 2013 at 02:40 PM 0
Share

you decide that, example for picking up..... a key, "Do stuff" shoud be replaced like keys += 1. if you don't know what += means it's exactly the same as key = key + 1 for example

avatar image LightSource · Mar 24, 2013 at 02:42 PM 0
Share

I mean do what ever you want your player to do. It could be play sound, destroy the object, start an animation, it's for you to add script to do what ever you want your player to do. We can't write the whole script for you, we don't even know what your game is. You will see variations of this in alot of scripts as to give a nudge in the right direction.

avatar image AlucardJay · Mar 24, 2013 at 02:50 PM 0
Share

DO STUFF ! $$anonymous$$ake it Happen !! Very clear !!!

Show more comments

Follow this Question

Answers Answers and Comments

14 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

Related Questions

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

Swapping Weapons In Game 0 Answers

Make it Spawn 1 Cube instead of infenity 1 Answer

Gun swap through pickup? 2 Answers

Strange GOs Bounce after parenting 2D game 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