works when I test against player to hummer, but not hummer to player
This really is the same angle though since you know the hummer.getAngle Z and player.getAngle Z angles
Taking for granted that the player is always facing the Hummer onActivate, what you need to calculate their relative position is the difference of the
playerAngle Z - hummerAngle Z
this value makes the solution to your problem well-defined since you can now calculate the angle between two vectors (angle Z is calculated based on the heading, at least for the player. For the Hummer it will probably be its heading as well, but at any rate it will be relative to a constant point in the Hummer. The following calculations are done with the hypothesis that hummer.getAngle Z returns the heading angle of the hummer relative to the world. If by any chance it is different you can measure it and change it accordingly).
- In order for the player to activate the trunk he must be "approximately" collinear to the hummer, meaning the difference is zero +- a tolerance value
- If the player is facing e.g. the right seat they are vertical but with a "minus" sign, so the difference would be -90 +- a tolerance value
- If the player is facing e.g. the left seat they are vertical but with a "plus" sign, so the difference would be 90 +- a tolerance value
and so on.
As long as your "arcs" do not conflict it is pretty well defined.
If for some reason you DO face conflicting arcs, you could also add a dx,dy check and you're good to go
If you also want to input a psycho condition, you can also check for altitude differences, in case the player is standing on the car when activating
The script would be something like this:
dz = player.getAngle Z - hummer.getAngle Zif dz > -15 && dz <= 15 ; 0 +- 15 degrees........... ;open trunkelseif dz > 75 && dz <= 105 ; 90 +-15 degrees.......... ;activate left seatelseif dz >-75 && dz <= -105 ; -90 +- 15 degress.......... ;activate left seatelseif dz >165 && dz <= 195 ; 180 +- 15 degrees.......... ;activate engineelse.......... ;if none of the arcs is valid show a message or something. You could also make the tolerance big enough so that there are no "invalid" arcs, ;in this case where you have four arcs, the tolerance would have to be +-45 degrees instead of the 15 I put in the example.endif
note that the above only really works if the hummer Z angle is in the 1st quadrant, since it can only be 0-360 (359?)
The way to work around this would be an anagoge of your angles to the first quadrant, like this:
set HA to hummer.getAngle Z set PA to player.getAngle Zif HA > 0 && HA <= 90..... ; do nothing, we're okelseif HA > 90 && HA <= 180 set HAAnagoged to HA - 90 set PAAnagoged to PA - 90elseif HA > 180 && HA <= 270 set HAAnagoged to HA - 180 set PAAnagoged to PA - 180elseif HA > 270 && HA <= 360 set HAAnagoged to HA - 270 set PAAnagoged to PA - 270endif
What is good about this approach is that you don't care what the Player Angle is; even if it's 45 it will e.g. become - 45 which, when put into the
playerAngle Z - hummerAngle Z
equation your relative difference will still be the same
I don't have FO3 installed right now to write the script but let me know if I missed something
Edit: Seeing it again, you could probably bypass the anagoge if you insert an absolute value to the 180 degree check e.g:
if abs(dz)> 165 && abs(dz)<=195...