The flying tank bug is a result of differential forces on the tank due to how we’re moving our tank. Currently, we apply Force to the track location which is at the bottom of the tank. Pushing the tank like this causes more force at the bottom than the top creating torque. While held to a level surface (by gravity in our case), the force applied to Z-axis is absorbed by surfaces (effectively limiting our force 2-Dimensionally). Once the tank is no longer level (has enough forward force and torque to overcome gravity), applied force affects the Z-axis lifting the tank (3-D force). You could see the effects of this you had double speed on the tank (Using Stick and Triggers together), the tank would start doing a wheelie. Attempting to turn (apply negative force on one track and positive force on the other) greatly increases torque. This can be handled the same way we solved sideways slippage, but vertically and only applying force negatively (effectively increasing gravity).
Thanks for this insight, Brian. Do you have a patchset or code snippet you can share which fixes this?
None that were effective and didn’t add more bugs
I wonder if we apply the forward force to the tank body (instead of the bottom of the tank tracks) whether that will fix this issue.
Or could we somehow apply the force to the top of the tank tracks instead of the bottom of the tank tracks?
For me, this game is unplayable with the flying tank bugs (for some reason it’s far worse in my game than it is in Ben’s videos) - quite disappointed to see the message at the top of this video that says “we never found a fix for this bug”.
Firstly my problem is massively exaggerated due to me being “clever” early on and creating an interesting landscape that had lots of undulations in it. If you have done this, go the landscape editor, use the flatten tool with flatten target set to 1.0, strength set to 1.0 and a nice big brush size. Flatten the big part of your area that is meant to be flat.
Secondly, rather than try to counteract the upward force by generating power at the bottom of the tank tracks, I am experimenting with applying the force to the tracks at a positive Z index location - i.e. attempting to push the tank from the middle of its mass rather than from the bottom its mass:
FVector ForceApplied = this->GetForwardVector() * this->CurrentThrottle * this->TrackMaxDrivingForce;
FVector ForceLocation = this->GetComponentLocation() + FVector(0.f, 0.f, this->ForceZIndexOffset);
So far a value of ForceZIndexOffset of 60.0 (cm) appears to be about right where the tank is neither pulling wheelies or endows).
Note: this is not solving the damn terrain-starts-flying bug, but is helping a little bit by pushing the tank from the middle of it’s mass rather than from the bottom (similar to @Brian_Upsher 's suggestion).
This is extremely disappointing and very frustrating for me. I’ve been patiently waiting to actually play my game without having all the tanks flipping upside down.
Has anyone found a solution? The game is unplayable for me.
Has anyone changed their tank movement to use the C++ feature for vehicle movement? I’m considering trying that.
Near the end of the section you make a suspension system and apply thrust to the wheels. That should eliminate most if not all these issues.
I am actually trying to separate the force in many pieces and applying in different location in X and one meter above ground (I can draw it to explain why that way, if someone wants to). It REDUCES the fly thing, but it is far for fixing. Is it possible to make better than this via FMath?
Here my code:
void UTankTrack::DriveTrack()
{
FVector ForceAppliedTenTimes = GetForwardVector() * CurrentThrottle * TrackMaxDrivingForce/10;
FVector ForceLocation1 = GetComponentLocation();
ForceLocation1.Z = ForceLocation1.Z + 100.f;
ForceLocation1.X = ForceLocation1.X + 5.f;
FVector ForceLocation2 = GetComponentLocation();
ForceLocation2.Z = ForceLocation2.Z + 100.f;
ForceLocation2.X = ForceLocation2.X + 15.f;
FVector ForceLocation3 = GetComponentLocation();
ForceLocation3.Z = ForceLocation3.Z + 100.f;
ForceLocation3.X = ForceLocation3.X + 25.f;
FVector ForceLocation4 = GetComponentLocation();
ForceLocation4.Z = ForceLocation4.Z + 100.f;
ForceLocation4.X = ForceLocation4.X + 35.f;
FVector ForceLocation5 = GetComponentLocation();
ForceLocation5.Z = ForceLocation5.Z + 100.f;
ForceLocation5.X = ForceLocation5.X + 45.f;
FVector ForceLocation6 = GetComponentLocation();
ForceLocation6.Z = ForceLocation6.Z + 100.f;
ForceLocation6.X = ForceLocation6.X - 5.f;
FVector ForceLocation7 = GetComponentLocation();
ForceLocation7.Z = ForceLocation7.Z + 100.f;
ForceLocation7.X = ForceLocation7.X - 15.f;
FVector ForceLocation8 = GetComponentLocation();
ForceLocation8.Z = ForceLocation8.Z + 100.f;
ForceLocation8.X = ForceLocation8.X - 25.f;
FVector ForceLocation9 = GetComponentLocation();
ForceLocation9.Z = ForceLocation9.Z + 100.f;
ForceLocation9.X = ForceLocation9.X - 35.f;
FVector ForceLocation10 = GetComponentLocation();
ForceLocation10.Z = ForceLocation10.Z + 100.f;
ForceLocation10.X = ForceLocation10.X - 45.f;
//After I need to stop to fly away. Two combined solution: put more than one vector of AddForce, also put Force at tops of Mass Center.
auto TankRoot = Cast<UPrimitiveComponent>(GetOwner()->GetRootComponent());
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation1);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation2);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation3);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation4);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation5);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation6);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation7);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation8);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation9);
TankRoot->AddForceAtLocation(ForceAppliedTenTimes, ForceLocation10);
}