Path planning method for virtual character, and electronic device and non-transitory computer- readable storage medium thereof
Abstract
A path planning method for a virtual character, an electronic device and a non-transitory storage medium are provided. The method includes acquiring a start and end points of the virtual character in a game scene, and determining an initial path sequence connecting the start and end points based on the game scene; obtaining a fitting curve by performing curve fitting on the initial path sequence; obtaining a sampling path sequence by sampling the fitting curve; determining a plurality of sub-path sequences for forming bends in the sampling path sequence; when a turning radius of the turning path point in the sub-path sequence is less than a preset first turning radius threshold, updating a path corresponding to the sub-path sequences in the fitting curve by re-performing the curve fitting on the turning path points in the sub-path sequence, and obtaining a target path sequence by sampling an updated fitting curve.
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 42 · Forward citations: 0.
Claims (16 — 3 Independent, 13 Dependent)
- Claim 1Independent Claim
A path planning method for a virtual character, wherein the virtual character is controlled by Artificial Intelligence (AI), and the method comprises: acquiring a start point and an end point of the virtual character in a game scene; generating a pathfinding grid model corresponding to the game scene; determining an inflection point from the start point to the end point according to the pathfinding grid model of the game scene; for each inflection point, in response to determining that the inflection point is located at a boundary between a walkable region and a non-walkable region in the pathfinding grid model, moving the inflection point to the walkable region along an edge of a grid of the pathfinding grid model where the inflection point is located, to update the inflection point and obtain an updated inflection point; taking the start point, the updated inflection point and the end point as initial path points to obtain an initial path sequence; taking the initial path points in the initial path sequence as control points to obtain a fitting curve; obtaining a sampling path sequence by sampling the fitting curve at an equal length, wherein the sampling path sequence comprises a plurality of sampling path points; determining a plurality of sub-path sequences for forming bends in the sampling path sequence, wherein each sub-path sequence comprises turning path points forming a same bend; and in response to determining that a turning radius of the turning path point in the sub-path sequence is less than a preset first turning radius threshold corresponding to kinematic constraints of the virtual character controlled by the AI, updating a path corresponding to the sub-path sequences in the fitting curve by performing the curve fitting on the turning path points in the sub-path sequence again, and obtaining a target path sequence that satisfies the kinematic constraints by sampling an updated fitting curve; wherein moving the inflection point to the walkable region along the edge of the grid where the inflection point is located, to update the inflection point and obtain the updated inflection point comprises: in response to determining that a length of the edge of the grid where the inflection point is located is greater than or equal to a preset length, moving the inflection point a first distance to the walkable region along the edge of the grid where the inflection point is located, to obtain the updated inflection point; wherein the preset length is a maximum width of the virtual character, and the first distance is half of the maximum width of the virtual character; in response to determining that the length of the edge of the grid where the inflection point is located is less than the preset length, moving the inflection point a second distance to the walkable region along the edge of the grid where the inflection point is located, to obtain the updated inflection point; wherein the second distance is half or one third of the edge of the grid where the inflection point is located; wherein in response to determining that the turning radius of the turning path point in the sub-path sequence is less than the preset first turning radius threshold, performing the curve fitting on the turning path points in the sub-path sequence again comprises: determining a sub-path sequence having the turning path point with the turning radius less than the preset first turning radius threshold as a target sub-path sequence; and in response to determining that a number of spaced sampling path points between two adjacent target sub-path sequences is less than a preset spaced number threshold, obtaining a new target sub-path sequence by merging the turning path points in the two adjacent target sub-path sequences and the spaced sampling path points; wherein the target path sequence comprises a plurality of target path points, and the method further comprises: determining a target path point with a turning radius less than a preset second turning radius threshold in the target path sequence, and determining the target path point with the turning radius less than the preset second turning radius threshold as a curvature to-be-improved path point, wherein the preset second turning radius threshold is less than the preset first turning radius threshold; determining a plurality of adjacent curvature to-be-improved path points as a curvature to-be-improved path sequence; for each curvature to-be-improved path sequence, determining a minimum turning radius circle corresponding to the curvature to-be-improved path sequence; and determining a mapping point of the curvature to-be-improved path point in the curvature to-be-improved path sequence on a circumference of the minimum turning radius circle, and updating the curvature to-be-improved path point by the mapping point.
- Claim 2Depends on #1
The method according to claim 1, wherein the method further comprises: determining, according to the pathfinding grid model, the initial path sequence from the start point to the end point by adopting a preset pathfinding algorithm.
- Claim 3Depends on #1
The method according to claim 1, wherein the fitting curve is a cubic Hermite curve.
- Claim 4Depends on #1
The method according to claim 1, wherein determining the sub-path sequences for forming the bends in the sampling path sequence, wherein the sub-path sequence comprises the turning path points forming the same bend, comprises: sequentially calculating a tangent-line included angle between tangent vectors of two adjacent sampling path points in the sampling path sequence; determining two sampling path points with the tangent-line included angle greater than a preset first included angle threshold as the turning path points; and determining a plurality of adjacent turning path points as the sub-path sequence.
- Claim 5Depends on #1
The method according to claim 1, further comprising: in response to determining that an arc length between two adjacent mapping points on the minimum turning radius circle is greater than a preset length threshold, adding at least one mapping point between the two adjacent mapping points.
- Claim 6Depends on #5
The method according to claim 5, wherein the plurality of target path points in the target path sequence comprises second target path points in addition to the curvature to-be-improved path points, and the method further comprises: sequentially calculating a transition fitting curve obtained by performing the curve fitting on the second target path points and the mapping points in an ascending order of distances between the second target path points and the minimum turning radius circle; and in response to determining that the transition fitting curve meets a preset condition, splicing the mapping points with the second target path points in the target path sequence, to update the target path sequence.
- Claim 7Depends on #1
The method according to claim 1, wherein the target path sequence comprises a plurality of target path points, and the method further comprises: determining two minimum turning circles for the virtual character according to the start point, an orientation and a minimum turning radius of the virtual character; determining a target minimum turning circle corresponding to a starting mode according to the starting mode of the virtual character, wherein the starting mode comprises forward-left turn, forward-right turn, backward-left turn and backward-right turn; determining a transition path sequence corresponding to each starting mode according to the target minimum turning circle and a first target path point, wherein the first target point is a target path point firstly located outside the target minimum turning circle in the target path sequence; determining a target transition path sequence from the transition path sequence; and processing the target path sequence according to the target transition path sequence to obtain a processed target path sequence.
- Claim 8Depends on #7
The method according to claim 7, wherein determining the transition path sequence corresponding to each starting mode according to the target minimum turning circle and the first target path point firstly located outside the target minimum turning circle in the target path sequence comprises: sampling the target minimum turning circle to obtain a turning circle waypoint; determining whether the turning circle waypoint is located in a walkable region of the game scene; in response to determining that the turning circle waypoint is located in the walkable region, determining the first target path point firstly located outside the target turning minimum circle in the target path sequence, and determining a target turning circle waypoint in the target minimum turning circle, wherein the target turning circle waypoint is a turning circle waypoint closest to the first target path point in a reverse direction of a path corresponding to the starting mode in the target minimum turning circle; calculating a turning-tangent-line included angle between tangent lines of the first target path point and the target turning circle waypoint; in response to determining that the turning-tangent-line included angle is less than a preset second included angle threshold, acquiring a turning circle waypoint between the target turning circle waypoint and the start point as a to-be-fit turning circle waypoint; performing the curve fitting on the to-be-fit turning circle waypoint and the first target path point to obtain a transition path curve; and sampling the transition path curve to obtain a transition path sequence.
- Claim 9Independent Claim
An electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the the computer program is executed by the processor, the processor is configured to: acquire a start point and an end point of a virtual character in a game scene; wherein the virtual character is controlled by Artificial Intelligence (AI); generate a pathfinding grid model corresponding to the game scene; determine an inflection point from the start point to the end point according to the pathfinding grid model of the game scene; for each inflection point, in response to determining that the inflection point is located at a boundary between a walkable region and a non-walkable region in the pathfinding grid model, move the inflection point to the walkable region along an edge of a grid of the pathfinding grid model where the inflection point is located, to update the inflection point and obtain an updated inflection point; take the start point, the updated inflection point and the end point as initial path points to obtain an initial path sequence; take the initial path points in the initial path sequence as control points to obtain a fitting curve; obtain a sampling path sequence by sampling the fitting curve at an equal length, wherein the sampling path sequence comprises a plurality of sampling path points; determine a plurality of sub-path sequences for forming bends in the sampling path sequence, wherein each sub-path sequence comprises turning path points forming a same bend; and in response to determining that a turning radius of the turning path point in the sub-path sequence is less than a preset first turning radius threshold corresponding to kinematic constraints of the virtual character controlled by the AI, update a path corresponding to the sub-path sequences in the fitting curve by performing the curve fitting on the turning path points in the sub-path sequence again, and obtain a target path sequence that satisfies the kinematic constraints by sampling an updated fitting curve; wherein the processor is further configured to: in response to determining that a length of the edge of the grid where the inflection point is located is greater than or equal to a preset length, move the inflection point a first distance to the walkable region along the edge of the grid where the inflection point is located, to obtain the updated inflection point; wherein the preset length is a maximum width of the virtual character, and the first distance is half of the maximum width of the virtual character; in response to determining that the length of the edge of the grid where the inflection point is located is less than the preset length, move the inflection point a second distance to the walkable region along the edge of the grid where the inflection point is located, to obtain the updated inflection point; wherein the second distance is half or one third of the edge of the grid where the inflection point is located; wherein the processor is further configured to: determine a sub-path sequence having the turning path point with the turning radius less than the preset first turning radius threshold as a target sub-path sequence; and in response to determining that a number of spaced sampling path points between two adjacent target sub-path sequences is less than a preset spaced number threshold, obtain a new target sub-path sequence by merging the turning path points in the two adjacent target sub-path sequences and the spaced sampling path points; wherein the target path sequence comprises a plurality of target path points, and the processor is further configured to: determine a target path point with a turning radius less than a preset second turning radius threshold in the target path sequence, and determine the target path point with the turning radius less than the preset second turning radius threshold as a curvature to-be-improved path point, wherein the preset second turning radius threshold is less than the preset first turning radius threshold; determine a plurality of adjacent curvature to-be-improved path points as a curvature to-be-improved path sequence; for each curvature to-be-improved path sequence, determine a minimum turning radius circle corresponding to the curvature to-be-improved path sequence; and determine a mapping point of the curvature to-be-improved path point in the curvature to-be-improved path sequence on a circumference of the minimum turning radius circle, and update the curvature to-be-improved path point by the mapping point.
- Claim 10Independent Claim
A non-transitory computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program, when executed by a processor, cause the processor to: acquire a start point and an end point of a virtual character in a game scene, wherein the virtual character is controlled by Artificial Intelligence (AI); generate a pathfinding grid model corresponding to the game scene; determine an inflection point from the start point to the end point according to the pathfinding grid model of the game scene; for each inflection point, in response to determining that the inflection point is located at a boundary between a walkable region and a non-walkable region in the pathfinding grid model, move the inflection point to the walkable region along an edge of a grid of the pathfinding grid model where the inflection point is located, to update the inflection point and obtain an updated inflection point; take the start point, the updated inflection point and the end point as initial path points to obtain an initial path sequence; take the initial path points in the initial path sequence as control points to obtain a fitting curve; obtain a sampling path sequence by sampling the fitting curve at an equal length, wherein the sampling path sequence comprises a plurality of sampling path points; determine a plurality of sub-path sequences for forming bends in the sampling path sequence, wherein each sub-path sequence comprises turning path points forming a same bend; and in response to determining that a turning radius of the turning path point in the sub-path sequence is less than a preset first turning radius threshold corresponding to kinematic constraints of the virtual character controlled by the AI, update a path corresponding to the sub-path sequences in the fitting curve by performing the curve fitting on the turning path points in the sub-path sequence again, and obtain a target path sequence that satisfies the kinematic constraints by sampling an updated fitting curve; wherein the processor is further configured to: in response to determining that a length of the edge of the grid where the inflection point is located is greater than or equal to a preset length, move the inflection point a first distance to the walkable region along the edge of the grid where the inflection point is located, to obtain the updated inflection point; wherein the preset length is a maximum width of the virtual character, and the first distance is half of the maximum width of the virtual character; in response to determining that the length of the edge of the grid where the inflection point is located is less than the preset length, move the inflection point a second distance to the walkable region along the edge of the grid where the inflection point is located, to obtain the updated inflection point; wherein the second distance is half or one third of the edge of the grid where the inflection point is located; wherein the processor is further configured to: determine a sub-path sequence having the turning path point with the turning radius less than the preset first turning radius threshold as a target sub-path sequence; and in response to determining that a number of spaced sampling path points between two adjacent target sub-path sequences is less than a preset spaced number threshold, obtain a new target sub-path sequence by merging the turning path points in the two adjacent target sub-path sequences and the spaced sampling path points; wherein the target path sequence comprises a plurality of target path points, and the processor is further configured to: determine a target path point with a turning radius less than a preset second turning radius threshold in the target path sequence, and determine the target path point with the turning radius less than the preset second turning radius threshold as a curvature to-be-improved path point, wherein the preset second turning radius threshold is less than the preset first turning radius threshold; determine a plurality of adjacent curvature to-be-improved path points as a curvature to-be-improved path sequence; for each curvature to-be-improved path sequence, determine a minimum turning radius circle corresponding to the curvature to-be-improved path sequence; and determine a mapping point of the curvature to-be-improved path point in the curvature to-be-improved path sequence on a circumference of the minimum turning radius circle, and update the curvature to-be-improved path point by the mapping point.
- Claim 11Depends on #1
The method according to claim 1, wherein the initial path sequence is a shortest path sequence among all paths that the virtual character passes through a movable region from the start point to the end point.
- Claim 12Depends on #4
The method according to claim 4, wherein the preset first included angle threshold is 20 degrees.
- Claim 13Depends on #1
The method according to claim 1, wherein the preset first turning radius threshold is than a minimum turning radius of the virtual character.
- Claim 14Depends on #13
The method according to claim 13, wherein the preset first turning radius threshold is equal to twice the minimum turning radius of the virtual character.
- Claim 15Depends on #1
The method according to claim 1, wherein the preset second turning radius threshold is the minimum turning radius of the virtual character.
- Claim 16Depends on #9
The electronic device according to claim 9, wherein the processor is further configured to: determine, according to the pathfinding grid model, the initial path sequence from the start point to the end point by adopting a preset pathfinding algorithm.
Technical Overview & Description
CROSS-REFERENCE TO RELATED APPLICATIONS The present disclosure is a U.S. National Phase Application of International Application No. PCT/CN2022/095030, filed on May 25, 2022, which is based on and claims the priority of China Patent Application No. 202210061294.3 filed on Jan. 19, 2022, entitled “ PATH PLANNING METHOD AND APPARATUS FOR VIRTUAL CHARACTER, ELECTRONIC DEVICE, AND STORAGE MEDIUM ” , and the entire contents of both of which are incorporated herein by reference for all purposes. TECHNICAL FIELD The present disclosure relates to a field of computer technology, and in particular, to a path planning method and apparatus for a virtual character, an electronic device and a non-transitory storage medium. BACKGROUND A virtual character controlled by artificial intelligence (AI), as a virtual character added to a game, is an important participant in the game, which plays an important role in protecting novices, improving matching speed, customizing game content and long-term operation of the game. For a movable AI virtual character, it is very important to find a path that meets the constraints if the virtual character needs to move from any given start position to the end position in the scene. In general, a sequence of waypoints connecting the start position and the end position is called a path, and a strategy of forming the path is called path planning. It should be noted that the information disclosed in this section is turned only for enhancing understanding of the BACKGROUND of the disclosure, and therefore, may contain information that does not constitute the prior art that is already known to those skilled in the art. SUMMARY The present disclosure provides a path planning method and apparatus for a virtual character, an electronic device and a non-transitory storage medium, including the following. A path planning method for a virtual character is provided and includes: acquiring a start point and an end point of the virtual character in a game scene, a
Cited By — Indexed Forward Citations (0 of 0 total)
No indexed citing patents in this generation yet. Ingest USPTO/PatentsView bulk citation tables via patents-ingest to expand the local forward citation graph.
References Cited — Backward Prior Art (42)
Non-Patent Literature (3)
- 1st Office Action dated Jun. 26, 2025 of Chinese Application No. 202210061294.3.
- International Search Report dated Oct. 14, 2022 of International Application No. PCT/CN2022/095030.
- Notice of Allowance dated Jan. 26, 2026 of Chinese Application No. 202210061294.3.