Hello,
So I’ve been following a course (I bet people around here hear about it a lot) which suggested that we make C++ classes that inherit from UStaticMeshComponent (that I’ll call SMC for shorts, from now on) to add some additional features to the component.
To make things clear I have to make a Tank which has the main body of the tank as the root component and right under it, a Turret and two Tracks (Left and Right) as well as a Gimball for the camera, then under the Turret a Barrel and under the Gimball a SpringArm which has the Camera under it.
The very first time I used it for the Barrel it did some weird things, sometimes not saving the mesh of the component but overall I still managed to fix it.
The issue got even worse when we had to make the Turret into a SMC subclass and put back the Barrel under it, or well basically remove it, add a new component based on the C++ class, select the correct mesh, put back the child component and select the correct socket after resetting the transform then save then rename then save again (because renaming somehow doesn’t work if there is a shadow of an old component with that name).
Anywho, this popped the “disappearing” issue where the Turret and the Barrel were not accessible as variables in the bluprint any-more and had me removing the two whole components, saving and compiling, re adding Turret under the regular SMC that was the root, socketing it renaming it etc, then the Barrel under it and socketing, renaming etc. and then saving again and compiling once again and it finally seemed to have fixed it.
Now fast forward into the course I had to make another UStaticMeshComponent for the Tracks this time, I did the same stuff, removed both regular SMC tracks and saved then added two components in the blueprint based on the Tracks C++ (called UTankTracks) then selected the mesh on both (not sure at this point), also modified some settings, selected the Pawn collisions preset (because that’s what the tank is) and added a Physics Material Override, until now everything seemed fine until I checked the blueprint and found that the static mesh was missing from one of the tracks, I added it back, saved and compiled and tested it in the viewport and it worked very well.
Now I was happy with the way everything was seemingly going and I decided to package the project for Windows (64bit), and there is where the real problems began.
As soon as I opened the .exe of the game and launched it I noticed that both of the Tank’s tracks where completely gone, and that the code that was in the TankTrack.cpp was however still running, I thought I might have mis selected the mesh so I selected it, saved and compiled then repackaged the game but I still had the same bug, I tried to play it in the viewport directly but both of the tracks were there and were working properly.
I thought that maybe by following the same steps as before I could maybe fix this new bug, I removed one track, saved and compiled, added it back and set it up completely, saved and compiled, then the static mesh of the other track disappeared, so I removed the other track too, saved and compiled, added another track component and set it up completely, saved and compiled and then tried again but I got some blueprint code errors which I fixed and then pressed play but the code of the tracks didn’t seem to be executed (I had logging on it and nothing showed up on the logs)
So I removed both tracks, and their blueprint usage, put them back one by one being extra cautious and saving and compiling at every little step, then put back their usage in blueprint and compiled, everything compiled fine so I confidently pressed play, but little did I expect the horror that happened next, I had an immense spam of errors and then the tracks suddenly became 4 and they all became “None”, I deleted one of the right tracks which deleted the other duplicated right track None but I could not delete the other 2 "None"s at all, even after restarting the whole Engine so I simply used Git to roll back.
I am still stuck in this loop, I also noticed that sometimes by adding a static mesh to one of the track a static mesh pops on the second track and gets selected as if it were a single component.
This is the main code of TankTrack.h
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class BATTLETANK_API UTankTrack : public UStaticMeshComponent
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = Input)
void SetThrottle(float Throttle);
// Max force per track in Newtons
UPROPERTY(EditDefaultsOnly, Category = Speed)
float MaxForce = 20000000.f;
};
and of TankTrack.cpp:
void UTankTrack::SetThrottle(float Throttle)
{
UE_LOG(LogTemp, Warning, TEXT("%s throtle: %f"), *GetName(), Throttle);
Cast<UPrimitiveComponent>(GetOwner()->GetRootComponent())->AddForceAtLocation(GetForwardVector() * Throttle * MaxForce, GetComponentLocation());
}
(the default includes are still there, I simply didn’t add them to make things shorter)
This is the Blueprint code, also currently the static mesh is properly selected on both the right and the left track but when I press play, not only do I not get the code of SetThrottle to run with the track but the track still does disappear in the packaged game;
Screenshot of the game when played from the viewport:
Screenshot of the game when played from the packaged game .exe:
Also after testing around left and right I managed to recreate the “Accessed None” errors by using Launch instead of play and opening the Output Log, this is what I got
These two blocs repeat for a while :
LogPlayLevel: Warning: [2019.05.02-07.28.23:984][365]LogScript: Warning: Accessed None trying to read property Right Track
LogPlayLevel: Tank_BP_C /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_C_0
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP:01A2
LogPlayLevel: Warning: [2019.05.02-07.28.23:984][365]LogScript: Warning: Script call stack:
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:InpAxisEvt_Right Track Throttle_K2Node_InputAxisEvent_4
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP
LogPlayLevel: Warning: [2019.05.02-07.28.23:984][365]LogScript: Warning: Accessed None trying to read property Left Track
LogPlayLevel: Tank_BP_C /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_C_0
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP:0170
LogPlayLevel: Warning: [2019.05.02-07.28.23:984][365]LogScript: Warning: Script call stack:
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:InpAxisEvt_Left Track Throttle_K2Node_InputAxisEvent_3
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP
Then this happened once :
LogPlayLevel: [2019.05.02-07.28.24:021][366]LogStreaming: Display: Flushing async loaders.
LogPlayLevel: [2019.05.02-07.28.24:142][366]LogUMG: Display: Widget Class MainMenu_C - Loaded Fast Template.
LogPlayLevel: [2019.05.02-07.28.25:144][425]LogStreaming: Display: Flushing async loaders.
LogPlayLevel: Warning: [2019.05.02-07.28.25:149][425]LogStreaming: Warning: FAsyncPackage::LoadImports for /Game/Tank/Tank_BP: Skipping import TankTrack /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B, depends on missing native class
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: ****DumpDependencies [Dependencies]:
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Export 55 /Game/Tank/Tank_BP.Tank_BP_C:Left Track_GEN_VARIABLE
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Linker is ../../../BattleTank/Content/Tank/Tank_BP.uasset
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep S_BEFORE_S Export 1 /Game/Tank/Tank_BP.Tank_BP_C (class BlueprintGeneratedClass)
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep C_BEFORE_S Import 49 /Game/Tank/Track.Track
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep S_BEFORE_C Import 7 /Script/BattleTank.TankTrack
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep S_BEFORE_C Import 70 /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep C_BEFORE_C Export 1 /Game/Tank/Tank_BP.Tank_BP_C (class BlueprintGeneratedClass)
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Missing Dependency, request for /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B but it hasn't been created yet.
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Cannot construct Left Track_GEN_VARIABLE in ../../../BattleTank/Content/Tank/Tank_BP.uasset because we could not find its template /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: ****DumpDependencies [Dependencies]:
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Export 56 /Game/Tank/Tank_BP.Tank_BP_C:Right Track_GEN_VARIABLE
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Linker is ../../../BattleTank/Content/Tank/Tank_BP.uasset
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep S_BEFORE_S Export 1 /Game/Tank/Tank_BP.Tank_BP_C (class BlueprintGeneratedClass)
LogPlayLevel: Error: [2019.05.02-07.28.25:170][425]LogStreaming: Error: Dep C_BEFORE_S Import 49 /Game/Tank/Track.Track
LogPlayLevel: Error: [2019.05.02-07.28.25:171][425]LogStreaming: Error: Dep S_BEFORE_C Import 7 /Script/BattleTank.TankTrack
LogPlayLevel: Error: [2019.05.02-07.28.25:171][425]LogStreaming: Error: Dep S_BEFORE_C Import 70 /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B
LogPlayLevel: Error: [2019.05.02-07.28.25:171][425]LogStreaming: Error: Dep C_BEFORE_C Export 1 /Game/Tank/Tank_BP.Tank_BP_C (class BlueprintGeneratedClass)
LogPlayLevel: Error: [2019.05.02-07.28.25:171][425]LogStreaming: Error: Missing Dependency, request for /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B but it hasn't been created yet.
LogPlayLevel: Error: [2019.05.02-07.28.25:171][425]LogStreaming: Error: Cannot construct Right Track_GEN_VARIABLE in ../../../BattleTank/Content/Tank/Tank_BP.uasset because we could not find its template /Script/BattleTank.Left Track_REMOVED_2D947EA1494DB3E4A38522BA20ADFB2B
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: ****DumpDependencies [Dependencies]:
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Export 237 /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_2.Left Track
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Linker is ../../../BattleTank/Content/_Levels/BattleGround.umap
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_S Export 233 /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_2.Body (class StaticMeshComponent)
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_S Import 5 /Game/Tank/Tank_BP.Tank_BP_C
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_S Import 37 /Script/Engine.PrimitiveComponent
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep S_BEFORE_C Import 13 /Script/BattleTank.TankTrack
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep S_BEFORE_C Import 118 /Game/Tank/Tank_BP.Tank_BP_C:Left Track_GEN_VARIABLE
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_C Export 234 /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_2 (class Tank_BP_C)
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Missing Dependency, request for /Game/Tank/Tank_BP.Tank_BP_C:Left Track_GEN_VARIABLE but it hasn't been created yet.
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Cannot construct Left Track in ../../../BattleTank/Content/_Levels/BattleGround.umap because we could not find its template /Game/Tank/Tank_BP.Tank_BP_C:Left Track_GEN_VARIABLE
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: ****DumpDependencies [Dependencies]:
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Export 238 /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_2.Right Track
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Linker is ../../../BattleTank/Content/_Levels/BattleGround.umap
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_S Export 233 /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_2.Body (class StaticMeshComponent)
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_S Import 5 /Game/Tank/Tank_BP.Tank_BP_C
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_S Import 37 /Script/Engine.PrimitiveComponent
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep S_BEFORE_C Import 13 /Script/BattleTank.TankTrack
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep S_BEFORE_C Import 119 /Game/Tank/Tank_BP.Tank_BP_C:Right Track_GEN_VARIABLE
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Dep C_BEFORE_C Export 234 /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_2 (class Tank_BP_C)
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Missing Dependency, request for /Game/Tank/Tank_BP.Tank_BP_C:Right Track_GEN_VARIABLE but it hasn't been created yet.
LogPlayLevel: Error: [2019.05.02-07.28.25:174][425]LogStreaming: Error: Cannot construct Right Track in ../../../BattleTank/Content/_Levels/BattleGround.umap because we could not find its template /Game/Tank/Tank_BP.Tank_BP_C:Right Track_GEN_VARIABLE
LogPlayLevel: Warning: [2019.05.02-07.28.25:277][425]LogTemp: Warning: TankAIController_0 is controlling Tank_BP_2
LogPlayLevel: Warning: [2019.05.02-07.28.25:277][425]LogTemp: Warning: Player is controlling Tank_BP_C_0
LogPlayLevel: [2019.05.02-07.28.25:277][425]LogUMG: Display: Widget Class PlayerUI_C - Loaded Fast Template.
LogPlayLevel: Warning: [2019.05.02-07.28.25:278][425]LogTemp: Warning: TankPlayerController_BP_C_0 is controlling Tank_BP_C_0
LogPlayLevel: Warning: [2019.05.02-07.28.25:278][425]LogScript: Warning: Accessed None trying to read property Right Track
LogPlayLevel: Tank_BP_C /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_C_0
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP:01A2
LogPlayLevel: Warning: [2019.05.02-07.28.25:278][425]LogScript: Warning: Script call stack:
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:InpAxisEvt_Right Track Throttle_K2Node_InputAxisEvent_4
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP
Then these two go back at it again
LogPlayLevel: Warning: [2019.05.02-07.28.25:278][425]LogScript: Warning: Accessed None trying to read property Left Track
LogPlayLevel: Tank_BP_C /Game/_Levels/BattleGround.BattleGround:PersistentLevel.Tank_BP_C_0
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP:0170
LogPlayLevel: Warning: [2019.05.02-07.28.25:278][425]LogScript: Warning: Script call stack:
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:InpAxisEvt_Left Track Throttle_K2Node_InputAxisEvent_3
LogPlayLevel: Function /Game/Tank/Tank_BP.Tank_BP_C:ExecuteUbergraph_Tank_BP
I’m honestly extremely confused and tired of trying to find a solution by now, I hope someone can give me some insight on this or that at least the bug gets fixed in a future patch
PS: Even though it says that it’s accessing None when I go to the blueprint editor this time I don’t see any None and everything looks perfectly fine and at it’s place, which arguably only makes things worse.