08.11.2018, 17:42
Quote:
challenge accepted (:
---- So I tried something, I'm not great at maths, but this is the most fitting way I figured it'd be possible to do. However, this method is not accurate, there are several factors to take into consideration: the distance between the vehicle and player multiplied by the vehicle's visible ratio (zoom in, zoom out - basically), etc, etc. Talk is cheap! Show me the code already! pawn Код:
Код:
player's position: x 143 - y -2585 - z -2522 - a 278 vehicle's position: x -1939 - y 1117 - z -2755 coordination differ: breath -2082 - height 3702 - depth -233 angle between points: 6837 radians between points: 119 angle differ: 158 - is facing: false player's position: x -401 - y 2899 - z 2652 - a 100 vehicle's position: x 121 - y 1290 - z 1518 coordination differ: breath 522 - height -1609 - depth -1134 angle between points: -4126 radians between points: -72 angle differ: 172 - is facing: false player's position: x -1308 - y 282 - z -2786 - a 1 vehicle's position: x 2440 - y 1067 - z -1979 coordination differ: breath 3748 - height 785 - depth 807 angle between points: 677 radians between points: 11 angle differ: 10 - is facing: true player's position: x -444 - y 1695 - z 2726 - a 284 vehicle's position: x 2853 - y -2546 - z -787 coordination differ: breath 3297 - height -4241 - depth -3513 angle between points: -2986 radians between points: -52 angle differ: 336 - is facing: false player's position: x 1765 - y 1832 - z -2541 - a 210 vehicle's position: x -606 - y 1975 - z 226 coordination differ: breath -2371 - height 143 - depth 2767 angle between points: 10114 radians between points: 176 angle differ: 33 - is facing: false player's position: x 714 - y 1793 - z -2932 - a 200 vehicle's position: x 2408 - y 629 - z -1329 coordination differ: breath 1694 - height -1164 - depth 1603 angle between points: -1976 radians between points: -34 angle differ: 234 - is facing: false player's position: x -79 - y 875 - z 1144 - a 224 vehicle's position: x 2370 - y 671 - z 818 coordination differ: breath 2449 - height -204 - depth -326 angle between points: -272 radians between points: -4 angle differ: 228 - is facing: false player's position: x -1340 - y -1675 - z -2347 - a 240 vehicle's position: x -608 - y -817 - z -423 coordination differ: breath 732 - height 858 - depth 1924 angle between points: 2837 radians between points: 49 angle differ: 190 - is facing: false player's position: x -1131 - y 742 - z 1971 - a 135 vehicle's position: x 314 - y 1650 - z -2243 coordination differ: breath 1445 - height 908 - depth -4214 angle between points: 1841 radians between points: 32 angle differ: 102 - is facing: false player's position: x -1011 - y -827 - z 243 - a 62 vehicle's position: x -578 - y -2238 - z 954 coordination differ: breath 433 - height -1411 - depth 711 angle between points: -4178 radians between points: -72 angle differ: 134 - is facing: false |
Look at Nero3D's post OP quoted.
Get the world angle from the player to the car (atan2 of the Player Pos - Vehicle Pos). Then get the player's facing angle (GetPlayerFacingAngle or GetPlayerCameraFrontVector + atan2).
Then you need to subtract the angles from one another, and clamp the value to [-180.0, 180.0]. The absolute value of that number is then the angle difference in degrees, you must then decide at which angle the player would be looking at/facing the car, and at which it isn't.