make character walk on the ceiling..ish

Hi all.
Im a little stock on where to go in the scripting department when it comes to gravity .
what i want to do is make the character walk on the “ceiling” or upside down if you will , like with planetery gravity, only this is a 2.5D platformer.

So when the player jumps and there is a platform over him then he sticks to the bottom of thet top level platform.
If thats makes any sense.

And thanks in advance

Hello there!

Do you want the gravity to actually change or just the character’s personal “gravity”? This piece of code should be in a script attatched to the player, and it will change the gravity. If you want only the character to be affected you’ll have to do so with rigidbody.AddForce(). Anyway, here’s the code:

void OnCollisionEnter(Collision collision)
{
    Physics.gravity = collision.contacts[0].normal * -10;
}

void OnCollisionExit(Collision collision)
{
    Physics.gravity = Vector3.down * 10;
}

you may find something usefule in this thread

Thanks for pointing me in the right direction :slight_smile:

i was wondering if one could do a transform.rotate on the main camera insted, so the whole world flips insted of the character