private bool displayActive = false; // don't update path when it's false. // Teleport target transform to ground position public void Teleport() { if (groundDetected && canTeleport) { if (EndZone.ClosestPoint(groundPos) == groundPos) { EndZone.gameObject.GetComponent <TriggerNextLevel>().Load(); } bodyTransform.position = groundPos + lastNormal * 0.1f; if (lastCubeTarget != null) { lastCubeTarget.Detach(bodyTransform.gameObject); lastCubeTarget = null; } if (cubeTarget != null) { cubeTarget.ApplyCollision(bodyTransform.gameObject); lastCubeTarget = cubeTarget; } } else { Debug.Log("Ground wasn't detected"); } }
private void TryRetrieval(GameObject target) { if (target == lastTarget) { timeIncrement += Time.deltaTime; if (timeIncrement >= DelayUntilRetrieval) { CubeType type = target.GetComponentInParent <CubeType>(); inventory.AddCube(type); if (type.attachedObjects != null) { List <GameObject> copy = new List <GameObject>(type.attachedObjects); foreach (GameObject obj in copy) { type.Detach(obj); } } if (target.transform.parent != null) { target = target.transform.parent.gameObject; } Debug.Log("Destroying target: " + target); target.GetComponent <CubeType>().DisableBehaviour("initial"); Destroy(target); timeIncrement = 0f; lastTarget = null; } } else { timeIncrement = 0f; } }