📌  相关文章
📜  如何统一迭代游戏对象 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:05.489000             🧑  作者: Mango

代码示例1
void FixedUpdate()

{
    GameObject objects = GameObject.FindGameObjectsWithTag("Enemy");
    var objectCount = objects.Length;
    foreach (var obj in objects)
    {
        // Move the players accordingly
        //var rb = 
        Vector2 direction = (player.position - transform.position).normalized;
        obj.rigidbody.velocity = direction * moveSpeed;

    }
}