Computer Science and Artificial Intelligence
YU Jiawen, WANG Yuting, PAN Wanbin, WANG Yigang
The unnatural motion of non-player characters (NPCs) is a common issue in pixel art games. This is especially obvious when an NPC is in motion where it usually moves along a pre-fixed path with a stiff motion posture,which significantly detracts from the game's fun, mystery, and/or vitality. To handle the above issue, i.e., generating a concise, smooth, and unpredictable motion path where an NPC can move along it by using adaptable postures, this study proposes a new motion generation approach based on optimization. Firstly, a novel two-level optimization method is presented, which integrates the RRT-Connect algorithm, particle swarm optimization, and Bresenham algorithm. It can rapidly, effectively, and automatically generate a preliminarily feasible and high-random motion path while also optimizing motion postures. Secondly, a greedy strategy is applied to simplify the generated path, shortening the length and improving the smoothness. Finally, based on the particle swarm optimization, a smoothing corner method is developed to further optimize the above-mentioned path and its related postures as well, resulting in final high-naturalness motion. The effectiveness of the proposed approach is verified through tests on several maps of varying complexities and NPCs with different shapes and sizes. The results demonstrate that the generated motion paths exhibit high randomness and the motion postures show significant adaptability. Meanwhile, compared with the existing related works, the proposed approach demonstrates great potential in enhancing the naturalness of NPC motions in pixel games.