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 lucax · Jul 08, 2014 at 03:26 PM · 2dvelocityplatformerendless runner

Running and Jumping problems of a 2D Endless Runner

Hey guys, its been few days and I am struggling with a very simple sounding problem.

I am working on a quick 2D endless runner which which basically just runs and jumps on a platform above then jump down on a platform below. Now the simple part which makes the programming complicated is that the platforms are always generated randomly but at same distance of X and Y.

Now I have tried to work with Rigidbody.Addforce. It can work fine to give the player horizontal speed but I simply can't get it work out the jumping. The deal here is the player must land on the platform above or below to collect the item but using the Rigidbody.Addforce the player just jumps and flys off and/or the velocity just Fs it up. (PS I don't want to turn the horizontal force off as I want the cube to keep moving forward)

Is there a way around this problem ? I have searched the forums and answers a lot but cannot quite find solution. Thanks for the help guys.

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
Best Answer

Answer by IvovdMarel · Jul 08, 2014 at 03:40 PM

If you want to make the player jump, think about what happens what actually happens when you jump. A force gets added at the moment you push yourself away from the ground, but no extra force gets added while you're in the air. Instead, because of gravity, you'll come down again. Make sure you use both AddForce (only once) and set the gravity in the rigidbody inspector

That's all you need for a jumping script. Also check out the Unity2D tutorial with the bean-guy.

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 lucax · Jul 08, 2014 at 05:14 PM 0
Share

So I should turn the horizontal addforce off when I add the jump force ? Also should I use Force$$anonymous$$ode.Impulse ?

avatar image
0

Answer by Enigmaticall · Jul 08, 2014 at 05:03 PM

It's tough to answer without your code to reference, but is it possible that you are using Input.GetKey instead of Input.GetKeyDown for your jumping key? You only want your character to add the force once, so make sure you are using Input.GetKeyDown

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Velocity Movement & Physics Interactions by Rigidbody2D 0 Answers

Rigidbody2D velocity changes when moving through a platform collider. 1 Answer

2D Physics Broke 1 Answer

Velocity from external objects 0 Answers

Why is my gameObject falling so slow? 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