# Add a wave to a Translate

 0 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 more ▼ asked Jul 22 '11 at 02:33 PM malakief 1 ● 1 ● 1 ● 1 SisterKy 2.4k ● 33 ● 41 ● 59 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 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 :( more ▼ answered Jul 22 '11 at 02:35 PM malakief 1 ● 1 ● 1 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 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 `````` more ▼ answered Jul 22 '11 at 02:59 PM drChengele 31 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x206
x41
x41
x20

asked: Jul 22 '11 at 02:33 PM

Seen: 662 times

Last Updated: Jul 22 '11 at 02:59 PM