iterate through a gameobject in unity
for(int i = 0; i < gameobject.transform.GetChildCount(); i++)
{
Transform Children = gameobject.transform.GetChild(i);
}
iterate through a gameobject in unity
for(int i = 0; i < gameobject.transform.GetChildCount(); i++)
{
Transform Children = gameobject.transform.GetChild(i);
}
how to iterate through a game object in unity
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;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us