Rotating an object based on mouse position?

Hi. I would like to be able to have an object rotate based on where my mouse is. It spawns when I click and I would like the rotation to be pointing towards my mouse.

Thanks in advance :slight_smile:

check this, and then have a look at Vector3.LookAt()

Here’s what I came up with:

        Vector3 mousePos = Input.mousePosition;
		// Account for the camera's y-position
		mousePos.z = 10.0f;
		Vector3 starShipWorldPosition = Camera.main.ScreenToWorldPoint(mousePos);
		starShipFaceDirection = starShipWorldPosition - transform.position;
		transform.LookAt (starShipFaceDirection);

It’s still a bit choppy when the Player & mouse aren’t moving it rotates back to looking forward, but at least it’s a start.