• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
single static mob avoidance
#1
(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.

[Image: tagent.png]
https://cdn.discordapp.com/attachments/3...tagent.png

if i have a second mob i just take its tangent into consideration 

[Image: tangent2.png]
https://cdn.discordapp.com/attachments/3...ngent2.png

BUT when i imagine more mobs that approach starts to look less appealing

[Image: tagent_3.png]
https://cdn.discordapp.com/attachments/3...gent_3.png

second approach: construct wp left and right of a mob with a triangle
[Image: triangle.png]
https://cdn.discordapp.com/attachments/5...iangle.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" 

[Image: circles.png]
https://cdn.discordapp.com/attachments/5...ircles.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=j6i76o6l...e=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




[Image: 2wp.png]
https://cdn.discordapp.com/attachments/5...94/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)

[Image: 4.png]
https://cdn.discordapp.com/attachments/5...3028/4.png

[Image: 3.png]
https://cdn.discordapp.com/attachments/5...9396/3.png
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)