BoredEngineer / MMT_Content

Machinery Modelling Toolkit is a plugin for UE4
Other
150 stars 43 forks source link

UE5EA support? #9

Open WellyWonder opened 2 years ago

WellyWonder commented 2 years ago

Any chance for UE5EA support?

Dealman commented 2 years ago

You can get it to run in UE5 if you compile it yourself with something like Rider, some minor fixes you'll have to make but the IDE will tell you what to do.

Biggest issue seems to be the Physics Constraints, so far I have been unable to fix it. Not sure if related to Chaos whereas this was made for PhysX, but I thought the 2 would be interoperable.

WellyWonder commented 2 years ago

Dear Lord, 7 months to a reply :'D and not good news either face palm but anyway, I will wait since I have zero knowledge in that matter :S :S hoping for a miracle to fix it to UE5, so far, this is the only matter holding my game from upgrading to UE5

BoredEngineer commented 2 years ago

You can get it to run in UE5 if you compile it yourself with something like Rider, some minor fixes you'll have to make but the IDE will tell you what to do.

Biggest issue seems to be the Physics Constraints, so far I have been unable to fix it. Not sure if related to Chaos whereas this was made for PhysX, but I thought the 2 would be interoperable.

Making it compile and run doesn't actually make it work. Old methods to hook into sub-stepping on physics don't work anymore. Pretty much non of the functions, that get or set data/forces, work anymore. There are some code examples new version of vehicle plugin and modular vehicle that give a pretty clear indication that pretty much all functions need to be re-made and different architecture is regards to sub-step custom physics loop need to be done. And all that work might be for nothing if even more changes will be done to Chaos.

I would like to make a new version of MMT for UE5.0 but currently I'm not sure when this might actually happen.

WellyWonder commented 2 years ago

If I may suggest, I would love if this plugin got EPIC mega grant, cause it deserves it.

Dealman commented 2 years ago

Making it compile and run doesn't actually make it work. Old methods to hook into sub-stepping on physics don't work anymore. Pretty much non of the functions, that get or set data/forces, work anymore. There are some code examples new version of vehicle plugin and modular vehicle that give a pretty clear indication that pretty much all functions need to be re-made and different architecture is regards to sub-step custom physics loop need to be done. And all that work might be for nothing if even more changes will be done to Chaos.

I would like to make a new version of MMT for UE5.0 but currently I'm not sure when this might actually happen.

Fair enough, I've only been toying around with it. But even with the MMT logic disabled, things would fly into the sky and from what I could tell it's due to the Physics Constraints. PC's in general just seems absolutely bonkers in UE5.

I was under the assumption that Chaos was pretty solid now, what with it being battletested by Fortnite for quite a while. I'd be rather surprised if they made any huge breaking changes at this time - but what do I know. It's Epic after all :P

As for sub-stepping, it's quite simple;

if (FPhysScene* PhysScene = GetWorld()->GetPhysicsScene())
{
    PhysScene->OnPhysSceneStep.AddUObject(this, &UMyComponent::MySubstepTickFunction);
}

As far as I'm aware, this only has to be done on BeginPlay as opposed to on Tick, should be a little more optimized? 🤷‍♂️

With all that said, I've used MMT a lot in the past but am nowadays working on my own system as a project to familiarize myself with UE5 C++. Your project is a huge inspiration, hope you don't mind 😅

Been working on the component visualization and suspension, been making decent progress but there's still so much work to be done. Really makes you appreciate the hard work you and 0lento put into this. 🙏 image

BoredEngineer commented 2 years ago

As for sub-stepping, it's quite simple;

That won't be triggered on every physics sub-step, it will be triggered only ones per frame in UE5.

Dealman commented 2 years ago

That won't be triggered on every physics sub-step, it will be triggered only ones per frame in UE5.

Oh... I was following this tutorial. It left out that information :P

Seems like I have some more research to do then. At the very least it enables sub-stepping for the actor.

I guess this explains my confusion when playing around with your plugin trying to learn how you used sub-stepping. I was outputting a counter for the normal tick and your sub-step tick, but they were always the same number. So I guess your method of doing that no longer works in UE5?

Edit:

Okay I've inspected the ChaosVehicles plugin a bit, whew lad. That's quite the rabbit hole. I see what you mean 😅

BoredEngineer commented 2 years ago

Yes, that method in tutorial is valid and a proper way to do sub-stepping in current UE4. What MMT uses is just older method. Both give the same result the difference is binding on BeginPlay vs on Tick. But in UE5 neither of those work. You get a hook to some "pre-physics setup" that is fired ones a frame.

I've hoped that what they use ChaosVehicles plugin would become a standard part of the engine. @0lento pointed me at this PR that was merged into the engine and it looks quite interesting. Most of the necessary functions seam to be there but I didn't dig into where "entry point" for sub-stepping is. Probably in some sort of "manager" class: https://github.com/EpicGames/UnrealEngine/commit/5cdd7b69d542f106544c1c6f598ad5d913b0dca3

Dealman commented 2 years ago

Ooh, that is very interesting indeed. Very nice to see that they're still working on Chaos Vehicles. I just wish they'd add some component visualization, it's so easy to work with and really makes the setup and tweaking process so much easier.

I was looking through ChaosVehicleManager and ChaosVehicleManagerAsyncCallback earlier today, seems like they may contain what you're looking for?

Seems pretty low-level, though and probably way out of my league. I'm just doing basic linetraces and simple math, nothing even remotely as advanced and cool as MMT or Chaos does.

That said, you can make a tank using Chaos Vehicle Plugin. You can disable the mechanical aspect of it and just use the wheel and suspension setups. But you'd have to make your own movement system using forces and whatnot, probably not ideal.

Reason I liked MMT was because it felt realistic, things felt like they had weight and were connected to the ground.

Hopefully we'll be able to do something similar with Chaos Vehicles once it has matured some more and more work been put into this modular system they're working on.

0lento commented 2 years ago

Actual substepping callback is just one thing, I sent earlier PR for MMT_Plugin which hacks the chaos async callback for MMT: https://github.com/BoredEngineer/MMT_Plugin/pull/12 but this only exposes the substepping itself to it and it doesn't make MMT functional on UE5. There's still the issue for getting up-to-date transform data and apparently chaos vehicles also have their own setup for forces. I haven't checked if the force change is required but I did verify that we can't read the per physics step transform data anymore from BodyInstance like we did on UE4 with PhysX: it's not giving updated data on physics substeps.

We had some discussion earlier about this with @BoredEngineer and it appears that best way to go about this could be to just mimic what ChaosVehicles do and try hook our things there if possible. The new modular chaos vehicle thing does seem to have the needed force functions so at this point I'd just suggest to wait and see how that evolves. At this moment it's still WIP and actual chaos vehicles seem to be still using the old approach. Meaning, it's probably good idea to just wait a bit because if the new modular approach lets us reuse existing modules even partially, it could reduce the boilerplate required for MMT to support chaos.

WellyWonder commented 2 years ago

anyone figured out how to replicate this plugin? For some reason M-113 along with the rest of examples don't replicate movement
Am using UE 4.27

Dragomirson commented 1 year ago

https://github.com/Dragomirson/MMT_Plugin_5.0 Complete.

Dealman commented 1 year ago

https://github.com/Dragomirson/MMT_Plugin_5.0 Complete.

Did you fix any of the aforementioned issues, only only the fact that it didn't compile? 🤔

Dragomirson commented 1 year ago

https://github.com/Dragomirson/MMT_Plugin_5.0 Complete.

Did you fix any of the aforementioned issues, only only the fact that it didn't compile? 🤔

The main problem lay in the file MMTBPFunctionLibrary.cpp which prevented the plugin from being compiled. PhyiscsActor.isValid did not work. To do this, I used FPhysicsInterface::isValid(PhyiscsActor).

Dragomirson commented 1 year ago

https://github.com/Dragomirson/MMT_Plugin_5.0 Complete.

Did you fix any of the aforementioned issues, only only the fact that it didn't compile? 🤔

at the moment, after these fixes, my plugin is working.

Dragomirson commented 1 year ago

https://github.com/Dragomirson/MMT_Plugin_5.0 Complete.

Did you fix any of the aforementioned issues, only only the fact that it didn't compile? 🤔

Just to call the functions of the physical actors, now use FPhysicsInterface.

chase03 commented 1 year ago

Doesn't it support UE5.1.0 possible? I failed to recompile in UE5.1.0, and showing "Could not find definition for module 'PhysX', " , "APEX"