Skip to content

Commit 0f630f3

Browse files
committed
attach_to
1 parent 6e7ad28 commit 0f630f3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

scripts/dmodels_animating.dsc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,31 @@ dmodels_catmullrom_proc:
162162
# FVector C = ( t2-t )/( t2-t1 )*B1 + ( t-t1 )/( t2-t1 )*B2;
163163
- determine <[b1].mul[<[t2].sub[<[t]>].div[<[t2].sub[<[t1]>]>]>].add[<[b2].mul[<[t].sub[<[t1]>].div[<[t2].sub[<[t1]>]>]>]>]>
164164

165+
dmodels_attach_to:
166+
type: task
167+
debug: false
168+
definitions: root_entity|target
169+
script:
170+
- if !<[root_entity].is_truthy> || !<[root_entity].has_flag[dmodel_model_id]||false>:
171+
- debug error "[DModels] invalid attach_to root_entity <[root_entity]>"
172+
- stop
173+
- if !<[target].is_truthy> || <[target]> !matches entity:
174+
- debug error "[DModels] invalid attach_to target <[target]>"
175+
- stop
176+
- flag <[root_entity]> dmodels_attached_to:<[target]>
177+
- flag server dmodels_attached.<[root_entity].uuid>:<[root_entity]>
178+
165179
dmodels_animator_world:
166180
type: world
167181
debug: false
168182
events:
169-
on tick server_flagged:dmodels_anim_active:
183+
on tick server_flagged:dmodels_attached priority:-20:
184+
- foreach <server.flag[dmodels_attached]> as:root:
185+
- if <[root].is_spawned||false> && <[root].flag[dmodels_attached_to].is_spawned||false>:
186+
- teleport <[root]> <[root].flag[dmodels_attached_to].location>
187+
- if !<[root].has_flag[dmodels_animation_id]>:
188+
- run dmodels_reset_model_position def.root_entity:<[root]>
189+
on tick server_flagged:dmodels_anim_active priority:-10:
170190
- foreach <server.flag[dmodels_anim_active]> as:root:
171191
- if <[root].is_spawned||false>:
172192
- run dmodels_move_to_frame def.root_entity:<[root]> def.animation:<[root].flag[dmodels_animation_id]> def.timespot:<[root].flag[dmodels_anim_time].div[20]> def.delay_pose:true

scripts/dmodels_main.dsc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@
117117
# animation: The name of the animation to play (as set in BlockBench).
118118
# timespot: The time (in seconds) from the start of the animation to select as the frame.
119119
# delay_pose: 'true' if playing fluidly to offset the pose application over time, 'false' to snap exactly to frame position.
120+
# dmodels_attach_to
121+
# Usage: Attaches a model's position/rotation to an entity.
122+
# Input definitions:
123+
# root_entity: The root entity gotten from 'dmodels_spawn_model'.
124+
# target: The entity to be attached to.
120125
# Flags:
121126
# Every entity spawned by DModels has the flag 'dmodel_root', that refers up to the root entity.
122127
# The root entity has the following flags:

0 commit comments

Comments
 (0)