GetActorViewHeight
fixed GetActorViewHeight (int tid)
Usage
This returns the view height of the actor, as a fixed point value. For a player, this corresponds to the Player.ViewHeight property, modified by crouching if needs be. For other actors, it corresponds to the CameraHeight if one is defined, or defaults to half their height otherwise.
Parameters
- tid: TID of the actor.
Return value
The view height of the actor, as a fixed point value.
Examples
This script will train a camera with a tid of 1 on the player and adjust its pitch to stay with the player even if crouched. Unfortunately it appears that as of version 2.4.1 this function does not possess the capacity to accept a tid of 0 and retrieve the activator's data.
script 1 (void) { int x, y, z, dist, angle, pitch; ChangeCamera(1, 0, FALSE); //To overcome GetActorViewHeight limitation... if (!ActivatorTID()) Thing_ChangeTID(0, 1000 + PlayerNumber()); while (TRUE) { x = GetActorX(0) - GetActorX(1); y = GetActorY(0) - GetActorY(1); z = GetActorZ(0) + GetActorViewHeight(ActivatorTID()) - GetActorZ(1); angle = VectorAngle(x, y); if ((angle + 0.125) % 0.5 > 0.25) dist = FixedDiv(y, sin(angle)); else dist = FixedDiv(x, cos(angle)); pitch = -VectorAngle(dist, z); SetActorAngle(1, angle); SetActorPitch(1, pitch); delay(1); } }
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.