A very strange error....
Options
Hello guys, I have a very strange error it is a null reference exception but everything is working fine
Here is the concerned line:
ArKeid0s
NullReferenceException: Object reference not set to an instance of an object AutomaticGunScriptLPFP.Aim () (at Assets/Low Poly FPS Pack/Components/Scripts/Weapon_Scripts/AutomaticGunScriptLPFP.cs:786) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0) Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:478) Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2068) Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3002) ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <55bb4164382346dfa5f9113093df0b12>:0) ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <55bb4164382346dfa5f9113093df0b12>:0) ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <55bb4164382346dfa5f9113093df0b12>:0) Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205) Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)Here is the error it is a beast lmao.
Here is the concerned line:
if (scope1 == true) { anim.SetBool("Aim Scope 1", false); }and this line is part of this function:
[PunRPC] //Aim #region Aim private void Aim() { if (isAiming) { if (ironSights == true) { gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView, ironSightsAimFOV, fovSpeed * Time.deltaTime); } if (scope1 == true) { gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView, scope1AimFOV, fovSpeed * Time.deltaTime); } if (scope2 == true) { gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView, scope2AimFOV, fovSpeed * Time.deltaTime); } if (scope3 == true) { gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView, scope3AimFOV, fovSpeed * Time.deltaTime); } if (scope4 == true) { gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView, scope4AimFOV, fovSpeed * Time.deltaTime); } //If iron sights are enabled, use normal aim if (ironSights == true) { anim.SetBool("Aim", true); } //If scope 1 is enabled, use scope 1 aim in animation if (scope1 == true) { anim.SetBool("Aim Scope 1", true); } //If scope 2 is enabled, use scope 2 aim in animation if (scope2 == true) { anim.SetBool("Aim Scope 2", true); } //If scope 3 is enabled, use scope 3 aim in animation if (scope3 == true) { anim.SetBool("Aim Scope 3", true); } //If scope 4 is enabled, use scope 4 aim in animation if (scope4 == true) { anim.SetBool("Aim Scope 4", true); } if (!soundHasPlayed) { mainAudioSource.clip = SoundClips.aimSound; mainAudioSource.Play(); soundHasPlayed = true; } //If scope 1 is true, show scope sight texture when aiming if (scope1 == true) { WeaponAttachmentRenderers.scope1SpriteRenderer.GetComponent <SpriteRenderer>().enabled = true; } //If scope 2 is true, show scope sight texture when aiming if (scope2 == true) { WeaponAttachmentRenderers.scope2SpriteRenderer.GetComponent <SpriteRenderer>().enabled = true; } //If scope 3 is true, show scope sight texture when aiming if (scope3 == true) { WeaponAttachmentRenderers.scope3SpriteRenderer.GetComponent <SpriteRenderer>().enabled = true; } //If scope 4 is true, show scope sight texture when aiming if (scope4 == true) { WeaponAttachmentRenderers.scope4SpriteRenderer.GetComponent <SpriteRenderer>().enabled = true; } } else { //When right click is released gunCamera.fieldOfView = Mathf.Lerp(gunCamera.fieldOfView, defaultFov, fovSpeed * Time.deltaTime); //If iron sights are enabled, use normal aim out if (ironSights == true) { anim.SetBool("Aim", false); } //If scope 1 is enabled, use scope 1 aim out animation if (scope1 == true) { anim.SetBool("Aim Scope 1", false); } //If scope 2 is enabled, use scope 2 aim out animation if (scope2 == true) { anim.SetBool("Aim Scope 2", false); } //If scope 3 is enabled, use scope 3 aim out animation if (scope3 == true) { anim.SetBool("Aim Scope 3", false); } //If scope 4 is enabled, use scope 4 aim out animation if (scope4 == true) { anim.SetBool("Aim Scope 4", false); } soundHasPlayed = false; //If scope 1 is true, disable scope sight texture when not aiming if (scope1 == true) { WeaponAttachmentRenderers.scope1SpriteRenderer.GetComponent <SpriteRenderer>().enabled = false; } //If scope 2 is true, disable scope sight texture when not aiming if (scope2 == true) { WeaponAttachmentRenderers.scope2SpriteRenderer.GetComponent <SpriteRenderer>().enabled = false; } //If scope 3 is true, disable scope sight texture when not aiming if (scope3 == true) { WeaponAttachmentRenderers.scope3SpriteRenderer.GetComponent <SpriteRenderer>().enabled = false; } //If scope 4 is true, disable scope sight texture when not aiming if (scope4 == true) { WeaponAttachmentRenderers.scope4SpriteRenderer.GetComponent <SpriteRenderer>().enabled = false; } } }If someone can help me i would be happy ^^
ArKeid0s
0