diff --git a/Source/Engine/Engine/Engine.cpp b/Source/Engine/Engine/Engine.cpp
index 07038f146..58a435cbb 100644
--- a/Source/Engine/Engine/Engine.cpp
+++ b/Source/Engine/Engine/Engine.cpp
@@ -65,6 +65,7 @@ Action Engine::FixedUpdate;
Action Engine::Update;
TaskGraph* Engine::UpdateGraph = nullptr;
Action Engine::LateUpdate;
+Action Engine::LateFixedUpdate;
Action Engine::Draw;
Action Engine::Pause;
Action Engine::Unpause;
@@ -198,6 +199,7 @@ int32 Engine::Main(const Char* cmdLine)
if (Time::OnBeginPhysics())
{
OnFixedUpdate();
+ OnLateFixedUpdate();
Time::OnEndPhysics();
}
@@ -273,6 +275,17 @@ void Engine::OnFixedUpdate()
}
}
+void Engine::OnLateFixedUpdate()
+{
+ PROFILE_CPU_NAMED("Late Fixed Update");
+
+ // Call event
+ LateFixedUpdate();
+
+ // Update services
+ EngineService::OnLateFixedUpdate();
+}
+
void Engine::OnUpdate()
{
PROFILE_CPU_NAMED("Update");
diff --git a/Source/Engine/Engine/Engine.h b/Source/Engine/Engine/Engine.h
index 6f8c5fe6e..31d1f6ea6 100644
--- a/Source/Engine/Engine/Engine.h
+++ b/Source/Engine/Engine/Engine.h
@@ -54,6 +54,11 @@ public:
///
static Action LateUpdate;
+ ///
+ /// Event called after engine update.
+ ///
+ static Action LateFixedUpdate;
+
///
/// Event called during frame rendering and can be used to invoke custom rendering with GPUDevice.
///
@@ -107,6 +112,11 @@ public:
///
static void OnLateUpdate();
+ ///
+ /// Late fixed update callback.
+ ///
+ static void OnLateFixedUpdate();
+
///
/// Draw callback.
///
diff --git a/Source/Engine/Engine/EngineService.cpp b/Source/Engine/Engine/EngineService.cpp
index ac58ba40c..204e926f1 100644
--- a/Source/Engine/Engine/EngineService.cpp
+++ b/Source/Engine/Engine/EngineService.cpp
@@ -33,6 +33,7 @@ static bool CompareEngineServices(EngineService* const& a, EngineService* const&
DEFINE_ENGINE_SERVICE_EVENT(FixedUpdate);
DEFINE_ENGINE_SERVICE_EVENT(Update);
DEFINE_ENGINE_SERVICE_EVENT(LateUpdate);
+DEFINE_ENGINE_SERVICE_EVENT(LateFixedUpdate);
DEFINE_ENGINE_SERVICE_EVENT(Draw);
DEFINE_ENGINE_SERVICE_EVENT_INVERTED(BeforeExit);
diff --git a/Source/Engine/Engine/EngineService.h b/Source/Engine/Engine/EngineService.h
index f4ae1b271..a142455d0 100644
--- a/Source/Engine/Engine/EngineService.h
+++ b/Source/Engine/Engine/EngineService.h
@@ -44,6 +44,7 @@ public:
DECLARE_ENGINE_SERVICE_EVENT(void, FixedUpdate);
DECLARE_ENGINE_SERVICE_EVENT(void, Update);
DECLARE_ENGINE_SERVICE_EVENT(void, LateUpdate);
+ DECLARE_ENGINE_SERVICE_EVENT(void, LateFixedUpdate);
DECLARE_ENGINE_SERVICE_EVENT(void, Draw);
DECLARE_ENGINE_SERVICE_EVENT(void, BeforeExit);
DECLARE_ENGINE_SERVICE_EVENT(void, Dispose);
diff --git a/Source/Engine/Scripting/Script.h b/Source/Engine/Scripting/Script.h
index 2304ea57c..769771f46 100644
--- a/Source/Engine/Scripting/Script.h
+++ b/Source/Engine/Scripting/Script.h
@@ -108,6 +108,13 @@ public:
{
}
+ ///
+ /// Called every fixed framerate frame (after FixedUpdate) if object is enabled.
+ ///
+ API_FUNCTION(Attributes = "NoAnimate") virtual void OnLateFixedUpdate()
+ {
+ }
+
///
/// Called during drawing debug shapes in editor. Use to draw debug shapes and other visualization.
///
diff --git a/Source/Engine/Scripting/Scripting.cpp b/Source/Engine/Scripting/Scripting.cpp
index 8796c7587..bec0e6c20 100644
--- a/Source/Engine/Scripting/Scripting.cpp
+++ b/Source/Engine/Scripting/Scripting.cpp
@@ -46,6 +46,7 @@ public:
void Update() override;
void LateUpdate() override;
void FixedUpdate() override;
+ void LateFixedUpdate() override;
void Draw() override;
void BeforeExit() override;
void Dispose() override;
@@ -100,6 +101,7 @@ namespace
MMethod* _method_Update = nullptr;
MMethod* _method_LateUpdate = nullptr;
MMethod* _method_FixedUpdate = nullptr;
+ MMethod* _method_LateFixedUpdate = nullptr;
MMethod* _method_Draw = nullptr;
MMethod* _method_Exit = nullptr;
Array> _nonNativeModules;
@@ -210,6 +212,12 @@ void ScriptingService::FixedUpdate()
INVOKE_EVENT(FixedUpdate);
}
+void ScriptingService::LateFixedUpdate()
+{
+ PROFILE_CPU_NAMED("Scripting::LateFixedUpdate");
+ INVOKE_EVENT(LateFixedUpdate);
+}
+
void ScriptingService::Draw()
{
PROFILE_CPU_NAMED("Scripting::Draw");
diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs
index 204401867..7a91b2d96 100644
--- a/Source/Engine/Scripting/Scripting.cs
+++ b/Source/Engine/Scripting/Scripting.cs
@@ -80,17 +80,22 @@ namespace FlaxEngine
public static event Action Update;
///
- /// Occurs on scripting 'late' update.
+ /// Occurs on scripting late update.
///
public static event Action LateUpdate;
///
- /// Occurs on scripting `fixed` update.
+ /// Occurs on scripting fixed update.
///
public static event Action FixedUpdate;
///
- /// Occurs on scripting `draw` update. Called during frame rendering and can be used to invoke custom rendering with GPUDevice.
+ /// Occurs on scripting late fixed update.
+ ///
+ public static event Action LateFixedUpdate;
+
+ ///
+ /// Occurs on scripting draw update. Called during frame rendering and can be used to invoke custom rendering with GPUDevice.
///
public static event Action Draw;
@@ -302,6 +307,11 @@ namespace FlaxEngine
FixedUpdate?.Invoke();
}
+ internal static void Internal_LateFixedUpdate()
+ {
+ LateFixedUpdate?.Invoke();
+ }
+
internal static void Internal_Draw()
{
Draw?.Invoke();