Quantcast
Viewing all articles
Browse latest Browse all 108

Multiplayer Gun Script

So here is the script for the gun using UnityEngine; using System.Collections; public class GunScript : MonoBehaviour { private GameObject FirePort; public Rigidbody BulletType; public int BulletSpeed; // Use this for initialization void Start () { FirePort = gameObject.transform.FindChild ("FirePoint").gameObject; } // Update is called once per frame void Update () { if (Input.GetButtonDown("Fire1")) { Rigidbody Bullet = (Rigidbody)Network.Instantiate(BulletType, FirePort.transform.position, transform.rotation, 0); Bullet.velocity = transform.TransformDirection (Vector3.forward * BulletSpeed); } } } And here is the script that deletes the bullets using UnityEngine; using System.Collections; public class BulletScript : MonoBehaviour { public float BulletDestroyTime; // Use this for initialization void Start () { } // Update is called once per frame void Update () { BulletDestroyTime -= Time.deltaTime; if(BulletDestroyTime <= 0){ Network.RemoveRPCs(networkView.viewID); Network.Destroy(gameObject); } } } It seems that when the bullet gets deleted is gives me these errors: View ID AllocatedID: (a view id number would be here) not found during lookup. Strange behaviour may occur Couldn't perform remote Network.Destroy because the network view 'AllocatedID:(view id again)' could not be located I have a Network View attached to the gun and network views attached to the bullets so plz help me.

Viewing all articles
Browse latest Browse all 108

Trending Articles