CreatePivot ( [parent] )
Parameters
| parent (optional) - parent entity of pivot |
Description
|
Creates a pivot entity. A pivot entity is an invisible point in 3D space whose main use is to act as a parent entity to other entities. The pivot can then be used to control lots of entities at once, or to act as a new centre of rotation for other entities: parent a moon to a pivot at a planet's centre, turn the pivot, and the moon orbits. Pivots are also handy as invisible markers - spawn points, waypoints, camera targets for PointEntity - and as the invisible 'body' a camera or model is attached to in a typical player controller. To set up the relationship, use EntityParent or the optional parent parameter available with all entity load/creation commands. That parameter is available with CreatePivot too, if you wish the pivot itself to have a parent. Remember that a child is still created at 0,0,0, not at its parent's position. See also: EntityParent, GetChild, CountChildren, PointEntity. |
Example
; CreatePivot Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-10 light=CreateLight() RotateEntity light,45,45,0 ; Create a pivot - an invisible entity with just a position and orientation pivot=CreatePivot() ; Parent a planet to the pivot, offset 4 units from it planet=CreateSphere(16,pivot) ScaleEntity planet,0.5,0.5,0.5 PositionEntity planet,4,0,0 EntityColor planet,0,150,255 While Not KeyDown(1) ; Turning the invisible pivot swings the planet around it TurnEntity pivot,0,1,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"The planet orbits the invisible pivot created by CreatePivot()" Flip Wend End
Index