# 3D objects: GetObjectAngles

```       Name: GetObjectAngles                                         [Show more]
Type: Subroutine
Category: 3D objects
Summary: Calculate the object's yaw and pitch angles, and set the object's
visibility, scale and type
Deep dive: Pitch and yaw angles
Context: See this subroutine in context in the source code
References: This subroutine is called as follows:
* BuildCarObjects (Part 3 of 3) calls GetObjectAngles
* BuildCarObjects (Part 3 of 3) calls via GetObjectAngles-2

Arguments:

A                    Object type

X                    The offset of the variable to use for the object's 3D
coordinates in the GetObjYawAngle routine:

* &F4 = xHelmetCoord

* &FA = xCoord1

* &FD = xCoord2

Other entry points:

GetObjectAngles-2    Use xCoord2 for the object's 3D coordinates in the call
to GetObjYawAngle

LDX #&FD               \ Set X = &FD so the calls to GetObjYawAngle and
\ GetObjPitchAngle use xCoord2 and yCoord2 for the
\ object's 3D coordinates

.GetObjectAngles

STA objectType         \ Store the object type in objectType

JSR GetObjYawAngle-2   \ Calculate the object's yaw angle, from the point of
\ view of the player, returning it in (JJ II)

LDY objectNumber       \ Set Y to the number of the object we are processing

LDA II                 \ Set the yaw angle for this object in (objYawAngleHi
STA objYawAngleLo,Y    \ objYawAngleLo) to (JJ II)
LDA JJ
STA objYawAngleHi,Y

JSR CheckForContact-2  \ Check to see if the object and the player's car are
\ close enough for contact, specifically if they are
\ within a distance of 37 from each other

JSR GetObjPitchAngle-2 \ Calculate the object's pitch angle, from the point
\ of view of the player, returning it in A and LL
\
\ If the object is not visible on-screen, the C flag is
\ set, which will hide the object in the following
\ routine

\ Fall through into SetObjectDetails to set the object's
\ visibility, scale and type
```