Wisin Posted July 19, 2014 Share Posted July 19, 2014 Hi, I was wondering if anyone could help me with making a function to check if a player is facing another, I got told to use findRotation useful function, but I don't know what to check exactly. Thanks. Link to comment
Wisin Posted July 19, 2014 Author Share Posted July 19, 2014 Sadly, it doesn't work, it almost never returns the player when I need it to. Link to comment
ViRuZGamiing Posted July 19, 2014 Share Posted July 19, 2014 https://wiki.multitheftauto.com/wiki/Ge ... enPosition Link to comment
CocaColaBear Posted July 20, 2014 Share Posted July 20, 2014 processLineOfSight, checkPlayers argument Link to comment
Moderators IIYAMA Posted July 20, 2014 Moderators Share Posted July 20, 2014 Hi, I was wondering if anyone could help me with making a function to check if a player is facing another, I got told to use findRotation useful function, but I don't know what to check exactly.Thanks. Where do you need it client or server side? Which will be the main filter of the functions you can use and can't use. Link to comment
Wisin Posted July 20, 2014 Author Share Posted July 20, 2014 I need it client side, this is what I tried: local sx, sy = guiGetScreenSize ( ) local tx, ty, tz = getWorldFromScreenPosition ( sx / 2, sy / 2, 7 ) local px, py, pz = getCameraMatrix ( ) local hit, _, _, _, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz, true, true, true, true, true, false, false, false, localPlayer ) if ( hit and isElement ( elementHit ) and getElementType ( elementHit ) == "player" ) then local px, py, pz = getElementPosition ( elementHit ) outputChatBox ( "hit: ".. tostring ( getPlayerName ( elementHit ) ) ) end The problem is that it hardly detects it, plus, I don't want it to be camera based, since I could just turn around and look at a player and it would return it. Link to comment
Bonsai Posted July 21, 2014 Share Posted July 21, 2014 So just use the peds position + calculate the position in a certain distance infront of it. Im pretty sure there already is some function on the wiki to do this, since its used on shooter maps to make projectiles fly the right direction. But its not that hard anyway. Then use processLineOfSight on these two positions and it always should check whats in the peds view. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now