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 awplays49 · Jan 18, 2015 at 02:24 AM · childchildrenweaponweaponsarms

methods of positioning weapons to hand

what do you do for this step by step so its always going through the players hand, even when the arm moves?

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

2 Replies

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

Answer by carrollh · Jan 18, 2015 at 02:46 AM

EDIT: after seeing @michael96schmidt's answer, it made me realize why I do it this way in my game. My weapons have rigidbodies and a lot of mass so they can bash things around. The more mass the thing has the further out of position it will get as you move around. His method is way better if you don't need rigidbodies on the weapons. You can achieve it in code with something like weapon.transform.SetParent(attachPoint.transform) /EDIT

The way I do it (which may be the naive way or the preferred way, I don't know), is in 2 parts:

1) After adding the character model to the scene, in the hierarchy I expand the joint tree for the character until I find where I want to put dynamic stuff (holsters, hands, etc). Then I add GameObjects to these joints, and then translate and rotate them into the correct position for what I need.

2) Then I attach a script to the weapon or object that looks like this:

 using UnityEngine;
 
 public class Weapon : MonoBehaviour {
 
     public Transform attachPoint;
     public GameObject owner;
     
     void Start()
     {
         if (owner != null)
         {
             transform.localScale = owner.transform.localScale;
         }
     }
 
     void Update()
     {
         if (owner != null)
         {
             transform.position = attachPoint.position;
             transform.rotation = attachPoint.rotation;
         }
         else Destroy(gameObject);
     }

3) Then I drag the GameObject I added to act as an attachment point or holster onto the scripts public Transform attachPoint in the Inspector.

Note: You might not need the Start() method or the Destroy call. For example you want the sword or whatever to stick around in scene after the owner dies or whatever.

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
avatar image
2

Answer by michael96schmidt · Jan 18, 2015 at 05:54 AM

I just put an empty gameobject as a child of the hand/arm and offset it to be in the position of where the weapon would be. I then just have the equipped weapon a child of that gameobject.

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 carrollh · Jan 18, 2015 at 05:00 PM 0
Share

This should totally work, as long as you don't have a rigidbody with any mass attached to the weapon. If you do, you'll have to update the weapon's position and rotation to stay put periodically.

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

27 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

enable/disable child objects? 2 Answers

How to Access Components in Children of GameObject? 1 Answer

change child texture problem 2 Answers

all parents of a transform 1 Answer

Set up rank children 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