I've been trying to convert this wonderful bit of code to work on the X/Z axis (ie. looking straight down on a plane).
At the mo, this is code for X/Y (looking into the distance).
Can you help. Thanks.
At the mo, this is code for X/Y (looking into the distance).
Can you help. Thanks.
; ----------------------------------------------------------------------------- ; PositionEntityFrom2D () ; ----------------------------------------------------------------------------- ; Positions an entity at 3D x/y co-ords translated from given 2D co-ords, at ; specified z position. Useful for positioning an entity at mouse x/y position, ; at its current z depth... ; ----------------------------------------------------------------------------- ; PARAMETERS... ; ----------------------------------------------------------------------------- ; REQUIRED... ; ----------------------------------------------------------------------------- ; entity is the entity to be positioned. ; x2d is the 2D x position you want translated to 3D. ; y2d is the 2D y position you want translated to 3D. ; z3d is the * 3D * z depth at which the translation should occur. ; ----------------------------------------------------------------------------- ; OPTIONAL... ; ----------------------------------------------------------------------------- ; positionGlobal defaults to false, as per PositionEntity. ; camZoom must be set manually if you've used CameraZoom to change it... ; ----------------------------------------------------------------------------- Function PositionEntityFrom2D (usecam, entity, x2d#, y2d#, positionGlobal = 0, camZoom# = 1) gw = GraphicsWidth () gh = GraphicsHeight () x# = -((gw / 2) - x2d) y# = (gh / 2) - y2d parent = GetParent (entity) EntityParent entity, usecam z3d# = Abs (EntityZ (entity)) div# = (gw / (2 / camzoom)) / z3d PositionEntity entity, x / div, y / div, z3d, positionGlobal EntityParent entity, parent End Function