A_SetAngle

From ZDoom Wiki
Jump to navigation Jump to search


Actor

native void A_SetAngle(double angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT)

Usage

Sets the angle of the calling actor (or the ptr actor) to angle.

In ZScript, angle is a directly modifiable Actor field; however, this function allows for sub-tic interpolation, making the change in angle appear smooth, which is not achievable otherwise. In DECORATE this function is the only way to change angle.

Parameters

  • double angle
The actor's new angle in degrees. This is an absolute value, so, if a relative angular change is desired, an expression referencing the actor's angle field is needed.
  • int flags
Only one flag is currently available:
  • SPF_INTERPOLATE — the angle is interpolated from old to new one.
  • int ptr
DECORATE-style pointer to the actor whose angle will be changed. Not necessary in ZScript.

Examples

This simple prop (using Cacodemon's sprite) spins in place:

class SpinningCacoProp : Actor
{
    States 
    {
    Spawn:
      HEAD A 1 A_SetAngle(self.angle + 15, SPF_INTERPOLATE);
      loop;
    }
}

This Shotgun slightly kicks the player's view horizontally and vertically (the latter is done with A_SetPitch):

class KickingShotgun : Shotgun
{
	States 
	{
	Fire:
		SHTG A 3;
		SHTG A 7
		{
			A_FireShotgun();
			A_SetAngle(self.angle + frandom(-3, 3), SPF_INTERPOLATE);
			A_SetPitch(self.pitch + frandom(3, 5), SPF_INTERPOLATE);
		}
		SHTG BC 5;
		SHTG D 4;
		SHTG CB 5;
		SHTG A 3;
		SHTG A 7 A_ReFire;
		Goto Ready;
	}
}

See also