Raycast gameobject to mouse click

I need to cast a raycast from a gameobject to where i clicked on the map. i have this code:

RaycastHit hit = new RaycastHit();
		RaycastHit hited = new RaycastHit();
		GameObject character = GameObject.Find(controller.getSelectedCharacter());

		if(gameObject.collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),out hit, Mathf.Infinity)){

But the raycast always point to the same place on the map, doesn’t matter where i click. I’ve tried with Debug.DrawLine and it draws right, only raycast goes crazy, I think it’s because raycast request a direction instead of a Vector3, i’ve tried to find how to transform Vector3 into Direction, but no lucky.

Debug.DrawRay() takes a position and a direction. You are passing it two positions. If you wanted to use DrawRay():

 Debug.DrawRay(character.transform.position,hit.point - character.transform.position);