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
2
Question by Catlard · Oct 28, 2011 at 12:29 PM · animationrigidbodyaiplatformerspritemanager2

Detecting the right time to play a landing animation?

Hey, so, here's an interesting problem. I've got a 2D sprite, in a platforming game (I'm using SpriteManager 2). The main character relies on a rigidbody to handle physics. I have a sprite animation sequence that I want to play whenever I get a certain distance from the ground, or whenever the player approaches the ground. I can change the framerate that the landing animation plays, to accomodate landing from various heights. But I haven't yet figured out a solution that solves all three of these problems:

1) The character can land on a platform by jumping up to it, meaning he will not land at the same height he started at.

2) The character can land on something by falling down to it from a higher platform, meaning, again, that he doesn't end up at the same height.

3) The character can jump at a range of heights--so putting a cube below him that detects when it hits the ground (and thus triggers the animation) doesn't really work correctly.

The way I'm currently attacking the problem is via the method mentioned in problem 3. Any idea of a better solution?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by wccrawford · Oct 28, 2011 at 12:34 PM

I would determine how fast you are falling, and raycast down. Using a calculation from the raycast distance and your current speed, figure out if the platform is close enough to start the animation.

This calculation is going to be dependent on how much time you need, etc.

Comment
Add comment · Show 4 · 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 Catlard · Oct 28, 2011 at 12:37 PM 0
Share

that's a good idea, I'll try that...and see if it works. Thanks a ton for the idea!

avatar image wccrawford · Oct 28, 2011 at 12:40 PM 1
Share

One thing I just thought of... You'll have to be careful of platforms you're passing over, but won't actually land on... So I'd check that you're actually going to land on the platform before starting the animation.

Oh, and going up, as well. I'd only start the animation if you're headed down.

avatar image syclamoth · Oct 28, 2011 at 12:42 PM 0
Share

Bah! Post ninja'd.

avatar image Catlard · Oct 28, 2011 at 03:23 PM 0
Share

tru dat! Yeah, that's the really tricky part--is figuring out which one you're going to land on. I guess you could just assume that you're going to land on the first thing you pass over, else{the bottom of the level}. There aren't that many platforms in the game that it would be an issue, I think. Good points, guys.

avatar image
2

Answer by syclamoth · Oct 28, 2011 at 12:36 PM

You could raycast towards the ground, using the rigidbody's velocity multiplied by the number of seconds ahead that you want to predict. Of course, this won't account for gravity- however, if you look up some physics equations, there are ways of getting around that (assuming a constant acceleration etc.). Then, if this raycast hits the ground (use a layermask or something), play your land-anticipation animation.

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 Catlard · Oct 28, 2011 at 03:21 PM 0
Share

Thanks, syclamoth! I think that will probably work better. And by "work better" i mean "I understand your explanation a bit more." Cheers, though.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Detecting the right time to play a landing animation? 1 Answer

Detaching a Physics Driven Object from a Character 2 Answers

the animation walk but he still in the same place and rotate left and right on this white circle 0 Answers

Enemy AI Animation 0 Answers

Matching character's rotation to the rotation of a animation - How? 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