• 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 OnePlusOneNS · Feb 07, 2014 at 10:02 PM · riggingcamera-look

Connect Camera and Muscles of a Model

Hey,

so I have a question which for me is very very complicated or atleast I can not think of any theory on how to solve this problem or even approach it. So basically I have a person Model. It is rigged within unity in the rig tab and I applied a humanoid rig on it. So this works all fine and when in the rig panel I can move him around and all that. Now I have one problem. First I also have to say that my method is probably not very common, but what I am doing is using a complete but still going to make it 1st Person. So the main question is, can I somehow make the head move along with the camera. The head is attached to the whole body, else I could have just attached it so that the head would be a sub object of the camera but in this case it does not work. So I want the head to watch down aswell when the camera is looking down.

I dunno what Information you guys need and also not if this is even possible, but here is one thing that I can show which is the Character Controller Script that I use, which is attached to the whole model.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent (typeof(CharacterController))]
 public class FirstPersonController : MonoBehaviour {
     
     public float movementSpeed = 5.0f;
     public float mouseSensitivity = 2.0f;
     public float upDownRange = 60.0f;
     public float jumpSpeed = 3.0f;
     
     bool sprintCoolDown = false;
     float desiredUpDown = 90;    
     float verticalVelocity = 0;
     
     CharacterController characterController;
     
     // Use this for initialization
     void Start () {
         
         Screen.lockCursor = true;
         characterController = GetComponent<CharacterController>();
         
     }
     
     // Update is called once per frame
     void Update () {        
         // Rotation
         
         float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
         transform.Rotate(0 , rotLeftRight , 0);
         
         desiredUpDown -= Input.GetAxis("Mouse Y") * mouseSensitivity;
         desiredUpDown = Mathf.Clamp(desiredUpDown, -upDownRange , upDownRange);
         Camera.main.transform.localRotation = Quaternion.Euler (desiredUpDown , 0 , 0 );
         
         // Movement of Character
         
         if(Input.GetKey(KeyCode.LeftShift) && sprintCoolDown == false) {
             movementSpeed = 8.0f;
             StartCoroutine(sprintCD());
         }
         else {
             movementSpeed = 5.0f;    
         }
         float forwardSpeed = Input.GetAxis("Vertical") * movementSpeed;
         float sideSpeed = Input.GetAxis("Horizontal") * movementSpeed;
         
         verticalVelocity += Physics.gravity.y * Time.deltaTime;
         
         if( characterController.isGrounded && Input.GetButtonDown("Jump") ) {
             verticalVelocity = jumpSpeed;    
         }
         
         Vector3 speed = new Vector3 ( sideSpeed , verticalVelocity , forwardSpeed );
         
         speed = transform.rotation * speed;
                         
         characterController.Move( speed * Time.deltaTime );
     
     }
     IEnumerator sprintCD() {
             yield return new WaitForSeconds(6);
             sprintCoolDown = true;
             yield return new WaitForSeconds(4);
             sprintCoolDown = false;        
         }
 }


I appreciate any help, so tell me if its possible and possibly how to do it. Or if its possible but extremely complicated. Or if it is impossible. :D

Thanks a lot. Kind Regards Cribbel

Comment
Add comment · Show 3
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 getyour411 · Feb 07, 2014 at 11:53 PM 0
Share

Basically you want to get a reference to the neck bone in your script and rotate it on the X axis and adjust camera rotation along with it; not impossible nor complicated.

avatar image OnePlusOneNS · Feb 08, 2014 at 10:01 AM 0
Share

Ah okay, still thanks for the answer. Gonna have try it differently then. :)

Thanks a lot. $$anonymous$$ind Regards Cribbel

avatar image PrimeDQ · Aug 20, 2014 at 02:11 AM 0
Share

It is possible to get the head to do so, but dont you want the whole body to move with the rotation along the x axis, and only the head to rotate along the y? so when you turn, your whole body will turn, and when you look up or down, only the head rotates with it?

0 Replies

· Add your reply
  • Sort: 

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

19 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Is it possible for two models to share one set of bones? 1 Answer

Mesh Swap or Switch on keydown 2 Answers

set a new camera target from another game objects script 1 Answer

Smooth move + orbit camera around target 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