private void OnPathUpdate() { lineRenderer.positionCount = pathEntity.VertexCount; for (int i = 0; i < pathEntity.VertexCount; i++) { lineRenderer.SetPosition(i, pathEntity.GetWayPointByIndex(i).WayPointPosition); } }
private void Update() { if (hasDestination) { var playerTransform = playerCircleEntity.PlayerTransform; playerCircleMovement.Move(currentDestinationPosition); if ((playerTransform.position - currentDestinationPosition).sqrMagnitude < 0.00001f) { pathEntity.RemovePoint(0); if (pathEntity.VertexCount == 0) { hasDestination = false; } else { SetDestination(pathEntity.GetWayPointByIndex(0).WayPointPosition); } } OnPlayerPathUpdate?.Invoke(); } }
private void Update() { if (Input.touchCount > 0) { var playerTouch = Input.GetTouch(0); if (playerTouch.phase == TouchPhase.Began && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(0)) { var ray = mainCamera.ScreenPointToRay(playerTouch.position); virtualPlane.Raycast(ray, out var distance); var clickedPosition = ray.GetPoint(distance); if (cameraBounds.Contains(clickedPosition)) { if (pathEntity.TryAddPoint(clickedPosition)) { if (playerPathFollower.HasDestination == false) { playerPathFollower.SetDestination(pathEntity.GetWayPointByIndex(0).WayPointPosition); } } } } } }