Hello, I just started and dont need you to show me the code for ti as that wouldnt help me but could you point me in the right direction on how to do this.
What i want is to move the object there to where the mouse is on the grassy plane. The camera position is what it will be like in the game. Any help in what to do or what resources i will need to look at to get this done.
This is a harder problem than many “drag-like” problems because the position of the game object is above the plane. Here are a couple of links that solved this problem using Unity’s mathematical plane:
You know your camera’s position and your plane’s position. Then use Input.mousePosition Unity - Scripting API: Input.mousePosition to capture the mouse’s position in pixels.
Then form a vector between your camera and the mouse’s position. Or use this Unity - Scripting API: Camera.ScreenPointToRay.
Use this vector/ray to check if it hits the plane and to locate where it hit in the game world/scene coordinates.
Then just apply transform.forward value of the moveable object to pointing towards this point and and create Vector3 forward = transform.TransformDirection(Vector3.forward);
Then you just move it with the wanted speed.
I might have gotten the translate part totally wrong but I think you can get the position where to go with the links and tips I gave you.