- Home /
old question
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)
Please format the code before posting a question. Its the 5th button from the left.
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.
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.
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.
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.
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.
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
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