How to keep local rotation when using raycasts?


When I try to make a game object and rotate it, I want to keep the raycast casting point rotating with the object in a local position, but the raycast point doesnt rotate the way I want it to. blue x is the raycast point.

My code:

var hit : RaycastHit;
	var desDir = transform.TransformDirection(Vector3.down);
	if (Physics.Raycast (Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z), desDir, hit, Mathf.Infinity)) {
		if (hit.transform.CompareTag("nem")){
			target = hit.transform;

Place an empty gameobject in the scene in the location and rotation you want it. Child it to the other Gameobject. Shoot raycast a forward from the empty gameobject