SetActorVelocity

From ZDoom Wiki
Jump to navigation Jump to search

bool SetActorVelocity (int tid, fixed velx, fixed vely, fixed velz, bool add, bool setbob)

Changes actor velocity.

Arguments

  • tid: TID of things to affect. If 0, the activator is used.
  • velx, vely, velz: The desired velocity for the affected things.
  • add: If true, each affected actor's velocity is modified by the velx, vely and velz parameters, rather than replaced by them.
  • setbob: If true, the speed adjustment influences the bobbing of any concerned player actor.

Examples

Put a Cacodemon on your map with the matching tid and have some target practice with this script.

script 1 (int tid)
{
  int angle, pitch, velx, vely, velz;
  while (GetActorProperty(tid, APROP_Health) > 0)
  {
    angle = random(0, 1.0);
    pitch = random(-0.25, 0.25);
    velx = FixedMul(cos(angle), FixedMul(cos(pitch), 10.0));
    vely = FixedMul(sin(angle), FixedMul(cos(pitch), 10.0));
    velz = FixedMul(sin(pitch), 10.0);
    SetActorVelocity(tid, velx, vely, velz, FALSE, FALSE);
    delay(random(1, 7) * 5);
  }
}