Need some help organizing my code (Custom movement and collision solving)

Hi guys! This is my first post here.

The game I’m currently prototyping involves lots of pushing objects mechanics in a gamey, non-realistic way. So I don’t want inertia, angular movement or anything like that in my “physics”, just collision solving based on the Minimum Translation Direction vector and the relative masses of the overlapped objects.

I already have a first draft of the system working and now I want to refactor my code and distribute it into reusable UComponent classes. The most obvious way to do so, I think would be to have a UMyCustomMovementComponent that updates the position and a UMyCustomCollisionSolvingComponent that solves the collision after that. To make sure that their respective Ticks happens on the expected order I would add the Actor Tick as a prerequisite for the UMyCustomMovementComponent Tick, and the UMyCustomMovementComponent Tick as a prerequisite for the UMyCustomCollisionSolvingComponent Tick.

The problem I’m facing with that is that some objects would still update, move and solve their collision before the others, wich can lead to some unwanted behaviours. And even worse, those unwanted behaviours would be framerate dependant.

So, ideally, what I want is to update all my Actors Ticks (and my Logic components), then update all my UMyCustomMovementComponent Ticks and after that update all my UMyCustomCollisionSolvingComponent Ticks.
What is the best way to setup this ?

Seems like UE has the concept of components, but doesn’t lets you write your own custom systems. Am I wrong ? Is there any way to iterate over all the components of a specific class?
Maybe I should use custom events instead of Ticks ? If so, where should I store and manage them ? Into a custom Actor that acts as a custom framework ? Into my GameMode ?

Thank you for reading. And sorry for my English.

There’s two methods I can think of. One is what I think you’ve already mentioned - you have a CollisionSolverManager actor or something that all the relevant Actors register themselves with, and that ticks all the movement and then does the collision solving.

The other method is to put the Components in different TickGroups. All Actors and Components in one TickGroup are ticked before ones in later groups, so you can be sure of your ordering that way. If you don’t mind making changes to the engine then you can add in extra tick groups if there aren’t enough. Actually if you’re going the CollisionSolverManager route then you’d probably want to put that in a different TickGroup to the Actors anyway.

Hope that helps.

Hi Stormharrier. Thanks for your answer.

Adding custom TickGroups is probably the best solution. Seems very easy to do, just have to add the new TickGroup to the ETickingGroup enum and then call RunTickGroup(TG_MyCustomTick) in UWorld::Tick.
But I wanted to avoid modifying the Engine itself if possible. It’s a very little change but I would have to deal with compiling the Engine myself, loosing the hability to update the Engine from the launcher and having to deal with merge conflicts myself, which sounds kinda scary.

Would be great if Epic give us a built in way to add custom TickGroups, though.

I already have a working version with custom Events in my GameMode, but it has it’s own problems and I’m not very happy with it, so maybe it’s just a matter of trying both approaches and see which is better.