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 /
This question was closed Mar 21, 2018 at 09:19 AM by cydonia for the following reason:

old question

avatar image
0
Question by cydonia · May 26, 2014 at 11:22 AM · rigidbodygravityturnoff

turning off gravity for a controller

ok, so I made a third person controller that will be the parent of an object that needs to move on the same plain, unfortunately I can not turn off gravity for it so no matter what it always falls.

I give it a ridged body and unchecked gravity, it still falls

I put in a script to set gravity to 0, it still falls

I change the motor scrip so gravity is set to o, it still F***ing falls

it seems no matter what I do I can not simply turn off gravity for it, I even used the complex motor scrip that lets you turn off gravity, it works, gravity is turned off, but the controller won't move because it's not on a solid surface.

basically I need a script that will turn off gravity for a controller, or a way to turn off the gravity, 3 days now of looking at questions like this and non have worked.

I REALLY want to find a way to simply turn off gravity on a controller but still let it move on the X and Z axis and NOT FALL AT ALL UNDER GRAVITY

hope to get acualy usfull answers because I have yet to find one and frankly I am annoyed as hell right now.

some more info, i'm making a project with a space craft that can move forward and back, left and right, but not up and down, it's third person looking from above and behind, I need it to be able to accelerate, turn, and have the camera follow behind, currently I have a controller than moves the way I need and the camera follows they way I need, but I can not turn off gravity for the controller at all no matter what I do, and I can't use the other controller script because it doesn't work in 0 gravity.

here is the script I have for the controller, I need the ability to turn off gravity for it and have it still work and move the object around on the X and Z plain.

 var speed = 3.0;
 
 var rotateSpeed = 3.0;
 
 function Update ()
 
 {
 
     var controller : CharacterController = GetComponent(CharacterController);
      
      
      
     // Rotate around y - axis
      
     transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
      
      
      
     // Move forward / backward
      
     var forward = transform.TransformDirection(Vector3.forward);
      
     var curSpeed = speed * Input.GetAxis ("Vertical");
      
     controller.SimpleMove(forward * curSpeed);
 
 }
 
 @script RequireComponent(CharacterController)


 
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 Lovrenc · May 26, 2014 at 11:24 AM 0
Share

Please format the code before posting a question. Its the 5th button from the left.

3 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by cydonia · May 26, 2014 at 03:51 PM

alright never mind, I just scrapped the scrip and did some messing around with the 3rd person controller that comes with unity and made it work, thanks anyway for trying.

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 General-Troll · May 26, 2014 at 01:20 PM

Cydonia,

If you want it to stay on the same y level, you can use the Is Kinematic. This will pretty much keep the character in the air unless the y changes through a script. The X and Z axis will be able to move freely, but the Y axis won't move.

Oh, and if this works, please mark it as correct so anyone else who views this will know if it works or not.

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 cydonia · May 26, 2014 at 01:32 PM 0
Share

that is a big negatory, with a rigid body, Gravity clicked off and Is $$anonymous$$inematic clicked on the sphere still falls like a stone.

avatar image
0

Answer by Sprawl · May 26, 2014 at 02:20 PM

If you're using a character Controller, make sure to set the gravity of the Chracter Motor to zero.

If you have a rigidbody, be sure to uncheck gravity.

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 cydonia · May 26, 2014 at 03:08 PM 0
Share

i'm using a basic character motor that doesn't give me that option and if you read my post I already mentioned I have turned off gravity with the rigid body and it still falls under gravity, if it acualy worked properly and turned off gravity when I unchecked gravity I wouldn't be here asking for help.

avatar image cydonia · May 26, 2014 at 03:11 PM 0
Share

a thought occurs, if this motor just isn't going to function properly maybe I can turn a first person controller into a 3rd person controller, but I would need to remove mouse look and make the A and D keys turn the controller ins$$anonymous$$d of strafe left and right, and that seems like a lot of work I don't fully know how to do, but if anyone can figure that out I would be happy.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Rigidbody y velocity is stuck on 0, gravity is not turned off. 2 Answers

Rigidbody gravity between planets 1 Answer

Enable rigidbody gravity,Enable Rigid body gravity 3 Answers

Raycasting ray go through object with gravity enabled 0 Answers

Turret floats away and pushes everything away from it 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