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
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
|
KX_GameObject(SCA_IObject)
==========================
.. module:: bge.types
base class --- :class:`SCA_IObject`
.. class:: KX_GameObject(SCA_IObject)
All game objects are derived from this class.
Properties assigned to game objects are accessible as attributes of this class.
.. note::
Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError,
if an object may have been removed since last accessing it use the :data:`invalid` attribute to check.
KX_GameObject can be subclassed to extend functionality. For example:
.. code-block:: python
import bge
class CustomGameObject(bge.types.KX_GameObject):
RATE = 0.05
def __init__(self, old_owner):
# "old_owner" can just be ignored. At this point, "self" is
# already the object in the scene, and "old_owner" has been
# destroyed.
# New attributes can be defined - but we could also use a game
# property, like "self['rate']".
self.rate = CustomGameObject.RATE
def update(self):
self.worldPosition.z += self.rate
# switch direction
if self.worldPosition.z > 1.0:
self.rate = -CustomGameObject.RATE
elif self.worldPosition.z < 0.0:
self.rate = CustomGameObject.RATE
# Called first
def mutate(cont):
old_object = cont.owner
mutated_object = CustomGameObject(cont.owner)
# After calling the constructor above, references to the old object
# should not be used.
assert(old_object is not mutated_object)
assert(old_object.invalid)
assert(mutated_object is cont.owner)
# Called later - note we are now working with the mutated object.
def update(cont):
cont.owner.update()
When subclassing objects other than empties and meshes, the specific type
should be used - e.g. inherit from :class:`BL_ArmatureObject` when the object
to mutate is an armature.
.. attribute:: name
The object's name. (read-only).
:type: string
.. attribute:: mass
The object's mass
:type: float
.. note::
The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0.
.. attribute:: linVelocityMin
Enforces the object keeps moving at a minimum velocity.
:type: float
.. note::
Applies to dynamic and rigid body objects only.
.. note::
A value of 0.0 disables this option.
.. note::
While objects are stationary the minimum velocity will not be applied.
.. attribute:: linVelocityMax
Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
:type: float
.. note::
Applies to dynamic and rigid body objects only.
.. note::
A value of 0.0 disables this option (rather then setting it stationary).
.. attribute:: localInertia
the object's inertia vector in local coordinates. Read only.
:type: list [ix, iy, iz]
.. attribute:: parent
The object's parent object. (read-only).
:type: :class:`KX_GameObject` or None
.. attribute:: groupMembers
Returns the list of group members if the object is a group object, otherwise None is returned.
:type: :class:`CListValue` of :class:`KX_GameObject` or None
.. attribute:: groupObject
Returns the group object that the object belongs to or None if the object is not part of a group.
:type: :class:`KX_GameObject` or None
.. attribute:: collisionCallbacks
A list of callables to be run when a collision occurs.
:type: list
.. attribute:: scene
The object's scene. (read-only).
:type: :class:`KX_Scene` or None
.. attribute:: visible
visibility flag.
:type: boolean
.. note::
Game logic will still run for invisible objects.
.. attribute:: record_animation
Record animation for this object.
:type: boolean
.. attribute:: color
The object color of the object. [r, g, b, a]
:type: :class:`mathutils.Vector`
.. attribute:: occlusion
occlusion capability flag.
:type: boolean
.. attribute:: position
The object's position. [x, y, z] On write: local position, on read: world position
.. deprecated:: use :data:`localPosition` and :data:`worldPosition`.
:type: :class:`mathutils.Vector`
.. attribute:: orientation
The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector. On write: local orientation, on read: world orientation
.. deprecated:: use :data:`localOrientation` and :data:`worldOrientation`.
:type: :class:`mathutils.Matrix`
.. attribute:: scaling
The object's scaling factor. [sx, sy, sz] On write: local scaling, on read: world scaling
.. deprecated:: use :data:`localScale` and :data:`worldScale`.
:type: :class:`mathutils.Vector`
.. attribute:: localOrientation
The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
:type: :class:`mathutils.Matrix`
.. attribute:: worldOrientation
The object's world orientation. 3x3 Matrix.
:type: :class:`mathutils.Matrix`
.. attribute:: localScale
The object's local scaling factor. [sx, sy, sz]
:type: :class:`mathutils.Vector`
.. attribute:: worldScale
The object's world scaling factor. [sx, sy, sz]
:type: :class:`mathutils.Vector`
.. attribute:: localPosition
The object's local position. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: worldPosition
The object's world position. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: localTransform
The object's local space transform matrix. 4x4 Matrix.
:type: :class:`mathutils.Matrix`
.. attribute:: worldTransform
The object's world space transform matrix. 4x4 Matrix.
:type: :class:`mathutils.Matrix`
.. attribute:: localLinearVelocity
The object's local linear velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: worldLinearVelocity
The object's world linear velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: localAngularVelocity
The object's local angular velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: worldAngularVelocity
The object's world angular velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: timeOffset
adjust the slowparent delay at runtime.
:type: float
.. attribute:: state
the game object's state bitmask, using the first 30 bits, one bit must always be set.
:type: int
.. attribute:: meshes
a list meshes for this object.
:type: list of :class:`KX_MeshProxy`
.. note::
Most objects use only 1 mesh.
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: sensors
a sequence of :class:`SCA_ISensor` objects with string/index lookups and iterator support.
:type: list
.. note::
This attribute is experemental and may be removed (but probably wont be).
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: controllers
a sequence of :class:`SCA_IController` objects with string/index lookups and iterator support.
:type: list of :class:`SCA_ISensor`
.. note::
This attribute is experemental and may be removed (but probably wont be).
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: actuators
a list of :class:`SCA_IActuator` with string/index lookups and iterator support.
:type: list
.. note::
This attribute is experemental and may be removed (but probably wont be).
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: attrDict
get the objects internal python attribute dictionary for direct (faster) access.
:type: dict
.. attribute:: children
direct children of this object, (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`'s
.. attribute:: childrenRecursive
all children of this object including childrens children, (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`'s
.. attribute:: life
The number of seconds until the object ends, assumes 50fps.
(when added with an add object actuator), (read-only).
:type: float
.. method:: endObject()
Delete this object, can be used in place of the EndObject Actuator.
The actual removal of the object from the scene is delayed.
.. method:: replaceMesh(mesh, useDisplayMesh=True, usePhysicsMesh=False)
Replace the mesh of this object with a new mesh. This works the same was as the actuator.
:arg mesh: mesh to replace or the meshes name.
:type mesh: :class:`MeshProxy` or string
:arg useDisplayMesh: when enabled the display mesh will be replaced (optional argument).
:type useDisplayMesh: boolean
:arg usePhysicsMesh: when enabled the physics mesh will be replaced (optional argument).
:type usePhysicsMesh: boolean
.. method:: setVisible(visible, recursive)
Sets the game object's visible flag.
:arg visible: the visible state to set.
:type visible: boolean
:arg recursive: optional argument to set all childrens visibility flag too.
:type recursive: boolean
.. method:: setOcclusion(occlusion, recursive)
Sets the game object's occlusion capability.
:arg occlusion: the state to set the occlusion to.
:type occlusion: boolean
:arg recursive: optional argument to set all childrens occlusion flag too.
:type recursive: boolean
.. method:: alignAxisToVect(vect, axis=2, factor=1.0)
Aligns any of the game object's axis along the given vector.
:arg vect: a vector to align the axis.
:type vect: 3D vector
:arg axis: The axis you want to align
* 0: X axis
* 1: Y axis
* 2: Z axis
:type axis: integer
:arg factor: Only rotate a feaction of the distance to the target vector (0.0 - 1.0)
:type factor: float
.. method:: getAxisVect(vect)
Returns the axis vector rotates by the objects worldspace orientation.
This is the equivalent of multiplying the vector by the orientation matrix.
:arg vect: a vector to align the axis.
:type vect: 3D Vector
:return: The vector in relation to the objects rotation.
:rtype: 3d vector.
.. method:: applyMovement(movement, local=False)
Sets the game object's movement.
:arg movement: movement vector.
:type movement: 3D Vector
:arg local:
* False: you get the "global" movement ie: relative to world orientation.
* True: you get the "local" movement ie: relative to object orientation.
:arg local: boolean
.. method:: applyRotation(rotation, local=False)
Sets the game object's rotation.
:arg rotation: rotation vector.
:type rotation: 3D Vector
:arg local:
* False: you get the "global" rotation ie: relative to world orientation.
* True: you get the "local" rotation ie: relative to object orientation.
:arg local: boolean
.. method:: applyForce(force, local=False)
Sets the game object's force.
This requires a dynamic object.
:arg force: force vector.
:type force: 3D Vector
:arg local:
* False: you get the "global" force ie: relative to world orientation.
* True: you get the "local" force ie: relative to object orientation.
:type local: boolean
.. method:: applyTorque(torque, local=False)
Sets the game object's torque.
This requires a dynamic object.
:arg torque: torque vector.
:type torque: 3D Vector
:arg local:
* False: you get the "global" torque ie: relative to world orientation.
* True: you get the "local" torque ie: relative to object orientation.
:type local: boolean
.. method:: getLinearVelocity(local=False)
Gets the game object's linear velocity.
This method returns the game object's velocity through it's centre of mass, ie no angular velocity component.
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
:type local: boolean
:return: the object's linear velocity.
:rtype: list [vx, vy, vz]
.. method:: setLinearVelocity(velocity, local=False)
Sets the game object's linear velocity.
This method sets game object's velocity through it's centre of mass,
ie no angular velocity component.
This requires a dynamic object.
:arg velocity: linear velocity vector.
:type velocity: 3D Vector
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
:type local: boolean
.. method:: getAngularVelocity(local=False)
Gets the game object's angular velocity.
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
:type local: boolean
:return: the object's angular velocity.
:rtype: list [vx, vy, vz]
.. method:: setAngularVelocity(velocity, local=False)
Sets the game object's angular velocity.
This requires a dynamic object.
:arg velocity: angular velocity vector.
:type velocity: boolean
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
.. method:: getVelocity(point=(0, 0, 0))
Gets the game object's velocity at the specified point.
Gets the game object's velocity at the specified point, including angular
components.
:arg point: optional point to return the velocity for, in local coordinates.
:type point: 3D Vector
:return: the velocity at the specified point.
:rtype: list [vx, vy, vz]
.. method:: getReactionForce()
Gets the game object's reaction force.
The reaction force is the force applied to this object over the last simulation timestep.
This also includes impulses, eg from collisions.
:return: the reaction force of this object.
:rtype: list [fx, fy, fz]
.. note::
This is not implimented at the moment.
.. method:: applyImpulse(point, impulse, local=False)
Applies an impulse to the game object.
This will apply the specified impulse to the game object at the specified point.
If point != position, applyImpulse will also change the object's angular momentum.
Otherwise, only linear momentum will change.
:arg point: the point to apply the impulse to (in world or local coordinates)
:type point: point [ix, iy, iz] the point to apply the impulse to (in world or local coordinates)
:arg impulse: impulse vector.
:type impulse: 3D Vector
:arg local:
* False: you get the "global" impulse ie: relative to world coordinates with world orientation.
* True: you get the "local" impulse ie: relative to local coordinates with object orientation.
:type local: boolean
.. method:: suspendDynamics()
Suspends physics for this object.
.. method:: restoreDynamics()
Resumes physics for this object.
.. note::
The objects linear velocity will be applied from when the dynamics were suspended.
.. method:: enableRigidBody()
Enables rigid body physics for this object.
Rigid body physics allows the object to roll on collisions.
.. method:: disableRigidBody()
Disables rigid body physics for this object.
.. method:: setParent(parent, compound=True, ghost=True)
Sets this object's parent.
Control the shape status with the optional compound and ghost parameters:
In that case you can control if it should be ghost or not:
:arg parent: new parent object.
:type parent: :class:`KX_GameObject`
:arg compound: whether the shape should be added to the parent compound shape.
* True: the object shape should be added to the parent compound shape.
* False: the object should keep its individual shape.
:type compound: boolean
:arg ghost: whether the object should be ghost while parented.
* True: if the object should be made ghost while parented.
* False: if the object should be solid while parented.
:type ghost: boolean
.. note::
If the object type is sensor, it stays ghost regardless of ghost parameter
.. method:: removeParent()
Removes this objects parent.
.. method:: getPhysicsId()
Returns the user data object associated with this game object's physics controller.
.. method:: getPropertyNames()
Gets a list of all property names.
:return: All property names for this object.
:rtype: list
.. method:: getDistanceTo(other)
:arg other: a point or another :class:`KX_GameObject` to measure the distance to.
:type other: :class:`KX_GameObject` or list [x, y, z]
:return: distance to another object or point.
:rtype: float
.. method:: getVectTo(other)
Returns the vector and the distance to another object or point.
The vector is normalized unless the distance is 0, in which a zero length vector is returned.
:arg other: a point or another :class:`KX_GameObject` to get the vector and distance to.
:type other: :class:`KX_GameObject` or list [x, y, z]
:return: (distance, globalVector(3), localVector(3))
:rtype: 3-tuple (float, 3-tuple (x, y, z), 3-tuple (x, y, z))
.. method:: rayCastTo(other, dist, prop)
Look towards another point/object and find first object hit within dist that matches prop.
The ray is always casted from the center of the object, ignoring the object itself.
The ray is casted towards the center of another object or an explicit [x, y, z] point.
Use rayCast() if you need to retrieve the hit point
:arg other: [x, y, z] or object towards which the ray is casted
:type other: :class:`KX_GameObject` or 3-tuple
:arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
:type dist: float
:arg prop: property name that object must have; can be omitted => detect any object
:type prop: string
:return: the first object hit or None if no object or object does not match prop
:rtype: :class:`KX_GameObject`
.. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly)
Look from a point/object to another point/object and find first object hit within dist that matches prop.
if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit.
if poly is 1, returns a 4-tuple with in addition a :class:`KX_PolyProxy` as 4th element.
if poly is 2, returns a 5-tuple with in addition a 2D vector with the UV mapping of the hit point as 5th element.
.. code-block:: python
# shoot along the axis gun-gunAim (gunAim should be collision-free)
obj, point, normal = gun.rayCast(gunAim, None, 50)
if obj:
# do something
pass
The face paremeter determines the orientation of the normal.
* 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
* 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow.
* prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
* prop off, xray on : idem.
* prop on, xray off: return closest hit if it matches prop, no hit otherwise.
* prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
The :class:`KX_PolyProxy` 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
:arg objto: [x, y, z] or object to which the ray is casted
:type objto: :class:`KX_GameObject` or 3-tuple
:arg objfrom: [x, y, z] or object from which the ray is casted; None or omitted => use self object center
:type objfrom: :class:`KX_GameObject` or 3-tuple or None
:arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
:type dist: float
:arg prop: property name that object must have; can be omitted or "" => detect any object
:type prop: string
:arg face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
:type face: integer
:arg xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
:type xray: integer
:arg poly: polygon option: 0, 1 or 2 to return a 3-, 4- or 5-tuple with information on the face hit.
* 0 or omitted: return value is a 3-tuple (object, hitpoint, hitnormal) or (None, None, None) if no hit
* 1: return value is a 4-tuple and the 4th element is a :class:`KX_PolyProxy` or None if no hit or the object doesn't use a mesh collision shape.
* 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping.
:type poly: integer
:return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
* object, hitpoint and hitnormal are None if no hit.
* polygon is valid only if the object is valid and is a static object, a dynamic object using mesh collision shape or a soft body object, otherwise it is None
* hituv is valid only if polygon is valid and the object has a UV mapping, otherwise it is None
:rtype:
* 3-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz))
* or 4-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`KX_PolyProxy`)
* or 5-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`KX_PolyProxy`, 2-tuple (u, v))
.. note::
The ray ignores the object on which the method is called. It is casted from/to object center or explicit [x, y, z] points.
.. method:: setCollisionMargin(margin)
Set the objects collision margin.
:arg margin: the collision margin distance in blender units.
:type margin: float
.. note::
If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
.. method:: sendMessage(subject, body="", to="")
Sends a message.
:arg subject: The subject of the message
:type subject: string
:arg body: The body of the message (optional)
:type body: string
:arg to: The name of the object to send the message to (optional)
:type to: string
.. method:: reinstancePhysicsMesh(gameObject, meshObject)
Updates the physics system with the changed mesh.
If no arguments are given the physics mesh will be re-created from the first mesh assigned to the game object.
:arg gameObject: optional argument, set the physics shape from this gameObjets mesh.
:type gameObject: string, :class:`KX_GameObject` or None
:arg meshObject: optional argument, set the physics shape from this mesh.
:type meshObject: string, :class:`MeshProxy` or None
:return: True if reinstance succeeded, False if it failed.
:rtype: boolean
.. note::
If this object has instances the other instances will be updated too.
.. note::
The gameObject argument has an advantage that it can convert from a mesh with modifiers applied (such as subsurf).
.. warning::
Only triangle mesh type objects are supported currently (not convex hull)
.. warning::
If the object is a part of a combound object it will fail (parent or child)
.. warning::
Rebuilding the physics mesh can be slow, running many times per second will give a performance hit.
.. method:: get(key, default=None)
Return the value matching key, or the default value if its not found.
:return: The key value or a default.
.. method:: playAction(name, start_frame, end_frame, layer=0, priority=0, blendin=0, play_mode=KX_ACTION_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0, blend_mode=KX_ACTION_BLEND_BLEND)
Plays an action.
:arg name: the name of the action
:type name: string
:arg start: the start frame of the action
:type start: float
:arg end: the end frame of the action
:type end: float
:arg layer: the layer the action will play in (actions in different layers are added/blended together)
:type layer: integer
:arg priority: only play this action if there isn't an action currently playing in this layer with a higher (lower number) priority
:type priority: integer
:arg blendin: the amount of blending between this animation and the previous one on this layer
:type blendin: float
:arg play_mode: the play mode
:type play_mode: one of :ref:`these constants <gameobject-playaction-mode>`
:arg layer_weight: how much of the previous layer to use for blending
:type layer_weight: float
:arg ipo_flags: flags for the old IPO behaviors (force, etc)
:type ipo_flags: int bitfield
:arg speed: the playback speed of the action as a factor (1.0 = normal speed, 2.0 = 2x speed, etc)
:type speed: float
:arg blend_mode: how to blend this layer with previous layers
:type blend_mode: one of :ref:`these constants <gameobject-playaction-blend>`
.. method:: stopAction(layer=0)
Stop playing the action on the given layer.
:arg layer: The layer to stop playing.
:type layer: integer
.. method:: getActionFrame(layer=0)
Gets the current frame of the action playing in the supplied layer.
:arg layer: The layer that you want to get the frame from.
:type layer: integer
:return: The current frame of the action
:rtype: float
.. method:: setActionFrame(frame, layer=0)
Set the current frame of the action playing in the supplied layer.
:arg layer: The layer where you want to set the frame
:type layer: integer
:arg frame: The frame to set the action to
:type frame: float
.. method:: isPlayingAction(layer=0)
Checks to see if there is an action playing in the given layer.
:arg layer: The layer to check for a playing action.
:type layer: integer
:return: Whether or not the action is playing
:rtype: boolean
|