Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Elliott Gossett
behavior-trees2
Commits
ce8f9ea5
Commit
ce8f9ea5
authored
Oct 26, 2017
by
Rugeon
Browse files
Early fun basic bot working, chases and shoots if player stays still
parent
df34330b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Assets/Complete/Scripts/Tank/Behaviours.cs
View file @
ce8f9ea5
...
...
@@ -23,9 +23,9 @@ namespace Complete
case
3
:
return
FunBehaviour
();
default
:
return
new
Root
(
new
Action
(()=>
Turn
(
0.1f
)));
return
new
Root
(
new
Action
(()
=>
Turn
(
0.1f
)));
}
}
...
...
@@ -36,7 +36,12 @@ namespace Complete
}
private
Node
RandomFire
()
{
return
new
Action
(()
=>
Fire
(
UnityEngine
.
Random
.
Range
(
0.0f
,
1.0f
)));
return
new
Action
(()
=>
Fire
(
UnityEngine
.
Random
.
Range
(
0.0f
,
0.5f
)));
}
private
Node
StopMoving
()
{
return
new
Action
(()
=>
Move
(
0
));
}
//
...
...
@@ -62,7 +67,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
,
...
...
@@ -80,23 +85,65 @@ namespace Complete
{
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
)))
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 and fire
new
Sequence
(
StopTurning
(),
new
Wait
(
0.8f
),
RandomFire
())
),
new
BlackboardCondition
(
"targetOnRight"
,
Operator
.
IS_EQUAL
,
true
,
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
,
true
,
Stops
.
IMMEDIATE_RESTART
,
// Go forwards
new
Sequence
(
new
Wait
(
0.1f
),
new
Action
(()
=>
Move
(
0.6f
)))
),
new
BlackboardCondition
(
"targetInFront"
,
Operator
.
IS_EQUAL
,
false
,
Stops
.
IMMEDIATE_RESTART
,
// Go backwards
new
Sequence
(
new
Wait
(
0.1f
),
new
Action
(()
=>
Move
(-
0.6f
)))
)
),
new
BlackboardCondition
(
"targetDistance"
,
Operator
.
IS_SMALLER_OR_EQUAL
,
20.0f
,
Stops
.
IMMEDIATE_RESTART
,
// Stop Moving
//new Sequence(StopTurning(),
//new Wait(0.1f),
StopMoving
()
//new Action(() => Move(0.0f)))
)
)
)
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment