Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Hamilcar-games · Jul 11, 2017 at 02:45 PM · animationanimatoranimator controllercharacter controllertransitions

problem with animations running then jumping

im new to animations ^ ^

i have a 3d model "humanoid" and attached to it a character controller i have 2 animation "run" & "jump" the run aniamtion i the default state (the game is an endless runner

and have this script attached to the player :

using UnityEngine;

public class player_mov : MonoBehaviour {

 private CharacterController cc;

 private Animator anim;

 public float speed;
 // Use this for initialization
 void Start () {
     cc = GetComponent<CharacterController> ();
     anim = GetComponent<Animator>();

 }
 
 // Update is called once per frame
 void Update () {

     cc.Move (Vector3.forward  * speed* Time.deltaTime );

     if (Input.GetKey(KeyCode.LeftArrow)) {

         cc.Move (Vector3.left  * speed* Time.deltaTime );
     }

     if (Input.GetKey (KeyCode.RightArrow)) {

         cc.Move (Vector3.right  * speed* Time.deltaTime );
     }

     if (Input.GetKey (KeyCode.Space)) {

         anim.Play ("JUMP");
     }

 }

}

with this i have 2 problems :

1-the jump animations play but dont go back to run animation

2-when i jump and then go back to running the run animation dont start from where the players has completed his jump but from thhe place which he started the jump

so if anyone can explain me in details how to make transitions between animation with custom input

and the problem n'2

n2 problem :

i just found that the character controller dont follow the player when he jumps !

so how to make it follow him

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by CheetahSpeedLion · Jul 12, 2017 at 04:13 AM

Hi, you'll need to use collision detection or the transform's position.

Using collision detection, you would need to tag the ground, then:

void OnCollisionEnter ( Collision collision) { if( collision.collider.tag == "Ground") anim.Play("RUN"); }

or using the transform's position:

void Update() { if( transform.position.y <= 0) anim.Play("RUN"); }

You could use a "grounded" boolean to keep track of this and not let the player jump if it isn't grounded. Also, you can use Mecanim instead of animator.Play if you need to use more states. Depends how complex you want to go.

Comment
Add comment · Show 2 · 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 Hamilcar-games · Jul 12, 2017 at 11:55 AM 0
Share

the jump and run animations works fine with the inputs the main problem is that the colliders dont follow the character when he jumps

avatar image CheetahSpeedLion Hamilcar-games · Jul 13, 2017 at 01:16 AM 0
Share

I think what you mean is your character animation moves your model up but the transform and all other components stay at y=0 or whatever your ground height is. If that's the case, you might want to go back to your animation and remove the vertical movement and handle that using transform.translate or any other method within Unity. In other words, the vertical movement shouldn't be baked inside the animation.

Areleli

avatar image
0

Answer by Merhex · Jul 12, 2017 at 12:02 PM

What do you mean by following?

And make sure you have set a transition in the Animator between your Running and Jumping state. So it can trigger and exit the other.

Comment
Add comment · Show 1 · 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 Hamilcar-games · Jul 18, 2017 at 08:34 PM 0
Share

when i jump the character controller keep it position and dont be in the player position when jumping and after the players jumps he returns to his last position where the jump animation begins

avatar image
0

Answer by Hanross · Aug 30, 2018 at 01:51 PM

Did you found the solution ? ,Did you found the solution ?? @Hamilcar-games

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

171 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

Related Questions

Is there any way to make the default animation transition instant? 2 Answers

Dynamically accessing value for multiple usage in AnimatorController transition conditions. 1 Answer

Animator Controller - Change State After Time 0 Answers

Root motion accuracy issue 0 Answers

How can I change my AnimatorState instantly? 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