Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. void CCharacterMovement::Physicalize()
  2. {
  3.     IEntity &entity = *GetEntity();
  4.     // Physicalize the player as type Living.
  5.     // This physical entity type is specifically implemented for players
  6.     SEntityPhysicalizeParams physParams;
  7.     physParams.type = PE_LIVING;
  8.     physParams.nSlot = -1;
  9.     physParams.mass = m_pCharacter->GetCVars().m_mass;
  10.  
  11.     pe_player_dimensions playerDimensions;
  12.  
  13.     // Prefer usage of a cylinder instead of capsule
  14.     playerDimensions.bUseCapsule = 0;
  15.  
  16.     // Specify the size of our cylinder
  17.     playerDimensions.sizeCollider = Vec3(0.3f, 0.3f, 1.0f);
  18.  
  19.     // Keep pivot at the player's feet (defined in player geometry)
  20.     playerDimensions.heightPivot = 0.0f;
  21.     // Offset collider upwards
  22.     playerDimensions.heightCollider = 1.0f;
  23.     playerDimensions.groundContactEps = 0.004f;
  24.  
  25.     physParams.pPlayerDimensions = &playerDimensions;
  26.  
  27.  
  28.     pe_player_dynamics playerDynamics;
  29.     playerDynamics.kAirControl = 0.f;
  30.     playerDynamics.mass = physParams.mass;
  31.     playerDynamics.kInertia = 0.01f;
  32.  
  33.     physParams.pPlayerDynamics = &playerDynamics;
  34.  
  35.     entity.Physicalize(physParams);
  36.     entity.EnablePhysics(true);
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement