GetHeadingAngleX

From GECK
Jump to: navigation, search


A function added by the New Vegas Script Extender version 6.3.1.

Description

Returns the X angle between the calling reference and the specified object in a range from -180 to 180 degrees. Unlike GetHeadingAngle, this can be called on non-actor references.

Syntax

[help]
(-180 to 180:float) callingReference.GetHeadingAngleX target:reference

Example

    ;* This code makes the player face SunnyREF (assuming they're nearby)
    ref rRefToFace = SunnyREF
    ref rRefToChangeAngle = Player

    float fNewXAngle = rRefToChangeAngle.GetHeadingAngleX rRefToFace 
    fNewXAngle += rRefToChangeAngle.GetAngle X

    float fNewZAngle = rRefToChangeAngle.GetAngle Z + rRefToChangeAngle.GetHeadingAngle rRefToFace

    rRefToChangeAngle.SetAngle Z fNewZAngle
    rRefToChangeAngle.SetAngle X fNewXAngle

Notes

  • Here is an alternate method to make the player face a ref, using V3Length and fATan2, provided by Xilandro:
    float deltaX = (Player.GetPos X) - (rRefToFace.GetPos X)
    float deltaY = (Player.GetPos Y) - (rRefToFace.GetPos Y)
    float deltaZ = (Player.GetPos Z) - (rRefToFace.GetPos Z)

    float vLen = V3Length deltaX deltaY 0

    float newX = fATan2 deltaZ vLen
    Player.SetAngle X newX 

    float newZAngle = Player.GetAngle Z + Player.GetHeadingAngle rRefToFace
    Player.SetAngle Z newZAngle

See Also