entity under crosshair
Moderator: Moderators
entity under crosshair
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 :/
test pointer
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.
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.
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
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
}
}


