summaryrefslogtreecommitdiff
path: root/doc/classes/Animation.xml
blob: a7cae709a4c6165d469ff09cb626fa0024c73261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Animation" inherits="Resource" category="Core" version="3.1">
	<brief_description>
		Contains data used to animate everything in the engine.
	</brief_description>
	<description>
		An Animation resource contains data used to animate everything in the engine. Animations are divided into tracks, and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track.
		[codeblock]
		# This creates an animation that makes the node "Enemy" move to the right by
		# 100 pixels in 1 second.
		var animation = Animation.new()
		var track_index = animation.add_track(Animation.TYPE_VALUE)
		animation.track_set_path(track_index, "Enemy:position.x")
		animation.track_insert_key(track_index, 0.0, 0)
		animation.track_insert_key(track_index, 0.5, 100)
		[/codeblock]
		Animations are just data containers, and must be added to nodes such as an [AnimationPlayer] or [AnimationTreePlayer] to be played back.
	</description>
	<tutorials>
		<link>https://docs.godotengine.org/en/latest/tutorials/animation/index.html</link>
	</tutorials>
	<demos>
	</demos>
	<methods>
		<method name="add_track">
			<return type="int">
			</return>
			<argument index="0" name="type" type="int" enum="Animation.TrackType">
			</argument>
			<argument index="1" name="at_position" type="int" default="-1">
			</argument>
			<description>
				Add a track to the Animation. The track type must be specified as any of the values in the TYPE_* enumeration.
			</description>
		</method>
		<method name="animation_track_get_key_animation" qualifiers="const">
			<return type="String">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="animation_track_insert_key">
			<return type="int">
			</return>
			<argument index="0" name="track" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<argument index="2" name="animation" type="String">
			</argument>
			<description>
			</description>
		</method>
		<method name="animation_track_set_key_animation">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="animation" type="String">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_get_key_end_offset" qualifiers="const">
			<return type="float">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_get_key_start_offset" qualifiers="const">
			<return type="float">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_get_key_stream" qualifiers="const">
			<return type="Resource">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_insert_key">
			<return type="int">
			</return>
			<argument index="0" name="track" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<argument index="2" name="stream" type="Resource">
			</argument>
			<argument index="3" name="start_offset" type="float" default="0">
			</argument>
			<argument index="4" name="end_offset" type="float" default="0">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_set_key_end_offset">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="offset" type="float">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_set_key_start_offset">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="offset" type="float">
			</argument>
			<description>
			</description>
		</method>
		<method name="audio_track_set_key_stream">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="stream" type="Resource">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_get_key_in_handle" qualifiers="const">
			<return type="Vector2">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_get_key_out_handle" qualifiers="const">
			<return type="Vector2">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_get_key_value" qualifiers="const">
			<return type="float">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_insert_key">
			<return type="int">
			</return>
			<argument index="0" name="track" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<argument index="2" name="value" type="float">
			</argument>
			<argument index="3" name="in_handle" type="Vector2" default="Vector2( 0, 0 )">
			</argument>
			<argument index="4" name="out_handle" type="Vector2" default="Vector2( 0, 0 )">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_interpolate" qualifiers="const">
			<return type="float">
			</return>
			<argument index="0" name="track" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_set_key_in_handle">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="in_handle" type="Vector2">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_set_key_out_handle">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="out_handle" type="Vector2">
			</argument>
			<description>
			</description>
		</method>
		<method name="bezier_track_set_key_value">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="value" type="float">
			</argument>
			<description>
			</description>
		</method>
		<method name="clear">
			<return type="void">
			</return>
			<description>
				Clear the animation (clear all tracks and reset all).
			</description>
		</method>
		<method name="copy_track">
			<return type="void">
			</return>
			<argument index="0" name="track" type="int">
			</argument>
			<argument index="1" name="to_animation" type="Animation">
			</argument>
			<description>
				Adds a new track that is a copy of the given track from [code]to_animation[/code].
			</description>
		</method>
		<method name="find_track" qualifiers="const">
			<return type="int">
			</return>
			<argument index="0" name="path" type="NodePath">
			</argument>
			<description>
				Return the index of the specified track. If the track is not found, return -1.
			</description>
		</method>
		<method name="get_track_count" qualifiers="const">
			<return type="int">
			</return>
			<description>
				Return the amount of tracks in the animation.
			</description>
		</method>
		<method name="method_track_get_key_indices" qualifiers="const">
			<return type="PoolIntArray">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="time_sec" type="float">
			</argument>
			<argument index="2" name="delta" type="float">
			</argument>
			<description>
				Return all the key indices of a method track, given a position and delta time.
			</description>
		</method>
		<method name="method_track_get_name" qualifiers="const">
			<return type="String">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
				Return the method name of a method track.
			</description>
		</method>
		<method name="method_track_get_params" qualifiers="const">
			<return type="Array">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
				Return the arguments values to be called on a method track for a given key in a given track.
			</description>
		</method>
		<method name="remove_track">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Remove a track by specifying the track index.
			</description>
		</method>
		<method name="track_find_key" qualifiers="const">
			<return type="int">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<argument index="2" name="exact" type="bool" default="false">
			</argument>
			<description>
				Find the key index by time in a given track. Optionally, only find it if the exact time is given.
			</description>
		</method>
		<method name="track_get_interpolation_loop_wrap" qualifiers="const">
			<return type="bool">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Returns [code]true[/code] if the track at [code]idx[/code] wraps the interpolation loop. Default value: [code]true[/code].
			</description>
		</method>
		<method name="track_get_interpolation_type" qualifiers="const">
			<return type="int" enum="Animation.InterpolationType">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Return the interpolation type of a given track, from the INTERPOLATION_* enum.
			</description>
		</method>
		<method name="track_get_key_count" qualifiers="const">
			<return type="int">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Return the amount of keys in a given track.
			</description>
		</method>
		<method name="track_get_key_time" qualifiers="const">
			<return type="float">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
				Return the time at which the key is located.
			</description>
		</method>
		<method name="track_get_key_transition" qualifiers="const">
			<return type="float">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
				Return the transition curve (easing) for a specific key (see built-in math function "ease").
			</description>
		</method>
		<method name="track_get_key_value" qualifiers="const">
			<return type="Variant">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
				Return the value of a given key in a given track.
			</description>
		</method>
		<method name="track_get_path" qualifiers="const">
			<return type="NodePath">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Get the path of a track. for more information on the path format, see [method track_set_path]
			</description>
		</method>
		<method name="track_get_type" qualifiers="const">
			<return type="int" enum="Animation.TrackType">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Get the type of a track.
			</description>
		</method>
		<method name="track_insert_key">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<argument index="2" name="key" type="Variant">
			</argument>
			<argument index="3" name="transition" type="float" default="1">
			</argument>
			<description>
				Insert a generic key in a given track.
			</description>
		</method>
		<method name="track_is_enabled" qualifiers="const">
			<return type="bool">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Returns [code]true[/code] if the track at index [code]idx[/code] is enabled.
			</description>
		</method>
		<method name="track_is_imported" qualifiers="const">
			<return type="bool">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Return true if the given track is imported. Else, return false.
			</description>
		</method>
		<method name="track_move_down">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Move a track down.
			</description>
		</method>
		<method name="track_move_up">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Move a track up.
			</description>
		</method>
		<method name="track_remove_key">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<description>
				Remove a key by index in a given track.
			</description>
		</method>
		<method name="track_remove_key_at_position">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="position" type="float">
			</argument>
			<description>
				Remove a key by position (seconds) in a given track.
			</description>
		</method>
		<method name="track_set_enabled">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="enabled" type="bool">
			</argument>
			<description>
				Enables/disables the given track. Tracks are enabled by default.
			</description>
		</method>
		<method name="track_set_imported">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="imported" type="bool">
			</argument>
			<description>
				Set the given track as imported or not.
			</description>
		</method>
		<method name="track_set_interpolation_loop_wrap">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="interpolation" type="bool">
			</argument>
			<description>
				If [code]true[/code], the track at [code]idx[/code] wraps the interpolation loop.
			</description>
		</method>
		<method name="track_set_interpolation_type">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="interpolation" type="int" enum="Animation.InterpolationType">
			</argument>
			<description>
				Set the interpolation type of a given track, from the INTERPOLATION_* enum.
			</description>
		</method>
		<method name="track_set_key_transition">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key_idx" type="int">
			</argument>
			<argument index="2" name="transition" type="float">
			</argument>
			<description>
				Set the transition curve (easing) for a specific key (see built-in math function "ease").
			</description>
		</method>
		<method name="track_set_key_value">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="key" type="int">
			</argument>
			<argument index="2" name="value" type="Variant">
			</argument>
			<description>
				Set the value of an existing key.
			</description>
		</method>
		<method name="track_set_path">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="path" type="NodePath">
			</argument>
			<description>
				Set the path of a track. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by ":".
				[b]Example:[/b] "character/skeleton:ankle" or "character/mesh:transform/local".
			</description>
		</method>
		<method name="track_swap">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="with_idx" type="int">
			</argument>
			<description>
			</description>
		</method>
		<method name="transform_track_insert_key">
			<return type="int">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="time" type="float">
			</argument>
			<argument index="2" name="location" type="Vector3">
			</argument>
			<argument index="3" name="rotation" type="Quat">
			</argument>
			<argument index="4" name="scale" type="Vector3">
			</argument>
			<description>
				Insert a transform key for a transform track.
			</description>
		</method>
		<method name="transform_track_interpolate" qualifiers="const">
			<return type="Array">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="time_sec" type="float">
			</argument>
			<description>
				Return the interpolated value of a transform track at a given time (in seconds). An array consisting of 3 elements: position ([Vector3]), rotation ([Quat]) and scale ([Vector3]).
			</description>
		</method>
		<method name="value_track_get_key_indices" qualifiers="const">
			<return type="PoolIntArray">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="time_sec" type="float">
			</argument>
			<argument index="2" name="delta" type="float">
			</argument>
			<description>
				Return all the key indices of a value track, given a position and delta time.
			</description>
		</method>
		<method name="value_track_get_update_mode" qualifiers="const">
			<return type="int" enum="Animation.UpdateMode">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Return the update mode of a value track.
			</description>
		</method>
		<method name="value_track_set_update_mode">
			<return type="void">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<argument index="1" name="mode" type="int" enum="Animation.UpdateMode">
			</argument>
			<description>
				Set the update mode (UPDATE_*) of a value track.
			</description>
		</method>
	</methods>
	<members>
		<member name="length" type="float" setter="set_length" getter="get_length">
			The total length of the animation (in seconds). Note that length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.
		</member>
		<member name="loop" type="bool" setter="set_loop" getter="has_loop">
			A flag indicating that the animation must loop. This is uses for correct interpolation of animation cycles, and for hinting the player that it must restart the animation.
		</member>
		<member name="step" type="float" setter="set_step" getter="get_step">
			The animation step value.
		</member>
	</members>
	<constants>
		<constant name="TYPE_VALUE" value="0" enum="TrackType">
			Value tracks set values in node properties, but only those which can be Interpolated.
		</constant>
		<constant name="TYPE_TRANSFORM" value="1" enum="TrackType">
			Transform tracks are used to change node local transforms or skeleton pose bones. Transitions are Interpolated.
		</constant>
		<constant name="TYPE_METHOD" value="2" enum="TrackType">
			Method tracks call functions with given arguments per key.
		</constant>
		<constant name="TYPE_BEZIER" value="3" enum="TrackType">
		</constant>
		<constant name="TYPE_AUDIO" value="4" enum="TrackType">
		</constant>
		<constant name="TYPE_ANIMATION" value="5" enum="TrackType">
		</constant>
		<constant name="INTERPOLATION_NEAREST" value="0" enum="InterpolationType">
			No interpolation (nearest value).
		</constant>
		<constant name="INTERPOLATION_LINEAR" value="1" enum="InterpolationType">
			Linear interpolation.
		</constant>
		<constant name="INTERPOLATION_CUBIC" value="2" enum="InterpolationType">
			Cubic interpolation.
		</constant>
		<constant name="UPDATE_CONTINUOUS" value="0" enum="UpdateMode">
			Update between keyframes.
		</constant>
		<constant name="UPDATE_DISCRETE" value="1" enum="UpdateMode">
			Update at the keyframes and hold the value.
		</constant>
		<constant name="UPDATE_TRIGGER" value="2" enum="UpdateMode">
			Update at the keyframes.
		</constant>
		<constant name="UPDATE_CAPTURE" value="3" enum="UpdateMode">
		</constant>
	</constants>
</class>