# Add a wave to a Translate

Hi,

im new on unity, and on game programming.
I’m trying to make a translate of a missile a little more than a simple transform.forward, im trying to add two waves on x and y axies.

here is the working code:

function Update () {

``````transform.Translate(Vector3.forward*60*Time.deltaTime);
``````

}

here is the wrong code:

private var player:GameObject;

player=gameObject.Find(“Player”);

private var distanceToPlayer:float;

distanceToPlayer=Vector3.Distance(transform.position,player.transform.position);

private var numIteration:float;

numIteration=1;

private var waveHeight:float;

waveHeight=1;

private var ondex:float;

private var ondey:float;

function Update () {

``````var ondex=waveHeight*Mathf.Sin((transform.position.x/distanceToPlayer)*Mathf.PI*numIteration);
var ondey=waveHeight*Mathf.Sin((transform.position.y/distanceToPlayer)*Mathf.PI*numIteration);
transform.Translate(ondex,ondey,Vector3.forward*60*Time.deltaTime,Space.World);
``````

}

Can you help me?
Thx

i forgot the error message:
BCE0023: No appropriate version of ‘UnityEngine.Transform.Translate’ for the argument list ‘(float, float, UnityEngine.Vector3, null)’ was found.
i don’t understand this error

The problem is you are passing the wrong argument in transform.Translate.

The third value in transform.Translate is an entire Vector3 instead of a float. Unity expects a single float value for the z coordinate of the translation, but you are giving it an entire vector so it doesn’t know how to use it.

You should write:

``````var ondex=waveHeight*Mathf.Sin((transform.position.x/distanceToPlayer)*Mathf.PI*numIteration);
var ondey=waveHeight*Mathf.Sin((transform.position.y/distanceToPlayer)*Mathf.PI*numIteration);
transform.Translate(ondex,ondey,60*Time.deltaTime,Space.World); // we took out the Vector3.forward
``````