AdjustTransformWithDurations

⚠ī¸ All examples in this Observe/Override method ShootEvents.OnEnter to gain access to stateContext.

AdjustTransform

Base class for AdjustTransformWithDurations. Seems to do nothing if passed to adjustTransform scriptable parameter. Do not use: your movement will be blocked indefinitely until you reset adjustTransform.

AdjustTransformWithDurations

Discovered by void*

Request to change player trajectory (view angles) and/or player position.

This code has to be executed in the context where you have access to StateContext for example: https://nativedb.red4ext.com/ShootEvents#OnEnter

Function has 3 types of behavior: set trajectory, set position or set both.

Changing player's trajectory to custom angles

This code will smoothly point your camera towards {0, 0, 0}.

local adjustRequest = AdjustTransformWithDurations.new();

-- Setting any duration to 0 or lower means "do not change"
-- Slide = change player position
-- Rotation = change player rotation / trajectory / viewing angles

adjustRequest:SetSlideDuration(-1.0); -- Disabling position adjustion
adjustRequest:SetRotationDuration(1); -- Rotation show be smooth and should happen in 1 second (presumably, second!)
adjustRequest:SetUseParabolicMotion(true); -- Do not just interpolate movement/rotation, use parabolic formula
adjustRequest:SetCurve(CName.new("None")); -- Setting curve to "None", no other curves were found in the sources
adjustRequest:SetRotation(ToEulerAngles {0, 0, 0}:ToQuat()); -- Setting target player's rotation

stateContext:SetTemporaryScriptableParameter("adjustTransform", adjustRequest, true);
How it looks in-game

Targeting an GameObject for trajectory

  1. Does not change player's pitch.

  2. Seems to target "nearest" targeting component (aka hitbox).

  3. SetRotation is ignored if target is set.

  4. Will freeze player in place/in air while it's aiming (same behavior as LookAt)

local adjustRequest = AdjustTransformWithDurations.new();
   
adjustRequest:SetSlideDuration(-1.0); -- Disabling position adjustion
adjustRequest:SetRotationDuration(1.0); -- Rotation show be smooth and should happen in ~1 second (presumably, seconds!)
adjustRequest:SetUseParabolicMotion(true); -- Do not just interpolate movement/rotation, use parabolic formula
adjustRequest:SetCurve(CName.new("None")); -- Setting curve to "None", no other curves were found in the sources
-- In this case aimAt is a GameObject
adjustRequest:SetTarget(aimAt); -- Setting target player's rotation

stateContext:SetTemporaryScriptableParameter("adjustTransform", adjustRequest, true);

This function seem to use TargetingSystem to find the "best component" and then calls a LookAt.

(Look at this function and this one)

How it looks in-game

Moving player

local adjustRequest = AdjustTransformWithDurations.new();
        
adjustRequest:SetSlideDuration(1.0); -- Setting duration of position change.
adjustRequest:SetRotationDuration(-1.0); -- Disabling rotation adjustion
adjustRequest:SetUseParabolicMotion(true); -- Do not just interpolate movement/rotation, use parabolic formula
adjustRequest:SetCurve(CName.new("None")); -- Setting curve to "None", no other curves were found in the sources

-- Getting player's position
local playerPosition = Game.GetPlayer():GetWorldPosition();
-- Adding 10 on the vertical axis
playerPosition.z = playerPosition.z + 10;

adjustRequest:SetPosition(playerPosition);

stateContext:SetTemporaryScriptableParameter("adjustTransform", adjustRequest, true);
How it looks in-game

Last updated