Rotate a gameobject(player)on the y axis towards mouse position in c#

been looking for a way to do this but havent found it in c# pleas god some one help us.

this is what we have so far for are character

using UnityEngine; using System.Collections;

public class carl : MonoBehaviour { public GameObject ProjectilePrefab;

public float PlayerSpeed;

// Update is called once per frame
void Update () 
{

    // Amout to move
    float inputX = Input.GetAxis("Horizontal") * PlayerSpeed * Time.deltaTime;
    float inputY = Input.GetAxis("Vertical") * PlayerSpeed * Time.deltaTime;

    // Move the Player
    transform.Translate(Vector3.forward * inputX) ;
    transform.Translate(Vector3.left * inputY) ;

    if (Input.GetKey("space"))
    {
            //Fire projectile
            Instantiate(ProjectilePrefab, transform.position, Quaternion.identity);

    }

}

}

You can do this:

  Vector3 MouseWorldPosition = MainCamera.camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
  transform.LookAt(MouseWorldPosition);
  transform.rotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y, 0));

Call this from your player script.

using UnityEngine; using System.Collections;

public class carl : MonoBehaviour { public GameObject ProjectilePrefab; public GameObject MainCamera;

public float PlayerSpeed;
public float QuaternionSpeed;

// Update is called once per frame
void Update ()  
{

    Vector3 MouseWorldPosition = MainCamera.camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
    transform.LookAt(MouseWorldPosition);
    transform.rotation = Quaternion.Euler(new Vector3(0, transform.rotation.eulerAngles.y, 0));

    // Amout to move
    float inputX = Input.GetAxis("Horizontal") * PlayerSpeed * Time.deltaTime;
    float inputY = Input.GetAxis("Vertical") * PlayerSpeed * Time.deltaTime;

    // Move the Player
    transform.Translate(Vector3.forward * inputX) ;
    transform.Translate(Vector3.left * inputY) ;

    if (Input.GetKey("space"))
    {
            //Fire projectile
            Instantiate(ProjectilePrefab, transform.position,Quaternion.identity);

    }

}

} there it is, he moves, and rotates kinda randomly, but does not rotate to look at mouse postition