public static bool CheckCell(PlayGrid grid, Vector2Int pos, List <Vector2Int> closeList) { if (grid.CheckIsInGrid(pos) && !closeList.Contains(pos)) { return(true); } return(false); }
private void FixedUpdate() { Vector2Int pos = new Vector2Int(Mathf.FloorToInt(transform.position.x), Mathf.FloorToInt(transform.position.z)); if (grid.CheckIsInGrid(pos)) { _rigidbody.AddForce(grid.GetCell(pos).FlowFieldOrientation *Acceleration); } _rigidbody.velocity = Vector3.ClampMagnitude(_rigidbody.velocity, MaxSpeed); }
private void Update() { if (Move) { Vector2Int posOnGrid = new Vector2Int(Mathf.FloorToInt(transform.position.x), Mathf.FloorToInt(transform.position.z)); if (Grid.CheckIsInGrid(posOnGrid)) { Rigidbody.AddForce(Grid.GetCell(posOnGrid).FlowFieldOrientation); } } Rigidbody.velocity = Vector3.ClampMagnitude(Rigidbody.velocity, MaxSpeed); }