unreal.BlueprintSpringMathLibrary

class unreal.BlueprintSpringMathLibrary(outer: Object | None = None, name: Name | str = 'None')

Bases: BlueprintFunctionLibrary

Blueprint Spring Math Library

C++ Source:

  • Module: Engine

  • File: BlueprintSpringMathLibrary.h

classmethod convert_half_life_to_smoothing_time(half_life) float

Convert a halflife to a smoothing time

Parameters:

half_life (float) – The half life of the spring. How long it takes the value to get halfway towards the target.

Returns:

The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate.

Return type:

float

classmethod convert_smoothing_time_to_half_life(smoothing_time) float

Convert a smoothing time to a half life

Parameters:

smoothing_time (float) – The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate.

Returns:

The half life of the spring. How long it takes the value to get halfway towards the target.

Return type:

float

classmethod convert_smoothing_time_to_strength(smoothing_time) float

Convert from smoothing time to spring strength.

Parameters:

smoothing_time (float) – The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate.

Returns:

The spring strength. This corresponds to the undamped frequency of the spring in hz.

Return type:

float

classmethod convert_strength_to_smoothing_time(strength) float

Convert from spring strength to smoothing time.

Parameters:

strength (float) – The spring strength. This corresponds to the undamped frequency of the spring in hz.

Returns:

The smoothing time of the spring in seconds. It is the time by which the output lags the input when critically damped, when the input is changing at a constant rate.

Return type:

float

classmethod critical_spring_damp_angle(out_angle, out_angular_velocity, target_angle, delta_time, smoothing_time=0.200000) -> (out_angle=float, out_angular_velocity=float)

Interpolates the angle InOutAngle towards TargetAngle with the motion of a critically damped spring. The velocity of InOutAngle is stored in InOutAngularVelocity in deg/s.

Parameters:
  • out_angle (float) – The value to be damped in degrees

  • out_angular_velocity (float) – The speed of the value to be damped in deg/s

  • target_angle (float) – The goal to damp towards in degrees

  • delta_time (float) – Timestep in seconds

  • smoothing_time (float) – The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutAngle to TargetX

Returns:

out_angle (float): The value to be damped in degrees

out_angular_velocity (float): The speed of the value to be damped in deg/s

Return type:

tuple

classmethod critical_spring_damp_float(out_x, out_v, target_x, delta_time, smoothing_time=0.200000) -> (out_x=float, out_v=float)

Interpolates the value InOutX towards TargetX with the motion of a critically damped spring. The velocity of X is stored in InOutV.

Parameters:
  • out_x (float) – The value to be damped

  • out_v (float) – The speed of the value to be damped

  • target_x (float) – The goal to damp towards

  • delta_time (float) – Timestep in seconds

  • smoothing_time (float) – The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutX to TargetX

Returns:

out_x (float): The value to be damped

out_v (float): The speed of the value to be damped

Return type:

tuple

classmethod critical_spring_damp_quat(out_rotation, out_angular_velocity, target_rotation, delta_time, smoothing_time=0.200000) -> (out_rotation=Quat, out_angular_velocity=Vector)

Interpolates the value InOutRotation towards TargetRotation with the motion of a critically damped spring. The velocity of InOutRotation is stored in InOutAngularVelocity in deg/s.

Parameters:
  • out_rotation (Quat) – The value to be damped

  • out_angular_velocity (Vector) – The speed of the value to be damped in deg/s

  • target_rotation (Quat) – The goal to damp towards

  • delta_time (float) – Timestep in seconds

  • smoothing_time (float) – The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutRotation to TargetRotation

Returns:

out_rotation (Quat): The value to be damped

out_angular_velocity (Vector): The speed of the value to be damped in deg/s

Return type:

tuple

classmethod critical_spring_damp_rotator(out_rotation, out_angular_velocity, target_rotation, delta_time, smoothing_time=0.200000) -> (out_rotation=Rotator, out_angular_velocity=Vector)

Interpolates the value InOutRotation towards TargetRotation with the motion of a critically damped spring. The velocity of InOutRotation is stored in InOutAngularVelocity in deg/s.

Parameters:
  • out_rotation (Rotator) – The value to be damped

  • out_angular_velocity (Vector) – The speed of the value to be damped in deg/s

  • target_rotation (Rotator) – The goal to damp towards

  • delta_time (float) – Timestep in seconds

  • smoothing_time (float) – The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutRotation to TargetRotation

Returns:

out_rotation (Rotator): The value to be damped

out_angular_velocity (Vector): The speed of the value to be damped in deg/s

Return type:

tuple

classmethod critical_spring_damp_vector(out_x, out_v, target_x, delta_time, smoothing_time=0.200000) -> (out_x=Vector, out_v=Vector)

Interpolates the value InOutX towards TargetX with the motion of a critically damped spring. The velocity of X is stored in InOutV.

Parameters:
  • out_x (Vector) – The value to be damped

  • out_v (Vector) – The speed of the value to be damped

  • target_x (Vector) – The goal to damp towards

  • delta_time (float) – Timestep in seconds

  • smoothing_time (float) – The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutX to TargetX

Returns:

out_x (Vector): The value to be damped

out_v (Vector): The speed of the value to be damped

Return type:

tuple

classmethod critical_spring_damp_vector2d(out_x, out_v, target_x, delta_time, smoothing_time=0.200000) -> (out_x=Vector2D, out_v=Vector2D)

Interpolates the value InOutX towards TargetX with the motion of a critically damped spring. The velocity of X is stored in InOutV.

Parameters:
  • out_x (Vector2D) – The value to be damped

  • out_v (Vector2D) – The speed of the value to be damped

  • target_x (Vector2D) – The goal to damp towards

  • delta_time (float) – Timestep in seconds

  • smoothing_time (float) – The smoothing time to use for the spring. Longer times lead to more damped behaviour. A time of 0 will snap InOutX to TargetX

Returns:

out_x (Vector2D): The value to be damped

out_v (Vector2D): The speed of the value to be damped

Return type:

tuple

classmethod damp_angle(angle, target_angle, delta_time, smoothing_time=0.200000) float

Smooths an angle in degrees using exponential damping towards a target.

Parameters:
  • angle (float) – The angle to be smoothed in degrees

  • target_angle (float) – The target to smooth towards in degrees

  • delta_time (float) – Time interval

  • smoothing_time (float) – Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Return type:

float

classmethod damp_float(value, target, delta_time, smoothing_time=0.200000) float

Smooths a value using exponential damping towards a target.

Parameters:
  • value (float) – The value to be smoothed

  • target (float) – The target to smooth towards

  • delta_time (float) – Time interval

  • smoothing_time (float) – Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Return type:

float

classmethod damp_quat(rotation, target_rotation, delta_time, smoothing_time=0.200000) Quat

Smooths a rotation using exponential damping towards a target.

Parameters:
  • rotation (Quat) – The rotation to be smoothed

  • target_rotation (Quat) – The target to smooth towards

  • delta_time (float) – Time interval

  • smoothing_time (float) – Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Return type:

Quat

classmethod damp_rotator(rotation, target_rotation, delta_time, smoothing_time=0.200000) Rotator

Smooths a value using exponential damping towards a target.

Parameters:
  • rotation (Rotator) – The rotation to be smoothed

  • target_rotation (Rotator) – The target to smooth towards

  • delta_time (float) – Time interval

  • smoothing_time (float) – Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Return type:

Rotator

classmethod damp_vector(value, target, delta_time, smoothing_time=0.200000) Vector

Smooths a value using exponential damping towards a target.

Parameters:
  • value (Vector) – The value to be smoothed

  • target (Vector) – The target to smooth towards

  • delta_time (float) – Time interval

  • smoothing_time (float) – Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Return type:

Vector

classmethod damp_vector2d(value, target, delta_time, smoothing_time=0.200000) Vector2D

Smooths a value using exponential damping towards a target.

Parameters:
  • value (Vector2D) – The value to be smoothed

  • target (Vector2D) – The target to smooth towards

  • delta_time (float) – Time interval

  • smoothing_time (float) – Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Return type:

Vector2D

classmethod spring_character_update(out_position, out_velocity, out_acceleration, target_velocity, delta_time, smoothing_time=0.200000) -> (out_position=Vector, out_velocity=Vector, out_acceleration=Vector)

Update the position of a character given a target velocity using a simple damped spring

Parameters:
  • out_position (Vector) – The position of the character

  • out_velocity (Vector) – The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

  • out_acceleration (Vector) – The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

  • target_velocity (Vector) – The target velocity of the character.

  • delta_time (float) – The delta time to tick the character

  • smoothing_time (float) – The time over which to smooth velocity. It takes roughly the smoothing time in order for the character to reach the target velocity.

Returns:

out_position (Vector): The position of the character

out_velocity (Vector): The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

out_acceleration (Vector): The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

Return type:

tuple

classmethod velocity_spring_character_update(out_position, out_velocity, out_velocity_intermediate, out_acceleration, target_velocity, delta_time, smoothing_time=0.200000, max_acceleration=1.000000) -> (out_position=Vector, out_velocity=Vector, out_velocity_intermediate=Vector, out_acceleration=Vector)

Update a position representing a character given a target velocity using a velocity spring. A velocity spring tracks an intermediate velocity which moves at a maximum acceleration linearly towards a target. This means unlike the “SpringCharacterUpdate”, it will take longer to reach a target velocity that is further away from the current velocity.

Parameters:
  • out_position (Vector) – The position of the character

  • out_velocity (Vector) – The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

  • out_velocity_intermediate (Vector) – The intermediate velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

  • out_acceleration (Vector) – The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

  • target_velocity (Vector) – The target velocity of the character.

  • delta_time (float) – The delta time to tick the character

  • smoothing_time (float) – The time over which to smooth velocity. It takes roughly the smoothing time in order for the character to reach the target velocity.

  • max_acceleration (float) – Puts a limit on the maximum acceleration that the intermediate velocity can do each frame. If MaxAccel is very large, the behaviour wil lbe the same as SpringCharacterUpdate

Returns:

out_position (Vector): The position of the character

out_velocity (Vector): The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

out_velocity_intermediate (Vector): The intermediate velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

out_acceleration (Vector): The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller.

Return type:

tuple

classmethod velocity_spring_damp_float(out_x, out_v, out_vi, target_x, max_speed, delta_time, smoothing_time=0.200000) -> (out_x=float, out_v=float, out_vi=float)

A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behavior. A SmoothingTime of 0 will give a linear interpolation between X and TargetX

Parameters:
  • out_x (float) – The value to be damped

  • out_v (float) – The velocity of the value to be damped

  • out_vi (float) – The intermediate target velocity of the value to be damped

  • target_x (float) – The target value of X to damp towards

  • max_speed (float) – The desired speed to achieve while damping towards X

  • delta_time (float) – The timestep in seconds

  • smoothing_time (float) – The smoothing time to use while damping towards X. Higher values will give more smoothed behaviour. A value of 0 will give a linear interpolation of X to Target

Returns:

out_x (float): The value to be damped

out_v (float): The velocity of the value to be damped

out_vi (float): The intermediate target velocity of the value to be damped

Return type:

tuple

classmethod velocity_spring_damp_vector(out_x, out_v, out_vi, target_x, max_speed, delta_time, smoothing_time=0.200000) -> (out_x=Vector, out_v=Vector, out_vi=Vector)

A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behavior. A SmoothingTime of 0 will give a linear interpolation between X and TargetX

Parameters:
  • out_x (Vector) – The value to be damped

  • out_v (Vector) – The velocity of the value to be damped

  • out_vi (Vector) – The intermediate target velocity of the value to be damped

  • target_x (Vector) – The target value of X to damp towards

  • max_speed (float) – The desired speed to achieve while damping towards X

  • delta_time (float) – The timestep in seconds

  • smoothing_time (float) – The smoothing time to use while damping towards X. Higher values will give more smoothed behaviour. A value of 0 will give a linear interpolation of X to Target

Returns:

out_x (Vector): The value to be damped

out_v (Vector): The velocity of the value to be damped

out_vi (Vector): The intermediate target velocity of the value to be damped

Return type:

tuple

classmethod velocity_spring_damp_vector2d(out_x, out_v, out_vi, target_x, max_speed, delta_time, smoothing_time=0.200000) -> (out_x=Vector2D, out_v=Vector2D, out_vi=Vector2D)

A velocity spring will damp towards a target that follows a fixed linear target velocity, allowing control of the interpolation speed while still giving a smoothed behavior. A SmoothingTime of 0 will give a linear interpolation between X and TargetX

Parameters:
  • out_x (Vector2D) – The value to be damped

  • out_v (Vector2D) – The velocity of the value to be damped

  • out_vi (Vector2D) – The intermediate target velocity of the value to be damped

  • target_x (Vector2D) – The target value of X to damp towards

  • max_speed (float) – The desired speed to achieve while damping towards X

  • delta_time (float) – The timestep in seconds

  • smoothing_time (float) – The smoothing time to use while damping towards X. Higher values will give more smoothed behaviour. A value of 0 will give a linear interpolation of X to Target

Returns:

out_x (Vector2D): The value to be damped

out_v (Vector2D): The velocity of the value to be damped

out_vi (Vector2D): The intermediate target velocity of the value to be damped

Return type:

tuple