|
entity - entity handle global (optional) - true to return the world y coordinate, false to return the coordinate relative to the entity's parent; false (default) |
|
Returns the y coordinate of an entity. With global false (the default) the coordinate is in the entity's parent's local space; pass true to get the entity's actual height in the world. If the entity has no parent, local and global are the same. Y+ is up, so this is the value to watch for jumps, falls and 'fell out of the level' checks. See EntityX for an overview of local and global coordinates. See also: EntityX, EntityZ, PositionEntity, EntityDistance. |
; EntityY Example
; ---------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,0,-10
light=CreateLight()
RotateEntity light,45,45,0
; A satellite parented to a pivot, offset 2 units along the pivot's y axis
pivot=CreatePivot()
satellite=CreateCube(pivot)
ScaleEntity satellite,0.5,0.5,0.5
PositionEntity satellite,0,2,0
EntityColor satellite,255,200,0
While Not KeyDown(1)
; Rolling the pivot wheels the satellite round, so its GLOBAL y changes
; constantly, while its LOCAL y (relative to the pivot) stays fixed at 2
TurnEntity pivot,0,0,1
; 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"
; EntityY with the global flag True returns the world-space y coordinate
Text 0,20,"EntityY(satellite,True) global = "+EntityY(satellite,True)
Text 0,40,"EntityY(satellite) local = "+EntityY(satellite)
Flip
Wend
End