# Walls not moving in

For my game I need the outer walls to close in towards the center, but for some reason they just hop forward into a close position instantly, then all collide in the center and take off in random directions. Help?

``````using UnityEngine;
using System.Collections;

public class ApproachWalls : MonoBehaviour {

public Vector3 pos;
public Vector3 newPos;
public Vector3 differenceOne = new Vector3(0,0,5);
public Vector3 differenceTwo = new Vector3(0,0,5);
public Vector3 differenceThree = new Vector3(5,0,5);
public Vector3 differenceFour = new Vector3(-5,0,5);
// Use this for initialization
void Start () {
pos = transform.position;
InvokeRepeating ("closeIn", 5.0f, 5.0f);
}

// Update is called once per frame
void Update () {

}

void closeIn (){
if (transform.position.z < 0 && transform.position.x == 0 && transform.position.z !=0) {
newPos += differenceOne;
rigidbody.MovePosition(newPos);

} else if (transform.position.z > 0 && transform.position.x == 0 && transform.position.z !=0) {
newPos += differenceTwo;
rigidbody.MovePosition(newPos);

} else if (transform.position.x < 0 && transform.position.z == 0 && transform.position.x !=0) {
newPos += differenceThree;
rigidbody.MovePosition(newPos);

} else if (transform.position.x > 0 && transform.position.z == 0 && transform.position.x !=0) {
newPos += differenceFour;
rigidbody.MovePosition(newPos);
}
}
void OnCollisionEnter (Collision col){
Physics.IgnoreCollision(col.collider, collider);

}
}
``````

if you can predefine the final and initial positions, you could use the Lerp function. (the tutorial for lerp is in the video tutorials offered by unity)