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 aled96 · Jul 11, 2014 at 05:38 PM · 2d2d-platformerjumpplatformer

Jump 2D error

Hi, i am making a 2D game, like "Super Mario", a platform game.

I have a terrain composed by differt parts, that are placed side by side (each part has its own edge collider 2D).

The character jumps if i press the UP arrow. Sometimes the character does a very big jump. This happens when the character jumps very near an object...

What can i do to solve this problem ?

Here you can download the demo of the game for testing and see what is the problem :)

https://www.dropbox.com/sh/x8ff4ajzg70h2k2/AAA03gDiLqd7ZXNBrnLt2L87a

Thank you so much :)

Comment
Add comment · Show 4
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 DGKN · Jul 11, 2014 at 05:54 PM 1
Share

Do you jump using AddForce or Velocity ?

avatar image aled96 · Jul 11, 2014 at 06:02 PM 0
Share

if(jump){

         anim.SetTrigger("Jump");        



             rigidbody2D.AddForce(new Vector2(0f, jumpForce));


             jump = false;


             anim.SetBool("Ground",false);


         }
avatar image Tehnique · Jul 11, 2014 at 06:10 PM 0
Share

Can you post how "jumpForce" is calculated?

avatar image aled96 · Jul 11, 2014 at 06:36 PM 0
Share

jumpForce is public variable, so i can chose it, now it is setted as 400

1 Reply

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

Answer by MrAkroMenToS · Jul 12, 2014 at 12:36 PM

The problem is, as I could saw if you jump next to an object you jump into the sky. I think this is because the addforce activates even if you are jumping.

I'd try to add a criteria.

Try this:

 if(rigidbody2D.velocity.y == 0){
 rigidbody2D.AddForce(new Vector2(0f, jumpForce));
 }

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 aled96 · Jul 12, 2014 at 01:16 PM 0
Share

It works but now, i cannot jump if i am walking..

avatar image aled96 · Jul 12, 2014 at 01:16 PM 0
Share

Because i use velocity also for walking and move the character

avatar image MrAkroMenToS · Jul 12, 2014 at 03:53 PM 1
Share

I see! Is the horizontal velocity the y or the vertical? If y is your horizontal change y to x in my code. If y is the vertical then change to this: if($$anonymous$$athf.Abs(rigidbody2D.velocity.y) <= 1) Play with the 1 number if it doesn't work! I hope it helped.

avatar image aled96 · Jul 13, 2014 at 07:44 AM 0
Share

Thank you much !!! :D Now it works :D

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

Make a 2D jump? 0 Answers

Moving platform player bounce when moving down 1 Answer

How can you make an object jump fluid while the object is rolling (2D) 0 Answers

Character clips into the ground in 2D platformer 0 Answers

Velocity in Unity2D 2 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