I tried making a AI, it didnt go well

This is a game AI, meant to target a enemy and once killed, move on, but the warriors jiggle because the numbers fluctuate between 3 and -3 for the movement because its never in line

3 Likes

I had the same problem, but I recommend using the bundle I have in my AI Test project. Here is the code:

{“data”:{“behavior”:{“v”:“2”,“nodes”:[{“inputCount”:0,“outputCount”:0,“name”:“Follow Nearest”,“behaviorType”:“logic.NodeGroup”,“x”:360,“y”:-448,“group”:"",“id”:“9f113f447879ec41”,“isMenuItem”:false},{“gateVal”:0,“mode”:“greater than”,“inputCount”:1,“outputCount”:2,“name”:“Filter”,“behaviorType”:“logic.logic.Filter”,“x”:720,“y”:64,“group”:“9f113f447879ec41”,“id”:“9f113f4500b42847”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:900,“y”:32,“group”:“9f113f447879ec41”,“id”:“9f113f451f3e2545”,“startVal”:-2,“tag”:“left”},{“delay”:0,“count”:0,“inputCount”:3,“outputCount”:1,“name”:“Timer”,“behaviorType”:“logic.triggers.Timer”,“x”:0,“y”:192,“group”:“9f113f447879ec41”,“id”:“9f113f45fb7ed747”},{“expression”:“A-B”,“default0”:0,“default1”:0,“default2”:0,“default3”:0,“default4”:0,“default5”:0,“params”:2,“version”:1,“tag”:"",“inputCount”:3,“outputCount”:1,“name”:“Expression”,“behaviorType”:“logic.logic.Expression”,“x”:540,“y”:64,“group”:“9f113f447879ec41”,“id”:“9f113f450c945740”},{“gateVal”:0,“mode”:“greater than”,“inputCount”:1,“outputCount”:2,“name”:“Filter”,“behaviorType”:“logic.logic.Filter”,“x”:720,“y”:256,“group”:“9f113f447879ec41”,“id”:“9f113f45ccb6724f”},{“expression”:“A-B”,“default0”:0,“default1”:0,“default2”:0,“default3”:0,“default4”:0,“default5”:0,“params”:2,“version”:1,“tag”:"",“inputCount”:3,“outputCount”:1,“name”:“Expression”,“behaviorType”:“logic.logic.Expression”,“x”:540,“y”:256,“group”:“9f113f447879ec41”,“id”:“9f113f45c7169340”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:900,“y”:320,“group”:“9f113f447879ec41”,“id”:“9f113f45aef9184e”,“startVal”:2,“tag”:“down”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:900,“y”:224,“group”:“9f113f447879ec41”,“id”:“9f113f451c6bd04b”,“startVal”:-2,“tag”:“up”},{“inputCount”:3,“outputCount”:3,“name”:“Velocity”,“behaviorType”:“logic.properties.Physics”,“x”:1080,“y”:160,“group”:“9f113f447879ec41”,“id”:“9f113f46a0ead044”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:900,“y”:128,“group”:“9f113f447879ec41”,“id”:“9f113f466a99954e”,“startVal”:2,“tag”:“right”},{“inputCount”:3,“outputCount”:1,“name”:“Switch”,“behaviorType”:“logic.logic.Switch”,“x”:180,“y”:160,“group”:“9f113f447879ec41”,“id”:“9f113f46bf0d7449”,"_startVal":0,“dataType”:2},{“inputCount”:1,“outputCount”:1,“name”:“Extractor”,“behaviorType”:“logic.properties.Extractor”,“x”:360,“y”:32,“group”:“9f113f447879ec41”,“id”:“9f113f4615288d40”,“targetId”:0,“prop”:“x”},{“inputCount”:1,“outputCount”:1,“name”:“Extractor”,“behaviorType”:“logic.properties.Extractor”,“x”:360,“y”:256,“group”:“9f113f447879ec41”,“id”:“9f113f46e8c76c47”,“targetId”:0,“prop”:“y”},{“inputCount”:0,“outputCount”:1,“name”:“Always”,“behaviorType”:“logic.triggers.Always”,“x”:-540,“y”:192,“group”:“9f113f447879ec41”,“id”:“9f113f461f6c7343”},{“inputCount”:2,“outputCount”:3,“name”:“Proximity”,“behaviorType”:“logic.components.Prox2”,“x”:-360,“y”:192,“group”:“9f113f447879ec41”,“id”:“9f113f4605818540”,“targetEntityId”:0,“threshold”:1000,“targetClassId”:15482598,“nearestOnly”:true,“firstObject”:false,“allObjects”:false,“contains”:false,“shape”:1},{“inputCount”:3,“outputCount”:1,“name”:“Switch”,“behaviorType”:“logic.logic.Switch”,“x”:-180,“y”:192,“group”:“9f113f447879ec41”,“id”:“9f113f4643665f4b”,"_startVal":1,“dataType”:2},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:360,“y”:128,“group”:“9f113f447879ec41”,“id”:“9f113f46fd69b345”,“startVal”:0,“roundMode”:1},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:360,“y”:352,“group”:“9f113f447879ec41”,“id”:“9f113f4641317741”,“startVal”:0,“roundMode”:1},{“inputCount”:2,“outputCount”:3,“name”:“Proximity”,“behaviorType”:“logic.components.Prox2”,“x”:-360,“y”:320,“group”:“9f113f447879ec41”,“id”:“9f113f46b214214c”,“targetEntityId”:0,“threshold”:50,“targetClassId”:15482598,“nearestOnly”:true,“firstObject”:false,“allObjects”:false,“contains”:false,“shape”:1},{“inputCount”:3,“outputCount”:1,“name”:“Switch”,“behaviorType”:“logic.logic.Switch”,“x”:-180,“y”:320,“group”:“9f113f447879ec41”,“id”:“9f113f466c2dd94f”,"_startVal":0,“dataType”:2},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:0,“y”:320,“group”:“9f113f447879ec41”,“id”:“9f113f465ec98c48”,“startVal”:0,“roundMode”:1}],“links”:[{“input_id”:“9f113f451f3e2545i1”,“output_id”:“9f113f4500b42847o0”},{“input_id”:“9f113f466a99954ei1”,“output_id”:“9f113f4500b42847o1”},{“input_id”:“9f113f46a0ead044i0”,“output_id”:“9f113f451f3e2545o0”},{“input_id”:“9f113f46bf0d7449i2”,“output_id”:“9f113f45fb7ed747o0”},{“input_id”:“9f113f4500b42847i0”,“output_id”:“9f113f450c945740o0”},{“input_id”:“9f113f451c6bd04bi1”,“output_id”:“9f113f45ccb6724fo0”},{“input_id”:“9f113f45aef9184ei1”,“output_id”:“9f113f45ccb6724fo1”},{“input_id”:“9f113f45ccb6724fi0”,“output_id”:“9f113f45c7169340o0”},{“input_id”:“9f113f46a0ead044i1”,“output_id”:“9f113f45aef9184eo0”},{“input_id”:“9f113f46a0ead044i1”,“output_id”:“9f113f451c6bd04bo0”},{“input_id”:“9f113f46a0ead044i0”,“output_id”:“9f113f466a99954eo0”},{“input_id”:“9f113f4615288d40i0”,“output_id”:“9f113f46bf0d7449o0”},{“input_id”:“9f113f46fd69b345i1”,“output_id”:“9f113f46bf0d7449o0”},{“input_id”:“9f113f46e8c76c47i0”,“output_id”:“9f113f46bf0d7449o0”},{“input_id”:“9f113f4641317741i1”,“output_id”:“9f113f46bf0d7449o0”},{“input_id”:“9f113f450c945740i0”,“output_id”:“9f113f4615288d40o0”},{“input_id”:“9f113f45c7169340i0”,“output_id”:“9f113f46e8c76c47o0”},{“input_id”:“9f113f4605818540i1”,“output_id”:“9f113f461f6c7343o0”},{“input_id”:“9f113f46b214214ci1”,“output_id”:“9f113f461f6c7343o0”},{“input_id”:“9f113f46fd69b345i0”,“output_id”:“9f113f4605818540o0”},{“input_id”:“9f113f4643665f4bi2”,“output_id”:“9f113f4605818540o0”},{“input_id”:“9f113f4641317741i0”,“output_id”:“9f113f4605818540o1”},{“input_id”:“9f113f4643665f4bi1”,“output_id”:“9f113f4605818540o2”},{“input_id”:“9f113f46bf0d7449i1”,“output_id”:“9f113f4643665f4bo0”},{“input_id”:“9f113f4643665f4bi0”,“output_id”:“9f113f4643665f4bo0”},{“input_id”:“9f113f450c945740i1”,“output_id”:“9f113f46fd69b345o0”},{“input_id”:“9f113f450c945740i2”,“output_id”:“9f113f46fd69b345o0”},{“input_id”:“9f113f45c7169340i1”,“output_id”:“9f113f4641317741o0”},{“input_id”:“9f113f45c7169340i2”,“output_id”:“9f113f4641317741o0”},{“input_id”:“9f113f466c2dd94fi1”,“output_id”:“9f113f46b214214co0”},{“input_id”:“9f113f466c2dd94fi2”,“output_id”:“9f113f46b214214co0”},{“input_id”:“9f113f466c2dd94fi1”,“output_id”:“9f113f46b214214co1”},{“input_id”:“9f113f466c2dd94fi2”,“output_id”:“9f113f46b214214co1”},{“input_id”:“9f113f466c2dd94fi0”,“output_id”:“9f113f46b214214co2”},{“input_id”:“9f113f46bf0d7449i0”,“output_id”:“9f113f466c2dd94fo0”},{“input_id”:“9f113f465ec98c48i1”,“output_id”:“9f113f466c2dd94fo0”},{“input_id”:“9f113f46a0ead044i2”,“output_id”:“9f113f465ec98c48o0”}]}}}





1 Like

The code doesnt import, and does this use large amounts of proximity?

Oh, really? And no, it only uses 2 proximity blocks. Ok just copy the bundle from the Flowlab Game Creator - AI Test

The object named “Here” has the bundle in it. Copy that into the object that is following another object. Then create another object that you can name “Follow Marker” only enable collisions for it though. Then, put the “Follow Marker” object in both proximities located in the bundle. Finally, attach the “Follow Marker” to the object that is being followed by the original object with the bundle located inside of it.

yeah, well, the proximity is 1000 blocks, and that is too much if there are 300 sprites with that behaviour

1 Like

Hmm… I suppose you can use globals with extractors connected to them, but it will only follow a random object, not the nearest one. But you can try.

I know, and to counter that, whatever is in its small range will get targeted

1 Like