• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to make unit pathfinding ignore unit collision?

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,657
@Ceday
For essentially 2 unit types, but it can be done for all units as long as it only removes the pathfinding collision and not actual collision.

@edo494
"as long as it only removes the pathfinding collision and not actual collision."
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
There is an ability with name "Ghost", which is used for undead shade unit's collision.If you add "ghost(visible)" to all units in your map that will probably do it.Because what that ability does is other units can walk through ghosts, but ghosts can not walk through other units.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
So every unit will simply lose collision with other units... what will keep them from all moving into a 5x5 square?
Can you imagine 600 units on such a small place?

Imagine I order them to attack move... but then without attacking neaarby units
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I just saw pathfinding part, perhaps when one of that specific unit types receive move order you can create a dummy unit with ghost(or you pre-create these ghost units for those units), order it to move to target point and make your unit follow dummy unit.I will think a better solution.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Movement Type Hover is interesting as it will move the unit straight into the group of units (desired effect) but it only works as long as I ordered it to move to a very short distance behind that unit.
A longer distance and it will go around them
 
So if I understould you right, then you only want to affect the internal pathfinding algorithm so that a unit will bump straight into another unit blocking it's path and will not walk around it - but you still want the unit to actually bump in there and collide with the other unit?

If so, then I'm afraid the only way to do that is to write a custom collision system.

You can basicly disable all default collision by adding ghost (visible) to all units. Then you check all units periodically if a unit is within X range and if so, you stop their movement.

Obviously, this only works for a couple dozens of units before the performance will take a huge hit. But you can greatly optimize this by hashing units and only check units that actually move.


So an algorithm like that in pseudo code would look like this:

Event: Unit is receives any order
Actions:
- Add unit to a list of "active" units
- Set CurrentPosition[unit] = Position of unit

Event: Periodic
Actions:
- Cycle through list of "active" units
- Enumerate all units in collision range
If FirstOfGroup() != null:
- stop movement and remove unit from active units
If not:
- Set LastPosition[unit] = CurrentPosition[unit]
- Set CurrentPosition[unit] = Position of unit
- Compare LastPosition[unit] with CurrentPosition[unit]
---> If equal, remove unit from the list of active units


Players could still cheat the system by rapidly applying orders to a unit that was stopped by collision. You can prevent that by force-executing the Periodic Trigger on every issued order.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
It doesnt even have to collide with that targeted unit.
However, that walking unit may not collide with other units that run into that same target.

I tried making the units flying which will make them move straight into other units but that makes them able to run into each other as well.
 
It doesnt even have to collide with that targeted unit.
However, that walking unit may not collide with other units that run into that same target.

I tried making the units flying which will make them move straight into other units but that makes them able to run into each other as well.
So you want the unit to only ignore collision with the target unit, but not with other units?

I'm very confused at what you actually want to do at this point.


Do you want the units to only ignore terrain pathing?

In that case, just remove the pathing information from all doodads and terrain tiles and make all your units ordinary ground units. You can't use blizzard cliffs then, though.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Ok, I will explain it in what I want as final result.

I have a map where two armies are going to fight each other to the death.
On this map, I have 2 (maybe more later on) horse rider unit types.
These units have a charge mechanic that they will trample foot units on contact (if they have enough speed).
Everything works... except that those riders are going to move around those units instead of straight in them.

So what I want is that the horseriders are ordered to move behind the first lines of units and trample them before they attack them regulary.
So those horse riders have to move straight into those units.

ef5LZhr.jpg
 

EdgeOfChaos

E

EdgeOfChaos

Add the classification "Walkable" to all units who you want him to pass through, as well as him.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Nope, giving units ghost will remove their collision from other units towards them.
Which is indeed something that had to be done... but not for actual walking.
It is only for pathfinding and with this, the units could literally walk through the other units.

When making all units classified as "walkable", your pathfinding thinks that it is walkable but when that rider comes to that infantry, it will still be blocked.

The only thing that now changes is the pathfinding route and that was the theoretical solution which just had to be found in the editors.
 
Nope, giving units ghost will remove their collision from other units towards them.
Which is indeed something that had to be done... but not for actual walking.
It is only for pathfinding and with this, the units could literally walk through the other units.

When making all units classified as "walkable", your pathfinding thinks that it is walkable but when that rider comes to that infantry, it will still be blocked.

The only thing that now changes is the pathfinding route and that was the theoretical solution which just had to be found in the editors.
Ah, so adding "walkable" doesn't actually disable the collision of units, but tricks the pathfinding AI into thinking it has disabled collision?

Interesting. I didn't know that, though you are probably the first guy ever who needs exactly this functionality and doesn't consider it a nasty bug. ;)
 

EdgeOfChaos

E

EdgeOfChaos

Actually several unit classifications are intended to do things. I believe Suicidal, Worker, Walkable, and Ward all have hardcoded effects. In this case, Walkable makes any unit perform exactly like a Circle of Power regardless of their collision, so if you're confused as to what the effect will be like, imagine your units are order-able Circles of Power.
 
Status
Not open for further replies.
Top