It’s not exactly game breaking, but the fact my local raycast makes my in-editor mouse offset now is a bit annoying. Can anything be done about this?
In other words, the mouse pointer was where the green arrow is shown in the pic. That was before the InverseTransformPoint business. Now my mouse pointer is where it’s shown in the pic. Of course the mouse pointer didn’t move, it’s just targeting differently.
// Update is called once per frame
void Update() {
// Cast ray
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
// Cursor on map
if (gridManager.GridCollider.Raycast(ray, out hitInfo, Mathf.Infinity))
{
// Get relative point
Vector3 relative = gridManager.GridTransform.InverseTransformPoint(hitInfo.point);
// Get tile coordinate
int coordX = Mathf.FloorToInt(relative.x / gridManager.GridTileSize);
int coordZ = Mathf.FloorToInt(relative.z / gridManager.GridTileSize);
currentTileCoord.Set(coordX, 0.01f, coordZ);