Exposing UE5 TickPhysicsAsync Event

I can’t seem to replicate the issue where you aren’t returned the correct transform, it seems to work fine for me. Are you able to send me the tests you did so I can try and replicate it?

With ATP_SetWorldLocation it sets the absolute position so it works as intended in terms of moving it at the centre of mass as the pivot, if you wanted to use it to just lock an axis I’d recommend using a physics constraint which can be done at runtime like this: Lock Rotation Axis at Runtime | Unreal engine Code Snippet

Thanks for the reply ! Yes, ATP_SetWorldLocation works fine if you want to moving Object with Center of Mass as the pivot. So if I want to set its Location with himself, I need to use Center of Mass as a Target and not the Transform with ATP_GetTransform.

I send you the Test Project. Blue cubes have no offset, White cubes have an offset, and Red cubes use Center of Mass as a Target. But I think that in the end, everything is coherent. I just need to integrate the fact that ATP_Set WorldLocation use the center of mass as the pivot !

Thanks for this Plugin, it really helps me with my game !

Project : WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free

I’m sorry for such trivial question. I’ve tried downloading the plugin AsyncTickPhysics from github. I’ve put it into Plugins folder in my project directory. I added this plugin to .uproject file under plugins. I’ve rebuild solution. I see it in Plugins inside of UE and also in my Solution Explorer in Visual studio but I still can’t add the header file to my Pawn class which I want to inherit from AsyncTickPawn. I just get an error "Cannot open source file “AsyncTickPawn.h” "… Is there something I am missing?

Have you added the plugin into your Build.cs file?

PrivateDependencyModuleNames.AddRange(new string[] { "AsyncTickPhysics" });

Thank You for reply. Indeed I havent added that, unfortunatelly it didnt solve the problem… I still cannot add the header file #include “AsyncTickPhysics.h”

that’s weird, if its enabled in your uproject file and inside the build.cs i dont see why it should be throwing that error. Have you regenerated your project files again? is it an intellisense error or an actual build error?

Thank You for Your response. It wasn’t a build error but just seemed lit VS doesn’t see the classes. I came back to the project after couple of days and all of a sudden it works.

I have one question though. Does this library provide me with something similar as Unity’s FixedUpdate? I am doing custom physics calculations but all I need to have is fixed timestep. I hoped that if I derive from AAsyncTickPawn in tick function deltaTime would be fixed but doesn’t seem like it. Could You point me to how could I achieve this?
Thanks!

I believe it is similar to unity’s FixedUpdate, you need to override the NativeAsyncTick function if you are using C++ and the deltatime should be fixed. If it isn’t you need to make sure it’s enabled inside your project settings. These are the settings I use inside my game:

Hello, I want to say that this does not work with Blueprints. Except I am doing something wrong.


These are my physics settings.

The problem here is that the Blueprint is not ticked by the async thread rather than the normal tick (i haven’t tested a c++ vehicle tbh). You can see this when you print out the delta time and in addition in the async tick the NumTicks / GameTimeSecond.

grafik

grafik

You will see that you get half the speed of your actor as you process half the force within a normal frame. This is crucial as with smooth framerate enabled your whole friction algorithm falls apart. When you game has a variable framerate it is also not working.

Btw.: Substepping is indeed working, try it out. Simply enable it in addition to my settings. But here other problems arise: When you set the MaxSubsteps to 1 you have the slow motion back, when you set it to 2 your springforces are…doubled?

*Uh forgot to mention: Its UE5.0.3

I recreated your number of ticks counter and for me it’s working correctly. Setting my Async Fixed Time Step Size to 0,01 gives me 100 ticks/sec, setting it to 0,005 gives me 200 ticks/sec.

I think your Max Physics Delta Time is set too low. Currently if your framerate gets below 120fps, the game engine will slow the whole game down to be able to tick 120 times per one game time second. And if your Fixed Frame Rate is set 60, your game is never going to reach 120fps.

In my project I have set my Max Physics Delta Time to 0,033333 (30fps) and Async Fixed Time Step Size to 0,01.
So as long as my framerate stays above 30fps, the Async Tick is going to fire 100 times per sec.
If my framerate gets below 30fps, let’s say 15fps, then my game will run at 0.5x speed (slow motion) and Async Tick would fire 50 times per real life second. But since the game is running at 0.5x speed, the Async Tick is still firing 100 times per game time second and all the physics and forces should still work similarly.

I hope I understood your problem correctly and this helps you.
And sorry for possibly unclear explanation. English is not first language.

1 Like

Hello,

I’m testing AsyncThickPhysics Plugin on my game project. Most of the time I get excellent results, but I’m experiencing weird glitches on physics sometimes.

Here’s video about the issue: physics-bug

I think I have tested all possible physics settings of the ball, physics materials and project settings…

I get the best results (except these random glitches) with following project settings:

I have also reduced Async Fixed Time Step Size to 0,01 and 0,005, but it’s not heping. For some reason 0,0025 gives best results for me.

Any suggestions on how to solve the problem?

Do you have CCD enabled for the ball or other moving components? I was having a bit similar issues on my project when CCD was enabled. After disabling CCD the problem went away.
CCD just doesn’t seem to work well in UE5 :confused:

I have not used Substepping and Tick Physics Async simultaneously so I don’t know if that could cause some issues too. (Do you even need Substepping when using Tick Physics Async?)
So maybe also try disabling Substepping and see what kind of results you are getting?

Thanks for the answer Jant.

I think the problem was in the Ball torque- and inertia settings… All good now.
I updated project now from 5.0 to 5.1 and disabled Async completely, but the bug still happened, so I decided to start from the clean table completely. My previous Ball Physics settings worked nicely in 4.26, but at the same time I updated project to 5.0 I started to utilize Async, so I assumed the problem could be there instead of ball settings.

1 Like

Hey @Claigo

thanks for the plugin.

I have a case where i have 4 wheels of type SceneComponent attached to a custom car body of type “AAsyncTickPawn” and there is no way to set wheels location and rotation from the Async Tick Physics update because engine crashes.

In the ATP plugin you have this function:

void UAsyncTickFunctions::ATP_SetWorldLocation(UPrimitiveComponent* Component, FVector Location);

but the wheels are SceneComponent. Would it be possible to create a function in general that updates a Scene Component as you do with the UPrimitiveComponent ?

Cheers !

Hi,

If you are just wanting to set a SceneComponents Location on the AsyncTick I would suggest just using the original SetWorldLocation node as the Physics Thread doesn’t hold a handle to SceneComponents, if you wanted the function to be changed for convenience sake you could edit it to be like this:

AsyncTickFunction.h Line 48

static void ATP_SetWorldLocation(USceneComponent* Component, FVector Location);

AsyncTickFunctions.cpp Line 162

void UAsyncTickFunctions::ATP_SetWorldLocation(USceneComponent* Component, FVector Location)
{
	if(!Component)
		return;

	if(UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(Component))
	{
		if(Chaos::FRigidBodyHandle_Internal* RigidHandle = GetInternalHandle(PrimitiveComponent))
		{
			const Chaos::FVec3 P = Location - RigidHandle->R().RotateVector(RigidHandle->CenterOfMass());
			RigidHandle->SetX(P);
		}
	}
	else
	{
		Component->SetWorldLocation(Location);
	}
}

Hi,

well simply calling Component->SetWorldLocation(Location); from the async tick crashes the engine so it is not possible. Calling that method from the normal Tick method works but the wheels jitter from time to time !

Wheel are parented to the car body and they suppose to move only on suspension direction but they also fall behind a little from time to time.

Any idea why in such case those wheels would seem desynced with the car from time to time !?

Hello ! I get this error message every time my game has been running for a few seconds. And I don’t know what it is or what to do. Anyone understand this ?

Assertion failed: IsInGameThread() [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Public\EngineUtils.h] [Line: 193]

UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_Engine
UnrealEditor_AsyncTickPhysics!AAsyncTickPawn::AsyncTick() [C:\Users\emile\Documents\Unreal Projects\ChessGun\Plugins\AsyncTickPhysics\Intermediate\Build\Win64\UnrealEditor\Inc\AsyncTickPhysics\AsyncTickPawn.gen.cpp:23]
UnrealEditor_AsyncTickPhysics!FAsyncPhysicsCallback::OnPreSimulate_Internal() [C:\Users\emile\Documents\Unreal Projects\ChessGun\Plugins\AsyncTickPhysics\Source\AsyncTickPhysics\Private\AsyncTickCallback.cpp:19]
UnrealEditor_Chaos
UnrealEditor_Chaos
UnrealEditor_Chaos
UnrealEditor_Chaos
UnrealEditor_Chaos
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
kernel32
ntdll

Hello Claigo, thanks a lot for your awesome plugin! I would like to know if its possible to implement the add force function with bone to the plugin. I have a huge ragdoll im controlling with forces and would like to use substepping for that.

Many thanks in advance.
Best regards

Looks like you are calling a function inside the async tick which can only be called on the game thread, you need to be careful on what you call during the async tick!

Sure, I’ve updated the github to allow the bone name to be specified for most of the functions now: Added BoneNames for most functions · Mr-Craig/AsyncTickPhysics@bd37555 · GitHub

2 Likes