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?
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?
aimEntity( holoEntity( whateverHologramIndex ) )
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.
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
"In [his] experience that was a sentence never to be uttered except to prove its own inaccuracy" --Orson Scott CardI'm not stupid!
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.
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.
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
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.
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/
Thanks Magos, that really helped!
You are all nice!![]()
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.
Bookmarks