transform.Translate but with raycast distance

i wanna move a point using transform Translate:

_objectToPlaceRoot.transform.Translate(_camera.transform.right * _input.x, Space.World);
_objectToPlaceRoot.transform.Translate(Vector3.up * _input.y, Space.World);

but also changing its Y position (height) based on a raycast at the same time

if (Physics.Raycast(from, dir, out RaycastHit hit, Mathf.Infinity, _treeLayer))
  hitpoint = hit.point;

i thought i can simply do it this way after the transform translate code

_objectToPlaceRoot.transform.position = new Vector3(_objectToPlaceRoot.transform.position.x, hitpoint.y, _objectToPlaceRoot.transform.position.z);

but the _objectToPlaceroot is just somewhere else in the world now.
how am i supposed to do that the right way?

If you define the 3 coponents of position and then make a new Vector3, it must work. If its what you are trying, then some of the steps is not doing what you thing. Debug the result of each “calculus”.

float posX = _objectToPlaceRoot.transform.position.x
Debug.Log ("X= " + posX);

and same for each component, and will see one of them is not what you thing.

Maybe the problem is in the raycast, then make another post asking for raycsast problem (you r position problem is irrelevant)