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 ExtremePowers · Jan 10, 2015 at 09:33 PM · positionfollowbonehead

World position question

I want the camera to sit in front of my head bone, and I can't attach it to the head bone because I only want the position of the head bone, not the rotation. I have tried this:

 function LateUpdate() {
     camera.position = Head.position;
     //The camera seems to be set to the head bones localPosition
 }

But that doesn't seem to make the position the same. It sets it to the initial position but doesn't follow if I change the rotation of the head bone.

Comment
Add comment · Show 6
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 cariaga · Jan 10, 2015 at 09:42 PM 0
Share

have you tried "local position"

 Head.localPosition
avatar image Guppie1337 · Jan 10, 2015 at 11:02 PM 0
Share

If you take the transform of the head bone, you could set the transform.position and be fine. I would do it that way and redefine the camera's transform rotation to take a persistent leveled value. $$anonymous$$aybe this requires you to set the camera in an empty child?

avatar image ExtremePowers · Jan 11, 2015 at 09:57 AM 0
Share

localPosition just make it stay at the bottom of the map, where the Head position would stay at its initial position.

avatar image ExtremePowers · Jan 11, 2015 at 10:05 AM 0
Share

If I try to use this code:

 function LateUpdate() {
      Debug.Log(Head.position.ToString());
      camera.position = Head.position;
 }

The bone doens't change position if I change the rotation of the parent bones?

avatar image Avash · Jan 11, 2015 at 11:54 AM 0
Share

Your code doesn't affect bones in any way, just the camera.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by incorrect · Jan 11, 2015 at 12:05 PM

 using UnityEngine;
 using System.Collections;
 
 public class AttachCamera : MonoBehaviour {
     public Transform target;
         
     void Update () {
         transform.position = target.position;
     }
 }

Just assign the target object in inspector and camera with that script will follow the object.

Btw, localPosition, localRotation are values relative to paren object, so they are useful when you want to adjust those position and rotation of an object relatively to it's parent. In your case you should use global world position.

Comment
Add comment · Show 7 · 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 ExtremePowers · Jan 11, 2015 at 12:07 PM 0
Share

I don't think I can use Update since the bone is included in an animation, so the animation will override the movement. That is exactly what I have been doing since the start.

avatar image incorrect · Jan 11, 2015 at 12:33 PM 0
Share

This script has nothing to do with your animation. Ok, I'll check it.

avatar image incorrect · Jan 11, 2015 at 12:44 PM 0
Share

Well, you know, in my case it worked like I've expected. I just assigned right body part from hierarchy of character and camera's position always followed it through animation.

Or am I missing something? Please, can you show me your character's hierarchy and describe what actually you want to make. Not how you think it can be done by setting position and all that coding, just tell how you want your camera move. Do you want it to follow characters head and be faced the same direction? Do you want it just to move and shake as the head does, but be faced some other direction? Or you have something else in $$anonymous$$d?

Hierarchy

снимок.jpg (31.3 kB)
avatar image ExtremePowers · Jan 11, 2015 at 12:46 PM 0
Share

The problem might be that the camera is a child of the character. I just want it to stand still in front of the head.

avatar image incorrect · Jan 11, 2015 at 12:52 PM 0
Share

Oh, c'mon, just don't make it a child of a character. :)

Or I can improve my script so it will work even though the camera is a child of your character. Just tell me, where in hierarchy you want it to be. Should be just a charater's root's child?

Show more comments

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

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

Related Questions

Camera rotation around player while following. 6 Answers

Cannot move or rotate child Object 5 Answers

How to bind two gameobjects together? 2 Answers

attaching armor to bone in proper position !!! help! 2 Answers

How can I get 'live' transform position of an object while it's animated? 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