Noclip Script

Hi! I want to make so when i press ā€œVā€ i get noclip and ignore gravity and collisions (kinda like Garrys mod)
I need some help :stuck_out_tongue:
This is what i got so far xD ;(

        if (Input.GetKeyDown(KeyCode.V))
        {
            Physics.gravity *= -1;
        }

I would suggest making your characters rigidbody kinematic.

// Start is called before the first frame update
public Rigidbody rb;
private bool isDisabled = false;

void Start()
{
    rb = GetComponent<Rigidbody>();
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.V))
    {
        if (!isDisabled)
        {
            DisableCollision();
        }
        else
        {
            EnableCollision();
        }
    }
}
void DisableCollision()
{
    rb.isKinematic = true;
}
void EnableCollision()
{
    rb.isKinematic = false;
}

Note: This will disable certain physics so you will need to specifically configure controls for moving up and down as this will most likely disable jumping.