Search code examples
c#unity-game-enginepath-finding

Astar pathinding maxSpeed value private. i cant change it


So i am making a game and using a* pathfinding. I want to change the maxSpeed value but its private and if i change it to public unity gives me the error

"Assets/AstarPathfindingProject/Core/AI/AIPath.cs(230,25): error CS0106: The modifier 'public' is not valid for this item"

can somebody help me with that.

the line for that:

float IAstarAI.maxSpeed { get { return maxSpeed; } set { maxSpeed = value; } }


Solution

  • AIPath derives from AIBase which already has a public maxSpeed value.

    If you look closely at IAstarAI.maxSpeed it gets/sets the maxSpeed from AIBase.

    You should be able to simply write:

    myAi.maxSpeed = 1f;