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 Grieve_physics · Jul 10, 2014 at 03:22 PM · rotationmovementmecanim

Archer Mecanim Animation - Not lining up correctly when movement is applied

Hi All,

Have an issue with mecanim and animations. to make it easy, I recorded and posted to Youtube here: https://www.youtube.com/watch?v=yuPWLhM7YPw the actual problem is shown @44seconds

Basically the archer mask does not line up with the archer aiming pivot, and cannot seem to work this problem out even after trying quite a few things. Most of the setup I believe I show in the video, and the script responsible for movement and aiming is:

 using UnityEngine;
 using System.Collections;
 
 /// <summary>
 /// Player animations.
 /// This script is attached to the Player. It controls the players animations.
 /// 
 /// This script access the ArrowAimingRayAnimation Script. It updates the boolean aimingBeam.
 /// </summary>
 
 public class PlayerAnimations : MonoBehaviour {
 
     //Variables Start
     Animator anim;
     public float speed = 6.0f;
     public float gravity = 20.0F;
     private Vector3 moveDirection = Vector3.zero;
     private CharacterController controller;
     private ArrowAimingRayAnimation ArrowAimScript;
     //Variables End
 
 //    public float headingAngle=0.0f;
     //Variables End
 
     // Use this for initialization
     void Start () 
     {
         if(networkView.isMine == true)
         { 
             anim = GetComponentInChildren<Animator>();
             controller = GetComponent<CharacterController>();
             ArrowAimScript = GetComponentInChildren<ArrowAimingRayAnimation>();
         }
         else
         { 
             enabled = false;
         }    
     }
     
     // Update is called once per frame
     void Update () 
     {
 
 
         // this gives you more control over the rotation around the look axis if needed
         var direction = new Vector3(Input.GetAxis ("Horizontal Right Stick"), 0, -Input.GetAxis ("Vertical Right Stick") );
         var rotation = Quaternion.LookRotation(direction, Vector3.up);
         if(direction.magnitude > 0.3f)
             transform.rotation = rotation;
 
 //        Debug.Log (rotation.eulerAngles.y);
         float v = Input.GetAxis ("Vertical");
         float h = Input.GetAxis ("Horizontal");
 
 
         //Check if there is movement input. If input exists then run code to move the player.
         if (h!=0 || v!=0)
         {
             //This controls the movement of the player
             if (controller.isGrounded) 
             {
                 // We are grounded, so recalculate move direction directly from axes
                 moveDirection = new Vector3(h, 0, v);
                 moveDirection *= speed;
             }
 
 
             // Move the controller
             moveDirection.y -= gravity * Time.deltaTime;
             controller.Move(moveDirection * Time.deltaTime);
 
             // Get a copy of your forward vector
             Vector3 forward = transform.forward;
             // Zero out the y component of your forward vector to only get the direction in the X,Z plane
             forward.y = 0;
             float headingAngle = Quaternion.LookRotation(forward).eulerAngles.y;
             var tempMoveDirection = Quaternion.LookRotation(moveDirection,Vector3.forward).eulerAngles.y;
             anim.SetFloat("direction", -1*(headingAngle - tempMoveDirection));
             anim.SetBool("movementInput", true);
         }
         else
         {
             anim.SetBool("movementInput",false);
         }
 
         //Checks to see if About to shoot. (Pulling Right Trigger) 
         if (Input.GetAxis ("FireWeapon") < -0.1f)
         {
             anim.SetBool("aiming", true);
             ArrowAimScript.aimingBeam = true;
         } 
         else 
         {
             anim.SetBool("aiming",false);
             ArrowAimScript.aimingBeam = false;
         }
         
 
     }
 }
 
 

Any help would be grateful for this one as I am losing hair over this issue and all out of ideas.

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
Best Answer

Answer by Grieve_physics · Aug 16, 2014 at 02:26 AM

For those with a similar issue.

It was found that this problem is caused by the limitations within the Unity Mecanim controls. I had to get custom animations built, with no root animations and set up a secondary walk cycle with the bow.

It is doable with certain assets available from the Asset Store, but they are not default with mecanim.

*Credit to Props for solution to this one.

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.

Follow this Question

Answers Answers and Comments

22 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

Related Questions

Looking for Unity 5 tutorials for perfect 3rdperson Character Movement 0 Answers

click to move workig script!! but pls help with rotation!! :( 1 Answer

How to make a RigidBody not go into ground when tilted foward? 2 Answers

Multiple movement modes in mecanim 0 Answers

Undesirable character flipping 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