Commit df34330b authored by Rugeon's avatar Rugeon
Browse files

Started adding my own behaviour, forward and back move

parent b768cf72
......@@ -20,6 +20,9 @@ namespace Complete
return SpinBehaviour(-0.05f, 1f);
case 2:
return TrackBehaviour();
case 3:
return FunBehaviour();
default:
return new Root (new Action(()=> Turn(0.1f)));
......@@ -36,6 +39,8 @@ namespace Complete
return new Action(() => Fire(UnityEngine.Random.Range(0.0f, 1.0f)));
}
//
/* Example behaviour trees */
......@@ -57,7 +62,7 @@ namespace Complete
Stops.IMMEDIATE_RESTART,
// Stop turning and fire
new Sequence(StopTurning(),
new Wait(2f),
//new Wait(2f),
RandomFire())),
new BlackboardCondition("targetOnRight",
Operator.IS_EQUAL, true,
......@@ -71,6 +76,32 @@ namespace Complete
);
}
private Root FunBehaviour()
{
return new Root(
new Service(0.2f, UpdatePerception,
new Selector(
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, true,
Stops.IMMEDIATE_RESTART,
// Go forwards
new Action(() => Move(0.6f))),
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, false,
Stops.IMMEDIATE_RESTART,
// Go forwards
new Action(() => Move(-0.6f)))
)
)
);
}
private void UpdatePerception() {
Vector3 targetPos = TargetTransform().position;
Vector3 localPos = this.transform.InverseTransformPoint(targetPos);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment