Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 4ntihero · Aug 04, 2015 at 07:19 AM · jumpjumpingfallingjumping objectfall

Another Slow Fall Problem...

I'm trying to make a platformer for my first project, and I have the moving around working. But jumping is proving a problem. I am using a function to make the player jump:

void Jump() { rigidbody.AddForce(Vector3.up * jumpSpeed); }

but the upward momentum seems isolated to the individual frames where the jump key is pressed, meaning a very unreliable/unrealistic jump arc. Also the model just hangs in the air and falls very, very slowly.

The model is 4 units tall, has a rigidbody with drag and angular drag set to 0, and mass set to 1. Gravity is set to -9.81. I've tried playing with the mass, to no avail, and it seems like changing gravity is the wrong approach.

I can't figure out what is slowing the models decent, and the other answers I've looked at on this site either don't apply to my situation, or don't have answers yet. Can you help me?

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
0

Answer by haim96 · Aug 04, 2015 at 07:26 AM

here some advice for jumping with physics:

  1. when you jump make sure you can't press jump again (double jump).you can do that with bool that set to true when press jump and false when get back on the ground. then check for it state when press jump. this way you will avoid apply multiple "addforce" in long jump press. it will make the jump more consistent.

  2. you can set the gravity multiple on your player's rigidbody. this will make him fall faster. it will effect your player only and not the whole project.

  3. you may want to try to apply the force as impulse for the jump. (forceMode.impulse) http://docs.unity3d.com/ScriptReference/ForceMode.Impulse.html

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 4ntihero · Aug 04, 2015 at 10:39 PM 0
Share

changing the mass of the rigidbody isn't changing anything at all, it still falls at the same rate. I've experimented with the code I was using. I've deleted my old script and started a new one, here it is in its entirety: using UnityEngine; using System.Collections;

public class PlayerController : $$anonymous$$onoBehaviour {

 public float moveSpeed;

 Rigidbody rb;

 void Start () {
     rb = GetComponent<Rigidbody> ();    
 }
 
 void FixedUpdate () 
 {
     float h = Input.GetAxisRaw ("Horizontal");
     float v = Input.GetAxis ("Vertical");
     Vector3 movement = new Vector3 (h * moveSpeed, 0f, 0f);
     rb.velocity = movement;
     if (v == 1) 
     {

     }
 
 }

}

with appologies moderators. I started the character above a plane, to see how it falls. It still falls very slowly, but when I //comment out all references to the rigidbody from the declaration of the variable (rb) to the assignement, it falls normally.

This suggests that calling the rigidbody in the script in any way interferes with its physics...

avatar image
0

Answer by 4ntihero · Aug 04, 2015 at 10:56 PM

I see the problem now, I apologize for not seeing it early, and thanks for the help.

When I was trying to set the horizontal velocity I was also setting the vertical velocity to 0. I have replaced the Y parameter of "movement" with the object's rigidbody.velocity.y. It seems to be falling normally now.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Jumping only once (2D) 2 Answers

I have a problem with my jump script 1 Answer

change multiple jump to single jump 1 Answer

Can't get platforming character to jump 2 Answers

jump and check ground problem! 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