I’ve read more than 10 questions exactly like this one and have tried all the solutions but I’m still getting errors.
I want to instantiate an object and give it a gravity scale of 0. Here is the code (C#):
(If button press…)
Rigidbody2D temporary;
temporary = Instantiate (GameObject.Find ("wood1x1"), new Vector2 (1, 1), Quaternion.identity) as Rigidbody2D;
temporary.gravityScale = 0;
What is actually happening is the object will instantiate, but the gravity scale won’t be set and I get “Object reference not set to an instance of an object” error in console. I feel like this should be a really easy fix, but I’m not seeing it. Any help would be great.