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 CubePhysics · May 15, 2014 at 02:42 PM · blendermodelanimationsfirst-person-controllerthird-person

How to link up animations with the first person controller(not answered yet!)

I used the first person controller unity asset as a third person controller by dragging the camera behind the capsule and i replaced the capsule with my model. I now want to hook up my model animations with first person controller, so when the first person controller moves forward my model plays the run animation or jumping pays the jump animation. The models animations are: "Run" "Standing" "Jump" "Falling". Can someone please help

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 Cherno · May 15, 2014 at 03:12 PM

The gameObject that has the mesh with your character model and animations needs an animatoion component that has all the animation clips stored. Then it's just a matter of playing the animations you want on that gameObject, using animation.Play or animation.Crossfade.

Comment
Add comment · Show 5 · 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 CubePhysics · May 15, 2014 at 03:15 PM 0
Share

I have done that but the animation for run doesnt work when going right,left,backwards so i used transform.rotate but that didnt work out too well same with the jumping, half the time the model doesnt play the animation when using play or crossfade

avatar image Cherno · May 15, 2014 at 04:21 PM 0
Share

First of all, check if all animation clips are imported correctly. After that, put Debug.Log("this works"); lines into your code whenever an animation is played so you know if something doesn't work right.

avatar image CubePhysics · May 15, 2014 at 06:02 PM 0
Share

the animations work its just that lets say im hold "D" and the player is moving to the right and playing the run animation but i want to switch to pressing "E" so i press "E" and the play moves left but half the time doesnt play the animation Run.

avatar image Magnetrate · May 15, 2014 at 09:13 PM 0
Share

I am not sure if this is going to work, but I think you can try this one out: If you are using C#, try to use GetButtonUp after GetButtonDown or Get$$anonymous$$eyDown, and make "GetButtonUp" stop running the animation, thus if you press another key the animations won't interfer

avatar image CubePhysics · May 16, 2014 at 04:40 PM 0
Share

ive done that with Get$$anonymous$$eyUp but thats what messes up my animations. This is the problem i think. If you are holding A for example and then you press D whilst holding A and then let go of A about a second later after pressing D, the model will go to the direction of D (in the fps controller, right) but it will not play the run animation because get the Get$$anonymous$$eyUp of A will tell the model to stop playing the run animation even though Get$$anonymous$$eyDown of D is saying Play the run animation. Here is the script. using UnityEngine; using System.Collections;

 public class Playermisc : $$anonymous$$onoBehaviour {
 
     public GameObject maincamera;
     public GameObject player;
     public float turnSpeed = 1.0f;
     public float time = 1f;
     public float speed = 1f;
     public bool defaultView = true;
     public bool leftView = true;
     public bool rightView = false;
 
 
     // Use this for initialization
     void Start () 
     {
         animation.Play("Standing");
         animation["Falling"].speed = 0.42f;
         animation["Jump"].speed = 1.2f;
         animation["Run"].speed = 0.8f;
         Screen.lockCursor = true;
         defaultView = true;
         leftView = true;
         rightView = false;
     }
     
     // Update is called once per frame
     void Update () 
     {   
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape))
         {
          player.GetComponent<$$anonymous$$ouseLook>().enabled = false;
          maincamera.GetComponent<$$anonymous$$ouseLook>().enabled = false;
         }
 
         if(Input.Get$$anonymous$$ouseButtonDown(0))
         {
          Screen.lockCursor = true;
          player.GetComponent<$$anonymous$$ouseLook>().enabled = true;
          maincamera.GetComponent<$$anonymous$$ouseLook>().enabled = true;
 
         }
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.W))
         {
             animation.CrossFade("Run");
         }
         if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.W))
         {
             animation.CrossFade("Standing");
 
         }
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.D))
         {
             animation.CrossFade("Run");
             transform.Rotate(0,90,0);
         }
         if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.D))
         {
             animation.CrossFade("Standing");
             transform.Rotate(0,-90,0);
             
         }
 
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.A))
         {
             animation.CrossFade("Run");
             transform.Rotate(0,-90,0);
 
         }
         if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.A))
         {
             animation.CrossFade("Standing");
             transform.Rotate(0,90,0);
 
         }   
          if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.S))
         {
             animation.CrossFade("Run");
             transform.Rotate(0,180,0);
         }
         if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.S))
         {
             animation.CrossFade("Standing");
             transform.Rotate(0,180,0);
         }
     
 
 
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
         {
             animation.CrossFade("Jump");
 
         }
 
 
     }
 }
 

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

MMD How to export model and animations to Unity as 3rd person controller? 2 Answers

Need help with import from blender to unity! 1 Answer

My toon shader seems to make a black hole. 0 Answers

blender bones in unity3D 1 Answer

multiple animations in inspector 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