Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Instantiating Rigidbodies on PhotonNetwork? Am I doing it wrong?

$
0
0
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);
		
	}

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>