我无法使用(point_distance)杀死任何接近我的英雄GMK的敌人

问题描述 投票:0回答:1

我对Game Maker程序中的代码有疑问我做了一个小游戏,游戏中的敌人会继续前进,将英雄放到他身边,而当敌人接近他时,他会转向他并射击他我正在使用此代码

var ex, ey;
ex = instance_nearest(x, y, enemy).x;
ey = instance_nearest(x, y, enemy).y;

if point_distance(x, y, ex, ey) < 150
{
     image_angle = point_direction(x, y, enemy.x, enemy.y);
}

该代码运行良好,但是问题在于,我的英雄只会在靠近第一个敌人时才向第一个敌人靠近,即使第一个敌人不在范围内也不会向其余敌人靠近请问有什么解决办法插画照片Heroes ignore the nearby enemy and only head for the first enemy to appear in the game

xcode game-maker gml
1个回答
0
投票

您可以使用类似collision_circle_list(...)的名称。此功能将为您提供在该圆内发生碰撞的所有对象的列表,您可以遍历它们以查找最接近,最远的对象。

© www.soinside.com 2019 - 2024. All rights reserved.