- Home /
Photon Errors?
This is a collection of many errors I get when I try to run the game with Photon Network.
I'm using Photon, and when i run the game, the console gives me an error: NullReferenceException: Object reference not set to an instance of an object Raycast.Update() (at Assets/Scripts/Raycast.cs:43)
The error is in the line if (pv.isMine == true)
I'm trying to check if the character is mine, so I can control it. Here is my void update for Raycast.cs:
void Update ()
{
PhotonView pv = PhotonView.Get(this);
if (pv.isMine == true)
{
PlayerStatecontroller();
PlayerAnims();
ammocount.text = ammo.ToString();
var ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
RaycastHit hit;
if (cooldownRemaining >= 0)
{
cooldownRemaining -= Time.deltaTime;
}
else if (cooldownRemaining < 0)
{
cooldownRemaining = 0;
}
if(Input.GetMouseButton (0) && cooldownRemaining <= 0 && ammo >= 1)
{
weapon.animation.Play("recoil");
ammo -= 1;
audio.PlayOneShot (shot, 0.5f);
if(Physics.Raycast(ray, out hit, 300))
{
Instantiate(sparks, hit.point, Quaternion.identity);
if (hit.collider.gameObject.tag == "Enemy" || hit.collider.gameObject.tag == "Player")
{
hit.collider.SendMessageUpwards("takeCurDmg", dmgStat, SendMessageOptions.DontRequireReceiver);
hit.collider.SendMessageUpwards("takeArmDmg", aPierce, SendMessageOptions.DontRequireReceiver);
Debug.DrawLine(ray.origin, hit.point, Color.red);
//Debug.Log (hit.collider.tag);
//Debug.Log ("Hit an enemy");
}
}
//flare.emit = false;
cooldownRemaining = cooldown;
}
if (Input.GetKeyDown (KeyCode.R) == true)
{
ammo += 150;
}
}
}
(Sorry if its long)
Another problem I get is that I define a GUIText, but when I run the game, the GUIText appears, but it doesn't update. A minor problem compared to the first one. Thanks in advance for help.
Answer by TrivialRoo · Sep 07, 2013 at 11:38 PM
OK, Nevermind, I fixed the problem. I changed it from "this" to:
void Update ()
{
PhotonView pv = PhotonView.Get (transform.parent);
if (pv.isMine)
{
Your answer
Follow this Question
Related Questions
AsyncOperation and Socket disable 0 Answers
Unknown identifier: 'supportDX11'. Error Fix? 1 Answer
System.Collections error while building the player for windows phone 8 1 Answer
Float From Scene1 to Scene2 1 Answer
touch 2d sprite collider 0 Answers