fixed AI not resetting

This commit is contained in:
maverickdgg 2023-03-25 18:47:42 +08:00
parent 89bfbf3100
commit e7ec24c15a
4 changed files with 30 additions and 21 deletions

View File

@ -5535,7 +5535,7 @@
- Is Trigger: false
Collision Tag: 5
Type: Box
Half Extents: {x: 0.600000024, y: 1.79999995, z: 0.400000006}
Half Extents: {x: 0.200000003, y: 1.79999995, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1

View File

@ -127,14 +127,17 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
private void AICheat()
{
StateMachine machine = GetScript<StateMachine>();
if(machine)
AILineOfSight los = GetScript<AILineOfSight>();
if(machine && los)
{
if (Input.GetKeyDown(Input.KeyCode.F))
if (Input.GetKeyDown(Input.KeyCode.K))
{
los.range = 5.0f;
machine.SetState(typeof(AlertState));
}
if(Input.GetKeyDown(Input.KeyCode.L))
{
los.range = 0.0f;
machine.SetState(typeof(IdleState));
}

View File

@ -42,11 +42,11 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>();
if (pc)
{
//pc.currentState = RaccoonStates.CAUGHT;
//if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
// pc.stateMachine.SetState(typeof(PlayerCaughtState));
pc.currentState = RaccoonStates.CAUGHT;
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
pc.stateMachine.SetState(typeof(PlayerCaughtState));
//pc.GotCaught();
pc.GotCaught();
if (ai)
{
ai.Reset();

View File

@ -14,7 +14,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
float windupTime = 8.0f / 30.0f;
float holdTime = 0.3f;
float seqTime = 8.0f / 30.0f;
float seqTime = 8.0f / 30.0f ;
float endTime = 0.5f;
@ -48,8 +48,19 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{
rigid.LinearVelocity = Vector3.Zero;
}
Transform transform = machine.GetComponent<Transform>();
AILineOfSight los = machine.GetScript<AILineOfSight>();
Transform playerTransform = ai.player.GetComponent<Transform>();
if (los && transform)
{
Vector3 direction = playerTransform.GlobalPosition - transform.GlobalPosition;
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
transform.LocalRotation = targetRotation;
}
ai.attackHitbox.SetActive(false);
}
@ -64,18 +75,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
rotate.lookAround = false;
}
Transform transform = machine.GetComponent<Transform>();
AILineOfSight los = machine.GetScript<AILineOfSight>();
Transform playerTransform = ai.player.GetComponent<Transform>();
if(los && transform)
{
Vector3 direction = playerTransform.GlobalPosition - transform.GlobalPosition;
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
transform.LocalRotation = targetRotation;
}
ai.attackHitbox.SetActive(false);
}
@ -106,11 +106,17 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
}
else if(seq)
{
if(timer <= 1.0f / 30.0f)
{
ai.attackHitbox.SetActive(true);
}
if(timer <= 0.0f)
{
seq = false;
end = true;
animator.PlayOneShot(ai.atkSeqAnim);
timer = endTime;