Hi All,
I’m new to Unity and this is my first ever post. Absolutely loving the engine so far and having a lot of fun experimenting with its features. I was wondering if someone could give me some guidance. Using c# I have written a simple script to instantiate a number of prefabs in my scene. Initially my prefabs are kinetic with no gravity. I want to allow them to draw in the scene then via a key press enable the gravity and disable the fact they are kinetic.
I have literally just added this very simple code to do so (where fixedPoint is the name of my prefab) :
if (Input.GetKeyDown("g"))
{
fixedPoint.GetComponent<Rigidbody>().isKinematic = false;
fixedPoint.GetComponent<Rigidbody>().useGravity = true;
}
This seems to work fine for any prefabs that are yet to be rendered to the scene. I was hoping to allow my prefabs to be drawn and then by clicking the ‘g’ key allow gravity to take effect for all of the prefabs in the scene.
Can anyone assist?
Thanks
Rob