Trying to assign new name, Unity says it can't find the object?

On the line where I’m trying to give a new name to a recently instantiated rigidbody, Unity is telling me that “Object reference is not set to an instance of an object”.

I’ve checked a few more questions/answers and I thought I was declaring this variable properly before trying to use it.

Have I missed something? Many thanks for your help.

Rigidbody newplayerShot = Instantiate (playerShot, launchSite, transform.rotation)as Rigidbody; = "playerShot";
newplayerShot.rigidbody.velocity = transform.up * shotSpeed;

Rigidbodies are components, you don’t instantiate them. Instantiate your prefab and then search for the rigidbody component that’s attached to it using GetComponent.

Edit: if it has a rigidbody attached to it you can just go


No need to getcomponent