Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Problems with IndexOutOfRangeException

$
0
0
Hey guys, i need some help, when I put this script appears this error: IndexOutOfRangeException: Array index is out of range. PlayerController.SwitchWeapon (Int32 w) (at Assets / Assets / scripts / PlayerController.cs: 81) PlayerController.Awake () (at Assets / Assets / scripts / PlayerController.cs: 39) follows the code snippets with error, i don't know what i have to do: using UnityEngine; using System.Collections; using UnityStandardAssets.Characters.FirstPerson; public class PlayerController : MonoBehaviour { //FPS CONTROLLER private FirstPersonController controller; //HOLDERS public Transform walkHolder; public Transform jumpHolder; public Transform swayHolder; public Transform recoilHolder; public Transform adsHolder; public Camera mainCamera; [SerializeField] public WeaponInfo[] allWeaponInfo; public WeaponInfo weapon; public int curWeapon; public int[] playerWeapons; private Vector3[] recoil = new Vector3[4]; public float health; public bool switching; public int nextWeapon = -1; // Use this for initialization void Awake () { SwitchWeapon (0); } // Update is called once per frame void FixedUpdate () { AnimationController (); RecoilController (); ADSController (); } void Update () { ShootController (); } void LateUpdate () { AmmoController (); } private void AnimationController(){ if (Input.GetKeyDown (KeyCode.Alpha1)) { nextWeapon = 0; } if (Input.GetKeyDown (KeyCode.Alpha2)) { nextWeapon = 1; } if (nextWeapon != -1 && nextWeapon != curWeapon && switching == false) { switching = true; swayHolder.GetComponent().Play ("WeaponDown"); } if (switching && swayHolder.GetComponent ().isPlaying == false) { SwitchWeapon (nextWeapon); } } private void SwitchWeapon(int w) { curWeapon = w; weapon = allWeaponInfo [playerWeapons[curWeapon]]; WeaponController (); }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>