How do I freeze a rigidbody2d using script?

I’m learning in class, I would like to know how we would go about freezing the position of my rigidbody2d on respawn. I’ve already asked my teacher, he personally has never done it, so he doesn’t know how.

There are a couple ways to do this. Try one or both to see which works best for your game.

If you change the RigidBody to be Kinematic, it will still retain physical properties, but not do any physics calculations for that body (Things can hit it, but it won’t react, no reaction to gravity, etc).

        var item = Instantiate<GameObject>(prefab);
        var rb = item.GetComponent<Rigidbody2D>();
        rb.bodyType = RigidbodyType2D.Kinematic;

Another option is to turn on all constraints.

        var item = Instantiate<GameObject>(prefab);
        var rb = item.GetComponent<Rigidbody2D>();
        rb.constraints = RigidbodyConstraints2D.FreezeAll;

I got the same error twice, it may be my fault, I’m just learning this, but, I got that "Type ‘PlayerController’ does not contain a definition for ‘SetActive’ and no extension method ‘SetActive’ of type “PlayerController’ Could be found. Are you missing an assembly reference?”