射击功能在半模式下起作用,但在全自动模式下不起作用

时间:2019-07-18 06:36:03

标签: c# unity3d photon

我正在将VArmory用于枪支系统,最近我开始将项目从离线转向在线。当它是一个离线游戏时,一切运行正常。现在,在半模式下使用相同的启动脚本时,它可以正常工作。但是,当我使用自动模式时,它将不再起作用。

错误日志:

NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:507)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, Photon.Realtime.Player player, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1065)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2734)
Photon.Pun.PhotonView.RPC (System.String methodName, Photon.Pun.RpcTarget target, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:410)
VArmory.Firearm.HoldTrigger () (at Assets/Assets/V Armory/Scripts/Interaction System/Weapons/Firearm Core/Firearm.cs:356)
VArmory.Trigger.PoseTrigger (System.Single input) (at Assets/Assets/V Armory/Scripts/Interaction System/Weapons/Firearm Parts/Trigger.cs:102)
VArmory.Firearm.Update () (at Assets/Assets/V Armory/Scripts/Interaction System/Weapons/Firearm Core/Firearm.cs:165)

行在函数中指定。

保持触发功能:

    protected virtual void HoldTrigger()
    {
        if (!releasedTriggerAfterPickUp)
            return;
        PhotonView photonView = PhotonView.Get(this);

        switch (fireSelector.FireMode)
        {
            case FireSelector._FireMode.semi:
                if (stackTriggerPulls && pulledTriggerWhileSlideWasBack)
                {
                    pulledTriggerWhileSlideWasBack = false;
                    photonView.RPC("Fire", RpcTarget.All);
                }
                break;
            case FireSelector._FireMode.burst:
                if (burstCount < 3)
                    photonView.RPC("Fire", RpcTarget.All);
                break;
            case FireSelector._FireMode.full:
                photonView.RPC("Fire", RpcTarget.All); //Line 356
                break;
        }
    }

姿势触发功能:

public virtual void PoseTrigger(float input)
{
    Vector3 desiredVector = initialPose;

    float hammerDelta = hammer ? hammer.touchPadDelta * poseInputScale : 0;

    if (poseInputScale != 0)
    {
        switch (poseAxis)
        {
            case Axis.x:
                desiredVector.x = (input * poseInputScale) + initialPose.x - hammerDelta;
                break;
            case Axis.y:
                desiredVector.y = (-input * poseInputScale) + initialPose.y + hammerDelta;
                break;
            case Axis.z:
                desiredVector.z = (input * poseInputScale) + initialPose.z - hammerDelta;
                break;
            case Axis.none:

                break;
        }
    }

    if (poseType == PoseType.position)
        transform.localPosition = desiredVector;
    else
        transform.localEulerAngles = desiredVector;

    //Do not pull back hammer if the gun is on safety

    float tempTriggerPull = hammer ? (hammer.Cocked ? doubleActionTriggerPull : triggerPull) : triggerPull;

    if (input >= tempTriggerPull)
    {
        if (releasedTrigger)
        {
            _TriggerPulled();
            releasedTrigger = false;
        }

        _TriggerHeld();
    }

    float tempTriggerRelease = hammer ? (hammer.Cocked ? doubleActionTriggerRelease : triggerRelease) : triggerRelease;

    if (input <= tempTriggerRelease && !releasedTrigger)
    {
        _TriggerReleased(); //Line 102
        releasedTrigger = true;
    }
}

枪支更新功能:

protected virtual void Update()
{
    time += Time.deltaTime;
    BulletTM();
    recoilManager.ApplyRecoil();

    if (!PrimaryHand)
        return;

    if (trigger) trigger.PoseTrigger(PrimaryHand.TriggerRotation); //Line 165

    if (PrimaryHand.Device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        TouchpadDownInput();

    if (PrimaryHand.Device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        TouchpadUpInput();

    if (PrimaryHand.Device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        releasedTriggerAfterPickUp = true;
}

0 个答案:

没有答案