• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

How to make unit pathfinding ignore unit collision?

Status
Not open for further replies.
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 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.
 
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,658
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,658
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,658
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