photonView.IsMine

Hi there,

I feel kinda dumb asking this but I think that "photonView.IsMine" is not working, at least is not working on my project. I'm following step by step the tutorial from the documentation and I got stuck in this part when you check the others beams and check the player health. When I get to add it into OnTriggerEnter and OnTriggerStay method I get an error, it shows like if I wrote it wrong. I've been looking at the whole script for two hours and I can't find what's wrong.

I would really appreciate it if you could help me.

Here's a link to a screenshot I took from the script (I couldn't figure out how to upload a picture here so I uploaded to Google Drive):

https://drive.google.com/open?id=1JXYEKxstXN2HkxptSvGKr2m03sXTM2_j

Also, I'll leave de PlayerManager script I have:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;


namespace Com.JmJdProd.Murderer
{

public class PlayerManager : MonoBehaviour
{
#region Private Fields

[Tooltip("The Beams GameObject to control")]
[SerializeField]
private GameObject beams;
//True, when the user is firing
bool IsFiring;
#endregion

#region Public Fields

[Tooltip("The current Health of our player")]
public float Health = 1f;

#endregion

#region MonoBehaviour CallBacks

///
/// MonoBehaviour method called on GameObject by Unity during early initialization phase.
///
void Awake()
{
if (beams == null)
{
Debug.LogError("Missing Beams Reference.", this);
}
else
{
beams.SetActive(false);
}
}


void OnTriggerEnter(Collider other)
{
if (PhotonView.IsMine)
{
return;
}


if (!other.name.Contains("Beam"))
{
return;
}
Health -= 0.1f;
}

void OnTriggerStay(Collider other)
{

if (!photonView.IsMine)
{
return;
}


if (!other.name.Contains("Beam"))
{
return;
}
Health -= 0.1f * Time.deltaTime;
}
void Update()
{

if (Health <= 0f)
{
GameManager.Instance.LeaveRoom();
}

ProcessInputs();

// trigger Beams active state
if (beams != null && IsFiring != beams.activeInHierarchy)
{
beams.SetActive(IsFiring);
}
}



#endregion

#region Custom

void ProcessInputs()
{
if (Input.GetButtonDown("Fire1"))
{
if (!IsFiring)
{
IsFiring = true;
}
}
if (Input.GetButtonUp("Fire1"))
{
if (IsFiring)
{
IsFiring = false;
}
}
}

#endregion
}
}

Comments

  • I have the same issue. People have been asking about this over and over. Could someone address it?

  • This question has been answered, but for whatever reason, they don't update the tutorial. Remove the check for photonview.ismine and just ProcessInputs(); You will add the check in the next section properly.

  • Hi @Persian99, @jwehr,

    Thank you for choosing Photon!

    Documentation page update done.

    Sorry for the inconvenience.

    Thanks you for your patience and understanding.

  • @JohnTube and @jwehr

    Thanks for answering, I just realized I missed something really important in the script ( 'MonoBehaviourPunCallBacks)

    Anyway, I really appreciate you took your time to answer.


    Thanks again and hope you have happy holidays.

Sign In or Register to comment.