Skip to content

Commit

Permalink
ai update
Browse files Browse the repository at this point in the history
  • Loading branch information
Taliayaya committed Sep 17, 2023
1 parent e204ef7 commit 769ecd4
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Assets/Resources/Prefabs/Ameise Variant.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ PrefabInstance:
propertyPath: onHealthChange.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 496458845, guid: c60559b31bc453d4592bc5925d48232c, type: 3}
propertyPath: m_Speed
value: 15
objectReference: {fileID: 0}
- target: {fileID: 496458845, guid: c60559b31bc453d4592bc5925d48232c, type: 3}
propertyPath: m_Height
value: 2
Expand Down Expand Up @@ -329,7 +333,7 @@ PrefabInstance:
- target: {fileID: 7611585065316723255, guid: c60559b31bc453d4592bc5925d48232c,
type: 3}
propertyPath: m_Name
value: Ameise
value: Ameise Variant
objectReference: {fileID: 0}
- target: {fileID: 7611585065316723257, guid: c60559b31bc453d4592bc5925d48232c,
type: 3}
Expand Down Expand Up @@ -535,7 +539,7 @@ SphereCollider:
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 2.5
m_Radius: 3.5
m_Center: {x: 0, y: 1, z: 0}
--- !u!82 &1850275427234497227
AudioSource:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 07cacc55dab8c4042b81c5647d4ea172, type: 3}
m_Name:
m_EditorClassIdentifier:
damage: 0
origin: {x: 0, y: 0, z: 0}
explosionPrefab: {fileID: 100002, guid: 99c73c92ac40473459640b165473206f, type: 3}
--- !u!96 &6656166727061531327
TrailRenderer:
serializedVersion: 2
Expand Down Expand Up @@ -111,7 +108,7 @@ TrailRenderer:
m_Time: 0.05
m_Parameters:
serializedVersion: 3
widthMultiplier: 4
widthMultiplier: 1
widthCurve:
serializedVersion: 2
m_Curve:
Expand Down
116 changes: 116 additions & 0 deletions Assets/Resources/Prefabs/Legion.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,15 @@ MonoBehaviour:
listenOrTriggersEvents: 0
holdFire: 0
ammo: {fileID: 11400000, guid: a6693c60172457f4e930b1c4d20539e6, type: 2}
fireBulletLayerMask:
serializedVersion: 2
m_Bits: 1
gunTransform: {fileID: 7611585064324400010}
gunAudioSource: {fileID: 7611585064415259503}
cameraTransform: {fileID: 0}
myParentColliderToIgnore: {fileID: 5731111181258434148}
ammoLeftOrRight: Left
canFire: 1
--- !u!1 &2935014233182562330
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -936,6 +940,11 @@ MonoBehaviour:
stepHeight: 1
smoothness: 1
bodyOrientation: 0
groundLayer:
serializedVersion: 2
m_Bits: 0
audioSource: {fileID: 0}
stepSounds: []
--- !u!1 &5357198258921249417
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1788,6 +1797,7 @@ GameObject:
- component: {fileID: 496458844}
- component: {fileID: 496458845}
- component: {fileID: 5731111181258434148}
- component: {fileID: 1269329004787466712}
m_Layer: 7
m_Name: Legion
m_TagString: Enemy
Expand Down Expand Up @@ -1839,6 +1849,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 457c51b2782849cb8505917c84afa333, type: 3}
m_Name:
m_EditorClassIdentifier:
unitType: 0
onHealthChange:
m_PersistentCalls:
m_Calls: []
onUnitDeath:
m_PersistentCalls:
m_Calls: []
engineAudioSource: {fileID: 0}
engineAudioSo: {fileID: 0}
faction: 1
agentSo: {fileID: 11400000, guid: 348277b5d0d31b94f99e1b44322f01bf, type: 2}
debugAgent:
Expand All @@ -1847,6 +1866,7 @@ MonoBehaviour:
debugSpot: 1
frontViewColor: {r: 0, g: 0, b: 1, a: 1}
sideViewColor: {r: 0, g: 1, b: 1, a: 1}
patrolWaypoints: []
demoParameters: {fileID: 11400000, guid: 54207af3f0293d54a84e4a6024f5506d, type: 2}
isRotating: 0
--- !u!114 &496458844
Expand Down Expand Up @@ -1897,6 +1917,102 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 7.0053587, y: 7.07, z: 7.5373974}
m_Center: {x: -0.013449073, y: 0.1500001, z: 0.4815683}
--- !u!82 &1269329004787466712
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7611585065316723255}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1001 &5275242341208758280
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/Resources/Prefabs/Lowe Variant.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 496458845, guid: c60559b31bc453d4592bc5925d48232c, type: 3}
propertyPath: m_Speed
value: 20
value: 7
objectReference: {fileID: 0}
- target: {fileID: 496458845, guid: c60559b31bc453d4592bc5925d48232c, type: 3}
propertyPath: m_Height
Expand Down Expand Up @@ -405,7 +405,7 @@ PrefabInstance:
- target: {fileID: 7611585065316723255, guid: c60559b31bc453d4592bc5925d48232c,
type: 3}
propertyPath: m_Name
value: Lowe
value: Lowe Variant
objectReference: {fileID: 0}
- target: {fileID: 7611585065316723257, guid: c60559b31bc453d4592bc5925d48232c,
type: 3}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Resources/ScriptableObjects/AI/Ameise.asset
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ MonoBehaviour:
fieldOfViewAngle: 270
viewDistance: 500
rotationSpeed: 5
idealDistanceFromEnemy: 5
idealDistanceFromEnemy: 30
deathEffect: {fileID: 0}
Binary file added Assets/Scenes/BaseQuest/NavMesh.asset
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Scenes/BaseQuest/NavMesh.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Assets/Scripts/AI/BehaviourTree/BasicNodes/AttackEnemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ protected override State OnUpdate()

private Coroutine ShootAtEnemy(WeaponModule weaponModule)
{
Debug.Log("Created Coroutine");
if (weaponModule.HoldFire)
{
return weaponModule.StartCoroutine(weaponModule.ShootHoldDuringTime(timeBeforeSpotExpired,
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/AI/BehaviourTree/BasicNodes/Patrol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Patrol : ActionNode

private IEnumerator<Vector3> _patrolPoints;
[CanBeNull] private List<Transform> _waypoints;

private Vector3? _goal;
protected override void OnStart()
{
if (!_isSet)
Expand Down
11 changes: 10 additions & 1 deletion Assets/Scripts/AI/BehaviourTree/BasicNodes/Wander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ public class Wander : ActionNode
private NavMeshAgent _agent;
private bool _isSet = false;
public int wanderRadius = 20;

private Vector3? _goal;
protected override void OnStart()
{
if (!_isSet)
{
_agent = blackBoard.GetValue<NavMeshAgent>("navMeshAgent");
blackBoard.TryGetValue("goal", out _goal);
_isSet = true;
}

Expand All @@ -36,7 +39,13 @@ private void WanderAround()
_agent.updateRotation = true;
_agent.angularSpeed = 120;
Vector3 randomDirection = Random.insideUnitSphere * wanderRadius;
randomDirection += _agent.transform.position;
if (_goal.HasValue)
{
randomDirection += _goal.Value;
blackBoard.RemoveValue("goal"); // we don't want to be stuck on the same goal
}
else
randomDirection += _agent.transform.position;
NavMeshHit hit;
NavMesh.SamplePosition(randomDirection, out hit, wanderRadius, 1);
Vector3 finalPosition = hit.position;
Expand Down

0 comments on commit 769ecd4

Please sign in to comment.