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 mlabarca · Jan 24, 2014 at 02:38 AM · animationphysics2d-platformerblendtreelive

Blend tree 2d platformer jump

Hi, I am trying to setup a platform jump/fall animation using blendtrees such as the one in this tutorial: http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-controllers

I'm using a vertical speed as parameter. Problem is that when the characther lands on its feet the vertical speed is zero, which is the same as in the top of the jump, thus that animation is picked briefly until my "ground" bool is set back to false.

Of course moving the groundcheck up makes that bool get set faster, but this makes it so people can jump again before even landing.

Making a normal animation would then disable the falling part, which is the cool part of the blend tree.

The only workaround i can think of is somehow detect when when i'm at the top of the jump, and create 2D blendtree that doesn't play that top-of-the-jump animation when the characther lands. Does that make any sense? Here be the related parts in my characther controller.

     void Update () {
         if (grounded && Input.GetKeyDown (KeyCode.Space)) 
         {
             rigidbody2D.AddForce (Vector2.up * jumpForce);
             anim.SetBool("ground",false);
         }
 
         grounded = Physics2D.Linecast (transform.position, groundCheck.position, whatIsground);
         anim.SetBool("ground",grounded);
 
         h = Input.GetAxis ("Horizontal");
 
         // If the player's horizontal velocity is greater than the maxSpeed...
 
         if(Mathf.Abs(rigidbody2D.velocity.x) > maxSpeed)
             // ... set the player's velocity to the maxSpeed in the x axis.
             rigidbody2D.velocity = new Vector2(Mathf.Sign(rigidbody2D.velocity.x) * maxSpeed, rigidbody2D.velocity.y);
     
     }
 
     void FixedUpdate () {
 
         grounded = Physics2D.Linecast (transform.position, groundCheck.position, whatIsground);
         anim.SetBool("ground",grounded);

 
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

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by underwally · May 03, 2014 at 04:17 AM

mlabarca, did you solve the problem ??? I'm having the exact same issue and can't get around it :(

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

Answer by monegames1225 · Mar 26, 2014 at 09:03 PM

you should have an idle animation that is separate from your jump/fall animation. the jump blend tree shouldn't have any sprites that are in your idle animation. it sounds like your jump/fall is using the idle frame for a zero vspeed. you shouldn't do that. the blend tree should just default back to your idle animation when grounded.

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
0

Answer by Zaqnafein · Jun 05, 2014 at 05:45 PM

I had the same problem in my proyect. I changed the Rigidbody2D Interpolate to None and the problem disappeared. Maybe this can help anyone with the same problem.

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

Answer by GaryCassette · Sep 26, 2018 at 11:31 AM

Hi, @mlabarca

I'm facing this same issue and looking solution for this. Have you found solution? or can someone look this? Thanks,

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

Answer by howler123 · Aug 24, 2019 at 10:16 PM

Have you tried attaching a child object called feet with a box collider set as Trigger positioned at the bottom of the character sprite with a script and an OnTriggerEnter2D that sets a value indicating you are touching the ground or have landed? That's what I have finally had to do.

 public class Feet : MonoBehaviour
 {
    void OnTriggerEnter2D(Collider2D other)
     { 
         if(other.tag.Equals("Foreground"))
         {
             GetComponentInParent<PlayerMovement>().jumping = false;
         }
     }
 }
 
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

24 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

Related Questions

Converting discrete intensity distribution to a continuous figure.,Discrete intensity to continuous figure. 0 Answers

Character Controller Component, Gravity/inertia, and Root Motion 0 Answers

A problem regarding to player animation with checkpoint in 2D platformer 0 Answers

Collision occurring when it should not! Help! 1 Answer

Playing an objects animation that has been hit by a RayCast 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