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 post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Venando · Feb 23, 2015 at 01:08 PM · positionvector3topdown

How to manage position of player sub objects

I'm making game in which player could switch between diferent types of weapons.

But, each weapon requares its own(weapon) position, hands position and rotation angle for all of them. The only solution I could imagine, is storing positions and rotations for all types of weapons.

Like this:

 Vector3 leftHandPos_0 = new Vector3 (-0.38f, -0.72f, 2f);
 Vector3 rightHandPos_0 = new Vector3 (0.29f, -0.66f, 1f);
 Vector3 gunPos_0 = Vector3.zero;
 Vector3 shootingPos_0 = new Vector3 (-0.02f, 0.66f, 0f);

 Vector3 leftHandPos_1 = new Vector3 (-0.38f, -0.72f, 2f);
 Vector3 rightHandPos_1 = new Vector3 (0.29f, -0.66f, 1f);
 Vector3 gunPos_1 = Vector3.zero;
 Vector3 shootingPos_1 = new Vector3 (-0.02f, 0.66f, 0f);

Cant quite get how solve this problem in more correct way.

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 melkorinos · Feb 23, 2015 at 02:12 PM 1
Share

You could also create empty gameobjects and parent them under your player. Name the left hand, right hand etc , and attach the weapons to them. You could then use some variable of the weapon, like its collider.size or collider.center to place them so they look ok

1 Reply

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

Answer by Baste · Feb 23, 2015 at 04:08 PM

If you're working with models from a 3D program that you or somebody you're working with is making (IE. not something from the asset store), a great trick is to add marker bones that signify the relative position and rotation of the weapon. Then you just set that bone as the weapon's parent, with a local position and rotation of Vector3.zero.

Another way to solve this is to add all of the weapons to the model, and disable the renderer on the ones that are not currently equipped. That'll allow you to position them manually.

In general, whenever you're writing something like this:

 Vector3 leftHandPos_0 = new Vector3 (-0.38f, -0.72f, 2f);

You're probably doing something wrong. If you change the weapon model, your code wont work anymore

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 Owen-Reynolds · Feb 23, 2015 at 06:28 PM 0
Share

Can also do the same thing in Unity by adding empty transforms (which is what the marker bones become, anyway.) But I think bone/empty "mount points" made with the model, in the modeling program, is a pretty standard thing. Like if you ask the modeler, they might cut you off with "sure, sure -- wondered why you didn't ask before."

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Instantiating objects at position 1 Answer

C# Transform modification. 1 Answer

How to stop transform movement at a certain point? 1 Answer

Any help with prevent camera from passing a specific coordinate? 1 Answer

How do i make an object move unpredictably? 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