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 jc_lvngstn · Nov 15, 2012 at 09:34 PM · positiongameobjectsgroundhand

Placing an object

Let's say I have a game, where you build structures. Each gameobject can be in one of three positions:

In your hand (being carried) Lying on the ground Being set upright

For example: A log. When you carry it, its side rests in your palm. When lying on the ground, its side rests against the ground. When set in the ground (planted, like a pole), its pivot needs to be in the center of the log, a little ways from the bottom.

A sword. In your hand, it is vertically flat, and points forward. On the ground, it is lying on its side (90 degrees rotation from when it is in your hand), and if (for whatever reason) you wanted to stick it in the ground, its pivot would be in inside the sword, near the blade tip.

So, each object needs three different pivots and rotations that it needs to be set at, depending on whether or not it is being carried, on the ground, or planted.

Any ideas on how to approach this? My current approach is to have this:

 Post
     Hand
     Ground
     Planted


Each child would have its position and rotations set to position the object correctly. The gameobject would be attached to the appropriate child. The Post parent would just be placed on the ground or attached to your hand. The child objects would automatically handle rotation and adjustment.

Any thoughts on this?

Comment
Add comment · Show 4
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 sparkzbarca · Nov 15, 2012 at 09:40 PM 0
Share

looks good. Your post has 3 states it can be in. Each state would have code to reach that state.

The annoying thing would be the transitions possibly. you'd need an animation to transition so an object in your hand is moved to sticking in the ground and then relased from being a child.

an object on the ground needs a pickup transition. an object stuck in the grounds need an uproot transition.

avatar image jc_lvngstn · Nov 16, 2012 at 04:57 PM 0
Share

Actually, I wasn't planning on there being an animation transition...but it might be a good idea. I was mostly concerned if it was a bad approach, or that maybe there was a better way. I think if I do have transitions, iTween would be fine :)

avatar image sparkzbarca · Nov 16, 2012 at 05:42 PM 0
Share

well you dont have to have transitions it just breaks immersion some to see objects magically transit.

avatar image jc_lvngstn · Nov 16, 2012 at 07:07 PM 0
Share

That's some polish I think it would be good to have, eventually. I think ideally, I would have animations for the character that show them dropping something, picking it up, planting it, etc.

1 Reply

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

Answer by CrucibleLab · Nov 16, 2012 at 07:33 PM

Not sure whether you solved this problem already but just to add my thoughts:

Granted there's probably a better approach out there, my suggestion to you would be to have a separate 'parent' mount point for each of the three states; namely, in-hand, on-ground, planted.

Start by creating an empty GameObject (let me call it the 'MountPoint') and giving it an meaningful name for the given state. For the 'in-hand' state, I'd say you need to make the Mount Point a child of the left/right hand that will hold the sword. Then you would make the sword object to be the child of the in-hand MountPoint.

What I'd do to ensure the accurate positioning of the sword in character's hand is to drag both the character object and sword object into the Scene and move the sword in the palm of your character before applying the changes to the prefab.

A similar method can be used for the other two states. Again, I am only assuming here that you'd want your sword to be located at a specific spot on your map and that's where you would need to place your MountPoint. Once the sword is assigned to the MountPoint as a child, you would only need to modify the location and/or rotation of the MountPoint to give the sword a visibly different orientation (e.g., lying flat on the ground vs. "planted" on the ground).

Again, probably not the smartest way to do this but it worked for me. I hope it helps. :)

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 jc_lvngstn · Nov 25, 2012 at 11:12 PM 0
Share

This approach seems to work very well. $$anonymous$$y prefab actually has three empty gameobjects as children (hand, ground, planted). Depending on what orientation I want the object to have, I just place it under the appropriate child. It's very easy to use the editor to position each one :)

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

11 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

Related Questions

Moving objects problem 1 Answer

Can you create characters only using unity? 1 Answer

how to control the horizontal position of object in a 4 units wide plane? 0 Answers

Check if two objects have the same position. 2 Answers

Respawn item again once it is destroyed. 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