how make object follow mouse cursor in 3d space
hello everyone , am new in that staff but am learning quickly from some days I was thinking to develop "pinalty soccer game " my idea was make the player object fallow the mouse in 3D space mean is if I swipe the mouse vertical the player move forward and back , and horizontal the player object move right and left and if I swipe like a circle the player object fallow the mouse like a circle exactly am looking int many objects but I am tired of thinking please help me am actually typed that but that not what I want
void Update () { float actualDistance; // initialize the actual distance between camera and player if (useInitialCameraDistance) { Vector3 toObjectVector = transform.position - Camera.main.transform.position; Vector3 linearDistanceVector = Vector3.Project (toObjectVector,Camera.main.transform.forward); actualDistance = linearDistanceVector.magnitude; } else { actualDistance = distance ; } Vector3 mousePosition = Input.mousePosition; mousePosition.z = distance; transform.position = Camera.main.ScreenToWorldPoint (mousePosition); }