So hey guys ive been out of ideas lately so ive decided to make a micro-clone of agar.io . Its in 3d mode with a camera in a top-down sort of view. The player is just a cube painted red. I am currently wondering how to make the player move twords the mouse cursor? Ive seen plenty of posts about this question but there either for unity 2d or they just in general arnt working. Any help would be great, thanks guys.
To get the position itself, use ScreenToWorldPoint
To make the cube look at your pointer, use Transform.LookAt
To make the cube move towards your pointer, use Vector3.MoveTowards
Was able to fix this. Final movement code as follows:
Vector3 v3;
v3 = Input.mousePosition;
v3.z = 10;
Vector3 target=transform.FindChild ("mainCamera").GetComponent<Camera> ().ScreenToWorldPoint (v3);
transform.position = Vector3.MoveTowards (transform.position, target, 1f);