![]() |
single static mob avoidance - Printable Version +- oGasai (http://darkenedlinux.com/ogasai) +-- Forum: My Category (http://darkenedlinux.com/ogasai/forumdisplay.php?fid=1) +--- Forum: Script development - Lua ressources (http://darkenedlinux.com/ogasai/forumdisplay.php?fid=48) +--- Thread: single static mob avoidance (/showthread.php?tid=380) |
single static mob avoidance - zerger - 03-12-2019 (disclaimer: i am just a hobby programmer) i started with a basic concept, if i can write a logic that can walk around a single mob i should be able to modify it and walk around multiple mobs. I want to the avoidance behavour look human like live steering vs pre calculated waypoints (wp) since the environment and mobs are static wp are a good solution i can test the area for obstacles with raycasts and literally see if the way to the wp is good my first approach was that i have a circle around a mob "aggro circle" and if i construct a tangent of that circle which runs through my destination xy i should be able to calculate a wp (random spot in blue area) if i take a An isosceles triangle in front of me, combine it with the tangent of the mob in my path i end up with an area in my isosceles triangle that is save to walk to. ![]() https://cdn.discordapp.com/attachments/388788162308341761/554619409914920969/tagent.png if i have a second mob i just take its tangent into consideration ![]() https://cdn.discordapp.com/attachments/388788162308341761/554619427874668544/tangent2.png BUT when i imagine more mobs that approach starts to look less appealing ![]() https://cdn.discordapp.com/attachments/388788162308341761/554619456878411787/tagent_3.png second approach: construct wp left and right of a mob with a triangle ![]() https://cdn.discordapp.com/attachments/541020519114211347/555018402159394817/triangle.png i have two sides of a right triangle a is the distance me <---> mob b is the distance mob <---> wp (which should be greater than the aggro range) c is root of (a*a+b*b) to calculate both wp left and right of the mob i construct two circles and the wp are at the circle intersections first circle has a the radius "b" and the other circle the radius "c" ![]() https://cdn.discordapp.com/attachments/541020519114211347/555018902271164417/circles.png where the two circles intersect i have my left and right waypoint i ended up with a working solution https://www.youtube.com/watch?v=j6i76o6lbH0&feature=youtu.be third approach: construct two wp left and right of the mob although approach two works it is not good enough and i refine my wp selection logic i construct two wp left and right of the mob and the distance between these wp is 1.5*radius of the aggrorcircle based on the point from approach two i construct the two new wp i again have two sides of a right triangle a is old wp <---> mob b is 0.75* aggroradius c is root of (a*a+b*b) and again circle intersections are used to calculate both wp ![]() https://cdn.discordapp.com/attachments/541020519114211347/555018763959926794/2wp.png video of the code in action https://www.youtube.com/watch?v=lElsPPEBsI4 so far so good but with obstacles it gets more complicated and should be somehow solved first idea: calculate more wp left right so if some of them are blocked the others can be used (again check with raycast) ![]() https://cdn.discordapp.com/attachments/541020519114211347/555020672812843028/4.png ![]() https://cdn.discordapp.com/attachments/541020519114211347/555020813947109396/3.png RE: single static mob avoidance - Syntax - 02-01-2020 (03-12-2019, 01:35 PM)zerger Wrote: (disclaimer: i am just a hobby programmer) Maybe no more lives, but where is you basic simple content link.. If Darklinux not continues the bot can you pls Upload the sourcer code Thx |