Add behaviour system

This commit is contained in:
Jens Pitkänen 2019-08-03 18:36:17 +03:00
parent 964c6add90
commit 7c6e81301b
26 changed files with 727 additions and 1 deletions

8
Assets/Prefabs.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e82359aad871514f8030fab874442e5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -120,6 +120,177 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &162528936
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 162528945}
- component: {fileID: 162528944}
- component: {fileID: 162528943}
- component: {fileID: 162528942}
- component: {fileID: 162528941}
- component: {fileID: 162528940}
- component: {fileID: 162528939}
- component: {fileID: 162528938}
- component: {fileID: 162528937}
m_Layer: 0
m_Name: Enemy (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &162528937
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10bbd1a0d6cdfe747980a222ff5625b2, type: 3}
m_Name:
m_EditorClassIdentifier:
Follow: {fileID: 162528939}
EnemySighted: {fileID: 162528938}
--- !u!114 &162528938
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48c46784c52bdad4db2a4382d9c46843, type: 3}
m_Name:
m_EditorClassIdentifier:
Radius: 5
--- !u!114 &162528939
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f7e23822f429fcc46a8fd9163e68f332, type: 3}
m_Name:
m_EditorClassIdentifier:
Target: {fileID: 0}
CloseEnoughRadius: 1
--- !u!114 &162528940
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 163f55033e69e2e4282c151e1a806bc6, type: 3}
m_Name:
m_EditorClassIdentifier:
Behaviours:
- {fileID: 162528939}
--- !u!114 &162528941
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbf2158cd27572e4599b4c813f555fd8, type: 3}
m_Name:
m_EditorClassIdentifier:
Trigger: {fileID: 162528938}
TriggeredNodes:
- {fileID: 162528940}
NotTriggeredNodes: []
--- !u!114 &162528942
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 978bec54408eb8f42a36fd68d7447f5a, type: 3}
m_Name:
m_EditorClassIdentifier:
MoveSpeed: 2
BehaviourTree: {fileID: 162528941}
--- !u!61 &162528943
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!50 &162528944
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 1
m_UseAutoMass: 0
m_Mass: 0.0001
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!4 &162528945
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 162528936}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1237792229}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &867100008 --- !u!1 &867100008
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -129,6 +300,14 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 867100009} - component: {fileID: 867100009}
- component: {fileID: 867100011}
- component: {fileID: 867100013}
- component: {fileID: 867100010}
- component: {fileID: 867100012}
- component: {fileID: 867100017}
- component: {fileID: 867100016}
- component: {fileID: 867100015}
- component: {fileID: 867100014}
m_Layer: 0 m_Layer: 0
m_Name: Enemy m_Name: Enemy
m_TagString: Untagged m_TagString: Untagged
@ -151,6 +330,138 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &867100010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 978bec54408eb8f42a36fd68d7447f5a, type: 3}
m_Name:
m_EditorClassIdentifier:
MoveSpeed: 2
BehaviourTree: {fileID: 867100012}
--- !u!50 &867100011
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 1
m_UseAutoMass: 0
m_Mass: 0.0001
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!114 &867100012
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbf2158cd27572e4599b4c813f555fd8, type: 3}
m_Name:
m_EditorClassIdentifier:
Trigger: {fileID: 867100015}
TriggeredNodes:
- {fileID: 867100017}
NotTriggeredNodes: []
--- !u!61 &867100013
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &867100014
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10bbd1a0d6cdfe747980a222ff5625b2, type: 3}
m_Name:
m_EditorClassIdentifier:
Follow: {fileID: 867100016}
EnemySighted: {fileID: 867100015}
--- !u!114 &867100015
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48c46784c52bdad4db2a4382d9c46843, type: 3}
m_Name:
m_EditorClassIdentifier:
Radius: 5
--- !u!114 &867100016
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f7e23822f429fcc46a8fd9163e68f332, type: 3}
m_Name:
m_EditorClassIdentifier:
Target: {fileID: 0}
CloseEnoughRadius: 1
--- !u!114 &867100017
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 867100008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 163f55033e69e2e4282c151e1a806bc6, type: 3}
m_Name:
m_EditorClassIdentifier:
Behaviours:
- {fileID: 867100016}
--- !u!1 &963194225 --- !u!1 &963194225
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -314,3 +625,83 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!1 &1237792228
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1237792229}
- component: {fileID: 1237792230}
m_Layer: 0
m_Name: Sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1237792229
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1237792228}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 162528945}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1237792230
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1237792228}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 472874229c563e241bddc073ec2dbb90, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0

8
Assets/Scripts.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 76894b576c01519458912fb3c127413b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/AI.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8927cc397df63fa45adc7ed6813abdc9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using UnityEngine;
namespace Saltosion.OneWeapon.AI {
public abstract class Behaviour : MonoBehaviour {
/* Returns whether or not Exectute() should be called this frame */
public abstract bool CanBehave(Enemy subject);
/* Returns whether or not this was a blocking behaviour, ie. should the behaviour processing be stopped here */
public abstract bool Execute(Enemy subject);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a71f2be3ac435374db85bc6262fb70d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using System;
using UnityEngine;
namespace Saltosion.OneWeapon.AI {
[Serializable]
public class BehaviourBranch : BehaviourNode {
public Trigger Trigger;
public BehaviourNode[] TriggeredNodes;
public BehaviourNode[] NotTriggeredNodes;
/* Returns true if any action was taken. */
public override bool Execute(Enemy subject) {
if (Trigger.IsTriggered(subject)) {
foreach (BehaviourNode Node in TriggeredNodes) {
if (Node.Execute(subject)) {
return true;
}
}
} else {
foreach (BehaviourNode Node in NotTriggeredNodes) {
if (Node.Execute(subject)) {
return true;
}
}
}
return false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bbf2158cd27572e4599b4c813f555fd8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
using System;
using UnityEngine;
namespace Saltosion.OneWeapon.AI {
[Serializable]
public class BehaviourLeaf : BehaviourNode {
public Behaviour[] Behaviours;
public bool IsLeaf { get { return Behaviours.Length > 0; } }
/* Returns true if any action was taken. */
public override bool Execute(Enemy subject) {
bool Acted = false;
foreach (Behaviour Behaviour in Behaviours) {
if (Behaviour.CanBehave(subject)) {
if (Behaviour.Execute(subject)) {
return true;
} else {
Acted = true;
}
}
}
return Acted;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 163f55033e69e2e4282c151e1a806bc6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using System;
using UnityEngine;
namespace Saltosion.OneWeapon.AI {
[Serializable]
public abstract class BehaviourNode : MonoBehaviour {
/* Returns true if any action was taken. */
public abstract bool Execute(Enemy subject);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29a12e34882786345a46452c9e98e2a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b193158c99ba71848aefda2781a1dcca
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,28 @@
using UnityEngine;
namespace Saltosion.OneWeapon.AI.Behaviours {
public class Follow : Behaviour {
public Transform Target;
public float CloseEnoughRadius;
public override bool CanBehave(Enemy subject) {
return true;
}
public override bool Execute(Enemy subject) {
if (Target != null) {
Vector2 position = subject.transform.position;
Vector2 targetPosition = Target.position;
Vector2 delta = targetPosition - position;
if (delta.magnitude > CloseEnoughRadius) {
delta -= delta.normalized * CloseEnoughRadius;
subject.StartMovingTo(position + delta);
return true;
}
}
subject.StopMoving();
return false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f7e23822f429fcc46a8fd9163e68f332
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
using UnityEngine;
namespace Saltosion.OneWeapon.AI {
public abstract class Trigger : MonoBehaviour {
public abstract bool IsTriggered(Enemy subject);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e937595fb1302b40bf1c12452c4fc3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ef1e0f63af4130344a32addd8ad51ff1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
using UnityEngine;
namespace Saltosion.OneWeapon.AI.Triggers {
public class EnemySighted : Trigger {
public float Radius;
public Enemy ClosestEnemy { get; private set; }
public override bool IsTriggered(Enemy subject) {
Collider2D[] NearbyEnemies = Physics2D.OverlapCircleAll(subject.transform.position, Radius);
float LowestDistance = float.PositiveInfinity;
bool FoundEnemy = false;
foreach (Collider2D Enemy in NearbyEnemies) {
float Distance = (Enemy.transform.position - subject.transform.position).magnitude;
Enemy EnemyComponent = Enemy.GetComponent<Enemy>();
if (EnemyComponent != null && Distance < LowestDistance && Enemy.gameObject != gameObject) {
LowestDistance = Distance;
ClosestEnemy = EnemyComponent;
FoundEnemy = true;
}
}
return FoundEnemy;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48c46784c52bdad4db2a4382d9c46843
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

37
Assets/Scripts/Enemy.cs Normal file
View File

@ -0,0 +1,37 @@
using UnityEngine;
using Saltosion.OneWeapon.AI;
namespace Saltosion.OneWeapon {
[RequireComponent(typeof(Rigidbody2D))]
public class Enemy : MonoBehaviour {
public float MoveSpeed;
public BehaviourNode BehaviourTree;
private Rigidbody2D Body;
private bool MovingToTarget = false;
private Vector2 TargetPosition;
private void Start() {
Body = GetComponent<Rigidbody2D>();
}
private void Update() {
BehaviourTree.Execute(this);
}
private void FixedUpdate() {
if (MovingToTarget) {
Body.velocity = (TargetPosition - Body.position).normalized * MoveSpeed;
}
}
public void StartMovingTo(Vector2 target) {
TargetPosition = target;
MovingToTarget = true;
}
public void StopMoving() {
MovingToTarget = false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 978bec54408eb8f42a36fd68d7447f5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
using UnityEngine;
using Saltosion.OneWeapon.AI;
namespace Saltosion.OneWeapon {
[RequireComponent(typeof(AI.Behaviours.Follow), typeof(AI.Triggers.EnemySighted))]
public class EnemyFollower : MonoBehaviour {
public AI.Behaviours.Follow Follow;
public AI.Triggers.EnemySighted EnemySighted;
private void Update() {
if (EnemySighted.ClosestEnemy == null) {
Follow.Target = null;
} else {
Follow.Target = EnemySighted.ClosestEnemy.transform;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 10bbd1a0d6cdfe747980a222ff5625b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Sounds.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23e985ea0d1437e478f5bf5b6b91884c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,7 +4,7 @@
Physics2DSettings: Physics2DSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 4 serializedVersion: 4
m_Gravity: {x: 0, y: -9.81} m_Gravity: {x: 0, y: 0}
m_DefaultMaterial: {fileID: 0} m_DefaultMaterial: {fileID: 0}
m_VelocityIterations: 8 m_VelocityIterations: 8
m_PositionIterations: 3 m_PositionIterations: 3