Lock/Freeze a character in position?

  • A* version: [5.4.5]
  • Unity version: [6.2.13]

Hi,

I was wondering if anyone has some tips on freezing a character in place.

I keep having npc’s pushing eachother, maybe in a large scale RTS game its not a huge problem, but for my game it looks really bad.

I read on the forum a bit, could not find too much about it, or i am searching for the wrong things.

I read about local avoidance, and understand it is indeed that, LOCAL avoidance, so i quickly understood this was not an answer to my problems.

Then i read about “Attackslots” a system thats apparently usually used to solve this, but now instead of walking to an attackslot (i still need to refine the logic, but thats not the issue) theyre all just pushing against eachother, drifting off the map basically, if i dont stop them.

I removed the enemies collision with eachother in the unity physics.

In the past i worked with Unity Navmesh, i could disable the Navmesh agent, and then i was free to do whatever, i could use transform rotation/movement till pathfinding was needed again, and then enable the agent. I tried that with A* but lets just say it wasnt happy with that lol.

I thought maybe a navmesh cut, but that would also take the agent off the navmesh if i cut the unit that needs to be locked?

I also saw i could set the unit to Locked, but the tooltip said Local Avoidance would be worse then?

Then i saw something about the layers, so then i tried to switch them to Obstacle layer when they were standing still attacking, that also didnt help.

I mean it could still be something i am doing wrong, but if anyone has some advice would be greatly appreciated!

So i added a penalty system on top of the attackslot system and switching them to obstacle layer when they switch to combat

that actually improved it by quite a lot, but i’d still love some advice/tips to get rid of sliding/pushing 100%, that would be great!

If you’d like them to stop moving altogether you can use either canMove with the FollowerEntity movement script, or simulateMovement for the AIPath, RichAI or AILerp movement scripts. These respective settings stop all movement, including local avoidance movement.

1 Like

I already tried some canmove, simulate movement etc, its probably my knowledge lacking, but i just could not get nice behavior out of the pathfinding. Kept pushing, sliding, not rotating properly.

After some testing;

Middle is out of the box behavior of Astar pathfinding with RVO.
Left is Astar with additions of my custom scripts.

Right is Agents Navigation asset out of the box.

For my project that was just way easier, so now im using Agents Navigation on Astar navmesh, my non combat npc’s are using Astar, and my combat are using Agents Navigation, and all my problems are solved.

1 Like