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
  • JohnTube
    JohnTube ✭✭✭✭✭
    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.
  • JohnTube
    JohnTube ✭✭✭✭✭
    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 developer@photonengine.com.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @zgbjmy2008, @Djo,

    Try replacing in PlayerManager.Update

    IsFiring != beams.activeSelf

    with

    IsFiring != beams..activeInHierarchy
  • JohnTube
    JohnTube ✭✭✭✭✭
    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!

  • JohnTube
    JohnTube ✭✭✭✭✭

    Done.

    Thank you for your patience and understanding.

  • It's work ,thanks :)

  • Hi there, loving the tutorial so far, but I got stuck on this part too. When I press ctrl to fire the beams nothing happens. I did try to Debug.Log to see whether it even registers the button being pressed, but id doesn't.
    Then I saw an error message regarding `GameObject beams`

    Assets/MultiGameTest/Scenes/PlayerManager.cs(16,28): warning CS0649: Field 'PlayerManager.beams' is never assigned to, and will always have its default value null

    Not sure if I understand well but it seems to me that the `GameObject beams` is not assigned and so it doesn't respond to any action.
    `My Robot Kyle` instance has a ProjectManager component and I did assign `Cube GameObject Beams` to beams and than I clicked on `Apply to prefab 'My Robot Kyle'`
    But in `My Robot Kyle` prefab the Beams has `None (Game Object)`

    I don't know if that is the problem or if I'm missing something else.
  • Alright I found the problem. I had one extra prefab I didn't know about and that one was the right one. I deleted the wrong one and did the changes on the correct one and now it works.