[C#] mouseposition to transform.position

Hello Unity-Community,

I’m really new in Unity 3d and I have my first big Problem.
I have the following Code:

float MouseX = Input.GetAxis("Mouse X");
float MouseY = Input.GetAxis("Mouse Y");
Obj11.position.x = MouseX;
Obj11.position.z = MouseY;

in the Update()-Function.
But ther’s this error Message:

I don’t know what I should do :frowning:
Please help me

You need to assign it to a local vector first. As such…

Vector3 pos = new Vector3(MouseX, Obj11.position.y, MouseY);
Obj11.position = pos;

Let me know if that works for you.

A BIG THANK YOU TO YOU
It works great, thank you :wink: