> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/scripting-cyberpunk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/scripting-cyberpunk/scripting/snippets-and-examples/camera/adjusttransformwithdurations.md).

# 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}`.

```lua
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);
```

<details>

<summary>How it looks in-game</summary>

<img src="https://i.imgur.com/iYdWnIZ.gif" alt="" data-size="original">

</details>

#### Targeting an `GameObject` for trajectory

> 1. <mark style="background-color:red;">**Does not change player's pitch.**</mark>
> 2. <mark style="background-color:red;">**Seems to target "nearest" targeting component (aka hitbox).**</mark>
> 3. <mark style="background-color:red;">**`SetRotation`**</mark><mark style="background-color:red;">**&#x20;**</mark><mark style="background-color:red;">**is ignored if target is set.**</mark>
> 4. <mark style="background-color:red;">**Will freeze player in place/in air while it's aiming (same behavior as**</mark> [**`LookAt`**](https://nativedb.red4ext.com/gametargetingTargetingSystem#LookAt)<mark style="background-color:red;">**)**</mark>

```lua
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](https://nativedb.red4ext.com/gametargetingTargetingSystem#GetBestComponentOnTargetObject) function and [this](https://nativedb.red4ext.com/gametargetingTargetingSystem#LookAt) one)

<details>

<summary>How it looks in-game</summary>

![](https://i.imgur.com/YboE9uJ.gif)

</details>

#### Moving player

```lua
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);
```

<details>

<summary>How it looks in-game</summary>

![](https://i.imgur.com/rGlTkSW.gif)

</details>
