Mathf.pingpong

when i use mathf.pingpong it move my object in both directions however i want it to start at 0 and go to ‘n’, as it stands instead of moving in both directions. My object is a simple cube object.

here is the code i am using to do this

using UnityEngine;
using System.Collections;

public class movePointer : MonoBehaviour {
// Use this for initialization
void Start () {

}
// Update is called once per frame
void Update () {
	transform.localScale = new Vector3(0.1f,0.1f,1.0f*Mathf.PingPong(Time.time*5.0f, 4));
	Debug.Log(transform.localScale = new Vector3(0.1f,0.1f,1.0f*Mathf.PingPong(Time.time*5.0f, 4)));
}
}

I know I havent explained what I want well so pls see the below image for a clearer explanation

current both ends move
i only want one end to move

Any help is appreciated

To get the behavior you want, remove the script from your block and attach it to an empty game object. Move the empty game object to the end of the block then make the block a child of the empty game object.

The code example at Unity - Scripting API: Mathf.PingPong does exactly what you want.

You can’t scale an object from one end. What you will need to do is scale and translate the object at the same time. That will give you the look you are going for.

as i couldnt get this going, an easy solution was sticking with the same code i had at the beginning.

Create an object in 3ds max and move it pivot point to one end, export it as an fbx file and import into unity.

Attach the script to this object and it works.

However i dont have a coded answer.

Other free 3d software will also work to do this if you cant get 3ds max