Problem with Movement and question about Instantiating

Hey guys. I have a problem. I’m making a game were targets move from the side and you have to shoot them. I wrote a script to make them move on the x axis, but they move kind of diagonally. What’s wrong? here’s the script:

var moveSpeed = 5.0;

function Update () {
	var x = Time.deltaTime * moveSpeed;
	transform.Translate(x,0,0);
}

Also, I can make an object instantiate automatically but how can I control the timing at which they spawn?

Here’s my script:

[CODEvar farMovingTarget : Transform;

function Update () {
var createTarget = Instantiate(farMovingTarget, GameObject.Find(“farMovingTargetSpawn”).transform.position, Quaternion.identity);
}][/CODE]

Help on this would be appreciated. Thanks.

The transform.Translate function moves the object along its local XYZ axes, so if the object is angled then its axes will not be aligned with the world axes and you’ll get diagonal movement. If you pass the value Space.World as the last parameter to transform.Translate then the object will move in world space:-

transform.Translate(x, 0, 0, Space.World);

Also, check that your camera is aligned with the world axes.

As for timing the objects’ instantiations, do you want to create new instances at regular intervals? You might find InvokeRepeating or a coroutine useful for this kind of thing.