Vezot
1
I want to move multiple cubes at the same time, although I don’t want to use parent/child because it seems to mess up rotations…
GameObject[] obj = GameObject.FindGameObjectsWithTag("Cube");
for (int i = 0; i < obj.Length; i++)
{
moveVector.x = Input.GetAxisRaw("Horizontal") * speed;
}
All you are doing in your for loop is setting moveVector.x as many times as there are cubes with said tag.
You would need to do something in your for loop which interacts with obj
Vezot
3
uh i tried a couple of things, can’t seem to get it work… started with C# a day ago… Could anyone please show me? I’d be grateful
Zephus
4
MoveVector is a Vector3 I guess? You just assigned a variable. It’s in the memory and doesn’t do anything at all.
To move an object you need to do stuff like
Or better yet look into Rigidbody and use
- Rigidbody.MovePosition
- Rigidbody.AddForce
- Rigidbody.velocity
Whatever fits your game.
Also multiply moveVector by Time.deltaTime to make it frame independent.