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
3
Question by $$anonymous$$ · Feb 24, 2014 at 02:45 AM · 2dgravitytop-downtop down

How to turn off gravity?

I'm working on a top-down game in unity, which is using 2d. However, I can't find a way to turn off gravity. Any help is much appreciated. Thanks in advance!

Comment
Add comment · Show 4
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 $$anonymous$$ · Feb 24, 2014 at 04:11 AM 0
Share

Gravity is only off when no scripts are attached, am I missing something?

avatar image robertbu · Feb 24, 2014 at 04:12 AM 0
Share

Are your scripts adding downward force to the object? Turning off gravity does not effect any force being applied by your scripts.

avatar image $$anonymous$$ · Feb 24, 2014 at 10:10 PM 0
Share

Turns out it was my code, thanks for the help everyone!

avatar image Dblfstr · Feb 24, 2014 at 10:17 PM 0
Share

Still, the answers below are correct for disabling gravity. Through settings, and through code. You should accept one of them as an answer.

4 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by chrismcrae5712 · Feb 24, 2014 at 02:48 AM

Try Edit > Project Settings > Physics and turn Y to 0. That'll make the Y Gravity 0 thus turning off gravity. Not sure if that's what you were looking for though. Hope it helps!

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
10

Answer by robertbu · Feb 24, 2014 at 02:46 AM

You can turn off gravity individually on each Rigidbody. In addition you can turn off gravity globally by:

 Edit > Project Settings > Physics2D

Or in code :

 Physics2D.gravity = Vector2.zero;

Comment
Add comment · Show 4 · 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 $$anonymous$$ · Feb 24, 2014 at 03:02 AM 0
Share

I'm not sure why,but neither method works for me. Thanks for the help tho!

avatar image robertbu · Feb 24, 2014 at 03:11 AM 0
Share

You are using 2D. I missed that. I've edited my answer for 2D.

avatar image ProbePLayer · Nov 22, 2014 at 06:17 PM 0
Share

Perfect answer. Thanks!

edit: although Physics2D.gravity is actually a 2d vector, so others should be aware of that.

avatar image robertbu · Nov 22, 2014 at 07:56 PM 0
Share

@ProbePlayer - thanks for catching the issue.

avatar image
2

Answer by Michio-Magic · Oct 18, 2015 at 06:06 PM

How to turn it on and off ...

This worked for me (attached script to game object).:

 public static var rigidbod : Rigidbody;
 
 function Awake () {  // initialise the variable
     rigidbod = GetComponent(Rigidbody);
 }
 
 function Update () {
       rigidbod.useGravity = false;
        // rigidbod.useGravity = true;
 }




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 Ironhide · Dec 18, 2015 at 01:04 PM 0
Share

Hi!

Im using your cript. I have this gravitygun and a ball. How do i make it that only when i hold the ball gravity is off. But then i can shoot the ball and i want gravity to turn back on.

Sry for my hard to read english..

avatar image Petomai · Aug 02, 2016 at 10:41 PM 0
Share

Is this Java? I am trying this as Java but it is not working.

avatar image
0

Answer by RadioactiveTechnologies · Nov 22, 2014 at 06:42 PM

OR:

 Physics.gravity.y = 0;
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

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

Related Questions

Avoiding 2D top-down diagonal movement 2 Answers

2D Top Down Character being Pulled down and movement script not working? 2 Answers

Can I emulate simple space-like gravity? 2 Answers

Top-down assets 1 Answer

Can anyone tell me what I'm doing wrong here? 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