Using the roll a ball tutorial my dart backs off the canvas

Hi, I am using the movement script from the roll a ball tutorial, but as soon as I start the game my dart backs off the canvas all by itself.

Here’s the code I’m using;

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {
	
	public float speed;
	
	private Rigidbody rb;
	
	void Start ()
	{
		rb = GetComponent<Rigidbody>();
	}
	
	void FixedUpdate ()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		
		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		
		rb.AddForce (movement * speed);
	}
}

Also, I want to use the arrow keys to move the dart left and right only, where would I need to put that script? In a new C# script or somewhere in this one possibly?

Any help would be totally appreciated :slight_smile: Thanks

This is my latest attempt to keep my dart only moving left and right.

using UnityEngine;
using System.Collections;

public class moveDart_LR : MonoBehaviour {

float speed = 1.0f;

void Update() {
	if (Input.GetKey (KeyCode.RightArrow)) 
		transform.Translate(Vector2.right * Time.deltaTime);
	if (Input.GetKey (KeyCode.LeftArrow)) 
		Transform.Translate(Vector2.left * Time.deltaTime);
}

}