Fixed AI C# Script for final submission #283

Merged
mushgunAX merged 8 commits from AIFinalFixesGAM300M3 into main 2022-11-25 22:33:58 +08:00
3 changed files with 14 additions and 2 deletions
Showing only changes of commit c5d490b8b2 - Show all commits

View File

@ -41,7 +41,15 @@ public partial class LeafAttack : BehaviourTreeNode
onEnter(BehaviourTreeNodeStatus.RUNNING);
//Succeed when stand in hurt box for long enough
float captureTime = (float)GetNodeData("captureTimeLeft");
//Debug.Log("Attempting to get blackboard data");
float? captureTime = (float?)GetNodeData("captureTimeLeft");
//Debug.Log("Got blackboard data");
if (captureTime == null)
{
status = BehaviourTreeNodeStatus.FAILURE;
onExit(BehaviourTreeNodeStatus.FAILURE);
return status;
}
captureTime -= Time.DeltaTimeF;
SetNodeData("captureTimeLeft", captureTime);
//Debug.Log(captureTime.ToString());

View File

@ -119,7 +119,7 @@ public partial class LeafChase : BehaviourTreeNode
//Play SFX
if (GetNodeData("isCapturing") != null && (bool)GetNodeData("isCapturing") == false)
{
Debug.Log("AI Play capturing SFX");
//Debug.Log("AI Play capturing SFX");
}
SetNodeData("isCapturing", true);

View File

@ -84,6 +84,10 @@ public partial class LeafPatrol : BehaviourTreeNode
}
waypoints = (List<GameObject>)GetNodeData("waypoints");
if (waypoints == null)
{
return;
}
Vector3 targetPosition = waypoints[currentWaypointIndex].GetComponent<Transform>().GlobalPosition;
//Reach waypoint by X and Z being near enough