fixed index out of range exception

This commit is contained in:
Dom Harris 2021-01-10 14:25:03 +00:00
parent 1df2866dcf
commit e40a284343
4 changed files with 10 additions and 6 deletions

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c271cfa846431634db54fa41238b7b35, type: 3}
m_Name: Accessibility Options
m_EditorClassIdentifier:
_mode: 2
_mode: 0
_calm:
_tunnel: {fileID: 2100000, guid: 439b4d6018bd23e4e91136d099c5b815, type: 2}
_vibe:

View File

@ -1,9 +1,6 @@
using System;
using Ktyl.Util;
using UnityEditor.ShaderGraph.Internal;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
using PlayerInput = Input.PlayerInput;
public class MovePlayer : MonoBehaviour

View File

@ -123,6 +123,7 @@ public class Weapon : ScriptableObject
public void FixedUpdate()
{
var toRemove = new List<int>();
// loop through the bullets. Backwards, because that is marginally quicker
for (var i = _bullets.Count - 1; i >= 0; i--)
{
@ -149,13 +150,17 @@ public class Weapon : ScriptableObject
_currentBullet.IsAlive = false;
_currentTransform.gameObject.SetActive(false);
_pool.ReturnObject(_currentTransform, _currentBullet.Idx);
_bullets.RemoveAt(i);
_bulletTransforms.RemoveAt(i);
toRemove.Add(i);
}
// apply the changes we made
_bullets[i] = _currentBullet;
}
foreach (var i in toRemove)
{
_bullets.RemoveAt(i);
_bulletTransforms.RemoveAt(i);
}
}
private bool CheckCollision(Transform instance, Vector3 prevPos, float size, out int numHits)

View File

@ -131,6 +131,8 @@ PlayerSettings:
preloadedAssets:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1