- Home /
Gravity - How to walk on ceiling
I am sorry if this is a duplicate question, but I failed to find an answer that would provide me with the mechanics on what to do. Basically, I am trying to let the player switch gravity, so that he and all the rigidbodies would fall on the ceiling. Problem is, I found out that the character controller is not affected by Physics.gravity, so I am now trying to find an alternate way.
I tried something like
void Update ()
{
CharControl.Move(gravityForce * Time.deltaTime);
}
void GravitySwitch()
{
gravityForce = Physics.gravity;
}
where I trigger GravitySwitch by a message on the event.
But the jump doesn't work now, due to the constant movement down. Is it possible to keep the basic mechanics of the CharacterController, and yet make it react to the Physics.Gravity? I need the player to walk on the ceiling and jump "down" just like with normal gravity.
Thanks in advance!
I've not looked at the character controller code much, but I would assume for jumping there's some sort of jump force vector employed - probably initialized to Vector3.up or something similar. You should be able to just reverse that when reversing gravity so the jump force points down ins$$anonymous$$d.
Answer by Berenger · Jan 22, 2013 at 04:04 PM
You should give a shot at rigidbody based characters : http://wiki.unity3d.com/index.php/RigidbodyFPSWalker or http://wiki.unity3d.com/index.php/PhysicsFPSWalker
Thank you! Required a little more scripting and reworking, but the basic principles are exactly what I needed!
Your answer
Follow this Question
Related Questions
Charactercontroller won't go down, only goes up 0 Answers
How to make player not fall during dash 1 Answer
Can someone help me with my TPS Controller/Camera? 1 Answer
Getting this character controll script working right 1 Answer
How to do this? 2 Answers