Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_boids

Plugin, ACE table, Discussion thread
Dependence: None


Introduction
Calculate steer force by flocking algorithm.

  • Cohesion: Stay close to the centre of the flock
  • Alignment: Head in the same direction of the flock
  • Separation: Avoid collisions with flock
This behavior would not change any property of instance. It only calculates steer force for reference.

Usage
Sample capx
Follows these steps to get steer force.
  1. Call "Action:Clean" to clean steer force to 0.
  2. Calculate steer force by "Action:Cohesion", "Action:Alignment", "Action:Separation". Parameter "Neighbors" might be picked by official line-of-sight behavior.
  3. Check if the result of steer force is not 0 by "Condition:Has force".
  4. If there has steer force, get this force by "Expression:ForceAngle" and "Expression:ForceMagnitude" in polar axis, or (Expression:ForceDx, Expression:ForceDy ) in orthogonal axis.  Use these info to control sprite like rotate the instance to this angle.
图片
Avoid obstacles
"Action:Separation" could be used to avoid obstacles by put the obstacles in parameter "Neighbors".
Apply force directly
Call "
Action:Apply force towards position" or "Action:Apply force at angle" to apply steer force directly.

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About