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 Jul 28, 2013 at 04:43 PM by robertbu for the following reason:

Multiple technical questions/Design discussion

avatar image
0
Question by MoradGM · Jul 28, 2013 at 03:49 PM · pickup

Picking up objects and dropping them

Hello. I want to add a functionality in my game to make the player able to pick up certain objects and dropping them.

The logic I want is that the player should move next to the object he wants picked up, then a GUI text shows up telling him "Press E to pickup/drop", and when he picks it up it should move infront of him while he is moving, and when he presses E again it should drop infront of him where he stopped (classic pickup/drop style.)

I am programming in C#, but I am missing the logic behind this. Can anyone please help? Pseudocode will be fine.

Comment
Add comment · Show 3
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 Lo0NuhtiK · Jul 28, 2013 at 04:37 PM 0
Share

Look at what you wrote.

The logic I want is that the player should move next to the object he wants picked up

Check the distance, or use collision.

then a GUI text shows up telling him "Press E to pickup/drop

Show gui text if distance is close or collided.

when he picks it up it should move infront of him while he is moving

If picked up, object becomes owned-by/parented-to the character, and it's position is set to some defined position in front of the character.

and when he presses E again it should drop infront of him where he stopped

If the button gets pressed again, object is disowned/unparented and (assu$$anonymous$$g it is a rigidbody that uses gravity) it falls to the ground.

avatar image robertbu · Jul 28, 2013 at 04:43 PM 1
Share

A question like this one that is more design discussion rather than solving a specific technical problem is not a good fit for Unity Answers. You have multiple technical questions here, with multiple different ways of solving them. There are also a number of posts on UA concerning pickup and drop. Research:

  • Input.Get$$anonymous$$eyDown() and Input.GetButtonDown() for getting the input.

  • OnCollisionStay() OnTriggerStay() and Vector3.Distance() for ways of detecting the object being near.

  • OnGUI for displaying messages.

  • Vector3.Lerp(), Vector3.$$anonymous$$oveTowards(), and making objects parents and children (Transform.parent) for picking something up.

If when you put together your script, you have difficulty what a specific part of your script, we welcome your new question.

avatar image MoradGM · Jul 28, 2013 at 06:04 PM 0
Share

Okay, I understand! Thank you for your pleasant feedback.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

16 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

Related Questions

How would go about making a weapon pick up? 3 Answers

Switching/Picking up items in a third-person game 2 Answers

Start FPS player off with no weapon 2 Answers

Pick Up Weapons 1 Answer

Trigger event from ground and activate the Object-child in the Camera 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