# Two object with difference logic find path for obtacles

#1

Hello everybody!

I have large world on server side which devided on many rooms (14*10 unit). The rooms have obtacles with various types. And i want force to move skeleton across pit, but other monster must go around. How i may implemented this?

#2

Hi

One option is to use tags: https://arongranberg.com/astar/docs/tags.php
The other option is to create multiple graphs and ensure that each unit only uses a specific graph: see the graphMask parameter on the StartPath method https://arongranberg.com/astar/docs/class_seeker.php#ab50a876ab529ceb3eb9b97deb5a48d1e

#3

First nice option! For second need dublicate objects, becose grid calculate around layermask, and we cant add two layer in one object. And this two very large grids =/

Ok. Yesterday i discussed with gamedisigner about this problem and we decision that skeletons dont findpath and walk straight. RVO block walk across obtacle. Now i tried something:

`void RecalculatePath() { if (enableFindPath) { readyToMove = false; nextRepath = Time.time + repathRate * (UnityEngine.Random.value + 0.5f); seek.StartPath(transform.position, target, OnPathComplete); } else { ABPath linePath = ABPath.Construct(transform.position, target, OnPathComplete); linePath.vectorPath = new List<Vector3>(); linePath.vectorPath.Add(transform.position); linePath.vectorPath.Add(target); OnPathComplete(linePath); } }`

Sometimes they pass through the obtacle. Can you advise me something?

#4

I’m not really sure what you are asking here?

#5

Sorry! The second attempt. I want skeletons to go straight from point A to B, and for example the dog was looking for a way to the point, bypassing obstacles. The code above allows the skeletons to go straight if enableFindPath = false. But sometimes they go through obstacles ignoring RVO.

#6

Well, since you bypass pathfinding completely it wouldn’t be able to find a path around any obstacles.
I’m not sure why it would be ignoring RVO though.

#7

Okay, I created a pit object using RVOSquareObtacle (to repel those who should not pass) and the GraphUpdaterScene (to bypass the pit, and not collide) configured layers and tags. Works fine, but FPS on the server has fallen from 2000 to 800. Objects of this type on the server are about 500. This worries me a bit, because these are, in fact, static objects.

#8

Hi

Currently RVO obstacles are unfortunately not as optimized as they could be. This means that they reduce the performance even when they are far away from agents. GraphUpdateScene components should work fine though.
An alternative is to use regular colliders on your AIs and have rigidbodies/character controllers on the AIs. Then the agents will be able to collide with the colliders even if they are using local avoidance (assuming you are using 4.x).

#9

Are you planning to fix this? I can try it myself if you give me direction.

#10

Eventually, yes. I’ve got a ton of things on my todo list though, so it might not be soon.

#11

is there any sense in the RVO, if I use rigidbody?

#12

Hi

RVO avoids other agents more smoothly than just rigidbodies.
Usually they are not used together, but sometimes it is useful to use a rigidbody and rvo if you e.g want your agents to push away small debris or similar things.