Hello BoredEngineer, this is very impressive to be all in Blueprints. Currently pondering over a BP implementation myself using Cable Components and Animation Trickery. I’ve been brainstorming at this with movie-magic in mind. I do feel a true physics simulation would render better result, but, not sure how performance heavy it is with multiple tanks in view. Are you up for discussion on your implementation?
Thank you, TechLord! The problem with cable is that it doesn’t have any kind of collision. Another issue is that you can’t sample points of the cable, which is necessary to place tread links.
Simulated tread links can be optimized by switching to simpler implementation, like animated spline for example and even further to skinned mesh with animated texture and then switching off tread animation completely.
The way I do it in implementation with individual tread links is by using spline component as a path guide. Each track has it’s own spline component, which is looped and manually wrapped around wheels. Control points are placed on top and under each road wheel and around sprocket and idler wheel. Control points over and under wheel are animated, the one around sprocket and idler are static. Each frame I move animated control points follow their corresponding wheel and engine recalculates tangents automatically. Collision object of suspension is big enough to cover both wheel and tread. All tread links are added in constructor as Instanced Static Mesh instances and on each frame distributed along the spline.
To illustrate my previous post:
Even higher fidelity can be achieved by adding more points and raycheking if they are colliding with landscape or road wheels. This is what I want to try before physics based implementation.
But first it’s necessary to find good way how spline animation can be improved so that length of the spline stays constant. With current approach, as control points move, length of the spline changes, which leads to tread links shifting their positions along the spline. One way is to iteratively move control points, which are not locked into collision, up or down until proper length of the spline is achieved. Kind of what they would do as track tension grows. Additionally their tangents should be scaled so that spline get’s less “curvy” as it get’s a higher tension.
Thanks for the reply back. You’ve save me some precious R & D Time. Interestingly, I’m currentlylearning to work with spline components, and I’ve ran into issues with using them in a full loop. I’m currently looking for a solution/workaround.
If your issue is about spline Up vector rotating as it approaches 90 degrees angle, flipping orientation upside down. Then solution is rather simple, you need to get a right vector at location and depending in which direction it’s looking roll the model 180 degrees or leave as it is. I had this issue with tracks and as you can see it works well. At least when mesh elements are separately placed. For generated mesh this might not work.
I was trying to build a more adequate approximation for a collision of wheels/tracks with landscape. What I use right now is SphereTrace, which works ok but obviously collides on sides beyond the tracks and doesn’t cover edges of the track.
First attempt was to use CapsuleTrace and filter-out collisions outside of the middle part (the cylinder), this doesn’t work because you can rotate CapsuleTrace, the capsule shape is always standing up just like one in character component:
https://answers.unrealengine.com/questions/304110/rotate-capsuletrace.html
The next attempt is to use SetLocation with sweep on specially made static mesh which is used only for collision. The results are really bad, outcome of sweep is really glitchy and returns collision points far beyond the area where it was asked to do them. Surprisingly it doesn’t matter what kind of collision primitive you use, custom collision or simple sphere, it’s all the same. I’ve compiled version with this setup if someone is curious to try it, just ride to any of the white platforms and you will see what I mean:
https://answers.unrealengine.com/questions/304110/rotate-capsuletrace.html
I suspect that it’s related to scale of objects, green obstacles are more uniformly and with less amplitude scaled then white ones. But I don’t understand why Line or Sphere trace don’t have such bug.
Simply Amazing. Totally appreciate the Visual. Our illustrations are similar, so, I’m feeling pretty good about myself as I was on the right track! (pun intended). I’m now looking into UE4 Apex Cloth Support for use as Track. The Cloth Physics does have Object/World Collisions/Physics. I do have concerns for pliability adjustment and performance, but, think its worthy of experimentation.
Glad you liked it. Do you think it’s possible to wrap the cloth as a loop? I haven’t tried it yet, might be a good way to do it.
That’s a good idea, haven’t thought of this. First I have to look into efficient way to construct a a chain link and connect them to each other, just to see a general performance impact. The other thing I’m worried about is how it will behave at high velocity, so far all the demos with physics tracks featured slow moving vehicles.
Thats looking really awesome, pretty realistic, for now i can say its spinnig wayy to fast. I hope i’ll be able to give some more crits later, keep up good work
Thank you, Micaki! Criticism is very welcome as for me it’s hard to judge if something is working right or wrong from player experience perspective - after spending last few week working on it you get used to how things work and don’t notice them
I need to get back at some point and double check if engine and drive train are working correctly. According to technical specification M113 have max speed of 65km/h on road and able to climb 31 degrees slope. As I don’t know many of the parameters of actual vehicle, they have to be guesstimated. One thing I had to cheat to get it moving fast enough and climb targeted surface is lower down mass of the drive train and track. I need to calculate a better approximation for this. Another part is friction coefficients, surprisingly enough it’s rather hard to find even ballpark estimations.
Nevertheless, for actual game I won’t be using real vehicle anyway so I can freely setup all parameters for the desired experience. The point of building M113 first is to test that algorithm provides plausible results.
Yeah, that’s my suspicion. I should try this approach to at least make sure that it’s a dead end. It might work just fine for something like Panzer III as they were relatively slow but if I want to build something like this:
then we are looking at speeds way beyond what is achievable by M133 and you already can see how fast the track itself spins at 40km/h.
My other suspicion is related to running algorithm logic at such speeds, even at 60 fps fast moving track might cover rather long distance along the vehicle so overlap events might trigger on/off faster than code would react.
I’m played in your demo and i think its very cool!!!, you do this for your self hobby project or want to sell this in marketplace in future?, also i saw you have particles from dust material when tank move on it, haw did you do that?
Thank you, Zip! I’m not sure about selling it as template. That would require time for technical support for a user base which can potential grow. I rather share it as sort of open project where people could contribute to it if they want and maybe monetize on some very specific implementations, where it’s easier for people to hire someone than spend time on understanding how all of it works. But these are just thoughts, I have only few hours a week to work on all of this.
Regarding the dust. I took standard explosion particle system and modified it a bit - removed everything except smoke, made it larger and with fewer elements. In real-time when I check collision of suspension I get a physics material of the actor with witch collision happened. If that material is “sand” then I check speed of the track and do a probability test if particles should be spawned or not, just to avoid spawning them on every frame. Very crude solution, ideally particles should be spawned ones and then recycled when needed.
thx for replay, i try something similar, but i use one emmiter(don’t spawn it, do only enable/disable and change particles templates) but with this method i have problem, when i change template, my particles immediately disappear ([bug]Immediately Particle disappear problem - FX - Unreal Engine Forums) so i think I try your method with spawn particles (with delay with 0.5 sec),thx
PS epic has c++ vehicle game(with buggy) and this buggy have very good realization of particle spawn but it on c++ and i don’t know how to get it to my vehicle on BP((((
I’m not sure that it’s suppose to work like this. I use particles that I destroyed after their life time run out.
The plan was to use them in the same fashion as cables, faking the front/rear track wheel roll. At the moment I’m working out going beyond 4 wheels with the vehicle template.
Hi BoredEngineer. I would be interested in joining in on open development. If you decided to submit as a ‘Tank’ Template to the marketplace, I would $upport that too. Could use a little advice on this from a Vehicle Physics Guru like yourself:)
I’ve responded in your thread but forgot to respond here
Development update:
I’m not working on new features right now as first priority is to re-factor code. The idea is to have a base abstract class which implements pretty much all of the necessary functionality in slightly generic way. To make an actual vehicle we make a children of this class and change meshes, suspension settings, tracks. In children we can override specific functions of parent, so for example spline animation can be handled in a different way depending on a vehicle type. In parallel I’ve started working on vehicle inspired by Howe and Howe Ripsaw. It’s suspension is rather different to M113 and it helps me in re-factoring my code.
I want to use this opportunity to answer DJMidKnight’s question in this thread: Treaded or Track type vehicle animation help - Character & Animation - Epic Developer Community Forums
just to keep it with the rest of the materials relevant to this project.
Visually my setup looks like this:
Pink spline is used to place links, one of the links is highlighted in yellow.
This is blueprint which animates treads:
- First we calculate new offset for the links using current linear speed of the track
- then we have a for loop from 0 to Amount of links - 1 where we evenly distribute links along the spline and shift their position by offset from previous step
- modulus operator (Division (whole and reminder)) is there to avoid numerical precision when offset is much larger than length of the spline and to handle negative offset when track goes backwards
- GetRightVectorAtDistanceAlongSpline is necessary to detect when looping spline flips upside/down so we can flip track link mesh too
- on the last link element we set Mark Render State Dirty (in UpdateInstanceTransform) so that new transform of instances is pushed to render
They do clip into objects. One of the ways to improve it is to add more control points on spline and ray check their position with both landscape and road wheels. I think this is how it’s done in that T-62 simulator on first page.