统一代码如何使障碍跟随玩家 [英] How do code in unity to make the obstacle follow the player

查看:74
本文介绍了统一代码如何使障碍跟随玩家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当玩家触摸障碍物的延伸对撞机时,玩家应该跟着障碍物(我的游戏中的蜘蛛)。我做了障碍物(蜘蛛)给动画师的动作手势而我写了代码但是障碍物没有跟随或

朝着方向移动。它只是显示当玩家与障碍物的碰撞器发生碰撞时的动作(腿部动作)手势。



我尝试了什么:



我试过这个代码并且坏了。请帮我查看障碍物对撞机的代码。

The player should be followed by the obstacle(spider in my game) when the player touches the extended collider of the obstacle.I made the obstacle(spider) to give the movement gestures in animator and I wrote the code but the obstacle is not following or
moving in direction .It just showing the movement (leg movements)gestures when the player collides with collider of the obstacle.

What I have tried:

I tried the code and got broken.Please help me with the code for the obstacle collider.

推荐答案

获取玩家的位置,并在下一次更新过程中更新蜘蛛相对于玩家的位置(即改变玩家的x,y,z) spider的变换组件靠近玩家的(变换)位置。)
Get the position of the player, and update the position of the spider relative to the player on the next update pass (i.e. change the x, y, z of the spider's Transform component to move closer to the player's (Transform) position).


这篇关于统一代码如何使障碍跟随玩家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆