Skip to content

Commit

Permalink
Remove compensation for gravity (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tryuan99 authored Oct 12, 2024
1 parent 2c49d34 commit 80a6d55
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
8 changes: 1 addition & 7 deletions Assets/Scripts/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,8 @@ protected virtual void AlignWithVelocity() {
}
}

protected Vector3 CalculateAcceleration(Vector3 accelerationInput,
bool compensateForGravity = false) {
protected Vector3 CalculateAcceleration(Vector3 accelerationInput) {
Vector3 gravity = Physics.gravity;
if (compensateForGravity) {
Vector3 gravityProjection = CalculateGravityProjectionOnPitchAndYaw();
accelerationInput -= gravityProjection;
}

float airDrag = CalculateDrag();
float liftInducedDrag = CalculateLiftInducedDrag(accelerationInput + gravity);
float dragAcceleration = -(airDrag + liftInducedDrag);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Interceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override void UpdateBoost(double deltaTime) {
Vector3 accelerationInput = boostAcceleration * rollAxis;

// Calculate the total acceleration
Vector3 acceleration = CalculateAcceleration(accelerationInput, compensateForGravity: false);
Vector3 acceleration = CalculateAcceleration(accelerationInput);

// Apply the acceleration force
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
Expand Down Expand Up @@ -97,7 +97,7 @@ protected override void UpdateMidCourse(double deltaTime) {
}

// Calculate and set the total acceleration
Vector3 acceleration = CalculateAcceleration(accelerationInput, compensateForGravity: true);
Vector3 acceleration = CalculateAcceleration(accelerationInput);
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Threats/FixedWingThreat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected override void UpdateMidCourse(double deltaTime) {
}

// Calculate and set the total acceleration
Vector3 acceleration = CalculateAcceleration(accelerationInput, compensateForGravity: true);
Vector3 acceleration = CalculateAcceleration(accelerationInput);
GetComponent<Rigidbody>().AddForce(acceleration, ForceMode.Acceleration);
}

Expand Down

0 comments on commit 80a6d55

Please sign in to comment.