Building a suspension for the Tank

Awesome work ! Though you should set the specular entry of your landscape material to zero

@Guillaume_Feraud:
Thanks for the huint with the specular setting, will do some artwork soon to make landscape and textures look better.

Update

Even though the tracks work good on ladscape, they have a clipping issue with edged object.

So i reworked one side of the suspension, obviously the right one:

Old/New comparison:

Was a hell of workā€¦a major advance imho.
Need to add the wheels againā€¦I will keep you updated.

4 Likes

Awesome work, inspiring

@sampattuzzi have a reac

How did you implement the sag in the track? Is it hard coded or does it depend on how much the wheels are stretching it?

@sampattuzzi:

The sag, right now it is still a bit faked.

I do know the total length of the chain each time i make it visual and the final goal is to have a static length all the time, what i do not have archieved right now, quite mad maths for me.
This will visually efffect the UPPER part of the track, it will be held up with suppport castors one day and sag between them depending on the state of the suspension and the resulting overalll track length of the lower part.

The sag you see right now is calculated locally by the end of contact of the track to an object and distance to the next contact of the track after the spacing.
I have a hardcoded spline shaped like a wave, which i scale by the distance of the spacing and then use it for the drop-off calculation of the single track tiles.

Curenttly i try to reimplment the lower castors again, which gives me a hard time calculating their position against a wave form track in one cycle instead of iterating it.
I just do not like to iterate heavy used stuff, but use clean and straigth maths instead, in most cases this is way better for performance imho and makes the code easy to read and understand.

So if someone has a cool and easy formular for a 2D Vector calculation, how i can get the position of a circle with a set radius over a spline while the imaginary Y-Axis(it is the upvector of the tank but just think of it as imaginery Y-Axis, we are looking at it in 2D here) is fixed in its X-Position and the Circle having a limited amount of Y-Axis travel using the spline function to calculate the nearest spline point from a given location in world spaceā€¦just let me know. It gives me a hard time right now.

1 Like

UPDATE

Lower track castors added again.

Finding the right position for the wheel in relation to the spline gave
me quite a hard time, took me 2 attempts to find the right and
cpu-friendly maths to do so.

Result is quite ok imho:

8 Likes

Looks amazing! To be technically accurate. The 7-72 model should have 3 return rollers supporting the top of the track.

Thatā€™s crazy impressive!

Iā€™ve had a coding break since 20th July as summer holidays and kids :smiley:
Iā€™m just coming to the end of the BattleTank section and come accross this post.
This is just ā€œWowā€ I dont even know where to begin to get anywhere close to this! But try i must as this is needed for any development i would want to make.

Thanks for sharing and showing it can be done with a little determination and hard work.
Great job mate and wish me luck! (Finishing off part 2 here i come!)

whoa that is some really impressive stuff. Great job!

This is just too incredible to keep in the BattleTank section so I have moved it to the showcase for all students to see what is possible when you set your mind to it.

2 Likes

I would be nice, to have a section for battle-tank where @ben or others leave code snippets of things like this, Iā€™m working on something much less complicated. But what Iā€™m envisioning is ā€œExercisesā€ without solutions, where Ben gives you some hints on what would work, and the students try and figure it out, and if you post a solution that works, you get access to all the other peopleā€™s answers.

Personally, Iā€™m trying to get a UV Panner to work, but my current Issue that Iā€™m working around is, that everytime I set the pannerā€™s U or V value for the track It resets the Pannerā€™s position, and then starts panning. So Iā€™m trying to ->Modulo<- (%) the values, so I get a remainder for a 0-1 UV space, which isnā€™t easy since Modulo is meant to run with Intā€™s not floats, so I found myself multiplying and dividing my solution, but I think Iā€™m hitting rounding errors.

In the UTankTrack class Iā€™m setting this in the constructor which makes a material instance, and allows me access to any material parameters :

MaterialInstance = UMaterialInstanceDynamic::Create(GetStaticMesh()->GetMaterial(0), this);	
this->SetMaterial(0, MaterialInstance);

And then I have a new Method Called UpdateMaterialPanner, that goes like this :

void UTankTrack::UpdateMaterialPanner(UMaterialInstanceDynamic* TrackMat)
{
	if (!TrackMat) { return; }
	float TrackSpeed = 0;
	
	FVector Velocity = TankRoot->GetComponentVelocity();
	float Speed = (Velocity.X) / GetWorld()->DeltaTimeSeconds;
        TrackMat->SetVectorParameterValue(FName(TEXT("TrackSpeedUV")), FVector(0.0, Speed , 0.0));
}

Which the last line is the thing that modifies the UVā€™s Position, but Iā€™m having an issue with the Velocity.X values Iā€™m getting and dividing them by the track length to get the tracks moving. Just an alternative to actually moving the tracks, which I know can be Performance Heavy, and as a VR Developer, Iā€™m used to making sacrifices to keep things ā€œrollingā€ (Pun) at 60+FPS. Preferably 90.

Hooolyā€¦!!! I was just thinking about a custom track for my own project aswell. You sir are higly inspiring! Thanks for sharing your progress, you gave me a bunch of directions how to do it.

Loved to see the progress you have made with time! Truly amazing!
I thought I should also try doing something like this. Is there some direction you could point me to? Some high level working of whatever you did and how you did it?

Thanks for sharing all of your work and taking the time to explain your steps!

How is the performance for many tanks in single scne? I am using MMT plugin for tank movment which is great too but the performance degrades with 5+ tanks.Awesome Work by the way.

can you tell me in which cpp file to write this codeā€¦
And can you show me the bluprintā€¦basically im trying this tooā€¦for days and im unable to figure outā€¦
i want to know how u used wheel meshes in rotating and basically everythingā€¦

what is the lastwheelrotation??

Privacy & Terms