查看其他标签但不查看他自己的标签
是否可以调用数组中的所有对象?或者使用该号码是唯一的方法吗?
public void Update()
{
Targetting ge = (Targetting)target.GetComponent("Targetting");
enemies = ge.targets;
float attackDistanceP = Vector3.Distance(target.transform.position, transform.position);
foreach (Transform enemy in enemies)
{
float enemyDistance = Vector3.Distance(enemy.transform.position, transform.position);
print(enemyDistance);
}
Debug.DrawLine(transform.position, waypointPosition, Color.black);
if (attackDistanceP < 8)
disableNow = true;
if (attackDistanceP > 8)
disableNow = false;
}
我想调用敌人[]数组中的所有对象。这样所有的敌人都能看到对方。但我不想让他们看到自己。我使用 GameObject.FindGameObjectsWithTag 来填充其他脚本中的数组。
Is it possible to call all the objects in an array? Or is using the number the only way?
public void Update()
{
Targetting ge = (Targetting)target.GetComponent("Targetting");
enemies = ge.targets;
float attackDistanceP = Vector3.Distance(target.transform.position, transform.position);
foreach (Transform enemy in enemies)
{
float enemyDistance = Vector3.Distance(enemy.transform.position, transform.position);
print(enemyDistance);
}
Debug.DrawLine(transform.position, waypointPosition, Color.black);
if (attackDistanceP < 8)
disableNow = true;
if (attackDistanceP > 8)
disableNow = false;
}
I want to call all of the objects in the enemies[] array. So that all of the enemies can see each other. But I don't want to them to see themselfs. Im using the GameObject.FindGameObjectsWithTag to fill the array in an other script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为您提供一些过早的优化:
Some premature optimization for you: