fixed index out of range exception
This commit is contained in:
parent
1df2866dcf
commit
e40a284343
|
@ -12,7 +12,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: c271cfa846431634db54fa41238b7b35, type: 3}
|
m_Script: {fileID: 11500000, guid: c271cfa846431634db54fa41238b7b35, type: 3}
|
||||||
m_Name: Accessibility Options
|
m_Name: Accessibility Options
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_mode: 2
|
_mode: 0
|
||||||
_calm:
|
_calm:
|
||||||
_tunnel: {fileID: 2100000, guid: 439b4d6018bd23e4e91136d099c5b815, type: 2}
|
_tunnel: {fileID: 2100000, guid: 439b4d6018bd23e4e91136d099c5b815, type: 2}
|
||||||
_vibe:
|
_vibe:
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
using System;
|
|
||||||
using Ktyl.Util;
|
using Ktyl.Util;
|
||||||
using UnityEditor.ShaderGraph.Internal;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.UI;
|
|
||||||
using PlayerInput = Input.PlayerInput;
|
using PlayerInput = Input.PlayerInput;
|
||||||
|
|
||||||
public class MovePlayer : MonoBehaviour
|
public class MovePlayer : MonoBehaviour
|
||||||
|
|
|
@ -123,6 +123,7 @@ public class Weapon : ScriptableObject
|
||||||
|
|
||||||
public void FixedUpdate()
|
public void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
var toRemove = new List<int>();
|
||||||
// loop through the bullets. Backwards, because that is marginally quicker
|
// loop through the bullets. Backwards, because that is marginally quicker
|
||||||
for (var i = _bullets.Count - 1; i >= 0; i--)
|
for (var i = _bullets.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
@ -149,13 +150,17 @@ public class Weapon : ScriptableObject
|
||||||
_currentBullet.IsAlive = false;
|
_currentBullet.IsAlive = false;
|
||||||
_currentTransform.gameObject.SetActive(false);
|
_currentTransform.gameObject.SetActive(false);
|
||||||
_pool.ReturnObject(_currentTransform, _currentBullet.Idx);
|
_pool.ReturnObject(_currentTransform, _currentBullet.Idx);
|
||||||
_bullets.RemoveAt(i);
|
toRemove.Add(i);
|
||||||
_bulletTransforms.RemoveAt(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply the changes we made
|
// apply the changes we made
|
||||||
_bullets[i] = _currentBullet;
|
_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)
|
private bool CheckCollision(Transform instance, Vector3 prevPos, float size, out int numHits)
|
||||||
|
|
|
@ -131,6 +131,8 @@ PlayerSettings:
|
||||||
preloadedAssets:
|
preloadedAssets:
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
|
- {fileID: 0}
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
m_HolographicPauseOnTrackingLoss: 1
|
m_HolographicPauseOnTrackingLoss: 1
|
||||||
|
|
Loading…
Reference in New Issue