Added object checks in leaf scripts

This commit is contained in:
Xiao Qi 2022-11-25 12:09:03 +08:00
parent 46ae50949e
commit d72a532623
4 changed files with 17 additions and 13 deletions

View File

@ -8676,15 +8676,7 @@
Scripts:
- Type: Homeowner1
Enabled: true
player: 2
waypoints:
- [2.70000005, 0, -2]
- [-0.300000012, 0, -2.70000005]
- [-2, 0, -3.79999995]
- [-4, 0, -2.0999999]
- [-2.9000001, 0, 2.4000001]
- [-1, 0, 4]
- [2.70000005, 0, 4]
waypointsPool: 51000
patrolSpeed: 1
chaseSpeed: 2
turningSpeed: 5

View File

@ -41,6 +41,12 @@ public partial class LeafAttack : BehaviourTreeNode
onEnter(BehaviourTreeNodeStatus.RUNNING);
//Succeed when stand in hurt box for long enough
object timeObj = GetNodeData("captureTimeLeft");
if (timeObj == null)
{
return BehaviourTreeNodeStatus.FAILURE;
}
float captureTime = (float)GetNodeData("captureTimeLeft");
captureTime -= Time.DeltaTimeF;
SetNodeData("captureTimeLeft", captureTime);

View File

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

View File

@ -12,7 +12,7 @@ public class MainMenu : Script
if (Input.GetKey(Input.KeyCode.Space))
{
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
SceneManager.ChangeScene(86098106);
SceneManager.ChangeScene(89830755);
Audio.StopAllSounds();
}