GetActorVelX

From ZDoom Wiki
Jump to: navigation, search

fixed GetActorVelX (int tid)

Usage

This returns the velocity of the actor along the X axis. Positive values means eastward movement; negative values are westward.

Parameters

  • tid: TID of the actor.

Return value

The X velocity of the actor, as a fixed point value.

Examples

This example prints the angle that the player is moving in based on x and y velocity.

script 1 enter
{
  int angle;
  while (TRUE)
  {
    angle = VectorAngle(GetActorVelX(0), GetActorVelY(0));
    print(f:angle);
    delay(1);
  }
}

This example prints the current speed of the player, using the FixedSqrt function.

script 1 enter
{
  int x, y, z, speed;
  while (TRUE)
  {
    x = GetActorVelX(0);
    y = GetActorVelY(0);
    z = GetActorVelZ(0);
    speed = FixedMul(x, x) + FixedMul(y, y) + FixedMul(z, z);
    print(f:FixedSqrt(speed));
    delay(1);
  }
}