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 tertera · Mar 09, 2021 at 10:00 PM · 2d-platformercoroutinejump

Inconsistent jump height

I'm using a coroutine to jump like in this tutorial :

https://www.gamasutra.com/blogs/DanielFineberg/20150825/244650/Designing_a_Jump_in_Unity.php

it adds a decreasing force in the coroutine while you jump, this is my first time using a coroutine for a jump so im not sure why the jump height changes.

alt text

screenshot-40.png (230.4 kB)
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
1

Answer by GeroNL · Mar 09, 2021 at 11:21 PM

Maybe you should debug the proportion force, before it do addforce. Then check several time, are the values give same value)?


and i see the sample in the website that you attach, your concept that you use is The Just Right right? i did not see it's give same height jump.


maybe you can try it by learping to the height you want, multiple it by curve for acceleration, and do the down after jump too, then give max to gravity * time.deltatime when it's still falling.

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 tertera · Mar 10, 2021 at 12:42 AM 0
Share

You're right, the proportion force isn't consistent. Do you have any resources on how to implement the jump you described or could you give me some pointers? I'm new to unity so I'm not sure how to multiply it by acceleration or how to handle gravity.

avatar image GeroNL tertera · Mar 10, 2021 at 01:39 AM 1
Share

try like this :

 public AnimationCurve curveJump;
 public float maxHeightJump = 2;
 public float jumpPower = 5; 
 private float tempY;
 
 ....
 private void Jump()
 {
     isJump=true;
     tempY= player.transform.position.y + maxHeightJump;
 }

 // in update
 if(is on ground and isJump)
 {
     if(player.transform.position.y <tempY )
     {
         player.transform.position.y = jumpPower * curveJump.Evaluate((player.transform.position -tempY)/maxHeightJump ) *Time.deltaTime;
     }
     else if(player.transform.position.y >= tempY )
     {
          isInJump = false;
     }
 }
 if(is not on ground and !isJump)
 {
 //do it same like jump but reverse it, make it simple first for undestanding the movement 
 }



Put grafik in aniationCurve, for jump give start point 1 then final point 0, then for fall is 0 - 1.


Try to know about this first :

 player.transform.position.y = jumpPower * curveJump.Evaluate((player.transform.position -tempY)/maxHeightJump ) *Time.deltaTime;
 // or you can put update it without condition, what will this doing
 player.transform.position.y = jumpPower  * Time.deltaTime;
 // Curve is just make different movement but will arrive on destiny in the same time. this is what i know about interpolation.


idk, is a correct one or not, but that was a concept i did. Hope it can help.

avatar image tertera GeroNL · Mar 10, 2021 at 04:32 AM 0
Share

Thank you so much! Your code really helped explain what an animation curve is, the way i understand it now is its basically a non linear lerp. Ill study up on it some more and try to code it.

Show more comments

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

133 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

Related Questions

Better jumping with "Lerpz" character controller 1 Answer

Can't Modify PlatformerCharacter2D Jump Force From Other Script 0 Answers

Jump Code Not Working (2D C#) 2 Answers

How do I get the character to jump in a 2d game, which is compatible with joysticks and keyboards? 0 Answers

Improvements to Jumping 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