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 Gleip · Dec 26, 2013 at 03:50 PM · 2djumpingplatformertopdown

Top-Down Jumping (2D)

I'm making a top down 2d game, and am struggling with adding a jump to my character.

I want the character to be able to jump over holes and low obstacles (but not high ones).

Essentially something akin to jumping in 2D Zelda titles.

Currently my game is setup to use XY, with gravity turned off (set to 0). Movement is based on simple Rigidbody addforce mechanics.

Any examples, or resources that could help me with this endeavor would be highly appreciated. C# is preferred, but UnityScript is acceptable.

Thank you for your time.

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 SethJH · Dec 26, 2013 at 08:11 PM

The best I could come up with would be: Assign some property denoting "hole" tiles to be recognized different from "floor" and "wall" tiles. Normally, while your character is not "jumping", when they come in contact with the hole tile they fall down it and die, or just act as a solid tile (your preference). When the player presses the jump key, set "jumping" to true and the character will "ignore" tiles tagged as holes, allowing them to move safely over it. The jump boolean would return to false after the player has traveled a certain number of tiles (2 is probably what you're looking for). The jump command should require you set a direction to jump (like LEFT ARROW + JUMP), and not allow the player to change directions again until they have landed. To simplify how long the jump should last, you may even replace the boolean Jump variable with a float Jump variable that is set to a number on jump and then decrements at a fixed rate until it reaches 0 again. (then you could have a property bool IsJumping { get { return Jump > 0; } } to check if the player is in midair). The Jump variable as a float would also give you a means of judging which frame of jumping animation to display.

Comment
Add comment · Show 3 · 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 Gleip · Dec 27, 2013 at 11:39 AM 0
Share

Thank you. I'll try this out shortly. I also think I may be able to work it into combat mechanics (jump over projectiles and such) with a simple check during collison.

avatar image chudangkhanhsasuke Gleip · Apr 17, 2018 at 09:16 AM 0
Share

can you share for me your jump code ?

avatar image FredMastro · May 15, 2014 at 12:59 PM 0
Share

I am doing the same thing and posted a question on giving the illusion of jumping from a top down, by scaling the sprite up and back down. The code originally was done in XNA but the concept is the same. http://stackoverflow.com/questions/20309661/scale-sprite-up-and-down-to-give-illusion-of-a-jump I'm in the process of converting it over to Unity.

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

21 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

Related Questions

2D Platformer Jump while Running Android 1 Answer

Advice needed on my first c# 2D jump script 1 Answer

2D jumping raycast question 0 Answers

Graceful 2D collision enabling/disabling for topdown jumping 1 Answer

2D platformer jumping that feels good 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