SA-MP Forums Archive
Detecting If Vehicle Approaches Person - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detecting If Vehicle Approaches Person (/showthread.php?tid=294780)



Detecting If Vehicle Approaches Person - Simon - 03.11.2011

Code!

Hey,

With this code above I'm trying to see if a velocity vector will intersect with a players position. I want to be able to detect if somebody is driving at a player when they press KEY_FIRE, however, this does not appear to work at all by doing the following steps:
My understanding tells me this should work? Is my understanding of this vector magic incorrect?

Thanks for any help!


Re: Detecting If Vehicle Approaches Person - CyNiC - 03.11.2011

I suggest you to use GetPlayerCameraFrontVector, since you can get a more accurately projectile position based on the player camera.

https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector


Re: Detecting If Vehicle Approaches Person - Simon - 03.11.2011

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
I suggest you to use GetPlayerCameraFrontVector, since you can get a more accurately projectile position based on the player camera.

https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector
Thanks for the suggestion, however the players camera direction can be changed with the flick of the mouse. It would work nicely if the camera always faced forward.


Re: Detecting If Vehicle Approaches Person - Simon - 06.11.2011

Any other suggestions? Pwetty pwease.


Re: Detecting If Vehicle Approaches Person - Kar - 09.06.2013

I know this post is old, but I've seen recently people wanted the same thing

- Project a point infront of the player
- Check the distance between the vehicle and player
- Check the angle between the vehicle and player or of vehicle
If the angle is in a range that the vehicle is going left or right, and the vehicle has velocity, then yes they drived passed the player
If the angle is directly inversely proportional with a range to the player then the vehicle is coming straight to them, if not, then they are going away from them