Here is my goal : I try to write a automatic flybycam script for planes :
1 - setpos a gamelogic in front of the plane,
2 - put the camera at the position of that gamelogic,
3 - camtarget the plane.
Now the problem is :
How can I detect the plane has passed the logic so it can be setpossed again in front of the plane and start the whole thing over in loop?
I thought this could work
@_lg distance _plane > 300
; plane is far away behind my gamelogic
@_lg distance _plane < 100
; _plane is close now
@_lg distance _plane > 300
; Plane is far away in front of my gamelogic, it should be passed by now...
WRONG!
When the plane starts 250 m high when it's far away and 100m high when it's close, distance is more then 100m so that second condition will never be met... * BUM* Distance is also measured in Z -coords
So, Is there some formula or function I can use combined with the speed of the vehicle?
Here is the script :
_camid = _this select 0
_unit = _this select 1
flybycam = true
_lg = "logic" camcreate [0,0,0]
#flybycalc
_spd = Speed _unit
_dist = (_spd * 1.1 + random 10)
_xpos = (getpos _unit select 0)+(sin (getdir _unit)*_dist)
_ypos = (getpos _unit select 1)+(cos (getdir _unit)*_dist)
_lg setpos [_xpos,_ypos,(getpos _unit select 2)]
_camid camsetpos getpos _lg
_camid camsettarget _unit
_camid camcommit 0
_wait = _Spd / 60
~_wait
?flybycam && alive _unit : goto "flybycalc"
deletevehicle _lg
exit
You have to run this in a camera script:
example
[_camera,Plane] exec "flybycam.sqs"
and
flybycam = false will exit the script
The _wait calculation is just temporary, it works fine when the speed of the plane is around 300- 400 km/h, but when the speed is lower the camera switches to fast imo.
Any suggestions how I can do this so it always works good in every situation (maybe also for cars, tanks,ect...) ?
If you are interested in this, dl the testdemo mission I'v made, no addons needed.Use your radio Alpha to start the demo.