我如何在预定式的gameObject中称呼另一个gameObject的可能性?
如果是不可能的,我至少可以使用射线跟踪找到它吗?
我想制作一些敌人的游戏对象(这些游戏是从预制的,随机产卵的实例化)总是看着玩家。
我认为我不能称其为XYZ坐标,但也许我可以使用射线缩放找到它们?我该怎么做?即使我知道什么是射线跟踪,并且在其他非统一项目中使用了它,我也不知道如何团结地实施它。
If that is not possible, can I at least find it using raytracing?
I want to make some enemy GameObjects (which are instantiated from a prefab, which spawn randomly) always look towards the player.
I don't think I can just call it's xyz coordinates, but maybe I can find them using raytracing? How exactly do I do that? Even if I know what raytracing is and used it before in other non-unity projects, I have no idea how to implement it in unity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的敌人应该能够以某种方式获得参考(可能是入门级的单例,或者是专业人士的依赖注入)并使用player.Transform.Posit.position。
基本上您的玩家应该看起来像这样:
然后敌人可以使用:
使玩家位置保持位置。
Your enemies should be able to get reference to player somehow (probably Singleton for entry level, or Dependency Injection for pros) and use player.transform.position
So basically your player should look like that:
And then enemy can use:
to get players position.