{"name":"cursorTarget","operator":null,"title":"cursorTarget","type":"command","url":"https://community.bistudio.com/wiki/cursorTarget","revid":373164,"updated":"2025-04-08T21:03:11Z","groups":["Object Detection"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns the target pointed at by the player (usually with cross-hairs). The target has to be known to the player to some degree (knowsAbout > 0). If target is completely unknown, command returns objNull.\n\nA valid target could belong to an enemy or a friendly side. Buildings are normally known to player and so are valid targets. Try nearTargets to see what else is considered a target.\nWhile friendly targets are usually known to the player, enemy targets can be totally unknown, especially if \"auto-spotting\" (or sometimes called \"auto-reporting\") is switched off. To check if auto-spotting is enabled: `difficultyEnabled \"autospot\"`.\n\ncursorTarget also returns locked target for the duration of the lock even if there is another target under the cursor. As soon as missile is fired, cursorTarget switches to current known target under cursor or objNull.\nTargeting (<kbd>T</kbd> in Arma 3) works regardless of the state of \"auto-spotting\".\n\nAdding a target to the known list could be done with reveal command. When auto-spotting is enabled, zooming on the enemy target with cross-hairs usually reveals the target.\nAs friendly targets are always known, zooming on friendly target could improve knowsAbout value.\n\nSide Relations can also influence target knowledge. For example east target is unknown target for civilian, but making them friends with setFriend instantly improves civilian knowledge of the east.","syntaxes":[{"syntax":"cursorTarget","since":null,"effect":null,"exec":null,"params":[],"returns":{"type":"Object","types":["Object"],"description":null,"text":"Object"},"form":"nullary","operator":null,"left":null,"right":null}],"examples":[{"text":"```sqf\nalive cursorTarget;\n```","code":["alive cursorTarget;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["cursorObject","getCursorObjectParams","laserTarget","nearTargets","knowsAbout","reveal","lineIntersects","lineIntersectsWith","lineIntersectsObjs","lineIntersectsSurfaces","intersect","checkVisibility"],"notes":[{"user":"FRL Myke","date":"2011-02-18T00:28:00Z","text":"If the player is in a vehicle and a lockable weapon is selected and a target is locked, the locked target will be returned, regardless if it is in sight or not."},{"user":".kju","date":"2011-03-11T12:48:00Z","text":"Addition to Myke's note:\nIt also works for infantry with launchers that canLock, like Javelin or AA.\nOnly the lock cursor must be visible on the target - not a full lock necessarily."},{"user":"Lou Montana","date":"2009-07-11T12:13:00Z","text":"- Player must know about what he is pointing to for this command to return something other than <NULL-OBJECT>\n- This command doesn't work through building windows\n- This recognition doesn't work with every object : soldiers, vehicles, big houses are ok, but not trees, plants, road signs or others little things"},{"user":"Killzone_Kid","date":"2013-08-23T22:16:00Z","text":"To add to User:Lou Montana's note, use reveal command on the object you want to be detected with cursorTarget when pointing at it.\nWithout it, distant units are most likely to return objNull even if you shoot and hit them.\n\nUnits that have been previously subjected to enableSimulation false; or enableSimulationGlobal false; may stay unrecognised for a long time even after simulation was re-enabled, returning objNull as cursorTarget.\nForce revealing units with reveal command usually solves the problem. For example:\n\n```sqf\n{ player reveal _x } forEach allUnits;\n```"},{"user":"DreadedEntity","date":"2014-12-03T18:40:00Z","text":"cursorTarget seems to change when your cursor enters an object's boundingBox.\nBecause of this, if the player is **inside** the boundingBox, the object will always be the current cursorTarget if the player is not looking at another object, although sometimes the object will remain the cursorTarget even if the player does."},{"user":"Pierre MGI","date":"2015-04-21T03:53:00Z","text":"cursorTarget will not return enemy units, even very close, if \"autoreport\" is disabled in game difficulty settings, and if player is alone.\nHowever, when enemy units open fire on player, the cursortarget becomes functional on these units. If player is in a group, cursortarget is also functional (report by other units)."},{"user":"Pierre MGI","date":"2016-02-05T20:38:00Z","text":"CursorTarget will return a <Null_Object> for all of thus which have a disabled simulation (_object enableSimulation false)."}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Detection","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}