====== ScrollObject following another ScrollObject ======
This routine will use the ''Update'' function of a ScrollObject, physics and some orxVECTOR math to always try to follow another object.
void Enemy::Update(const orxCLOCK_INFO &_rstInfo)
{
orxOBJECT *enemyObject = this->GetOrxObject();
orxVECTOR enemyPosition = orxVECTOR_0;
this->GetPosition(enemyPosition, orxTRUE);
orxVECTOR playerPosition = orxVECTOR_0;
playerPosition = karbon_game::GetInstance().GetPlayerPosition(); //you'll need to implement this function in your game code
orxVECTOR directionToShip = orxVECTOR_0;
orxVector_Sub(&directionToShip, &playerPosition, &enemyPosition);
orxVECTOR speedTowardsShip = orxVECTOR_0;
orxVector_Normalize(&speedTowardsShip, &directionToShip);
orxVector_Mulf(&speedTowardsShip, &speedTowardsShip, 0.3);
orxObject_ApplyImpulse(enemyObject, &speedTowardsShip, orxNULL);
}
[Enemy]
Graphic = @
Texture = enemy.png
Pivot = center
Body = EnemyBody
[EnemyBody]
Dynamic = true
PartList = EnemyBodyPart
[EnemyBodyPart]
Type = box
Solid = false