I'm trying to turn off the gravity for one instantiated prefab clone, if something in the game happens. I have this:
public class Controller : MonoBehaviour
public Transform randomcoin;
private void Start()
if ( ... )
{ randomcoin.GetComponent<Rigidbody>.useGravity = false; }
This gives me this error:
Component.GetComponent<T>() is a method, which is not valid in the given context
Does anyone know how I can fix this?
You're missing () in randomcoin.GetComponent<Rigidbody>
It should be like this:
randomcoin.GetComponent<Rigidbody>()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With