I just wanted to add regarding trailers: if you enable swing drive (and maybe twist) on a spawned physics cosntraint actor, which is onyl available via blueprints (and probably code) (its nto in the settings) and locking all the angular setups except twist I left to 1 degree you get a MUCH more stable setup.
If I could get it even more stable I could almost make my project come true! Makes me really wanna dig into the code after final exams and start learning the UE4 API.
I would be careful with limits smaller than 5 degrees, according to Unity’s physics programmer those kind of constraints are hard for engine to reinforce. But at the same time it’s great if it works for you.
Couldn’t see all the details in the video from the phone, will check it when I’m back from holidays.
It’s a really nice project I like the instanced meshes for tracks, it looks so much better than just using animated materials. I’ve been working on a new movement component concept which would model the suspension better than the current PhysX implementation of NWheeled vehicles (I dislike ray traced wheel collisions there). My approach for spline is a bit different, I create it procedurally based on wheel location and then put it in 2 arrays to apply force and animation.
I don’t know if you fixed it by now but in your project I was getting the track to “slide” over the wheels after driving a few meters and stopping. It looked like some variable precision issue so I tried to fix it by saving only the remainder to the track var.
Replaced this (in animate treads function):
I’m having a small problem with my implementation and maybe you know what is the cause of it and how to fix it - when the tank reaches a certain speed, the physical simulation becomes unbalanced (also some precision issue?) and the suspension is bumping wheels on a flat surface. It still drives ok but visually it’s not as good as your implementation (rock solid at all speeds). I could try an further disconnect the visual wheels from simulated wheels, make them work on some sort of traces, but I want a better solution than that.
In the end of the video you can see the wheels starting to bounce at high speed:
Thank you!
Not sure what you mean. Do you re-create spline on every frame by drawing it from wheel to wheel contact point or it’s made one time in constructor? Do you do anything to keep length of the spline exactly the same all the time?
Ohhh, I’ll try that. My impression was that tracks slides because spline length is not constant, it get’s a bit longer/shorter when suspension compresses. Solution to this was slightly more complicated then I wanted it to be so I’ve left it as it is for now.
[/QUOTE]
This is a general problem with rigid bodies and collision at high speed. I’m using sphere trace and this is why it’s so smooth, there is no collision involved. One way you can mitigate it and don’t resort to using ray trace is to use physics material with very little restitution and no friction. This is how I’m doing it on AeroSled and so far it gets bouncy glitch only on landscape (general issue of landscape collision), on custom mesh it doesn’t seam to be bouncing. The downside is that you have to simulate friction but basic code is already there both in tracked vehicles and aerosled suspension component.
Specifically for tanks, even better solution is to make a custom cylinder collision query, then you get benefit of “smoother collision” and more adequate collision shape.
This year started with a funny incident - my CPU water-cooling system started leaking and water went on videocard, motherboard and potentially PSU. After replacing cooling system I’ve found out that my PC doesn’t work anymore, so I had to replace some other parts and eventually re-install OS and the rest of the software. It took almost 4 days out of my vacation
Anyway, back to work. Today I’ve submitted update with some small changes here and there, forgot to mention some of the on GitHub:
update A_Tracked_Vehicle with a fix provided by Tooner; Thank you, Tooner! Tracks animation is much smoother now.
after proper conversion of vehicle momentum into force, friction should be calculated more correctly now and generally is a much larger force than before
values for MuX and MuY went down, they look a bit more like real life friction coefficients
I’ve added wheel’s torque as a part of the force taken into account for calculation of friction; results were not too visible, perhaps power output of the engine is not realistic (too small) or default value of “Tread and Transmission Mass” is too large; this effects steering as well, probably there is a bug somewhere around taking into account mass of tracks and transmission in calculations; I’ve set Tread and Transmission Mass for both M113 and Ripsaw to much smaller values and handling was greatly improved, which is a good thing but I need to understand exactly why
removed some weird coefficients from the steering differential and now as you turn left and right the power should be translated more proportionally; steering only left/right will provide an equal but opposing torque on tracks, if both left/right and forward/backward are pressed than one track goes into neutral and second one get’s twice the normal torque; this gives at least two turning radi in addition to neutral turn; steering at high gear is still difficult as vehicle is mostly rolling forward, you need to brake to loose some speed to do a sharp turn
found interesting bug where Ripsaw starts to jitter when standing in place; apparently at some configuration of position of center of mass relative to suspension handles, suspensions and friction start to play “tug of war” which leads to both horizontal and vertical oscillation of the vehicle; slightly lowering center of mass removes this behavior; most likely it’s just a general stability consideration where suspension root should be higher than vehicle’s center of mass
Aerosled’s suspension is slightly re-balanced and fixed constraint of back-left ski, which was apparently on the other side of the vehicle
I was looking into some other issues and wanted to improve suspension setup for A_Tracked_Vehicle. Unfortunately, architecture is not so flexible in terms of re-factoring code and interchanging big parts of logic. I need a better architecture and component based approach look like a good idea. Next step would be to check if there were some good developments in 4.1 and 4.11 regarding component and check why my Moment Of Inertia for transmission is effecting vehicle that much.
I’m still curious if you managed to fix that physics bug with excavator
I’ve double checked my code which deals with passing some of the friction to tracks themselves - that’s what makes them roll on a slope if you don’t press breaks. The code looks fine but it has a heavy dependency on the weight of the track+sprocket+transmission. Currently, variable “Tread and transmission mass” is responsible for this weight and tweaking it makes a huge impact on the behavior of the tank. be default it’s set to 200 kg (don’t remember why) which is realistically very low for something like M113.
I had to do a ton of googling to get these numbers:
According to this source: http://www.tgl-sp.com/m113-track-shoe-assy
approximate weight of a single T130E1 track shoe is 20.7 lbs or 9.389362 kg, we have 64 of these on a side so 600.919168 kg is a full track. How heavy is sprocket I couldn’t find, but I got it’s part number [NSN: 3020-00-141-1154 Part Number: 11678255]
which doesn’t help much as most of the shops didn’t mention it’s weight. Anyway, let’s say it’s about 5 kg or maybe even 10, not much of the difference comparing to the weight of the track. The point is that ball park estimate weight is much higher than what is used right now. With the current setup if you set “Tread and transmission mass” to 100kg, M113 becomes very agile, if you set it to 50 you can start doing drifts
I imagine that with about 610kg it will be barely controllable, but that’s a realistic weight!
There are two places where “Tread and transmission mass” is used, one is mentioned above and second one is calculation of Moment Of Inertia for transmission. We need it to convert engine/transmission torque to angular acceleration, so that we can figure out how fast transmission and sprockets and as a result tracks should spin. I need to properly calculate moment of inertia, most likely what I do right now is use simple formula for a cylinder I=1/2MR^2 with M of “Tread and transmission mass” and R of sprocket. Which is little bit too high More specifically it’s sprocket is made out of depleted uranium or something. Back to googling to get some idea how engine of M113 was connected to sprockets. Yeah and I don’t really have a good grasp on how to calculate moment of inertia for the track itself as it’s not rotating around it’s center but sprocket.
Forgot something else, so suspension on Aerosled is setup in such a way that it pushes only chassis. I was avoiding pushing both chassis and ski with it as I thought it’s going to give a hard time to solver to keep ski above the ground. Yesterday, I’ve tried to apply suspension force to both parts and to my surprise it works really well, Aerosled became much more controllable and ski are properly pushed away if it flips on the side. Force need to be tweaked a bit, as it technically became twice as large, but otherwise I’m very happy with results and will publish at least compiled version today.
Not Git update yet but I was checking what is going on weird with moment of inertia of transmission system. I’ve ended up splitting weight of the track and sprocket into separate variables. Moment of inertia is now calculate as a cylinder for sprocket and as a hoop for the track, this should match real thing much better, for even better precision the rest of the elements, such as gearbox and axle should be added too.
More interesting is what I’ve found regarding friction force effecting tracks themselves. Right now just a part of the total friction force has effect on track, this force is necessary for the tank to roll downhill in neutral. The way how I calculate this force seam to be very wrong and values that provide more realistic behavior just don’t match the math. It seams to me that I have a much bigger issue here and my logic of calculating friction for the whole system of chassis/tracks/engine is wrong.
For a time being I will simply tweak a magnitude of friction force pushing on tracks to have a linear dependency on track mass and multiplied by some magical constant to make tank more agile.
If someone has a good idea of how system should work please let me know, I’m getting a bit stuck on this issue as majority of the discussed friction models focus on car’s tires, which is not really applicable here.
Hi, first of all thx BoredEngineer – very good job on this project!!! best track thing for now!!!
Also I have a question and suggestion:
1 Can i use skeletal mesh for body?(if yes maybe i can some how connect(maybe with sockets on physical wheels?) my bones on skeletal mesh to your suspension? for creating realistic suspension effect) like in standard vehicle class with vehicle animation BP?
2 will be nice adding a little physics effect on spline(if its a possible off course) for creating hanging/wiggle tracks effect
3 also i have future suggestion for suspension, for now what i see suspension work only up and down, but in real tanks wheels move little in front/back side(for example now wheel move in +Z -Z only direction but nice to see additional to suspension that wheels can move also a little on +X -X direction)
It should be possible to replace root body in A_Tracked_Vehicle. First add new skeletal mesh and make sure to have the same setting for physics and mass and etc. as on root body. Then replace references to root body in the code and now you can finally delete root. Normally “suspension” component itself is not animated but it drives animation of the wheel so it’s better to connect bones to wheels instead of suspension.
It’s possible to add this with some creative math or animation based on inertia of control points, I’ll look into this in feature.
It depends on suspension, torsion bars indeed move in arch and can be simulated as angular springs, in principal M113 should have torsion bars and Ripsaw should have a regular spring and dampener. I want to add more types of suspension using component based approach. It’s rather difficult to add such options right now because of architecture and dependency between functions. Either component based approach or heavy refactoring is required to add such features.
Checked code regarding friction effecting rotation of the track, including an alternative implementation and it seams to be just fine. Except small bug which is fixed not. It looks like there isn’t enough torque coming from the engine. Which is rather weird as two types of rolling friction that I have are rather conservative. Most likely I’m missing some extra gear which should additionally multiply power output, after all, gear box which I’m modelling is not automatic as on real M113.
Anyway, being able to tweak steering of the vehicle is more important, so I’ve added new “performance” variable EngineExtraPowerRatio by default it multiplies transmission output by 3.
Added new feature for friction simulation, now both static and kinetic friction is simulated. Variables MuX and MuY are replaced with their static and kinetic counterparts. The end result looks like this: https://www.dropbox.com/s/bfsgox7y66vvghy/Static_and_Kinetic_Friction.gif?dl=0
Transition between tracks having a good grip and starting to slip is much more clear. This helps with steering as well, by applying a little bit of break before the turn we can intentionally skid vehicle into new direction.
Default mass of the sprocket was upgraded to 65kg, didn’t knew they are so heavy, they even made in two pieces so it’s easier to install them. I pretend that Ripsaw is using rubber band tracks, their weight was dropped to 280kg.
Changes committed to GitHub and new executable is uploaded.
Hi, thanks for your work!!! i try to change body static mesh to skeletal mesh in parent class(after compile it say me about missing static mesh reference and i reconnect new reference from skeletal mesh…) after that in parent class all compile good, but child m113 vehicle bp(from parent class) when i open it and try recompile --my editor go crash (4.11 p3)a so now try play with it more, but i try to ask what purpose using static mesh body instead of skeletal mesh???
PS How you think your vehicle bp can bee convert in something similar like standard vehicle class(but specially for tank type vehicles)? with setup all main vehicle settings(engine suspension, gears, skeletal models geometry, animation BP and etc)? maybe you even can add this to Epic engine “out of the box”? i think Epic MUST GIVE YOU A GRAND FOR THIS WORK!!!
tooner, feels weird that you don’t credit bored engineers coding in your youtube video.
is this being used in Squad now?
I’m a long time PR player and supported squad from the start… thought about contacting the dev team for the tracked vehicles as that is something that interests me… but never did.
If you are working on squad and using these blueprints then please give him credit… at least.
And if they ever need help on the tracked vehicles from anyone who also cares… you know where to look.
I get this after adding Skeletal mesh(i not remove anything, only add skeletal mesh) changing parent of m113, and compile(parent class compile success!!!) but in child m113 i get error
UPDATE: i don’t know what happen, but after restarting editor all start working again)))) for now i create body with single static mesh (just replace standard boredenginer body by my test tank body) and add new component skeletal mesh to parent, and on this skeletal mesh component i set suspension tower and weapons with some other stuff and set all physics for skeletal mesh to 0.001 and for now i like result, oh can wait to see my tank in action)))
PS now working on visual suspension for my tank, maybe some one know where i can get world transform from wheels?
I would be very surprised if someone would use this setup for commercial purpose as it’s not really working well with sub-stepping and varied FPS. This is the general problem of doing custom physics in BP. From what I understood Tooner made a setup using static meshes and constraints. This is why his wheels are jumping at high velocity.
This is expected behavior because M113 and Ripsaw are trying to “insert” static mesh which is already assigned to them. Before changing static mesh to skeletal mesh in A_TrackedVehicle, first switch custom static mesh in M113 and Ripsaw to default of the parent: