简体   繁体   English

Javascript AI Jump平台游戏

[英]Javascript ai jump platformer

So i am trying to make a 2d platformer but i am having trouble with the ai. 所以我试图做一个2D平台游戏,但我在AI方面遇到了麻烦。 I can make the enemy follow me around perfectly when we start on the same platform but not when we start at the opposite side of the map like so. 当我们在同一平台上启动时,我可以使敌人完美地跟随我,但是当我们在地图的另一侧启动时,我不能这样。

http://imgur.com/t1Xw9lx http://imgur.com/t1Xw9lx

so i want the enemy to jump because there is no platform below. 所以我想让敌人跳,因为下面没有平台。 What would be the best way to let the ai know where and when to jump? 让AI知道何时何地跳跃的最佳方法是什么?

Just think of the platforms as nodes that are connected. 只需将平台视为已连接的节点即可。 If you had a bottom platform, both top and bottom would be "choices" for the AI when it reaches the edge of the left/right platforms. 如果您有底部平台,则当AI到达左右平台的边缘时,顶部和底部都是AI的“选择”。 There, your platform should contain data to which platforms is it connected to. 在那里,您的平台应包含与其连接到的平台的数据。

You might want to add some data on your platforms like level/height so the AI knows what it should do when it transitions from platform to platform, whether it should jump up to the next plaform or just drop down. 您可能想要在平台上添加一些数据,例如水平/高度,以便AI知道当它从一个平台过渡到另一个平台时应该做什么,无论是跳到下一个平台还是只是下拉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM