Yellow bug PhotonNetwork.Instantiate bullet
Options
when I have a player slides along the wall of the playing field and sparks spawn
Received OnSerialization for view ID 2240. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined
Then this view ID 2240 is assigned a bullet when I put the observe option = unreliable on reliable delta compressed, this yellow error does not occur. How to make so that this error does not occur on observe option = unreliable ?
void OnCollisionStay2D (Collision2D other) // respawn sparks when the slide on the wall { if (photonView.isMine!) return; for (int i = 0; i <other.contacts.Length; i ++) { Vector2 hitPoint = other.contacts [i] .point; PhotonNetwork.Instantiate (Resources.Load ( "Sparks") name, new Vector3 (hitPoint.x, hitPoint.y, 0), transform.rotation, 0.); } }and at this moment it shoots bullets arises yellow bug -
Received OnSerialization for view ID 2240. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined
Then this view ID 2240 is assigned a bullet when I put the observe option = unreliable on reliable delta compressed, this yellow error does not occur. How to make so that this error does not occur on observe option = unreliable ?
using UnityEngine; using System.Collections; public class Bullet : Photon.MonoBehaviour { public float speed_bullet; private Rigidbody2D rb; void Awake() { if (photonView.isMine) { rb = GetComponent<Rigidbody2D>(); rb.velocity = -transform.up.normalized * speed_bullet; } } void OnCollisionEnter2D(Collision2D other) { if (!photonView.isMine) return; for (int i = 0; i < other.contacts.Length; i++) { Vector2 hitPoint = other.contacts[i].point; PhotonNetwork.Instantiate(Resources.Load("Sparks").name, new Vector3(hitPoint.x, hitPoint.y, 0), transform.rotation, 0); } StartCoroutine(bullet_self_destruct_()); } IEnumerator bullet_self_destruct_() { GetComponent<SpriteRenderer>().enabled = false; GetComponent<BoxCollider2D>().enabled = false; while (GetComponent<AudioSource>().isPlaying == true) yield return new WaitForSeconds(0.1f); PhotonNetwork.Destroy(gameObject); } }
using UnityEngine; public class NetworkBullet : Photon.MonoBehaviour { void Start() { correctPlayerPos = transform.position; correctPlayerRot = transform.rotation; } void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { stream.SendNext(transform.position); stream.SendNext(transform.rotation); stream.SendNext(GetComponent<Rigidbody2D>().velocity); } else { correctPlayerPos = (Vector3)stream.ReceiveNext(); correctPlayerRot = (Quaternion)stream.ReceiveNext(); GetComponent<Rigidbody2D>().velocity = (Vector2)stream.ReceiveNext(); } } private Vector3 correctPlayerPos; private Quaternion correctPlayerRot; void Update() { if (!photonView.isMine) { transform.position = Vector3.Lerp(transform.position, correctPlayerPos, Time.deltaTime * 5f); transform.rotation = Quaternion.Lerp(transform.rotation, correctPlayerRot, Time.deltaTime * 5f); } } }
0