Page 1 of 1
entity under crosshair
Posted: Thu Jul 12, 2007 8:57 pm
by c_los
Is there a way to get the $targetname of an entity under the crosshair (such as a cube script_object)? I know there is a command to get a shader under the crosshair :/
Posted: Sun Jul 15, 2007 8:58 pm
by jv_map
Unfortunately no such command exists

Posted: Wed Jul 18, 2007 4:02 pm
by Condor
I have another question whichs similar to this one:
Is there any way to move the cursor over the screen independet from the players angle ingame and a function which returns the mousekeys pressed and the cursorposition?
test pointer
Posted: Thu Jul 19, 2007 4:03 am
by tltrude
Try this tutorial map.
Test Pointer Map
Review: A new item has been added to your inventory! With this tutorial map you can add a pointer for selecting buttons on any control panel. The map has panels for a four story elevator, touchtone phone, and a fireworks rocket launcher. A .map file, a playable pk3, and a text version of the script are included.
Posted: Thu Jul 19, 2007 11:28 am
by Condor
Ah, yes, thats what I need, thank you

Posted: Sun Jul 22, 2007 5:40 pm
by c_los
But couldn't I do something along the lines of the 'flashlight' thing and just check what it isTouching and get the returned entity?
Posted: Tue Jan 01, 2008 3:36 pm
by Rookie One.pl
Well, there is a way. You can do a trace, but you need to have a list of objects that the trace can possibly collide with beforehand (in the example it's an array called local.entitieslist). It would go something along these lines (off the top of my head):
Code: Select all
local.start = local.player gettagposition "eyes bone" // this is not exactly the player's viewpoint, but it's pretty close
local.dir = angles_toforward local.player.angles
local.end = local.start + local.dir * 64 // change 64 to how far you want the trace to go; 16 units is 1 foot
local.hit = trace local.start local.end
local.ent = spawn script_origin origin local.hit
for (local.i = 1; local.i <= local.entitieslist.size; local.i++) {
if (local.ent isTouching local.entitieslist[local.i]) {
// got a hit, run your code here
break // this exits the loop
}
}