public void FillPathVolume(MoveDirection dir, int step) { int index = 0; while (index <= step) { pathFillers.Add((GameObject)Instantiate(invisibleObstacle, transform.position + dir.AsVector() * index, transform.rotation)); ++index; } }
public float GetObstacleOffsetStep(MoveDirection dir, int step) { int toObstacleStep = step; float checkDistance = step + 0.5f; RaycastHit hit; if (Physics.Raycast(transform.position, dir.AsVector(), out hit, checkDistance, obstacleLayerMask)) { toObstacleStep = Mathf.RoundToInt(Vector3.Distance(transform.parent.position, hit.transform.position + getObstacleCompensationVector(dir))); } return toObstacleStep; }
private void updateNextPoint() { currentStep = moveUtils.GetCurrentStep(); Vector3 nextPointOffsetVector = direction.AsVector() * currentStep; nextPoint = agent.transform.position + nextPointOffsetVector; if (willCollideWithObstacleOnMove()) { currentStep = (int)getStepCorrectedByObstacle(); nextPoint = agent.transform.position + currentStep * direction.AsVector(); direction = moveUtils.HandleObstacle(currentStep); fillPathVolume(); return; } fillPathVolume(); direction = moveUtils.GetNextDirection(); }
public bool WillCollide(MoveDirection dir, int step) { foreach (GameObject pathFiller in pathFillers) { Destroy(pathFiller); } if (Physics.Raycast(transform.position, dir.AsVector(), step, obstacleLayerMask)) { return true; } return false; }
public float GetObstacleOffsetStep(MoveDirection dir, int step) { int toObstacleStep = step; float checkDistance = step + 0.5f; RaycastHit hit; if (Physics.Raycast(transform.position, dir.AsVector(), out hit, checkDistance, obstacleLayerMask)) { toObstacleStep = Mathf.RoundToInt(Vector3.Distance(transform.parent.position, hit.transform.position + getObstacleCompensationVector(dir))); } return(toObstacleStep); }
private void FixedUpdate() { if (InvertPacman.gameState != GameState.Play) { return; } currentDirection = GetNextDirection(); var totalMovement = currentDirection.AsVector() * moveSpeed * Time.fixedDeltaTime; transform.position += totalMovement; }
public bool WillCollide(MoveDirection dir, int step) { foreach (GameObject pathFiller in pathFillers) { Destroy(pathFiller); } if (Physics.Raycast(transform.position, dir.AsVector(), step, obstacleLayerMask)) { return(true); } return(false); }
// Update is called once per frame private void FixedUpdate() { if (InvertPacman.gameState != GameState.Play) { return; } var pressedDirection = MoveDirection.Idle; if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W) || Input.GetAxis("Vertical") > DEADZONE) { pressedDirection = MoveDirection.Up; } else if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S) || Input.GetAxis("Vertical") < -DEADZONE) { pressedDirection = MoveDirection.Down; } if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A) || Input.GetAxis("Horizontal") < -DEADZONE) { pressedDirection = MoveDirection.Left; } else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D) || Input.GetAxis("Horizontal") > DEADZONE) { pressedDirection = MoveDirection.Right; } if (pressedDirection != MoveDirection.Idle) { currentDirection = pressedDirection; } var totalMovement = currentDirection.AsVector() * moveSpeed * Time.fixedDeltaTime; player.transform.position += totalMovement; }
public void FillPathVolume(MoveDirection dir, int step) { int index = 0; while (index <= step) { pathFillers.Add((GameObject)Instantiate(invisibleObstacle, transform.position + dir.AsVector() * index, transform.rotation)); ++index; } }