Question by
sps_pasha · Jan 08, 2021 at 09:31 AM ·
aipathfinding
A* Pathfinding project feeling from player
I trying to force feel enemy from player using A* Pathfinding project, but enemy always moving to (0, 0, 0).
Code:
if (isChasing) {
// A score of 1000 is approximately equal to the cost of moving one world unit.
int theGScoreToStopAt = 100000;
// Create a path object
FleePath path = FleePath.Construct(transform.position, player.position, theGScoreToStopAt);
Debug.Log(path.startPoint + " / " + path.endPoint);
// This is how strongly it will try to flee, if you set it to 0
//it will behave like a RandomPath
path.aimStrength = 1;
// Determines the variation in path length that is allowed
path.spread = 4000;
// Get the Seeker component which must be attached to this GameObject
Seeker seeker = GetComponent<Seeker>();
// Start the path and return the result to MyCompleteFunction (which is a function you have to
//define, the name can of course be changed)
seeker.StartPath(transform.position, path.endPoint);
}
}
Comment
Best Answer
Answer by sps_pasha · Jan 08, 2021 at 01:37 PM
I killing myself during 2 hours, solution is change:
seeker.StartPath(transform.position, path.endPoint);
To:
seeker.StartPath(path);
Your answer
Follow this Question
Related Questions
How do I make AI objects not walk on top of each other? 5 Answers
Artificial pathfinding with colliders 0 Answers
Spawning object with new random pathing.,Randomly moving after spawn 0 Answers
Making the AI to reach the destination without a Navmesh? 0 Answers
Astar Pathfinding check if areas are connected (Please Help!) 0 Answers