Move object with another object script isn't working

Hi.

I have two cubes. I want one cube (ObjectA) to move with another cube (ObjectB) which is to be moved about i my game. I tried doing this, with two variables (ObjectA, ObjectB):

ObjectA.transform.position = ObjectB.transform.position;

This doesn’t work. The two cubes simply fly around/disappear. Is this because this code no longer works with Unity 5? If so, does anyone know what I can do? I’m not familiar with Unity 5’s new physics.

Thanks.

We’d need to see the context of where you’re doing this.

The whole script would be best, and please indent/format correctly and use code tags: http://forum.unity3d.com/threads/using-code-tags-properly.143875/

That’s assigning them to the exact same position, so if they have physics properties attached to them (rigidbodies and colliders), they’re going to behave very strangely. Do you want to “glue” them together? Do you want them to mirror their movements? What are you trying to accomplish exactly?