- Home /
Rigid body component added without me telling it to be added,Rigid body component being added when it is never told to
I have a prefab that does not have a rigid body attached. All it has is a sprite rendered and my own custom script. The custom script DOES NOT require a rigid body and doesn’t use one at all. The script simply tries to lock the rotation on validate with my own custom script. The problem is whenever I drag the custom prefab into the game scene it adds a rigid body to it. I have tried to delete that component off the object but when I apply it to the prefab it automatically re adds it. Since this has to deal with unity adding components for no reason I am assuming it is something to do with the coding of the unity engine itself as there is no documentation I found anywhere relating to this problem
I seem to have found the main problem. My custom script was named "Joint" and it seems that unity has a base abstract class with the name of Joint that inherits from component and all joint components inherit from that Joint class.
The problem is that while it seems I can "Override" the joint class with my own. The editor reads my custom class and assumes it is a custom class as well as the base class for joints. Therefore it forces the GameObject to include a rigid body component. I'm not sure why this is or how it decides to read the script, but this is what was causing the issue.