Update: The Y-Axis works perfectly. It is only one the X axis that a “big leap” problem occurs.
Maybe this has to do with my camera angle/settings?
Problems:
Green Circle = 3D sphere collider (represented by 2D sprite green circle, billboarded to the camera.)
So the Green Circle is a 3D object placed exactly on the ground in the 3D worldspace.
I raycast to terrain composed of a box collider
My code is pretty standard.
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 10000, LayerMask.GetMask("Ground")))
{
Debug.DrawRay(ray.origin, ray.direction * 10000, Color.green, 3);
myCursorObject.transform.position = hit.point;
}
This is a 3D world with flat terrain (box colliders = “Ground” layer)
The camera is at an angle looking down from a distance, with an X rotation of 60 (isometric view).
I have two problems
- Mouse Position doesn’t always translate to world position. As you can see in the above image, I can move the mouse and it will NOT follow the object. There are random amounts the mouse has to move before the image also moves. It seems random. Sometimes it has big leaps in world position; sometimes it updates more accurately. Here’s the big leap:
- Software Cursor lags. This is placed in Update(), and the mouse will move faster than the software cursor (green circle).
How can I achieve a more accurate Mouse to WorldPosition?