• 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 27, 2015 at 04:13 PM by meat5000 for the following reason:

Next time include code which demonstrates that you tried it for yourself.

avatar image
-1
Question by Legendairy · Jul 27, 2015 at 10:58 AM · physics

Gravity on a cube. walking around the cube like youd walk around the globe, you dont fall off the earth--you dont fall off the cube..

So ive asked this question before but each time i get a pretty useless answer because im apparently not being specific when i say i want gravity on a cube--i want to walk around the cube like youd walk around a sphere--i DO NOT want to fall off The cube is a sphere except flat it has 6 sides and each side will have something on it, for example a house on each side, i want to walk into each house and say hi to the people in there and ask for a cup of sugar. i do not want to fall off this cube, i dont want to jump off this cube, i want to walk around it, let me say it again, i. want. to. walk. around. my. cube. i dont care how its done, i want to walk around a cube. ive applied a rigid body to it like someone had suggested but low and behold i fell off so obviously this method doesnt work or it was poorly and half assed explained. i dont know how i can be more specific then this, if for whatever reason this isnt specific, give it another read and use a bit more imagination. Im not being rude, ive asked the same question 5 times and i get either nothing or people looking it in black and white saying i wasnt technical enough. well im new give me a break and help me out.

Comment
Comments Locked · 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 tanoshimi · Jul 27, 2015 at 04:04 PM 1
Share

"Im not being rude" Well, that's a matter of opinion....

Rather than ask the same question five times and demand people read it again and use more imagination than the "half assed" explanations that have already been offered, why not describe what effort you've put in to solve your problem?

3 Replies

  • Sort: 
avatar image
1

Answer by Graham-Dunnett · Jul 27, 2015 at 11:00 AM

Gravity in Unity assumes that your game is running on a flat terrain. So typically the ground is in the xz plane, and gravity is acting in a negative y axis. You're using a terrain that is 6-sided on a cube. You will need to adjust the gravity direction each time your character moves from one cube side to another.

Comment
Comments Locked · 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 Ellenack · Jul 27, 2015 at 04:46 PM

I woulg go like Graham Dunnett said. In pseudo-code, you would get something like that (in 2D for a simple explanation) :

 vec2 playerPos;
 vec2 cubeCenter;
 
 vec2 playerDir = (playerPos-cubeCenter).normalized; // player position relative to the cube
 
 if( abs(playerDir).x > abs(playerDir.y) )
 {
     // The player is on a face on the left or the right
 
     if( playerDir.x > 0 ) // right
         gravity = ( -1, 0 ) // gravity push him left
     else // left
         gravity = ( 1, 0 ) // gravity push him right
 }
 else
 {
     The Player is on a face on the top or the bottom
 
     if( playerDir.y > 0 ) // top
         gravity = ( 0, -1 ) // gravity push him down
     else // bottom
         gravity = ( 0, 1 ) // gravity push him up
 }

However, beware the corners, it might need a little tweaking to go through them correctly (a lerp of the gravity so he start falling and then touch the ground for a nice effect)

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 meat5000 · Jul 27, 2015 at 04:10 PM

Start with a sphere for conceptualising.

Apply a 'downward' force from each Object to the centre of the World depending on its orientation. Switch Gravity field off.

When that works switch to a cube and adjust as needed (by moving where the object 'thinks' the centre is).

Its easy.

Comment
Comments Locked · 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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D 360 degress platformer example needed 0 Answers

What is the proper usage of SphereCast 1 Answer

How to limit the motion direction of a GameObject? 1 Answer

My sword pushes enemies around? 1 Answer

Version 3.2 gives no OnTriggerExit when collider is parented 12 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