void LateUpdate() { RaycastHit hit = CommandKeeper.GetCameraRaycastHit(); if (hit.collider != null) { BuildingBlockPassport pass = hit.collider.GetComponentInParent <BuildingBlockPassport>(); if (pass != null) { ///// Vector3 hitObjPosition = pass.transform.position; Vector3Int hitObjPositionInt = new Vector3Int( (int)Mathf.Floor(hitObjPosition.x), (int)Mathf.Round(hitObjPosition.y), (int)Mathf.Floor(hitObjPosition.z) ); transform.position = hitObjPositionInt; //Debug.Log("hit pos=" + transform.position); } } } // LateUpdate() ///
/////////////////////////////////////////////////////////////////////////////// void LateUpdate() { if (isCursorOn) { RaycastHit hit = CommandKeeper.GetCameraRaycastHit(); if (hit.collider != null) { BuildingBlockPassport pass = hit.collider.GetComponentInParent <BuildingBlockPassport>(); if (pass != null) { ///// Vector3 hitObjPosition = pass.transform.position; Vector3Int hitObjPositionInt = new Vector3Int( (int)Mathf.Floor(hitObjPosition.x), (int)Mathf.Round(hitObjPosition.y), (int)Mathf.Floor(hitObjPosition.z) ); //////// lastCursorRotationAngle = CalculateCursorRotation(CommandKeeper.GetPlayerRotationAngle()); canBuildOnLastCursorPosition = CanIBuildAndWhere(hitObjPositionInt, hit.point, out lastCursorPosition); positiveCursor.position = lastCursorPosition; negativeCursor.position = lastCursorPosition; if (positiveRotator != null) { positiveRotator.SetHorizontalRotation(lastCursorRotationAngle); } if (negativeRotator != null) { negativeRotator.SetHorizontalRotation(lastCursorRotationAngle); } positiveCursor.gameObject.SetActive(canBuildOnLastCursorPosition); negativeCursor.gameObject.SetActive(!canBuildOnLastCursorPosition); } // if (pass != null) /// } else // raycasted collider == null /// { positiveCursor.gameObject.SetActive(false); negativeCursor.gameObject.SetActive(false); } } // if isCurosrOn /// } // LateUpdate() ////
void LateUpdate() { RaycastHit hit = CommandKeeper.GetCameraRaycastHit(); transform.position = hit.point; }