[OPEN-SOURCE] Machinery Modelling Toolkit

So the main reason why it slides is because this implementation of the friction is reactive, meaning it react to velocity and if there is no velocity there won’t be any friction. The side effect of this is that object will start moving under influence of gravity and only after friction will react. This is why it slides.
There are two ways I know of to fix this. One is to add a breakable physics constraint when vehicle stops and it will keep it from sliding. The other is to use @0lento’s idea where a fix can be added to correct specifically for force of gravity. I haven’t tried neither of them on the actual tank model and just on some primitives. I’ll see if I can address this while rewriting friction code, which I’m busy with right now.
So short answer is that this issue will be addressed at some point.

Ok. thanks for the clarification. (and sorry for the double post :))

No worries. I got it working partially with a physics constraint, unfortunately we can’t set constraint as breakable from BP so I need to wrap it into a c++ component first.

Update

Added “static friction lock” functionality which prevents vehicle from sliding on slope. Tried couple of different approaches and one which spawns a breakable physics constraint finally works. I don’t remember who exactly suggested it first, I think it was [MENTION=252207]Black Phoenix[/MENTION].
With generous help of @0lento made a small function that allows to set physics constraint as breakable, programmatically from BP. For some reason setters are not exposed to BP and it wasn’t trivial on how to apply new settings, just setting their values does nothing.

For now, most of the implementation is in BP and two vehicles have this feature: 4WheeledVehicle and LightTankTraceWheelsWithAnimBP (T-26 in the main level).
I’ll use BP of tank highlight changes which where made:
Friction component’s physics update now returns a boolean to indicate if static friction was achieved during calculations, while wheels/tracks weren’t rotating. Points which achieved such state are counted.

Then we check if all or more than 80% of all friction points have achieved such state and advance a simple timer to make sure that lock is not engaged immediately but takes a second or two:

In case if not enough points achieved static state, like if user pressed on throttle and wheels started to spin, then we destroy constraint if it was already made:

If we pass timer check then constraint can be made, but first we calculate a sum of all friction limits on points. Friction limit is a normal force multiplied by static friction coefficient, if more than this amount of force is applied to an object then object should start to move. So we need our locking constraint to be breakable and use total friction limit as breakable force threshold:

When constraint is broken on PhysX level it gets deactivated but UE4 component stays alive. Which means we need to track OnConstraintBroken event and destroy component. For this reason, creation of constraint had to be moved into CustomEvent, so we can bind some logic to OnConstraintBroken.
New constraint component is added when CreateStaticLock custom event is called:

Custom function is used to set constraint as breakable and logic to destroy constraint when it gets broken is added:

The end result is rather simple, if you posses 4WheeledVehicle or LightTankTraceWheelsWithAnimBP, after enabling debug mode (Shift+Alt+D) you will see on-screen messages when lock is activated or destroyed:

Applying larger enough force, as a result of colliding into vehicle, will automatically break constraint. In my tests, constraint was broken at the instant of collision so you don’t even notice that constraint was even there.
In case of tank I had to set logic to check if 80% percent of friction points are in static case because with many wheels and not equal distribution of weight, some points can stay in kinematic case just because they don’t support enough weight. Raising static friction coefficient can solve this too, but it has a direct effect on vehicle handling. In this case, lowering amount of contacts that need to be in static state is a better compromise.

Unrelated change - switched suspension of LightTankTraceWheelsWithAnimBP to use sweep shapes and it restored it mobility, it can drive over all obstacles again.

Latest version of MMT Content is on github and new version of MMT Plugin will be uploaded shortly.

 @MagnusAnder let me know how this fix works for you. It's quite possible that I've missed some test cases.

Update

Added new high-poly tread element for the light tank, to demonstrate new features of track animation:

  • now treads are aligned properly to each other, previously you could see pins not matching on curves

  • treads are now always aligned with sprocket teeth

  • experimental track sway for selected parts of the track (only top part of the track is effected by sway)

  • all treads are actually moving, so you can use material where each tread have a unique character to it:

  • option to update treads rendering manually, for example if you want to use multiple tread elements instead of a single type of instance as on tanks in BF1:
    https://i.ytimg.com/vi/ETN5MBvYkas/maxresdefault.jpg
    each 4-th tread has a different shape than the rest

for this you can use this function:
TrackAnimation_Custom_rendering_part2.PNG
which provides you array of transforms for all treads.

You can set name of Instanced Static Mesh component to ‘none’:


to avoid updating your ISM from inside of component.

I’ll see how common type of track like this, made from multiple parts can be added:

(fixed image link)

Nice. I hope I can find some time to try it out :slight_smile: Thanks

Update

Added new sprocket model that can supports two different types of tracks - single element tread and two elements tread:

Single element is “latched” by the lower curve and in two elements configuration the joining link is “latched” by two upper curves:

The new two elements tread looks like this disassembled:

New options in TrackAnimation component to support two elements treads:


First option enables lag compensation of skeletal mesh rotation animation. It simply updates tread instances with one frame lag so they match with skeletal mesh elements (sprocket in this case). This option is not needed if you use separate static mesh components to render sprockets.
Second set of options is configuration of secondary piece of the tread, including name of the additional ISM component to render secondary instances.

[EDIT]
My apologies to people with older PCs, some of the new meshes are very high-poly, this way it was faster to make them and have good visual latching of track elements.
This updated is already on github.

And latest executable can be accessed here:

Forgot to update plugin. It’s synced now and latest version is on git-hub.

Update

Fixed an old bug - worthy of separate commit. Previously, track velocity wasn’t properly projected on the contact surface, it was assumed to be parallel to the friction component X vector and projected to the contact surface later. This is wrong as in case of vertical obstacle in front of the tank, sprocket would press against it and normal of the contact surface would coincide with track velocity vector leaving almost 0 projected velocity to work with. In new implementation only speed (float value) instead of velocity (vector) is passed to friction component. Friction component assumes that at any point of contact, track is moving parallel to the contact surface and this provides a proper magnitude of track velocity to work with. This fix enables tanks to properly scale vertical obstacles as you can see from video. I’ve recorded new sprocket and tracks in action too:

I love you so much right now for making this- this is exactly what I needed. I’m working on a project and I’ve been spending a lot of nights just thinking about how I would even get a realistic tank to work properly with how much of a noob I am. If I do succeed in making heavy/medium tanks with this concept I’ll make sure to post it here!

You are very welcome! Let me know if something is not clear. As of now, you’ll have to use existing setups to understand how it works. Sadly there isn’t much documentation besides tool-tips of components.

Hi,

sound rally really cool <3 unfortunally i cannot make this working on my machine.

i am using UE 4.14.0 source version, so i download the 4.14 version of the project from github .

when i open it , it give the message that UE_Editor_mmt and UE_Editor_mmt_content dll need to be rebuilt .
if i click OK it give me another message that it cannot be done and that i have to build it manually .

btw for some reason i don’t have the explorer context menu option for uplugin files .

also i have tried to install the plugin globally in the engine source plugins folder, regenerating the solution with the bat file … etc , but it have completly broken the engine,
and i had to rebuild the entire source > 6 hours or so …

so any help on how to setup this is much appreciated .

anyway thanks for sharing

Hi,

4.14 branch is actually for 4.14.3 - I should name branches correctly in the feature. I’m not sure if projects can be downgraded to previous version, but I would still try “Switch version” option and select 4.14.0

That could be because project version is later than 4.14.0. This sucks, so you can’t generate VS project either then?

Never tried it as engine plugin, there could be some options in build.cs which are missing for this.

If you have to stay with 4.14.0, then maybe grab 4.13 branch and upgrade it to 4.14.0?
Could you explain your use case for 4.14.0 specifically? In the feature I could make separate branches for each intermediate version, like 4.15.1, 4.15.2 and etc

nothing special for using 4.14.0, i had some problems in the past with the launcher so i had to download UE4 and build it from source .
and because i have a very slow connection i cannot do it for every new version or intermediate.

i will try the 4.14.3 or 4.15 and see if it works, hopefully the difference between dependencies for versions are not too big in term of download size .

this is for every uplugin or uproject file, didn’t find any documentation on how to make the integration of UE4 source version with the explorer .

btw : what UE4 version do u recommend for retesting: 4.14.3, 4.15 ,… ?

Latest - 4.15.1, master branch is on it

same problem :frowning:

so i have grabed UE 4.15.1 and built it .
downloaded the MMT project from https://github.com//MMT_Content (download as zip)

put it inside my UE4 projects folder

when i open it i have the same issue as before :

then it show me another message :

Project files could not be generated. Log output:

any idea please ?

I think, in any case you need to re-generate VS project files first, so you can compile MMT plugin after this. Take a look at the end of this thread regarding explorer’s context menu:

Wait a second, I think its a bug with repo!