Fixed many things.

This commit is contained in:
2022-05-16 17:59:47 +07:00
parent 150efde055
commit 06fdfc077c
8 changed files with 290 additions and 41 deletions

View File

@ -1113,6 +1113,7 @@ MonoBehaviour:
enemy: {fileID: 164324136889094180, guid: 2d8d8fcef9fc43144982428bd40ad6f0, type: 3}
isFiring: 0
lookSpeed: 50
fireAnimation: 0
--- !u!114 &9003219069727127243
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1127,7 +1128,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
raycast: {fileID: 1105574061174270723}
firePoint: {fileID: 8024036354822949060}
_projectilePrefab: {fileID: 1564468091806366, guid: f1dc4df701f37324c98ea16f41770afc,
projectilePrefab: {fileID: 1990380580032880, guid: 46b312e00ed9c1f459ea9f0e55bfac77,
type: 3}
gun: {fileID: 8024036354822949060}
--- !u!195 &3763807728217797723
@ -1198,8 +1199,8 @@ MonoBehaviour:
NumStackedVectorObservations: 1
m_ActionSpec:
m_NumContinuousActions: 0
BranchSizes: 01000000
VectorActionSize: 01000000
BranchSizes: 030000000400000003000000
VectorActionSize: 030000000400000003000000
VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
@ -1239,8 +1240,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3a5c9d521e5ef4759a8246a07d52221e, type: 3}
m_Name:
m_EditorClassIdentifier:
DecisionPeriod: 5
TakeActionsBetweenDecisions: 1
DecisionPeriod: 15
TakeActionsBetweenDecisions: 0
--- !u!114 &4758249021326882836
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -310,6 +310,75 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 140697604}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1001 &248773156
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2060099472}
m_Modifications:
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.x
value: 32.75
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.y
value: -1.75
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.z
value: 8.01
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323927, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_Name
value: navPointPrefab5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f58a14c8ba97dfa4f9f4103bbee852d4, type: 3}
--- !u!1 &293522538
GameObject:
m_ObjectHideFlags: 0
@ -829,12 +898,12 @@ PrefabInstance:
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.x
value: 26.44
value: 45.18
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.y
value: -0.02
value: -2.24
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
@ -883,6 +952,93 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f58a14c8ba97dfa4f9f4103bbee852d4, type: 3}
--- !u!1001 &573995418
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2060099472}
m_Modifications:
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.z
value: -12.9
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323927, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_Name
value: navPointPrefab4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f58a14c8ba97dfa4f9f4103bbee852d4, type: 3}
--- !u!4 &573995419 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
m_PrefabInstance: {fileID: 573995418}
m_PrefabAsset: {fileID: 0}
--- !u!114 &573995420 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7378066357312323925, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
m_PrefabInstance: {fileID: 573995418}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &577106247
GameObject:
m_ObjectHideFlags: 0
@ -1107,6 +1263,12 @@ Transform:
m_Father: {fileID: 350524557}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &684960225 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
m_PrefabInstance: {fileID: 248773156}
m_PrefabAsset: {fileID: 0}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
@ -1375,6 +1537,75 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &946062733
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2060099472}
m_Modifications:
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_RootOrder
value: 5
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.x
value: 30.8
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.y
value: -2.26
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323927, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_Name
value: navPointPrefab6
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f58a14c8ba97dfa4f9f4103bbee852d4, type: 3}
--- !u!1001 &1035463159
PrefabInstance:
m_ObjectHideFlags: 0
@ -1390,17 +1621,17 @@ PrefabInstance:
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.x
value: 14.28
value: 41.88
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: -1.69
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: 12.3
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
@ -1543,7 +1774,7 @@ Mesh:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh19228
m_Name: pb_Mesh19226
serializedVersion: 10
m_SubMeshes:
- serializedVersion: 2
@ -1718,6 +1949,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1314532551 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7378066357312323925, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
m_PrefabInstance: {fileID: 1405869922}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1343495431
PrefabInstance:
m_ObjectHideFlags: 0
@ -1817,17 +2060,17 @@ PrefabInstance:
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.x
value: 36.25
value: 0.1
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.74
value: -2.2
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
propertyPath: m_LocalPosition.z
value: 18.04
value: 23
objectReference: {fileID: 0}
- target: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
@ -1973,6 +2216,12 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1488699521}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1551964658 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7378066357312323926, guid: f58a14c8ba97dfa4f9f4103bbee852d4,
type: 3}
m_PrefabInstance: {fileID: 946062733}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1553331019
GameObject:
m_ObjectHideFlags: 0
@ -2318,11 +2567,13 @@ MonoBehaviour:
m_EditorClassIdentifier:
spawnPointsForDefendersTeam:
- {fileID: 906771657}
spawnPointsForAttackersTeam:
- {fileID: 1299625858}
spawnPointsForAttackersTeam:
- {fileID: 573995420}
- {fileID: 1314532551}
AIPrefab: {fileID: 1740317275426328350, guid: be2f9603c4cf8194b9c67f41250d63d0,
type: 3}
PlayerPrefab: {fileID: 6633355367928764388, guid: 0d0b10717aa98fe44bcf651ad0901a89,
PlayerPrefab: {fileID: 2528273238195332181, guid: b5b04f22586a72c438dddf26e4474a4b,
type: 3}
--- !u!114 &1858987091
MonoBehaviour:
@ -2588,6 +2839,9 @@ Transform:
- {fileID: 1299625857}
- {fileID: 906771656}
- {fileID: 1419663744}
- {fileID: 573995419}
- {fileID: 684960225}
- {fileID: 1551964658}
m_Father: {fileID: 350524557}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -77,6 +77,7 @@ public class CharacterFactory : MonoBehaviour
{
GameManager._defendersTeam.RegisterAgent(npc);
}
npc.GetCharacter.Team = team;
npc.SetModel(team.ToString(), null, InferenceDevice.Default );
gameobject.GetComponent<MovementController>().PointStartID = spawnPoint.PointId;

View File

@ -52,7 +52,7 @@ public class MovementController : MonoBehaviour
{
return MapManager.Instance.NavPoints
.Where(point =>
(_idNavPointDict[PointStartID].Position - point.Position).magnitude < SettingsReader.Instance.GetSettings.MovementDistance)
(transform.position - point.Position).magnitude < SettingsReader.Instance.GetSettings.MovementDistance)
.ToList();
}
@ -69,15 +69,12 @@ public class MovementController : MonoBehaviour
{
if (navMeshAgent.isStopped == true) navMeshAgent.isStopped = false;
navMeshAgent.SetDestination(_idNavPointDict[PointStartID].Position);
PointEndID = PointStartID;
PointStartID = -1;
(PointEndID, PointStartID) = (PointStartID, PointEndID);
}
public void StopOnPath()
{
navMeshAgent.isStopped = true;
PointStartID = -1;
PointEndID = -1;
}
public void ReachedDestination()

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Animators.Leonid_Animator;
using Animators.Leonid_Animator.Bot;
using Unity.MLAgents;
@ -74,7 +75,6 @@ public class NPC : Agent, ICharacter
private void Update()
{
print(IsFiring);
_botLocomotion.UpdateAnimatorValues();
}
@ -89,7 +89,7 @@ public class NPC : Agent, ICharacter
public override void CollectObservations(VectorSensor sensor)
{
// Debug.Log("Collect observations called!");
Debug.Log("Collect observations called!");
_navPointIdDict = MapManager.Instance.IDToNavPoint;
if (_navPointIdDict is null)
Debug.LogError("Cant Find Nav Point Dictionary");
@ -105,7 +105,6 @@ public class NPC : Agent, ICharacter
sensor.AddObservation(candidates.Count);
sensor.AddObservation(_moveController.PointStartID);
sensor.AddObservation(_moveController.PointEndID);
// Debug.Log("Done common!");
//state sensors
sensor.AddObservation((int)NpcState.State);
sensor.AddObservation((int)NpcBodyState.State);
@ -113,7 +112,6 @@ public class NPC : Agent, ICharacter
sensor.AddObservation(_navPointIdDict[_moveController.PointStartID].DeathAttr);
sensor.AddObservation(_navPointIdDict[_moveController.PointEndID].DeathAttr);
sensor.AddObservation(_moveController.FlagDistance);
// Debug.Log("Done state sensors!");
//point sensors
foreach (var point in candidates)
@ -130,26 +128,25 @@ public class NPC : Agent, ICharacter
GameManager.IsHaveSeenByEnemy(GetCharacter.Team.GetOppositeTeam(),
point.Position).ToInt()
});
}
// Debug.Log("Done collect observations!");
} ;
}
public override void OnActionReceived(ActionBuffers actions)
{
var result = actions.DiscreteActions;
print(result[0]);
if (result[0] == 0)
{
if (_navPointIdDict[_moveController.PointStartID].navType != NavPointType.Cover)
return;
NpcState = _coverState;
switch (result[1])
{
case 0: Peek(); break;
case 1: Cover(); break;
case 3: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
case 4: NpcState = _directState; break;
default: throw new ArgumentException("Undefined Action recieved");
case 2: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
case 3: break;
default: throw new ArgumentException("Undefined Action received");
}
}
if (result[0] == 1)
@ -164,7 +161,9 @@ public class NPC : Agent, ICharacter
case 0: _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]);
NpcState = _runningState; Debug.Log("Go to point " + result[2]);break;
case 1: NpcState = _directState; break;
default: throw new ArgumentException("Undefined Action recieved");
case 2: break;
case 3: break;
default: throw new ArgumentException("Undefined Action received");
}
}
@ -176,7 +175,9 @@ public class NPC : Agent, ICharacter
{
case 0: _moveController.StopOnPath(); NpcState = _directState; break;
case 1: _moveController.ReturnToStartPoint(); NpcState = _runningState; break;
default: throw new ArgumentException("Undefined Action recieved");
case 2: break;
case 3: break;
default: throw new ArgumentException("Undefined Action received");
}
}
}

View File

@ -45,9 +45,6 @@ public class FlagZone : MonoBehaviour
case "Attacker":
occupAttackers--;
break;
default:
Debug.LogWarning("Exited non-team entity");
break;
}
}
private void Update()

View File

@ -79,7 +79,6 @@ public class AimAssistant : MonoBehaviour
private void StopShooting()
{
print("stop shooting");
_firelock = false;
isFiring = false;
fireAnimation = false;
@ -89,7 +88,6 @@ public class AimAssistant : MonoBehaviour
{
while (true)
{
print("in Shooting");
_shooting.Shoot();
yield return new WaitForSeconds(_fireCountdown);
}

View File

@ -19,8 +19,8 @@ MonoBehaviour:
MovementSpeed: 1
DefTeamAI: 3
AtcTeamAI: 3
NumOfDefenders: 1
NumOfAttackers: 1
NumOfDefenders: 2
NumOfAttackers: 2
HasHumanDefender: 0
HasHumanAttacker: 0
HealthPickupAmount: 50