Skip to content

Commit

Permalink
Statemachine controlled Zombie patrol behavior updated with fixing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
baponkar committed Oct 8, 2022
1 parent 9e15a4a commit 8be9764
Show file tree
Hide file tree
Showing 16 changed files with 264 additions and 4,822 deletions.
1 change: 0 additions & 1 deletion Assets/AttackNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protected override State OnUpdate() {
Health targetHealth = targetingSystem.Target.GetComponent<Health>();
if(targetingSystem.TargetDistance <= 2f)
{
Debug.Log(targetingSystem.TargetDistance);
if(targetHealth.isDead)
{
return State.Success;
Expand Down
173 changes: 164 additions & 9 deletions Assets/TheKiwiCoder/BehaviourTree/Example/ExampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &129060774
PrefabInstance:
Expand All @@ -278,7 +278,7 @@ PrefabInstance:
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
propertyPath: m_RootOrder
value: 5
value: 7
objectReference: {fileID: 0}
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
Expand All @@ -298,7 +298,7 @@ PrefabInstance:
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
Expand All @@ -308,7 +308,7 @@ PrefabInstance:
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
Expand All @@ -323,7 +323,7 @@ PrefabInstance:
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
value: 180
objectReference: {fileID: 0}
- target: {fileID: 9085547358668908740, guid: 7a17e775fac3cb34185350eb45f247ff,
type: 3}
Expand Down Expand Up @@ -420,6 +420,12 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &772348888 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8995942413041342849, guid: 218b6943addde914480e690a08891835,
type: 3}
m_PrefabInstance: {fileID: 1369468811}
m_PrefabAsset: {fileID: 0}
--- !u!1 &818890465
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -895,6 +901,75 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1279630299}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1001 &1369468811
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342848, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8995942413041342849, guid: 218b6943addde914480e690a08891835,
type: 3}
propertyPath: m_Name
value: Waypoints
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 218b6943addde914480e690a08891835, type: 3}
--- !u!1 &1396657976
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1081,7 +1156,7 @@ Transform:
m_GameObject: {fileID: 1505403008}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 4, y: 4, z: 4}
m_LocalScale: {x: 8, y: 4, z: 8}
m_Children:
- {fileID: 2134935569}
- {fileID: 1932936374}
Expand All @@ -1094,7 +1169,7 @@ Transform:
- {fileID: 1279630300}
- {fileID: 818890466}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1677364043
GameObject:
Expand Down Expand Up @@ -1377,7 +1452,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1932936370
GameObject:
Expand Down Expand Up @@ -1655,6 +1730,11 @@ PrefabInstance:
propertyPath: m_Name
value: Zombie_with_tree
objectReference: {fileID: 0}
- target: {fileID: 2730409801006516144, guid: 0f263ae2822f5b44781165e1ff4f77da,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0f263ae2822f5b44781165e1ff4f77da, type: 3}
--- !u!1001 &7921516704270268615
Expand All @@ -1664,11 +1744,26 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1017684937180284815, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_LocalPosition.y
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1373999114323958381, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: waypoints
value:
objectReference: {fileID: 772348888}
- target: {fileID: 1373999114323958383, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_Name
value: Zombie
objectReference: {fileID: 0}
- target: {fileID: 1373999114323958394, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_Mass
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2687018619856873596, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_RootOrder
Expand All @@ -1687,7 +1782,7 @@ PrefabInstance:
- target: {fileID: 2687018619856873596, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: -15.8
objectReference: {fileID: 0}
- target: {fileID: 2687018619856873596, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
Expand Down Expand Up @@ -1724,5 +1819,65 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3802817527617732353, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.47087502
objectReference: {fileID: 0}
- target: {fileID: 3802817527617732353, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.07065612
objectReference: {fileID: 0}
- target: {fileID: 4048770506210324302, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.044787288
objectReference: {fileID: 0}
- target: {fileID: 4164850095625685825, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -0.000000055879347
objectReference: {fileID: 0}
- target: {fileID: 4164850095625685825, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: -0.00000006891789
objectReference: {fileID: 0}
- target: {fileID: 4235334380189531847, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.04478731
objectReference: {fileID: 0}
- target: {fileID: 4235334380189531847, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0.08392096
objectReference: {fileID: 0}
- target: {fileID: 5029383726056699883, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.3038763
objectReference: {fileID: 0}
- target: {fileID: 5029383726056699883, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -0.036873613
objectReference: {fileID: 0}
- target: {fileID: 5371530100476478080, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.049724847
objectReference: {fileID: 0}
- target: {fileID: 7036740335024461257, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -0.0000016492559
objectReference: {fileID: 0}
- target: {fileID: 7036740335024461257, guid: e7efd3135f6438845adbcc14555c3ca0,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: -0.0000003799796
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e7efd3135f6438845adbcc14555c3ca0, type: 3}
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/_Zombie_ai/Scripts/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Shoot()
{
hitEffect.transform.position = hit.point;
hitEffect.Emit(1);
Debug.Log("We hit " + hit.transform.name);


Health health = hit.transform.GetComponent<Health>();
if(health != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,26 +259,26 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 8687361259792135078}
m_Position: {x: 30, y: 230, z: 0}
m_Position: {x: 280, y: 10, z: 0}
- serializedVersion: 1
m_State: {fileID: 358510870992995906}
m_Position: {x: 360, y: 240, z: 0}
m_Position: {x: 280, y: 100, z: 0}
- serializedVersion: 1
m_State: {fileID: 2349931639356563113}
m_Position: {x: 300, y: -40, z: 0}
m_Position: {x: 50, y: -120, z: 0}
- serializedVersion: 1
m_State: {fileID: -4419605309656715239}
m_Position: {x: 300, y: 100, z: 0}
m_Position: {x: 50, y: 100, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: 6239713540154731195}
- {fileID: 7464396335392860035}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_AnyStatePosition: {x: 70, y: 10, z: 0}
m_EntryPosition: {x: 300, y: -120, z: 0}
m_ExitPosition: {x: -130, y: 10, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 8687361259792135078}
--- !u!1101 &7464396335392860035
Expand Down
14 changes: 1 addition & 13 deletions Assets/_Zombie_ai/_Zombie_NPC/Scripts/NPCAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@
using UnityEngine.AI;

using baponkar.npc.zombie;


// [RequireComponent(typeof(UnityEngine.AI.NavMeshAgent))]
// [RequireComponent(typeof(NPCHealth))]
// [RequireComponent(typeof(Rigidbody))]
// [RequireComponent(typeof(DebugNavmeshAgent))]
// [RequireComponent(typeof(NPCVisonSensor))]
// [RequireComponent(typeof(NPCSoundSensor))]
// [RequireComponent(typeof(AudioSource))]
// [RequireComponent(typeof(CapsuleCollider))]
// [RequireComponent(typeof(NPCCall))]

public class NPCAgent : MonoBehaviour
{
#region Variables
Expand Down Expand Up @@ -48,7 +36,7 @@ public class NPCAgent : MonoBehaviour
public NPCTargetingSystem targetingSystem;

public GameObject waypoints;
public Transform attackOrigin;//This point to determine attack
//public Transform attackOrigin;//This point to determine attack


public bool playerSeen = false;
Expand Down
1 change: 0 additions & 1 deletion Assets/_Zombie_ai/_Zombie_NPC/Scripts/NPCAttackState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void NPCState.Update(NPCAgent agent)
{
if(agent.targetingSystem.HasTarget && agent.targetingSystem.TargetDistance <= agent.config.attackRadius)
{
Debug.Log(agent.targetingSystem.TargetDistance);
if(timer <= 0f )
{
Attack(agent);
Expand Down
Loading

0 comments on commit 8be9764

Please sign in to comment.