I’ve been working on a small multiplayer project with a friend, and I am attempting to create a script that will handle instantiating thrown objects, like grenades or other objects, using PhotonNetwork.Instantiate in C#. I keep receiving an error that says;
“Error CS0029: Cannot implicitly convert type ‘UnityEngine.GameObject’ to ‘UnityEngine.Rigidbody’”
This makes sense to me, but the problem comes along when I review the code, just saying I am a bit new to C# with Unity so I need some help figuring out why this is wrong:
void throwObject () { // throws the specified object. (Needs to be a rigidbody) Rigidbody objectToThrow; objectToThrow = PhotonNetwork.Instantiate( selectedObject, transform.position, transform.rotation, 0 ) ; objectToThrow.velocity = transform.TransformDirection(Vector3.forward * throwForce); } ` `