Tank won't move and disappearing tracks

I just finished " a better component architecture".

Every time i compile, unreal “forgets” I set up the static meshes for the tracks, and when I play the game, it loads the tank without the tracks!
it also forgets the physics material override.

I believe this has something to do with the initializing of the tracks, it seems to re-initialize them every time and to forget what I set up for it.

Even after I manually re-add both the static meshes and the physics materials, the tank won’t move. at all.

The weird part is that at this point, it stops reacting to the bumpers, too.

Anyone else had this and can help?

I’m attaching a link to my git hub repository:

It is inside the “non working” branch".

Thanks :slight_smile:

As for the second part of your questiong regarding the disappearing tracks

Same problem I’m fighting against. The C++ component classes derived from StaticMeshComponent lose their SM when recompiling. Happens with turret and barrel as well.

It seems, that it only happens, if the .h file is changed (but no guarantee for this). Sometimes, the components even get into such a bad state, that the mesh even gets lost when just restarting the UE4Editor without any compilation of C++ code. In that case, the components have to be deleted and added in again.

There has been discussion about this being caused by changing UPROPERTY values to private. See
https://answers.unrealengine.com/questions/816388/view.html and the referenced issue link
https://issues.unrealengine.com/issue/UE-63298

Other discussions are about the Hot Reload feature making things fail. There’s quite a lot discussion on that topic.

But I think, there’s another problem, because changing a working .h file just with a comment also leads to that loss.

It is getting more and more confusing. For example, I found that other variables get lost, as you say. For example, I had situation, that a changed Collision Preset value was lost after reopening the editor. BUT: this did not get lost, if I had a Physical Material assigned as well. So both did not disappear, but Collision Preset w/o Physical Material got lost. Only way out here: remove and readd components.

I am still experimenting. See my test project for this on https://github.com/herb64/UE4-SMC-problem
With this project, I can reproduce the vanishing mesh on my system. But strange enough: cloning onto another system - and no error. So I think, this might also be related to some stuff being held in precompiled headers or whaterver. Maybe from time to time its useful to delete all unnecessary files and open the project from scratch, rebuilding the .sln etc…

My current workaround

In the test project above, you’ll find a description of my workaround by simply implementing the class constructor and loading the required static mesh here. This works for me at the moment, although it is realy ugly :frowning: . And it is not helping in any case, at some times, things still get screwed up.

Here’s an example from my code for the tracks:

// Just switch workaround off by commenting this
#define WORKAROUND

/*
 * W O R K A R O U N D   F O R   V A N I S H I N G   S T A T I C  M E S H
 * Set static mesh within the constructor manually
 */
UTankTrack::UTankTrack()
{
#ifdef WORKAROUND
	// We simply use the Engine Cone Basic Shape
	static ConstructorHelpers::FObjectFinder<UStaticMesh>SM_Track(TEXT("/Game/Tank/tank_fbx_Track"));
	UStaticMesh* TrackMesh = SM_Track.Object;
	if (TrackMesh != nullptr) {
		UE_LOG(LogTemp, Warning, TEXT("Set track mesh %s"), *TrackMesh->GetName());
		this->SetStaticMesh(TrackMesh);
	}
	else {
		UE_LOG(LogTemp, Error, TEXT("Could not set static mesh to component"));
	}
#endif
}

I hope this helps a little bit with the static mesh…

Thank you for the reply!
I’m not versed enough in programming yet and it took me a while to understand everything you wrote.

When the same issue occurred with the barrel, the fix I used was to assign the static mesh through the blueprint construction script, that seemed to work well so far, but it just won’t work with the tracks.

Manually setting the static mesh through code is ugly, as you said, I’ll keep looking for solutions in order to avoid this. thank you for sharing!
I’ll keep posting here if I find anything.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms