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

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

[Image: tangent2.png]

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

[Image: tagent_3.png]

second approach: construct wp left and right of a mob with a triangle
[Image: 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" 

[Image: circles.png]

where the two circles intersect i have my left and right waypoint
i ended up with a working solution 

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]

video of the code in action

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]

[Image: 3.png]

Messages In This Thread
single static mob avoidance - by zerger - 03-12-2019, 01:35 PM
RE: single static mob avoidance - by Syntax - 02-01-2020, 08:08 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)