• 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 /
  • Help Room /
avatar image
0
Question by dmduffy05 · Sep 03, 2018 at 09:39 PM · animationimportingmouselookmixamofirst-person

FP MouseLook and Animating

I want to have my player be able to move $$anonymous$$s head and arms up and down with the mouse and the body rotate left and right with the mouse with animations (such as walk, idle, strafe, back, etc..). The problem is that when I try and do any of these t$$anonymous$$ngs they just won't rotate. My theory is that the animation is preventing the mouse look script from rotating the objects it needs to rotate, but I need to animate the arms and stuff. (especially the arms when aiming)

(Model was made with Fuse and the animations were done in Mixamo)

MouseLook Script

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Networking;
 
 [AddComponentMenu("Camera-Control/Mouse Look")]
 public class FPSCamScript : NetworkBehaviour
 {
     public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
     public RotationAxes axes = RotationAxes.MouseXAndY;
     public float sensitivityX;
     public float sensitivityY;
     public float minimumX = -360F;
     public float maximumX = 360F;
     public float minimumY = -60F;
     public float maximumY = 60F;
     float rotationY = 0F;
 
     void Start()
     {
         sensitivityX = PlayerPrefs.GetFloat("sensitivity");
         sensitivityY = PlayerPrefs.GetFloat("sensitivity");
         Cursor.lockState = CursorLockMode.Locked;
     }
 
     void Update()
     {
 
         if (!isLocalPlayer)
         {
             return;
         }
 
         if (Input.GetMouseButtonDown(1))
         {
             sensitivityX = PlayerPrefs.GetFloat("adssens");
             sensitivityY = PlayerPrefs.GetFloat("adssens");
         }
         else if (Input.GetMouseButtonUp(1))
         {
             sensitivityX = PlayerPrefs.GetFloat("sensitivity");
             sensitivityY = PlayerPrefs.GetFloat("sensitivity");
         }
 
         if (axes == RotationAxes.MouseXAndY)
         {
             float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
 
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
 
             transform.localEulerAngles = new Vector3(0, rotationX, 0);
             transform.GetC$$anonymous$$ld(9).GetC$$anonymous$$ld(2).GetC$$anonymous$$ld(0).GetC$$anonymous$$ld(0).GetC$$anonymous$$ld(2).transform.GetC$$anonymous$$ld(0).transform.localEulerAngles = new Vector3(-rotationY, 0, 0); //RArm
             transform.GetC$$anonymous$$ld(9).GetC$$anonymous$$ld(2).GetC$$anonymous$$ld(0).GetC$$anonymous$$ld(0).GetC$$anonymous$$ld(0).transform.GetC$$anonymous$$ld(0).transform.localEulerAngles = new Vector3(-rotationY, 0, 0); //LArm
             transform.GetC$$anonymous$$ld(9).GetC$$anonymous$$ld(2).GetC$$anonymous$$ld(0).GetC$$anonymous$$ld(0).GetC$$anonymous$$ld(1).GetC$$anonymous$$ld(0).transform.localEulerAngles = new Vector3(-rotationY, 0, 0); //Head & Camera
         }
         else if (axes == RotationAxes.MouseX)
         {
             transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
         }
         else
         {
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
 
             transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
         }
 
     }
 
 }
 



Player Hierarchy alt text Object Containing Script alt text

unity-2018-09-03-16-38-15.png (12.0 kB)
unity-2018-09-03-16-38-31.png (7.0 kB)
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 Wesley21spelde · Jan 13, 2021 at 11:53 AM

Maybe t$$anonymous$$s works

Animator anim;

 void Start()
 {


     anim = GetComponent<Animator>();


 }
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

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

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

Related Questions

Maya Vertex Animation import 1 Answer

Blenshapes keyframes dont show up in the animation window. UNITY 0 Answers

Unity + Mixamo - Animations playing weird 2 Answers

How to Read Custom Attributes from a timeline as opposed to the Animator 0 Answers

Deformed Character Mesh on Import 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