How to set node penalty based on z position?

I’m using this

gg =;
GraphNode[] nodes = gg.nodes;
foreach ( GraphNode node in nodes ) {
	node.Penalty = (uint)node.position.z/1000;

to try and make it so my seeker doesn’t travel in the positive Z direction but it makes all my seekers cut across the graph all at the same Z position until they all reach the same X position and then continue in the -Z direction


There is no way to penalise them for walking in a specific direction unfortunately.
The penalty indicates how hard it is for them to walk on that particular node. So what I think is happening is that they all find that their current Z position has a really high penalty, so they move down to a region with a much lower penalty and move along the X axis to roughly where they want to go, then they will move along the Z axis because even though it is harder to walk where the Z coordinate is higher, they still need to get there somehow. That way their path will have the lowest total cost (roughly the length of it + the penalties on all the nodes it traverses).

But if the node penalty is descending based on the z position of the node, everything in front of them should be a lower penalty right? You recommended me to do this in my other post

Yes, but that will never prevent them from moving in that direction, they will just avoid nodes with a high z coordinate as much as possible.

Thats what I’m looking for but my code in my original post is not working.

Figured it out, even though my graph isn’t rotated, for some reason the Z position on the nodes is actually the Y position causing the behavior in my first post. I switched my code to Y and it works how I wanted.