Returns pitch angle needed for src_entity to face dest_entity (degrees, -180 to 180).
Takes src_entity (source entity handle), dest_entity (destination entity handle).
Returns delta pitch in degrees (Double), or 0.0 if either entity invalid.
3D Graphics
Parameters & Returns
Parameters
src_entityInt
dest_entityInt
Returns
Double
Quick Summary
Returns pitch angle needed for src_entity to face dest_entity (degrees, -180 to 180).
Takes src_entity (source entity handle), dest_entity (destination entity handle).
Returns delta pitch in degrees (Double), or 0.0 if either entity invalid.
Technical Exegesis...
Returns pitch angle needed for src_entity to face dest_entity (degrees, -180 to 180). Takes src_entity (source entity handle), dest_entity (destination entity handle). Returns delta pitch in degrees (Double), or 0.0 if either entity invalid. Validates both entities exist, calculates direction vector (dx, dy, dz), computes horizontal distance sqrt(dx*dx + dz*dz), computes target pitch angle atan2(dy, horizontalDist), subtracts current src pitch, normalizes to [-180, 180] range.
Returns pitch angle needed for src_entity to face dest_entity (degrees, -180 to 180). Takes src_entity (source entity handle), dest_entity (destination entity handle). Returns delta pitch in degrees (Double), or 0.0 if either entity invalid. Validates both entities exist, calculates direction vector (dx, dy, dz), computes horizontal distance sqrt(dx*dx + dz*dz), computes target pitch angle atan2(dy, horizontalDist), subtracts current src pitch, normalizes to [-180, 180] range. Vertical rotation angle to face target.
This function calculates pitch delta. Pitch angle: X-axis rotation (vertical plane), controls up/down facing direction, uses atan2(dy, horizontalDistance) to get target angle in degrees. Horizontal distance: sqrt(dx*dx + dz*dz) is distance in XZ plane (ignoring Y), needed for correct pitch calculation (avoids gimbal issues). Delta calculation: targetPitch = atan2(dy, horizontalDist) * 180/PI, currentPitch = src.rotation.x, delta = targetPitch - currentPitch, normalized to shortest rotation ([-180, 180]). Normalization: while delta > 180 subtract 360, while delta < -180 add 360, ensures shortest rotation path. Sign convention: positive Y is up, positive dy gives positive pitch (look up), negative dy gives negative pitch (look down). Use cases: (1) AI aiming (tilt NPC head to look at player), (2) Turret elevation (pitch turret to aim at flying target), (3) Camera tracking (tilt camera to follow target vertically), (4) Animation blending (blend between looking up/down), (5) Weapon aiming (pitch gun barrel toward target). Common pattern: deltaP=b3dDeltaPitch(entity, target), b3dTurnEntity(entity, deltaP*0.1, 0, 0) for smooth tilting. Typical usage: calculate angle to target, apply fraction of delta each frame for smooth rotation, combine with b3dDeltaYaw for full 2-axis tracking. Sign interpretation: positive delta means tilt up (look up), negative delta means tilt down (look down), magnitude is degrees to turn. Smooth rotation: apply delta*rate instead of full delta for interpolated tilting (rate=0.1 for slow tilt, rate=1.0 for instant snap). Performance: O(1) calculation (atan2 and sqrt, very fast), suitable for every frame per entity. Invalid entities: returns 0.0 if either handle invalid. Related: b3dDeltaYaw calculates horizontal yaw angle to target, b3dTurnEntity applies rotation delta, b3dPointEntityAt instantly faces target (alternative to gradual rotation).