Skip to content

Commit

Permalink
fixed AI failing to go up stairs
Browse files Browse the repository at this point in the history
  • Loading branch information
Saarg committed Apr 3, 2018
1 parent ac046af commit a4d24a0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ Material:
- ScrollSpeed: 0.2
- _AmazingThreshold: 0.72
- _BumpScale: 1
- _CautionThreshold: 0.9677419
- _CautionThreshold: 1
- _ColorMask: 15
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _Glossiness: 0.5
- _GoodThreshold: 1.9354838
- _GoodThreshold: 2
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
Expand Down
10 changes: 5 additions & 5 deletions Assets/Scenes/_Dungeon/_Dungeon01.unity
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ NavMeshSettings:
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 1
cellSize: 0.12
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
Expand Down Expand Up @@ -7774,7 +7774,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 19935311}
m_LocalRotation: {x: -0, y: -0.9766559, z: -0, w: -0.21480992}
m_LocalPosition: {x: 60.8, y: 42.1, z: -66.7}
m_LocalPosition: {x: 59.3, y: 42.1, z: -67.122}
m_LocalScale: {x: 1.0000006, y: 1, z: 1.0000006}
m_Children: []
m_Father: {fileID: 676391790}
Expand Down Expand Up @@ -78455,7 +78455,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 176824474}
m_LocalRotation: {x: -0, y: -0.21481141, z: -0, w: 0.9766556}
m_LocalPosition: {x: -11.046019, y: 8.9759445, z: 32.042942}
m_LocalPosition: {x: -9.54602, y: 8.9759445, z: 32.46495}
m_LocalScale: {x: 1.0000005, y: 1, z: 1.0000005}
m_Children:
- {fileID: 943217278}
Expand Down Expand Up @@ -383478,7 +383478,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 193222, guid: 7f4b11db547f35b458692d1b41e1de49, type: 2}
propertyPath: m_StaticEditorFlags
value: 4294967295
value: 4294967287
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 7f4b11db547f35b458692d1b41e1de49, type: 2}
Expand Down
Binary file modified Assets/Scenes/_Dungeon/_Dungeon01/NavMesh.asset
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/Scenes/_Dungeon/_Dungeon01/NavMesh.asset.meta

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

16 changes: 14 additions & 2 deletions Assets/Scripts/BaseAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class BaseAI : NetworkBehaviour {
Coroutine shootingCoroutine = null;
Coroutine interruptCoroutine = null;

Rigidbody rb;

// Use this for initialization
void Start() {
if (weaponObj == null) {
Expand All @@ -70,10 +72,12 @@ void Start() {
shootingController.weapon = weapon;
}

agent = gameObject.GetComponent<NavMeshAgent>();
agent = GetComponent<NavMeshAgent>();
lastDetectTarget = Time.time;
gameObject.GetComponent<Living>().OnDeath += OnDeath;
GetComponent<Living>().OnDeath += OnDeath;
CmdSetBool("moving", true);

rb = GetComponent<Rigidbody>();
}

public void SetShooter(bool val)
Expand Down Expand Up @@ -130,6 +134,14 @@ void Update() {
}
}

void FixedUpdate()
{
if (agent.enabled) {
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
}
}

void UpdateMovement()
{
if (currentNodeDestination == null)
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/NavMeshAreas.asset
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ NavMeshProjectSettings:
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.5
agentSlope: 50
agentClimb: 0.7
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
Expand Down

0 comments on commit a4d24a0

Please sign in to comment.