Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CharacterCommandFly.c
Go to the documentation of this file.
1class SCR_CharacterCommandFly : ScriptedCommand
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
43 // get local translations
44 PrePhys_GetTranslation(trans); // in case this returns false ... trans is still zero
45
46 //trans = vector.Zero;
47
48 // XZ side translation
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 }
88
89 //------------------------------------------------------------------------------------------------
90 // called when all animation / pre phys update is handled
91 override bool PostPhysUpdate(float pDt)
92 {
93 Print("SCR_CharacterCommandFly::PostPhysUpdate: " + pDt.ToString());
94
96 if (m_bNeedFinish)
97 {
98 return false;
99 }
100
101 return true; // handled with SetFlagFinished();
102 }
103
104 ChimeraCharacter m_pCharacter;
105 CharacterControllerComponent m_pController;
106 CharacterInputContext m_Input;
107 CharacterAnimationComponent m_AnimationComponent;
109 float m_fTime;
110 bool m_bNeedFinish;
111
112 float m_fSpeedX;
113 float m_fSpeedY;
114 float m_fSpeedZ;
115 float m_fSpeedXV;
116 float m_fSpeedYV;
117 float m_fSpeedZV;
118
120 float m_fMovementSpeed = 25;
121 float m_fMovementSpeedFltTime = 0.3;
122 float m_fMovementSpeedFltMaxChange = 100;
123
125 bool moveUp = false;
126}
proto native bool PrePhys_GetTranslation(out vector pOutTransl)
void OnDeactivate()
called when command ends
proto native void PrePhys_SetTranslation(vector pInTransl)
Definition Math.c:13
void ScriptedCommand(BaseAnimPhysComponent pAnimPhysComponent)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.