Instantiating rigidbody error
Options
Hi there,
I have what I feel should be a very simple question. I'm trying to instantiate a rigidbody by calling PhotonNetwork.Instantiate, but when I try to add it to this script it comes up with the error: No overload method for PhotonNetwork.Instantiate takes ‘3’ arguments. How can I edit this script so that it will still work in the same way and instantiate the object across the network?
I have what I feel should be a very simple question. I'm trying to instantiate a rigidbody by calling PhotonNetwork.Instantiate, but when I try to add it to this script it comes up with the error: No overload method for PhotonNetwork.Instantiate takes ‘3’ arguments. How can I edit this script so that it will still work in the same way and instantiate the object across the network?
using UnityEngine; using System.Collections; public class Shoot : MonoBehaviour { public Rigidbody projectile; public float speed = 20; void OnMouseDown() { audio.Play(); Rigidbody instantiatedProjectile = PhotonNetwork.Instantiate(projectile, transform.position, transform.rotation) as Rigidbody; instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0,speed)); } }
0
Comments
-
Hi,
you need to reference a prefab that is within a Resource folder in your assets, so you should use "GameObject" not "RigidBody" to reference your projectile.
https://doc.photonengine.com/en/pun/current/tutorials/instantiation
also, you need to specify a group, so it takes another argument:
http://doc-api.exitgames.com/en/pun/current/class_photon_network.html#a843d9f62d28ab123c83291c1e6bb857d
Bye,
Jean0