Move CUBE to another Cubes POSITION

I am trying to move a block to another blocks position, but the cube moves away from the other cube?

The line of code:

cube.transform.position = movePosBlock.transform.position;

Full Code:

if (Input.GetMouseButtonDown(1))
{
if (GameObject.Find("movePosBlock(Clone)") == null)
{
object mPB = Instantiate(movePosBlock, g, Quaternion.identity);
Vector3 moveTo = movePosBlock.transform.position;
stuartCharacter.transform.position = moveTo;
}

}

Any Help? :?

Store the position of the other cube before you start moving it then move to the stored position.

Still not working? :frowning:

Doesn’t matter i fixed it, but how to i get the block to move to the position like a person is walking?

you mean smoothly over time?

Yeah, that’s what i meant

Multiply your transform by Time.deltaTime

could you give me an example:

This is the code i have:

Ray ray = camera.ScreenPointToRay(Input.mousePosition);

        Vector3 g = new Vector3(Mathf.Round(hit.point.x), Mathf.Ceil(hit.point.y), Mathf.Round(hit.point.z));

Cube.transform.position = g;
Cube.transform.position = g * Time.deltaTime;

Hmm… Doesn’t work

Perhaps have a look at iTween in the app store?

But you just play the animation while moving and make sure the speed is appropiate for the animation.

Work great, but how do i make it so it goes the speed the whole time it is moving because it kinda starts fast then slows down?

iTween.MoveTo(cube, g, 5);