hi,why the beams can't (active =true) in the 5 step Building the player? But use

When I finish "Adding The Beams Models" but the beams cant turn "true",I think its null, but I use default MonoBehaviour and delete photonView.IsMine Its worked... why?

image
image

PlayerManager:

using UnityEngine;
using UnityEngine.EventSystems;

using System.Collections;
using Photon.Pun;

//using Photon.Pun;

public class PlayerManager : MonoBehaviourPunCallbacks
{
    [SerializeField]
    private GameObject beams;

    private  bool IsFiring =false;
    void Awake()
    {
        if (beams != null)
        {
            beams.SetActive(false);
        }
       
    }

    // Update is called once per frame
    void Update()
    {
        if (photonView.IsMine)
        {
            ProcessInputs();
        }

        // trigger Beams active state
        if (beams != null && IsFiring != beams.activeSelf)
        {
            beams.SetActive(IsFiring);
        }
    }
    void ProcessInputs()
    {
        if (Input.GetButtonDown("Fire1"))
        // if(Input.GetKeyDown(KeyCode.Space))
        {
            if (!IsFiring)
            {
                IsFiring = true;
            }
        }
        if (Input.GetButtonUp("Fire1"))
        //if(Input.GetKeyUp(KeyCode.Space))
        {
            if (IsFiring)
            {
                IsFiring = false;
            }
        }
    }
}

Answers

  • I'm blocked at this part of the tutorial too... made a post on the forum some days ago, still no answer... it's unbelievable to find errors like that in a TUTORIAL... i'm really confused
  • Hi @zgbjmy2008,

    Thank you for choosing Photon and for taking the time to report this!

    Could you or @Djo help me better understand the issue here?
    What is the expected behaviour and actual behaviour?
  • Expected behaviour is "My Robot Kyle" Beams supposed to be hided at first then only trigger and appear when we press "Fire1" button after we linked "PlayerManager" script to Kyle, at "Controlling The Beams With User Input" part of the tutorial.

    And actual behaviour is "My Robot Kyle" Beams are hided but they do not appear when press "Fire1" with no errors in console.
  • Hey @zgbjmy2008, @Djo,

    Sorry for the delay on this one, sometimes I miss notifications or forget.
    I will take a look and try to reproduce.

    Expect a post early next week.
    Otherwise, feel free to ping me again here or via [email protected]
  • Hi @zgbjmy2008, @Djo,

    Try replacing in PlayerManager.Update

    IsFiring != beams.activeSelf

    with

    IsFiring != beams..activeInHierarchy
  • JohnTubeJohnTube mod
    edited December 2019
    Hey @zgbjmy2008, @Djo,

    Sorry for the confusion & the mistake here.
    We fixed this.

    At this step of the tutorial, we do not need the photonView.IsMine check.
    So get rid of it and instead you should have in PlayerManager:
    
            void Update()
            {
                ProcessInputs ();
    
                // trigger Beams active state
                if (Beams != null && IsFiring != Beams.activeInHierarchy)
                {
                    Beams.SetActive(IsFiring);
                }
            }
    I would like to thank Erik Sombroek (from poki.com) for finding this and sharing it with us!
  • Why don't you fix the actual tutorial!

  • Done.

    Thank you for your patience and understanding.

  • It's work ,thanks :)

Sign In or Register to comment.