+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 11

Thread: How to find out if player is aiming at a holo?

  1. #1
    Wire Sofaking Nikita is on a distinguished road Nikita's Avatar
    Join Date
    May 2009
    Posts
    422

    Default How to find out if player is aiming at a holo?

    Once again I fail at angles. Is there any formula that I can use to know if or not a player is aiming at a certain holo with arbitrary coordinates?

  2. #2
    Wire Sofaking
    Hitman271 will become famous soon enough Hitman271's Avatar
    Join Date
    Feb 2008
    Location
    Why? You looking for somebody?
    Posts
    536

    Default Re: How to find out if player is aiming at a holo?

    aimEntity( holoEntity( whateverHologramIndex ) )
    Quote Originally Posted by Anticept View Post
    This is not some place where you can toss your dick around and expect people to suck it.
    Give me rep if I helped you

    CAPS LOCK IS CRUISE CONTROL FOR AWESOME

    How The Clocks at Valve Work

    Gpu Problem? Refer to This!

    CLICK HERE TO MAKE A HELP THREAD

    GENERATION 7: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
    Social experiment.

  3. #3
    Wirererer jacoby6000 is an unknown quantity at this point jacoby6000's Avatar
    Join Date
    Feb 2008
    Location
    behind you when you aren't looking
    Posts
    275

    Default Re: How to find out if player is aiming at a holo?

    This will give you the angle part, you can make the tolerance stuff urself I think.

    Code:
    TargetAngle=Player:shootPos()-holoEntity(I):pos()
    CurrentAngle=Player:eyeAngles()
    if(CurrentAngle:inRange(TargetAngle-Tolerance,TargetAngle+Tolerance){
     Player is aiming at holo
    }else{
     Player is not aiming at holo
    
    Quote Originally Posted by mattwd0526 View Post
    >.< So yours echoes everything back, except in rainbow? That's like having Richard Simmons follow you around...
    I'm not stupid!
    "In [his] experience that was a sentence never to be uttered except to prove its own inaccuracy" --Orson Scott Card

  4. #4
    Wirererer timas will become famous soon enough timas's Avatar
    Join Date
    Apr 2007
    Location
    Vennesla, Norway
    Posts
    134

    Default Re: How to find out if player is aiming at a holo?

    Oh god, i did all theese calculations with trigonometry xD Didden't know it whas this simple.

    If you'd been listening you'd know that Nintendos! pass trough everything! - Colonel Jack. O'Niel
    Good news everyone!
    I have invented a device that makes your read this in your head, in my voice.

  5. #5
    Wire Sofaking Nikita is on a distinguished road Nikita's Avatar
    Join Date
    May 2009
    Posts
    422

    Default Re: How to find out if player is aiming at a holo?

    Sorry, neither works because there is no inRange for angles, and aimEntity does not accept an entity as a parameter except the one before ':'.

    Thanks for Player:shootPos() though, I totally forgot about that one.

  6. #6
    Master of Mars
    Magos Mechanicus will become famous soon enough Magos Mechanicus's Avatar
    Join Date
    May 2008
    Posts
    717

    Default Re: How to find out if player is aiming at a holo?

    First up, use a vector dot product to get the angle between the player's camera facing and the direction from the player to the hologram.
    Toholo = Hologram:pos() - Player:shootPos()
    Angle = acos( Player:eye():dot(Toholo:normalized()) )

    Now, you could just check whether the angle is smaller than a fixed amount, but if your hologram is very far away it might be within 5 degrees or whatever even though you're pointing far away from it. To compensate for that, we need trig. We know (or at least can get with holoScaleUnits(Index) ) the size of the hologram. For the most simplistic collision checking, we can assume the hologram is a sphere with this radius. So we draw up a right triangle where one side is the line from player to hologram and the other is that radius, then use arctangent to find the angle we're missing. Now we have an angle tolerance that scales to the hologram's distance from the player.

    Radius = holoScaleUnits(Hologramindex):length()
    Angletolerance = atan( Radius/Toholo:length() )
    if(Angle < Angletolerance){ Player is looking at hologram, do stuff }
    Last edited by Magos Mechanicus; 02-08-2010 at 05:10 PM. Reason: Mixed up atan() arguments.
    I can wire anything directly into anything! I'm the Professor!
    -Professor Hubert Farnsworth

  7. #7
    Drone Madman
    Lyinginbedmon will become famous soon enough Lyinginbedmon will become famous soon enough Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,037

    Default Re: How to find out if player is aiming at a holo?

    I just use

    Des=Holo:pos()
    Pro=Owner():shootPos()
    Pro+=Pro:distance(Des)*Owner:eye()
    if(Pro:distance(Des)<=X){do stuff}
    The Olympus Technologies drones, totally not SkyNet in Gmod form.
    Cronus: The Ultimate Drone, definitely SkyNet in Gmod form.
    The gBrain Project, the drone controls system that thinks it's better than you

    Need to learn how to make your own drones? Check out Drones with a Mad Scientist for my tutorials on how to do it.

  8. #8
    Wire Sofaking
    Divran will become famous soon enough Divran will become famous soon enough Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    1,233

    Default Re: How to find out if player is aiming at a holo?

    Quote Originally Posted by Lyinginbedmon View Post
    I just use

    Des=Holo:pos()
    Pro=Owner():shootPos()
    Pro+=Pro:distance(Des)*Owner:eye()
    if(Pro:distance(Des)<=X){do stuff}
    Me too.

    I even did this for my lua aimbot (which I made yesterday) to determine who is closest to my crosshair and then lock on to that person (edit: note: closest to my crosshair, not aimpos. edit2: imagine a line drawn from my crosshair to my aimpos. whoever is closest to that line that's better explained.)
    PewPew (New GCombat): http://www.wiremod.com/forum/wiremod...w-gcombat.html
    SVN TUTORIAL: http://www.facepunch.com/showthread.php?t=688324
    E2 THREAD: http://www.wiremod.com/forum/custom-...ns-thread.html
    MY SVN LINK:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    

  9. #9
    Wire Sofaking Nikita is on a distinguished road Nikita's Avatar
    Join Date
    May 2009
    Posts
    422

    Default Re: How to find out if player is aiming at a holo?

    Thanks Magos, that really helped!

    You are all nice!

  10. #10
    Expressionism 2.0

    Syranide has disabled reputation Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,179

    Default Re: How to find out if player is aiming at a holo?

    If you want to know ONLY when a player has the target on a holo, check out "ray-triangle/quad/cube/etc intersection" equations.

    Otherwise, "ray point-distance" equqations can be used to just know how far off you're aiming. Meaning, you can for instance use the size of the holo to estimate a radius.

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts