Toggling Component's Function on a gameObject

Hello Everyone,

I’m trying to toggle the Kinematic function of the Rigidbody component of a gameObject from false to true. This is the line of code I’m trying to use:

this.GetComponent(isKinematic = true);

This is clearly not working. I think I am also having troubles referencing the gameObject with the .this code. Any help with that as well? Thank you for your time.

Hi I think it’s just a syntax issue, would help if you post the specific error. If it is just the syntax this should work but must be in the script attached to the gameObject which has the rigidbody component.

this.GetComponent<Rigidbody>().isKinematic = true; // for Rigidbody
this.GetComponent<Rigidbody2D>().isKinematic = true; // for Rigidbody2D