Gravity issue, player movement!

Ok so, I have it when i press fire 1 the gravity flips and i go up to the ceiling. The problem is the head of my player is at the ceiling. I need to flip him around so he can walk on the ceiling.
Here is the gravity script.

var speed = 10;
function Update ()
{
    if(Input.GetButtonDown("Fire1"))
    {
        if(speed > 0)
        {
            Physics.gravity = Vector3(0, speed, 0);
            speed = -10;
            
        }
        else
        {   
            Physics.gravity = Vector3(0, speed, 0);
            speed = 10;
           
        }
    }
}

Why not just make a quick little animation that flips him up and down.

how do i do that? I attempted that but it keeps repeating animation and i cant move my player after it.

1 Answer

1

When you flip directions, flip your player object 180 degrees (character controller and everything).

Agreed, make sure to flip THE WHOLE OBJECT. Also make sure your animation is not set to repeat.