FPS using mouse to move rather than keys

Hi
I am developing a First person game but would like to use the mouse to move on a click to move as opposed to the keys. I also need to disable Y movement and restrict the x movement to 180. I dabbled with the standard unity FPS but is seems very jagged on movement and from what I can see being a new user, their doesn’t seem to be a way to restrict y movement. Can someone help with this or suggest a good tutorial on this type of movement. Thanks

If your problem is jagged movement might be the only thing you need is to lerp the movement.

Here’s what it should look like:

using UnityEngine;
using System.Collections;

public class adsasd : MonoBehaviour {


	private Vector3 newPosition;
	void Update () {
		Vector3 oldPosition = transform.position;
		//TODO
		//if clicked change newPosition instead of transform
		transform.position = Vector3.Lerp( oldPosition, newPosition, 0.5f);
	}
}

What this snippet does is smooth out the movement from A to B by the interpolator of 0.5f. You can modify the interpolator value as you like, but preferably keep it between 0f and 1f.

Make a capsule, add a Camera as a child of the capsule and set it so the camera is looking in the same forward direction as the capsule. Import the MouseLook script from the standard assets. Attach a mouse look script to the capsule and change the “Axis” variable to X only. Add another mouse look script onto the camera and change the “Axis” variable to Y only(you can also restrict the amount with the Minimum Y and Maximum Y values).
Make this script and add it to the capsule:

public class MoveForward : MonoBehaviour {

	public float speed;
	

	void Update () 
	{
		if (Input.GetMouseButton(0))
		{
			transform.Translate(Vector3.forward * speed * Time.deltaTime);
		}
	}
}

This is a very basic way of doing it. This script will make the capsule move forward when the left mouse button is held down.

Try this

using UnityEngine;
using System.Collections;

public class ClickToMove : MonoBehaviour 
{
	public float speed;
	public CharacterController controller;
	private Vector3 position;

	public AnimationClip run;
	public AnimationClip idle;

	public static bool attack;
	public static bool die;

	public static Vector3 cursorPosition;

	public static bool busy;

	// Use this for initialization
	void Start () 
	{
		position = transform.position;
		busy = false;
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(!busy)
		{
			locateCursor();
			if(!attack&&!die)
			{
				if(Input.GetMouseButton(0))
				{
					//Locate where the player clicked on the terrain
					locatePosition();
				}

				//Move the player to the position
				moveToPosition();
			}
			else
			{
			}
		}
	}

	void locatePosition()
	{
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit hit;

		if(Physics.Raycast(ray, out hit, 1000))
		{
			if(hit.collider.tag!="Player"&&hit.collider.tag!="Enemy")
			{
				position = hit.point;
			}
		}
	}

	void locateCursor()
	{
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit hit;
		
		if(Physics.Raycast(ray, out hit, 1000))
		{
			cursorPosition = hit.point;
		}
	}

	void moveToPosition()
	{
		//Game Object is moving
		if(Vector3.Distance(transform.position, position)>1)
		{
			Quaternion newRotation = Quaternion.LookRotation(position-transform.position, Vector3.forward);

			newRotation.x = 0f;
			newRotation.z = 0f;

			transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * 10);
			controller.SimpleMove(transform.forward * speed);

			animation.CrossFade(run.name);
		}
		//Game Object is not moving
		else
		{
			animation.CrossFade(idle.name);
		}
	}

}