Description
The OnComponentFixedUpdate
property is an event handler that is invoked during the fixed update phase of the component's lifecycle. This phase is typically used for physics-related updates, as it is called at a consistent rate independent of the frame rate. This property allows you to assign a delegate or lambda expression that will be executed during each fixed update cycle.
Usage
To use the OnComponentFixedUpdate
property, assign a method or lambda expression to it. This method will be called every fixed update cycle, allowing you to perform operations that need to be updated consistently, such as physics calculations or other time-sensitive logic.
Example
// Example of using OnComponentFixedUpdate
public class MyComponent : Component
{
public MyComponent()
{
// Assign a lambda expression to OnComponentFixedUpdate
OnComponentFixedUpdate = () =>
{
// Your fixed update logic here
// For example, apply a constant force to a Rigidbody
var rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null)
{
rigidbody.ApplyForce(Vector3.Down * 9.81f);
}
};
}
}