TranslateEntity entity,x#,y#,z#[,global]
Parameters
|
entity - entity handle x# - x amount that entity will be translated by y# - y amount that entity will be translated by z# - z amount that entity will be translated by global (optional) - true to translate along the world axes even for a child of a rotated parent; false (default) translates in the parent's space |
Description
|
Translates an entity relative to its current position but not its orientation - along fixed axes. The entity moves in a fixed direction regardless of which way it is facing. Imagine a game character doing a triple somersault as it jumps: translating by a positive y amount moves it straight up in the air no matter where it is facing mid-somersault. That makes TranslateEntity the natural command for gravity, jumping, knockback and any other velocity that lives in world space. This is one of three ways to change position: TranslateEntity - moves along fixed world axes, ignoring the entity's orientation. MoveEntity - moves along the entity's own local axes (direction depends on which way it faces). PositionEntity - jumps the entity to an absolute position instead of shifting it. For a child entity the translation is in its parent's space by default; pass true for global to translate along the world axes regardless of the parent's rotation. See also: MoveEntity, PositionEntity, PositionMesh. |
Example
; TranslateEntity Example ; ----------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,0,-10 light=CreateLight() RotateEntity light,45,45,0 ; A tumbling satellite satellite=CreateCone(16) EntityColor satellite,255,200,0 RotateEntity satellite,Rnd(0,360),Rnd(0,360),Rnd(0,360) While Not KeyDown(1) ; Reset translation values each frame - otherwise the satellite would never stop x#=0 y#=0 z#=0 ; Cursor keys and A/Z set this frame's translation If KeyDown(203) Then x=-0.1 If KeyDown(205) Then x=0.1 If KeyDown(208) Then y=-0.1 If KeyDown(200) Then y=0.1 If KeyDown(44) Then z=-0.1 If KeyDown(30) Then z=0.1 ; TranslateEntity moves along the WORLD axes: up is always up, no matter ; which way the satellite is facing. Compare MoveEntity (local axes) ; and PositionEntity (absolute coordinates). TranslateEntity satellite,x,y,z ; The satellite tumbles constantly - yet the keys always move it the same way TurnEntity satellite,1,1,0 RenderWorld Text 0,0,"Cursors/A/Z: translate Esc: exit" Text 0,20,"TranslateEntity satellite,"+x+","+y+","+z+" (world axes)" Flip Wend End
Index