Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CharacterCommandFly.c
Go to the documentation of this file.
2 {
3  //------------------------------------------------------------------------------------------------
4  // constructor
5  void SCR_CharacterCommandFly(BaseAnimPhysComponent pAnimPhysComponent, SCR_CharacterCommandSwimST pTable, ChimeraCharacter pCharacter, CharacterControllerComponent pController)
6  {
7  m_pCharacter = pCharacter;
8  m_pController = pController;
9  m_AnimationComponent = CharacterAnimationComponent.Cast(pAnimPhysComponent);
10 
11  m_Input = pController.GetInputContext();
12  m_Table = pTable;
13  }
14 
15  //------------------------------------------------------------------------------------------------
16  override void OnActivate()
17  {
18  m_AnimationComponent.PhysicsEnableGravity(false);
19  }
20 
21  //------------------------------------------------------------------------------------------------
22  override void OnDeactivate()
23  {
24  Print("SCR_CharacterCommandFly::OnDeactivate");
25  m_AnimationComponent.PhysicsEnableGravity(true);
26  }
27 
28  //------------------------------------------------------------------------------------------------
29  // called to set values to animation graph processing
30  override void PreAnimUpdate(float pDt)
31  {
32  }
33 
34  //------------------------------------------------------------------------------------------------
37  override void PrePhysUpdate(float pDt)
38  {
39  Print("SCR_CharacterCommandFly::PrePhysUpdate: " + pDt.ToString());
40 
41  vector trans = vector.Zero;
42 
44  PrePhys_GetTranslation(trans); // in case this returns false ... trans is still zero
45 
46  //trans = vector.Zero;
47 
49  vector locDir;
50  float speed;
51  float swimSpeedX = 0, swimSpeedZ = 0, swimSpeedY = 0;
52 
53  // get int movement
54  vector movDir = m_pController.GetMovementDirWorld();
55  //m_Input.GetMovement(speed, locDir);
56 
57  if (movDir.Length() > 0)
58  {
59  swimSpeedZ = movDir[2] * m_fMovementSpeed;
60  swimSpeedX = movDir[0] * m_fMovementSpeed;
61  }
62 
63  if (m_Input.GetJump() > 0)
64  {
65  moveUp = !moveUp;
66  }
67  else
68  {
69  // m_bNeedFinish = true;
70  }
71 
72  if( moveUp )
73  swimSpeedY = 2;
74 
75 
76  // filter velocities
77  m_fSpeedX = Math.SmoothCD(m_fSpeedX, swimSpeedX, m_fSpeedXV, m_fMovementSpeedFltTime, m_fMovementSpeedFltMaxChange, pDt);
78  m_fSpeedY = Math.SmoothCD(m_fSpeedY, swimSpeedY, m_fSpeedYV, m_fMovementSpeedFltTime, m_fMovementSpeedFltMaxChange, pDt);
79  m_fSpeedZ = Math.SmoothCD(m_fSpeedZ, swimSpeedZ, m_fSpeedZV, m_fMovementSpeedFltTime, m_fMovementSpeedFltMaxChange, pDt);
80 
81  // add velocity
82  trans[0] = trans[0] + m_fSpeedX * pDt;
83  trans[1] = trans[1] + m_fSpeedY * pDt;
84  trans[2] = trans[2] + m_fSpeedZ * pDt;
85 
87  PrePhys_SetTranslation(trans);
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  // called when all animation / pre phys update is handled
92  override bool PostPhysUpdate(float pDt)
93  {
94  Print("SCR_CharacterCommandFly::PostPhysUpdate: " + pDt.ToString());
95 
97  if (m_bNeedFinish)
98  {
99  return false;
100  }
101 
102  return true; // handled with SetFlagFinished();
103  }
104 
105  ChimeraCharacter m_pCharacter;
106  CharacterControllerComponent m_pController;
107  CharacterInputContext m_Input;
108  CharacterAnimationComponent m_AnimationComponent;
110  float m_fTime;
111  bool m_bNeedFinish;
112 
113  float m_fSpeedX;
114  float m_fSpeedY;
115  float m_fSpeedZ;
116  float m_fSpeedXV;
117  float m_fSpeedYV;
118  float m_fSpeedZV;
119 
121  float m_fMovementSpeed = 25;
122  float m_fMovementSpeedFltTime = 0.3;
123  float m_fMovementSpeedFltMaxChange = 100;
124 
126  bool moveUp = false;
127 }
CharacterInputContext
Definition: CharacterInputContext.c:12
m_fMovementSpeed
float m_fMovementSpeed
filter value
Definition: SCR_CharacterCommandSwim.c:234
SCR_CharacterCommandSwimST
Definition: SCR_CharacterCommandSwim.c:4
ScriptedCommand
Definition: ScriptedCommand.c:12
SCR_CharacterCommandFly
Definition: SCR_CharacterCommandFly.c:1