浏览代码

Added is path ready condition

/main
Amel Negra 4 年前
当前提交
3f4c581e
共有 3 个文件被更改,包括 37 次插入34 次删除
  1. 26
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsPathReadySO.cs
  2. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsPathReadySO.cs.meta
  3. 34
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasReachedRoamingDestinationSO.cs

26
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsPathReadySO.cs


using UnityEngine;
using UnityEngine.AI;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "IsPathReady", menuName = "State Machines/Conditions/Is Path Ready")]
public class IsPathReadySO : StateConditionSO
{
protected override Condition CreateCondition() => new IsPathReady();
}
public class IsPathReady : Condition
{
private NavMeshAgent _agent;
public override void Awake(StateMachine stateMachine)
{
_agent = stateMachine.gameObject.GetComponent<NavMeshAgent>();
}
protected override bool Statement()
{
return _agent.pathPending;
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsPathReadySO.cs.meta


fileFormatVersion: 2
guid: d7d71e8bf881dee488a5491b967c81e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

34
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasReachedRoamingDestinationSO.cs


using UnityEngine;
using UnityEngine.AI;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(fileName = "HasReachedRoamingDestination", menuName = "State Machines/Conditions/Has Reached Roaming Destination")]
public class HasReachedRoamingDestinationSO : StateConditionSO
{
protected override Condition CreateCondition() => new HasReachedRoamingDestination();
}
public class HasReachedRoamingDestination : Condition
{
private NavMeshAgent _agent;
private float _startTime;
private bool _agentDefined;
public override void Awake(StateMachine stateMachine)
{
_agent = stateMachine.gameObject.GetComponent<NavMeshAgent>();
_agentDefined = _agent != null;
}
protected override bool Statement()
{
//Debug.Log("This agent is defined" + _agentDefined);
//Debug.Log("This agent has path " + _agent.hasPath);
Debug.Log("distance remaining" + _agent.remainingDistance);
return _agent.remainingDistance < 0.01;
//value to use 0.1? and has path
//!_agent.hasPath ||
}
}
正在加载...
取消
保存