Commit 790a0745 authored by Rugeon's avatar Rugeon
Browse files

Made a simple bot that flees the player

parent 76360d1f
......@@ -24,8 +24,8 @@ namespace Complete
return FunBehaviour();
case 4:
return DeadlyBehaviour();
//case 5:
// return SpookedBehaviour();
case 5:
return SpookedBehaviour();
default:
return new Root(new Action(() => Turn(0.1f)));
......@@ -129,7 +129,7 @@ namespace Complete
new BlackboardCondition("targetDistance",
Operator.IS_GREATER, 20.0f,
Stops.IMMEDIATE_RESTART,
// Stop turning and fire a medium range shot
// Stop turning and fire a long range shot
LongFire())
))
......@@ -266,6 +266,57 @@ namespace Complete
);
}
private Root SpookedBehaviour()
{
return new Root(
new Service(0.2f, UpdatePerception,
new Sequence(//Sequence allows behaviour to rotate and move at same time
new Selector(
new BlackboardCondition("targetOffCentre",
Operator.IS_SMALLER_OR_EQUAL, 0.1f,
Stops.IMMEDIATE_RESTART,
// Stop turning if target is not off center
new Sequence(
StopTurning())),
new BlackboardCondition("targetOnRight",
Operator.IS_EQUAL, false,
Stops.IMMEDIATE_RESTART,
// Turn right toward target
new Action(() => Turn(1.0f))),
// Turn left toward target
new Action(() => Turn(-1.0f))
),
new Selector(//Go forwards or backwards at the same time as other actions
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, false,
Stops.IMMEDIATE_RESTART,
// Go forwards if the target is behind
new Sequence(
new Wait(0.1f),
new Action(() => Move(0.8f)))
),
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, true,
Stops.IMMEDIATE_RESTART,
// Go backwards if the target is in front
new Sequence(
new Wait(0.1f),
new Action(() => Move(-0.8f)))
)
)
)
)
);
}
private void UpdatePerception() {
Vector3 targetPos = TargetTransform().position;
......
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