Skip to content

UMjPerturbation

Mouse-driven body perturbation matching MuJoCo simulate's behaviour.

Input gestures (mirrored from upstream simulate): - Double-click LMB on a body → select (no force applied). - Ctrl + RMB drag with selection → translate (virtual position spring). - Ctrl + LMB drag with selection → rotate (virtual orientation spring). - Release button → stop drag; selection persists. Uses MuJoCo's own mjv_applyPerturbForce every physics pre-step to convert refpos/refquat/refselpos into xfrc_applied — identical spring feel to simulate. The plugin-side code only has to manage the reference positions/orientations from UE mouse input.

Attribute Value
Kind Class
UE Macro UCLASS
Inherits UActorComponent
Blueprint Spawnable ✅ Yes

Properties

Private Properties

Property Type Description
Manager AAMjManager* Cached manager (owner).
ClickHitWorldUE FVector Click-time state used to re-derive refpos each frame.

Manager

Cached manager (owner).

ClickHitWorldUE

Click-time state used to re-derive refpos each frame.

  • Type: FVector

Functions

Public Functions

General

Function Returns Description
HandleSelect() void Line-trace from the cursor and, if a body is hit, latch selection.
StartTranslate() void Begin a translate drag (Ctrl+RMB press with a body selected).
StartRotate() void Begin a rotate drag (Ctrl+LMB press with a body selected).
UpdateDrag() void Update drag refpos/refselpos/refquat from current cursor + per-frame
StopDrag() void Stop the current drag (mouse release). Selection persists.
HasSelection() bool Is a body currently latched (pert.select > 0)?
IsDragging() bool Is a drag currently active (LMB/RMB held)?
HandleSelect

Line-trace from the cursor and, if a body is hit, latch selection.

  • Signature: HandleSelect(const FVector& CursorOrigin, const FVector& CursorDirection)
StartTranslate

Begin a translate drag (Ctrl+RMB press with a body selected).

  • Signature: StartTranslate(const FVector& CursorOrigin, const FVector& CursorDirection)
StartRotate

Begin a rotate drag (Ctrl+LMB press with a body selected).

  • Signature: StartRotate()
UpdateDrag

Update drag refpos/refselpos/refquat from current cursor + per-frame

  • Signature: UpdateDrag(const FVector& CursorOrigin, const FVector& CursorDirection, float MouseDx, float MouseDy)
StopDrag

Stop the current drag (mouse release). Selection persists.

  • Signature: StopDrag()
HasSelection

Is a body currently latched (pert.select > 0)?

  • Signature: HasSelection()
  • Returns: bool
IsDragging

Is a drag currently active (LMB/RMB held)?

  • Signature: IsDragging()
  • Returns: bool

Private Functions

General

Function Returns Description
ResolveBodyIdFromActor() int32 Resolve a hit actor to a MuJoCo body_id. Returns <=0 if no match.
DrawDebugSpring() void Draw a debug line from the world selection point to the ref target.
ResolveBodyIdFromActor

Resolve a hit actor to a MuJoCo body_id. Returns <=0 if no match.

  • Signature: ResolveBodyIdFromActor(const class AActor* Actor, const FVector& HitWorldUE)
  • Returns: int32
DrawDebugSpring

Draw a debug line from the world selection point to the ref target.

  • Signature: DrawDebugSpring()