diff --git a/Assets/Prefabs/Input/PlayerAI.prefab b/Assets/Prefabs/Input/PlayerAI.prefab
index dbc3e09db..f24ee7cbc 100644
--- a/Assets/Prefabs/Input/PlayerAI.prefab
+++ b/Assets/Prefabs/Input/PlayerAI.prefab
@@ -106,6 +106,11 @@ Transform:
m_CorrespondingSourceObject: {fileID: 5285924196574601758, guid: 2872a05bf8e94d541a70726bb35085f3, type: 3}
m_PrefabInstance: {fileID: 4812172812220652073}
m_PrefabAsset: {fileID: 0}
+--- !u!4 &884546609350937026 stripped
+Transform:
+ m_CorrespondingSourceObject: {fileID: 5660690314102821867, guid: 2872a05bf8e94d541a70726bb35085f3, type: 3}
+ m_PrefabInstance: {fileID: 4812172812220652073}
+ m_PrefabAsset: {fileID: 0}
--- !u!4 &1198073272138160539 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5938045475689792434, guid: 2872a05bf8e94d541a70726bb35085f3, type: 3}
@@ -249,7 +254,7 @@ MonoBehaviour:
bottomCaster: {fileID: 196519995927016420}
topCaster: {fileID: 3481771409427924515}
stepHeight: 0.5
- playerRoot: {fileID: 0}
+ playerRoot: {fileID: 884546609350937026}
steppingIgnoreMask:
serializedVersion: 2
m_Bits: 0
diff --git a/Assets/Scripts/Control&Input/AIMovement.cs b/Assets/Scripts/Control&Input/AIMovement.cs
index 18c18db84..30f3b0ed6 100644
--- a/Assets/Scripts/Control&Input/AIMovement.cs
+++ b/Assets/Scripts/Control&Input/AIMovement.cs
@@ -30,6 +30,17 @@ private void Update()
}
}
+ protected override bool IsInAir()
+ {
+ // TODO using stepping ground thing here doesn't really work...
+ return base.IsInAir();
+ }
+
+ public bool IsInAirRightNow()
+ {
+ return !IsGroundedAccurate();
+ }
+
protected override void FixedUpdate()
{
var direction = -transform.forward;
diff --git a/Assets/Scripts/Control&Input/PlayerMovement.cs b/Assets/Scripts/Control&Input/PlayerMovement.cs
index fb28ac6a2..768681fa4 100644
--- a/Assets/Scripts/Control&Input/PlayerMovement.cs
+++ b/Assets/Scripts/Control&Input/PlayerMovement.cs
@@ -351,7 +351,7 @@ private IEnumerator LeapTimeout()
/// No, this does not work if the cast start at the bottom.
///
/// Whether or not the player is in the air
- private bool IsInAir()
+ protected virtual bool IsInAir()
{
bool isAir = !Physics.BoxCast(hitbox.bounds.center, new Vector3(.5f, .5f, .2f), Vector3.down, out RaycastHit hit, Quaternion.identity, 0.5f + airThreshold, groundCheckMask);
ground = isAir ? null : hit.collider;
@@ -444,7 +444,7 @@ private void UpdateRotation()
if (!CanLook)
return;
var lookSpeedFactor = inputManager.ZoomActive
- ? inputManager.IsMouseAndKeyboard ? LookSpeedZoom * mouseZoomSpeedFactor: LookSpeedZoom
+ ? inputManager.IsMouseAndKeyboard ? LookSpeedZoom * mouseZoomSpeedFactor : LookSpeedZoom
: lookSpeed;
var lookInput = inputManager.IsMouseAndKeyboard
? inputManager.lookInput
@@ -475,12 +475,17 @@ private void OnDrawGizmos()
/// More accurate ground detection for use in stepping up edges. Uses raycast to check for ground directly beneath the player.
///
/// true if player is touching the ground, false if not touching ground
- private bool FindSteppingGround()
+ protected bool FindSteppingGround()
+ {
+ return IsGroundedAccurate() && state is GroundState.Grounded;
+ }
+
+ protected bool IsGroundedAccurate()
{
RaycastHit hitGround;
if (Physics.Raycast(playerRoot.position, Vector3.down, out hitGround, 0.01f))
{
- if (hitGround.normal.y > 0.0001f && state == GroundState.Grounded)
+ if (hitGround.normal.y > 0.0001f)
{
return true;
}
diff --git a/Assets/Scripts/Gamestate/AIManager.cs b/Assets/Scripts/Gamestate/AIManager.cs
index 97963cc1d..b6dd8db96 100644
--- a/Assets/Scripts/Gamestate/AIManager.cs
+++ b/Assets/Scripts/Gamestate/AIManager.cs
@@ -230,7 +230,7 @@ private IEnumerator LookForTargets()
var hasAmmoBoxBody = ammoBoxCollector.CanReload;
var isOutOfAmmo = gunController && gunController.stats.Ammo < 1;
- var isInAir = aiMovement.enabled && aiMovement.StateIsAir;
+ var isInAir = aiMovement.IsInAirRightNow();
if (hasAmmoBoxBody && isOutOfAmmo && !isInAir)
{
var ammoBox = AmmoBox.GetClosestAmmoBoxForAI(transform.position);
@@ -248,7 +248,12 @@ private IEnumerator LookForTargets()
agent.stoppingDistance = itemStoppingDistance;
agent.SetDestination(DestinationTarget.position);
}
- else if (!aiMovement || !aiMovement.enabled)
+ else if (!aiMovement.enabled && isInAir)
+ {
+ Debug.Log("DISABLING AGENT NOW");
+ DisableAgent();
+ }
+ else
{
FindPlayers();
}