22
22
@type orientation: 3x3 Matrix [[float]]
23
23
@ivar scaling: The object's scaling factor. list [sx, sy, sz]
24
24
@type scaling: list [sx, sy, sz]
25
@ivar timeOffset: adjust the slowparent delay at runtime.
26
@type timeOffset: float
28
def endObject(visible):
30
Delete this object, can be used inpace of the EndObject Actuator.
31
The actual removal of the object from the scene is delayed.
35
Gets the game object's visible flag.
27
39
def setVisible(visible):
29
41
Sets the game object's visible flag.
31
43
@type visible: boolean
47
Gets the game object's state bitmask.
50
@return: the objects state.
54
Sets the game object's state flag.
55
The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
33
59
def setPosition(pos):
35
Sets the game object's position.
61
Sets the game object's position.
62
Global coordinates for root object, local for child objects.
66
@param pos: the new position, in local coordinates.
68
def setWorldPosition(pos):
70
Sets the game object's position in world coordinates regardless if the object is root or child.
37
72
@type pos: [x, y, z]
38
73
@param pos: the new position, in world coordinates.
51
86
@type orn: 3x3 rotation matrix, or Quaternion.
52
87
@param orn: a rotation matrix specifying the new rotation.
88
@note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
90
def alignAxisToVect(vect, axis):
92
Aligns any of the game object's axis along the given vector.
94
@type vect: 3d vector.
95
@param vect: a vector to align the axis.
97
@param axis:The axis you want to align
100
- 2: Z axis (default)
102
def getAxisVect(vect):
104
Returns the axis vector rotates by the objects worldspace orientation.
105
This is the equivalent if multiplying the vector by the orientation matrix.
107
@type vect: 3d vector.
108
@param vect: a vector to align the axis.
110
@return: The vector in relation to the objects rotation.
54
113
def getOrientation():
66
126
ie no angular velocity component.
68
128
@type local: boolean
69
@param local: - False: you get the "global" velocity ie: relative to world orientation.
129
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
70
130
- True: you get the "local" velocity ie: relative to object orientation.
71
131
@rtype: list [vx, vy, vz]
72
132
@return: the object's linear velocity.
134
def setLinearVelocity(velocity, local = 0):
136
Sets the game object's linear velocity.
138
This method sets game object's velocity through it's centre of mass,
139
ie no angular velocity component.
141
@type velocity: 3d vector.
142
@param velocity: linear velocity vector.
144
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
145
- True: you get the "local" velocity ie: relative to object orientation.
147
def getAngularVelocity(local = 0):
149
Gets the game object's angular velocity.
152
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
153
- True: you get the "local" velocity ie: relative to object orientation.
154
@rtype: list [vx, vy, vz]
155
@return: the object's angular velocity.
157
def setAngularVelocity(velocity, local = 0):
159
Sets the game object's angular velocity.
161
@type velocity: 3d vector.
162
@param velocity: angular velocity vector.
164
@param local: - False: you get the "global" velocity ie: relative to world orientation (default).
165
- True: you get the "local" velocity ie: relative to object orientation.
74
167
def getVelocity(point):
76
169
Gets the game object's velocity at the specified point.
168
282
@type other: L{KX_GameObject} or list [x, y, z]
285
def getVectTo(other):
287
Returns the vector and the distance to another object or point.
288
The vector is normalized unless the distance is 0, in which a NULL vector is returned.
290
@param other: a point or another L{KX_GameObject} to get the vector and distance to.
291
@type other: L{KX_GameObject} or list [x, y, z]
292
@rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
293
@return: (distance, globalVector(3), localVector(3))
171
295
def rayCastTo(other,dist,prop):
173
297
Look towards another point/object and find first object hit within dist that matches prop.
175
299
The ray is always casted from the center of the object, ignoring the object itself.
176
300
The ray is casted towards the center of another object or an explicit [x,y,z] point.
301
Use rayCast() if you need to retrieve the hit point
178
303
@param other: [x,y,z] or object towards which the ray is casted
179
@type other: L{KX_GameObject} or string
304
@type other: L{KX_GameObject} or 3-tuple
180
305
@param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
181
306
@type dist: float
182
307
@param prop: property name that object must have; can be omitted => detect any object
184
309
@rtype: L{KX_GameObject}
185
310
@return: the first object hit or None if no object or object does not match prop
b'\\ No newline at end of file'
312
def rayCast(objto,objfrom,dist,prop,face,xray,poly):
314
Look from a point/object to another point/object and find first object hit within dist that matches prop.
315
if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
316
if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element.
319
# shoot along the axis gun-gunAim (gunAim should be collision-free)
320
ob,point,normal = gun.rayCast(gunAim,None,50)
325
The ray ignores the object on which the method is called.
326
It is casted from/to object center or explicit [x,y,z] points.
328
The face paremeter determines the orientation of the normal::
329
0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
330
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
332
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
333
The prop and xray parameters interact as follow::
334
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
335
prop off, xray on : idem.
336
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
337
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.
338
The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
339
If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
341
The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
343
@param objto: [x,y,z] or object to which the ray is casted
344
@type objto: L{KX_GameObject} or 3-tuple
345
@param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
346
@type objfrom: L{KX_GameObject} or 3-tuple or None
347
@param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
349
@param prop: property name that object must have; can be omitted => detect any object
351
@param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
353
@param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
355
@param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
357
@rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
358
or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
359
@return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
360
If no hit, returns (None,None,None) or (None,None,None,None)
361
If the object hit is not a static mesh, polygon is None