public Image debugImage; //just for now // Use this for initialization protected virtual void Start() { heightCorrector = currentAssignedGridPlane.transform.up; heightCorrector *= transform.localScale.y / 2; transform.position = currentAssignedGridPlane.transform.position + heightCorrector; currentAssignedGridPlane.taken = true; movementState = BlockMovementState.Default; rotate = false; desiredRotation = transform.localRotation; degreesToRotate = 90; #region or laserInputUpdate inputLasers = LaserManager.Instance.GetInputLasers(this); activeLasersLastFrame = new bool[laserInputs.Length]; imagesLastFrame = new Texture2D[laserInputs.Length]; for (int i = 0; i < laserInputs.Length; i++) { activeLasersLastFrame[i] = laserInputs[i].active; if (laserInputs[i].inputLaser != null) { imagesLastFrame[i] = laserInputs[i].inputLaser.image; } else { imagesLastFrame[i] = null; } } #endregion }
void PerformSnapToPosition() { if (currentAssignedGridPlane.transform.position + heightCorrector != transform.position) { transform.position = Vector3.Lerp(transform.position, (currentAssignedGridPlane.transform.position + heightCorrector), PlayerController.Instance.blockSnappingSpeed * Time.deltaTime); //if we change planes // transform.up = Vector3.Lerp(transform.up, currentAssignedGridPlane.transform.up, PlayerController.Instance.blockSnappingSpeed * Time.deltaTime); } else { movementState = BlockMovementState.Default; } }
//diese Funktion sorgt dafür dass unser Block nach der bewegung shön weich landed public void SnapToPosition(GridPlane gridPlane) { movementState = BlockMovementState.Dropping; if (currentAssignedGridPlane != null) { currentAssignedGridPlane.taken = false; } //transform.position = gridPlane.transform.position + new Vector3(0, 0.5f, 0); currentAssignedGridPlane = gridPlane; currentAssignedGridPlane.taken = true; heightCorrector = currentAssignedGridPlane.transform.up; heightCorrector *= transform.localScale.y / 2; }
//Diese funktion sorgt dafür, dass unser Object sich schön smooth von seimem GridPlane zu unserem Finger bewegt, wenn wir ihn bewegen wollen und dass es in der luft ebenfalls schön smooth fliegt public void SetMovePosition(Vector3 position) { targetDragPosition = position; movementState = BlockMovementState.Moving; }