Simple flow field.  
 More...
|  | 
| Vector2 | Lookup (Vector2 position) | 
|  | Lookup direction from flow.  More... 
 | 
|  | 
Simple flow field. 
Definition at line 8 of file SimpleFlowField.cs.
◆ ComputeDirectionFromPosition()
  
  | 
        
          | virtual Vector2 Agents.SimpleFlowField.ComputeDirectionFromPosition | ( | int | x, |  
          |  |  | int | y |  
          |  | ) |  |  |  | inlineprotectedvirtual | 
 
Compute flow direction from a given position. Defaults with a right vector. 
- Parameters
- 
  
    | x | X coordinate |  | y | Y coordinate |  
 
- Returns
- Flow direction
Reimplemented in Agents.ImageFlowField.
Definition at line 77 of file SimpleFlowField.cs.
 
 
◆ Lookup()
  
  | 
        
          | Vector2 Agents.SimpleFlowField.Lookup | ( | Vector2 | position | ) |  |  | inline | 
 
Lookup direction from flow. 
- Parameters
- 
  
  
- Returns
- Direction vector
Definition at line 55 of file SimpleFlowField.cs.
   57             var rect = 
new Rect2(GlobalPosition, 
size);
 
   58             if (rect.HasPoint(position))
 
   60                 var x = (int)Mathf.Clamp((position.x - GlobalPosition.x) / 
Resolution, 0, 
cols - 1);
 
   61                 var y = (int)Mathf.Clamp((position.y - GlobalPosition.y) / 
Resolution, 0, 
rows - 1);
 
FlowDirection[] field
Flow field
int Resolution
Grid resolution
 
 
 
◆ RefreshDirections()
  
  | 
        
          | void Agents.SimpleFlowField.RefreshDirections | ( |  | ) |  |  | inlineprotected | 
 
Refresh flow directions. 
Definition at line 85 of file SimpleFlowField.cs.
   87             for (
int j = 0; j < 
rows; ++j)
 
   89                 for (
int i = 0; i < 
cols; ++i)
 
   91                     var idx = i + (j * 
cols);
 
   92                     var direction = 
field[idx];
 
   94                     direction.RectRotation = Mathf.Rad2Deg(direction.Direction.Angle());
 
Vector2 Direction
Direction vector
virtual Vector2 ComputeDirectionFromPosition(int x, int y)
Compute flow direction from a given position. Defaults with a right vector.
 
 
 
◆ cols
  
  | 
        
          | int Agents.SimpleFlowField.cols |  | protected | 
 
 
◆ field
◆ Resolution
      
        
          | int Agents.SimpleFlowField.Resolution = 30 | 
      
 
 
◆ rows
  
  | 
        
          | int Agents.SimpleFlowField.rows |  | protected | 
 
 
◆ size
  
  | 
        
          | Vector2 Agents.SimpleFlowField.size |  | protected | 
 
 
The documentation for this class was generated from the following file: