Hi,
I encountered with a problem when using Linecast in the GridGenerator.cs class GridGraph. In example Example9_Penalties I changed in the script TargetMover.cs class TargetMover function UpdateTargetPosition
[details=Edit TargetMover UpdateTargetPosition]> public void UpdateTargetPosition () {
Vector3 newPosition = Vector3.zero;
bool positionFound = false;
float velocity = 1f;
var directionPosition = Vector3.zero;
if (Input.GetKey("w"))
{
directionPosition += new Vector3(0, 0, velocity);
}
if (Input.GetKey("a"))
{
directionPosition += new Vector3(-velocity, 0, 0);
}
if (Input.GetKey("s"))
{
directionPosition += new Vector3(0, 0, -velocity);
}
if (Input.GetKey("d"))
{
directionPosition += new Vector3(velocity, 0, 0);
}
if (directionPosition != Vector3.zero)
{
var graph = AstarPath.active.graphs[0];
var updateGraph = graph as IRaycastableGraph;
GraphHitInfo hit;
List<GraphNode> trace = new List<GraphNode>();
bool result = updateGraph.Linecast(target.position, target.position + directionPosition, null, out hit, trace);
newPosition = hit.point;
positionFound = true;
}
}[/details]
to using WASD to move himself gameObject Target, not using spiders-bot. In the end, the Linecast in the direction from right to left and from top to bottom works well (https://gyazo.com/8516cb5eeb29c10d00274cfcb731823b),
in the opposite direction the target is in an impassable area and gets stuck there (https://gyazo.com/6beae0d2be12b57de12535cec2f13f63) (inside the Linecast() it enters in condition (!startNode.Walkable) {…return true;}) I use A* Pathfinding Project Pro 4.1.7 (branch beta) and Unity 2017.1.2p2. (I have downloaded)
I have to check the result Linecast() and if it`s true - to do the offset in the direction of movement. Yesterday released version 4.1.8 Pro, but I haven’t tried.
The task to try a movement on joystick on the grid. I havent found any good information about this in Internet, and I’m not sure that this can be done adequately on a grid and most likely
will have to use Navmesh/Recast, which uses precise geometry of the world. What do you think, Is it worth to experiment with the grid or directly use Navmesh/Recast? If the Linecast I can handle with offsetting
how to make a smooth glide I don’t know.