• 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 oliver_ · May 09, 2011 at 05:03 AM · characterparentcontrol

Parent an object to character controller

How to I connect a object (eg. a gun/sword) to character controller? Im working with a first person character controller and a sword. Ive tried connecting the sword to the characters main camera. As that is the only way it'll work so the sword "follows" the character/camera movements. This works ok, except for the fact that it somehow restricts the characters movements, like speed and moving left/right/foward/back. Thank you to anyone that can tell me where I am going wrong. Or better yet, a new method.

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

· Add your reply
  • Sort: 
avatar image
0

Answer by superventure · May 09, 2011 at 07:30 AM

You cant just drag and drop the sword into the players hand bone? You could also say in the swords code

var hand: Transform; //drag and drop hand bone here in the inspector

transform.parent = hand.transform; transform.position = hand.position;

if you have a collider in the sword, it will still collide with the player when they try to move in gameplay. Set the swords collider to trigger, and it will not interfere with the players movement anymore

hope this helps

Comment
Add comment · Show 4 · 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 superventure · May 09, 2011 at 07:33 AM 0
Share

Oop, just realized you meant you DONT have an actual player mesh? well you could still achieve this with and empty game object, parented the same way. Just make an empty game object and put a character controller on that

avatar image oliver_ · May 11, 2011 at 05:52 AM 0
Share

The only problem is that the sword is just a simple model without any code. (As i cant code anyway...)

avatar image superventure · May 11, 2011 at 08:46 AM 0
Share

Its simple enough to slap a java script on it... the code I gave you is basically all you need in an update function. If you're not willing to do even that, I dont know what else to tell you :(. Otherwise, if you still need instruction with that step, just ask

avatar image psychentist · Apr 30, 2012 at 02:02 AM 0
Share

Roll up your lazy sleeves, and hit up that API. The only way to learn scripting is to practice it.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to make camera position relative to a specific target. 1 Answer

Sprite animation not functioning correctly. 0 Answers

Character Rotation point at Mouse 1 Answer

Player slows down when hitting an incline 0 Answers

C# Movement Script 3 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