Hello Guys! I'm Telling To Teach About How To Make Simple Enemy AI In Top Down Games.
Step 1:
First You Need Create Graphics Like This
Step 2:
Insert Behavior In This List
For Body:
-Pathfinding
For Turret:
-Turret Behavior
-Pin
Here's The Code
<sub-events>
<event-block sid="163577834960557">
<conditions>
<condition id="-18" name="On created" sid="4281055271434106" type="EnemyTank_Base" />
</conditions>
<actions>
<action id="-4" name="Set position to another object" sid="5058862818873756" type="EnemyTank_Turret">
<param id="0" name="Object">EnemyTank_Base</param>
<param id="1" name="Image point (optional)">0</param>
</action>
<action behavior="Pin" id="0" name="Pin to object" sid="1346754480110631" type="EnemyTank_Turret">
<param id="0" name="Pin to">EnemyTank_Base</param>
<param id="1" name="Mode">0</param>
</action>
<action behavior="Pathfinding2" id="0" name="Find path" sid="29365021045719" type="EnemyTank_Base">
<param id="0" name="X">random(0,LayoutHeight+1)</param>
<param id="1" name="Y">random(0,LayoutHeight+1)</param>
</action>
<action behavior="Turret" id="1" name="Add object to target" sid="2019182226234584" type="EnemyTank_Turret">
<param id="0" name="Target">PlayerTank_Base</param>
</action>
<action behavior="Turret" id="1" name="Add object to target" sid="11145249886703" type="EnemyTank_Turret">
<param id="0" name="Target">FriendlyTank_Base</param>
</action>
</actions>
</event-block>
<event-block sid="3858550942875802">
<conditions>
<condition id="-6" name="Every X seconds" sid="2670897857223108" type="System">
<param id="0" name="Interval (seconds)">2.0</param>
</condition>
</conditions>
<actions>
<action behavior="Pathfinding2" id="0" name="Find path" sid="3391881602001852" type="EnemyTanks">
<param id="0" name="X">random(0,LayoutHeight+1)</param>
<param id="1" name="Y">random(0,LayoutHeight+1)</param>
</action>
</actions>
</event-block>
<event-block sid="6753699591358611">
<conditions>
<condition behavior="Pathfinding2" id="5" name="On arrived" sid="7063045528682552" type="EnemyTanks" />
</conditions>
<actions>
<action behavior="Pathfinding2" id="0" name="Find path" sid="5950165379724284" type="EnemyTanks">
<param id="0" name="X">random(0,LayoutHeight+1)</param>
<param id="1" name="Y">random(0,LayoutHeight+1)</param>
</action>
</actions>
</event-block>
<event-block sid="9077278802086329">
<conditions>
<condition behavior="Pathfinding2" id="0" name="On path found" sid="8927582173010199" type="EnemyTanks" />
<condition id="-11" name="For Each" sid="7208858873037174" type="System">
<param id="0" name="Object">EnemyTanks</param>
</condition>
</conditions>
<actions>
<action behavior="Pathfinding2" id="1" name="Move along path" sid="6299763840062121" type="EnemyTanks" />
</actions>
</event-block>
<event-block sid="7245582049393619">
<conditions>
<condition behavior="Turret" id="1" name="On shoot" sid="9071969090130075" type="EnemyTank_Turret" />
</conditions>
<actions>
<action id="0" name="Spawn another object" sid="7252762257753358" type="EnemyTank_Turret">
<param id="0" name="Object">EnemyTank_Projectile</param>
<param id="1" name="Layer">"Projectiles_0"</param>
<param id="2" name="Image point">0</param>
</action>
<action id="0" name="Play" sid="4341613316359344" type="Audio">
<param id="0" name="Audio file">Small Cannon</param>
<param id="2" name="Loop">0</param>
<param id="3" name="Volume">-10</param>
<param id="1" name="Tag (optional)">""</param>
</action>
</actions>
</event-block>
</sub-events>
</event-group>
Now Preview The Layout
Enjoy!
You Need WinRAR To Upload The Pack.