I have been working on a top down tank RTS type project and am to a point where I would like to start on enemy ai.
where I have started with the enemy ai script is to have it get a list of assets, and sort out the units in the group "scout" , it receives a signal from the main map script defining the the map limit coordinates, then once the map coordinates and assets list is defined it sends a location for the first scout unit in the array which is just calculated from its current location to send it to the mirror location on the other side of the map. that works fine, it will make the trip and stop there if I set things up so that it can,
but of coarse whats the fun in that :-D
so now in testing as a first step I set it up so the scout can not make it to its destination, and adjusted the vehicle script to signal the ai script that the unit is stuck, and that works fine, the signal is sent and the value sent with it is that kinematicbody:1587 is stuck. and the global location where it stopped moving.
what I am wondering is how to go about receiving that information back to the AI script and have the AI script look at kinematicbody:1587 and know its job was to scout and the destination it had been sent to, how to go about organizing that type of mission objectives for when units sent out to do a task get stuck or find the wrong end of ten player tanks I can make the AI script able to respond?
the problem is not that the vehicle is stuck that is just part of the vehicle script shared by all vehicles, 50 collisions and it reverses and stops
what I have for a script so far is not very worked on and I am just looking for a push in the right direction as to how things like that could be accomplished.
this is where I started with that script, it is probably pretty far off what an AI script is going to look like and that is why I am asking for suggestions.... :-)
var assets = 
var scouts = 
var scouting_pos =
var map_size = Vector2.ZERO
var map_pos = Vector2.ZERO
var is_scouting = false
if ! is_scouting:
assets = get_children()
for num in assets:
if map_size and scouts.size() != 0:
var x = map_size.x - scouts.global_position.x + map_pos.x
var y = map_size.y - scouts.global_position.y + map_pos.y
scouts.target = scouting_pos
is_scouting = true
func _on_map_dimensions(map_area , cell_size):
map_pos.x = map_area.position.x * cell_size.x
map_size.x = map_area.end.x * cell_size.x
map_pos.y = map_area.position.y * cell_size.y
map_size.y = map_area.end.y * cell_size.y
func _on_enemy_ui(message, unit, location):
print("unit ", unit, " is stuck at ", location)
the printed output is
[[KinematicBody2D:1566], [KinematicBody2D:1587], [KinematicBody2D:1608], [StaticBody2D:1629], [StaticBody2D:1647], [KinematicBody2D:1667], [KinematicBody2D:1688]]
push destination(897.429932, 2026.570068)
unit [KinematicBody2D:1587] is stuck at (3836.321045, 1174.662842)
that output pretty much just tells me that everything worked "push destination" comes from "scouts.target = scouting_pos" sending the target location to the vehicle script
there is two enemy jeeps two enemy tanks and two stationary gun positions the jeeps are in group scout, I am able sort the units but am not sure which direction to go in to start sorting the objectives and who was sent on an objective.