- Home /
Problem making a Network projectile Instantiate.
I have been following the Merry Fragmas 2 video, but wanted to add a physical bullet. I was reading some of the documentation and got to this http://docs.unity3d.com/Manual/UNetSpawning.html Don't really know how to implement it into my code. I know I have to put something in [command] to send it to the server but have no idea how. Sorry I'm dumb... ha..ha..
'using UnityEngine; using UnityEngine.Networking;
public class shooting : NetworkBehaviour {
public Rigidbody toast;
public float speed = 20;
public float x;
public float y;
public ParticleSystem crumbs;
public float fireRate;
private float nextFire;
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0) && Time.time >nextFire)
{
nextFire = Time.time + fireRate;
crumbs.Stop();
crumbs.Play();
Rigidbody instantiatedProjectile = Instantiate(toast, transform.position, transform.rotation)
as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(x, y, speed));
Destroy(instantiatedProjectile.gameObject, 2.0f);
}
}
} '
it's 5 am and I don't even know how to use a forum right..
I found out my problem I was reading old documentation and was too tired to realized that. I was using Network.instantiate ins$$anonymous$$d of the new Spawn. Somehow I linked the one with the right code in it but never read it right. Sorry for the inconvenience! http://docs.unity3d.com/$$anonymous$$anual/UNetSpawning.html :D