This commit is contained in:
CortexCore
2023-12-16 23:30:08 +08:00
parent 78216a3d47
commit 961ae8feb4
33 changed files with 369 additions and 148 deletions

View File

@@ -23,7 +23,7 @@ namespace NodeCanvas.Tasks.Conditions
public BBParameter<float> viewAngle = 70f;
public Vector3 offset;
public Transform blockingObject;
public string report;
private RaycastHit hit;
@@ -41,29 +41,46 @@ namespace NodeCanvas.Tasks.Conditions
if ( Vector3.Distance(agent.position, t.position) <= awarnessDistance.value ) {
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
blockingObject = hit.collider.transform;
if ( hit.collider != t.GetComponent<Collider>() ) {
return false;
report = hit.collider.name;
}
}
report = "Good Vigil Direct Hit";
return true;
}
if ( Vector3.Distance(agent.position, t.position) > maxDistance.value ) {
report = "Out of max distance";
return false;
}
if ( Vector3.Angle(t.position - agent.position, agent.forward) > viewAngle.value ) {
// if ( Vector3.Angle(t.position - agent.position, agent.forward) > viewAngle.value ) {
// report = "Out of view angle";
// return false;
// }
var direction = t.position - agent.position;
var dir = Quaternion.LookRotation(direction);
var angle = Quaternion.Angle(agent.rotation, dir);
if (Vector3.Dot(agent.forward, direction) > 0 && viewAngle.value > angle)
{
}
else
{
report = $"Out of view angle:{angle}";
return false;
}
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
blockingObject = hit.collider.transform;
if ( hit.collider != t.GetComponent<Collider>() ) {
report = hit.collider.name;
return false;
}
}
report = "Good Vigil";
return true;
}