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 remeris · Aug 29, 2013 at 09:43 PM · movementrigidbodygravityjumpingforce

Rigidbody--Addforce on a Spherical Platform(A Globe)

Hey guys.

So my goal is a little 2d Brawler, where you can go around the world fighting bad guys. The world is shaped as a sphere, and players can walk around the globe.

Similar to something like: http://www.youtube.com/watch?v=eD0dv0kO9oI

I'm using a fake gravity system to keep the player grounded onto the planet.

I'm pretty lost as to how to handle Jumping/Flying at this point though. Just trying to get a jump button working using Addforce, the player character will often get pushed backwards, or will just slide backwards along the ground. Any ideas as to how I could implement a jump/fly mechanic on this sphere world?

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 robertbu · Aug 29, 2013 at 10:20 PM 0
Share

Without code, we can only guess about your issues. Are you adding force using 'transform.up'?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DESTRUKTORR · Aug 29, 2013 at 10:34 PM

Firstly, that's a circle, not a sphere. Spheres are 3D, circles are 2D (well, technically they're 1D, but that's beyond the scope of what I'm getting into, here...). There is no third dimension in that game, and if you had the characters able to walk over a sphere, it would be a 3D game.

Proper terminology aside, the biggest issue you've got here is that you want to have a gravitational center rather than a gravitational direction (which is how Unity's gravitational system works). The first thing you'll want to do to fix this issue is to ensure the "use gravity" boolean on all the rigidbodies you're using is set to false (or "off").

Next comes the more challenging part: You're going to need to somehow manage all the objects that will be affected by gravity to have force applied to them (or their positions altered, in the case that their rigidbodies are kinematic) such that they are pulled toward the center of the circle being used.

Now that the gravity is out of the way, you'll need to ensure that the rotation of the objects is correct, with respect to the center of the planet. To do this, simply find the angle at which the objects are at, with respect to the planet's center, then find the angle that is perpendicular to that angle (Hint: Add or subtract 90 degrees, or pi/2, if using radians :P).

You'll have to recalculate the rotations each frame (or at least each time their angle with respect to the planet's center is changed).

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
0

Answer by Jojo B · Oct 01, 2013 at 03:17 PM

the simplest way i can think of is to use some vector maths if you do for gravity rigidbody.addForce(Gravity*mass*Vector3.Normalize(planet.position-transform.position));

note that gravity is whatever force you want per mass so earth is 9.81 N/kg

and for the jump

rigidbody.addForce(jumpForce*Vector3.Normalize(transform.position-planet.position));

and jumpForce is a variable

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

21 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

Related Questions

A* Rigidbody. Aron Granberg 1 Answer

Tornado throwing back force after pulling 1 Answer

Help with player movement and jumping 0 Answers

How to clear all forces but not the gravity force? 1 Answer

Character drops from air when using velocity Jump and transform.translate direction after releasing W key 0 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