Advertisement
lordned

bool CBasePlayer::SetObserverTarget

Apr 5th, 2011
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. bool CBasePlayer::SetObserverTarget(CBaseEntity *target)
  2. {
  3.     if ( !IsValidObserverTarget( target ) )
  4.         return false;
  5.    
  6.     // set new target
  7.     m_hObserverTarget.Set( target );
  8.  
  9.     // reset fov to default
  10.     SetFOV( this, 0 ); 
  11.    
  12.     if ( m_iObserverMode == OBS_MODE_ROAMING )
  13.     {
  14.         Vector  dir, end;
  15.         Vector  start = target->EyePosition();
  16.        
  17.         AngleVectors( target->EyeAngles(), &dir );
  18.         VectorNormalize( dir );
  19.         VectorMA( start, -64.0f, dir, end );
  20.  
  21.         Ray_t ray;
  22.         ray.Init( start, end, VEC_DUCK_HULL_MIN , VEC_DUCK_HULL_MAX );
  23.  
  24.         trace_t tr;
  25.         UTIL_TraceRay( ray, MASK_PLAYERSOLID, target, COLLISION_GROUP_PLAYER_MOVEMENT, &tr );
  26.  
  27.         JumptoPosition( tr.endpos, target->EyeAngles() );
  28.     }
  29.    
  30.     return true;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement