Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
11 Jun 22 - 14 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 /
This question was closed Jul 29, 2015 at 01:41 AM by meat5000 for the following reason:

Duplicate Question

avatar image
-1
Question by Aquillis · Jul 29, 2015 at 01:08 AM · jumpingerror-building-playernon-static

About RigidBody2D.AddForce()...(Revised without spelling Errors)

Can I please have a actual answer to my question:

Hey, I need some help with my coding. I'm trying to figure out how to create jumping easily and without much to code, unfortunately I found that I do not seem to have Rigidbody2D.AddForce() for my drop-down list to insert. I want to learn how to make characters able to jump in the game, but I am unsure of other methods that can be made on the fly--as I've seen a load of people in need of help use AddForce for making their characters jump. Is there anyway that I can still incorporate this method in my Unity 5.1.f03 version, or do I need to do something a lot more complicated and different?

EDIT: I apologize for my rudeness, but I actually need some help with this as I really, really want to make a video-game by myself.

Comment
Add comment · Show 1
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 meat5000 ♦ · Jul 29, 2015 at 01:41 AM 1
Share

Ins$$anonymous$$d of editing to apologise, why not edit out the rudeness?

Write a proper question, get a proper answer.

You didn't even search google. The first hit makes this a duplicate question.

2 Replies

  • Sort: 
avatar image
4

Answer by YoungDeveloper · Jul 29, 2015 at 01:05 AM

Mod who told you about spelling mistakes is 100% right. If OP can't invest enough energy and work for nicely formatted question, why possible answer givers must break their heads thinking what u meant with what. It's consider totally disrespectful to throw garbage text at someone and expect them to invest their time helping you. #endmoral

What comes to your question, yes, you can use add force for rigidbody to simulate jump effect, or write hard coded custom jump which doesn't take physics. Add force isn't any different from previous versions (from syntax perceptive), so its the same. You clearly haven't included any code or actual tried anything, so there's that. Internet and Youtube is full or any kind of character controller tutorials (3d and 2d), so it would be arrogant to say that there is no information on this topic.

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
avatar image
1

Answer by MegaChuck64 · Jul 29, 2015 at 01:11 AM

well you should definitely have that as an option. Make sure use GetComponent first. like this

 using UnityEngine;
 using System.Collections;
 
 public class JumpScript : MonoBehaviour {
 
     
     Rigidbody2D rB;
     public float jumpSpeed = 5;
     
     void Start ()
     {
         rB = GetComponent<RigidBody2D>();
     }
     
     void Update()
     {
         if (Input.GetKeyDown(Keycode.Space))
         {
             rB.AddForce(transform.up * jumpSpeed);
         }
     }




Comment
Add comment · Show 2 · 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 Aquillis · Jul 29, 2015 at 01:30 AM 0
Share

Alright, I've added the GetComponent in the way you've done it, but now it seems that only one jump is allowed before it returns to it not being able to use the Space input the way it should. I'll go on ahead and look up how to fix that. Thank you very much!

avatar image MegaChuck64 · Jul 29, 2015 at 02:38 AM 0
Share

try adding "Time.deltaTime" after rB.AddForce(transform.up * jumpSpeed.

 rB.AddForce(transform.up * jumpSpeed * Time.deltaTime);



if you put something in the "void Update", it happens once per frame. so unless you have a really high frame rate, your code will only work sometimes. Since it has to start right on a frame. so if you click jump in between frames it wont work. "Time.deltaTime" multiplies by the time in seconds it took to complete the last frame, creating a seamless jump that works every time.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Even / Constant Speed and Jumping 2D 1 Answer

I want my player to jump only once. How?, 1 Answer

How can I make my character jump & move him by zone 0 Answers

Smoother movement and jumping with rigidbodies 1 Answer

Character jumps to high on start moving 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