/
CameraFX_State_FollowObjectVelocityZoom_onLoop.lua
27 lines (24 loc) · 1.39 KB
/
CameraFX_State_FollowObjectVelocityZoom_onLoop.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--------------------------------------------------------------------------------
-- State............ : FollowObjectVelocityZoom
-- Author........... :
-- Description...... :
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function CameraFX.FollowObjectVelocityZoom_onLoop ( )
--------------------------------------------------------------------------------
local dt = application.getLastFrameTime ( )
local x, y, z = object.getTranslation ( this.hTrackingTarget ( ), object.kGlobalSpace )
local speed = dynamics.getLinearSpeed ( this.hTrackingTarget ( ) )
local vx, vy, vz = dynamics.getLinearVelocity ( this.hTrackingTarget ( ), object.kGlobalSpace )
local radius = object.getBoundingSphereRadius ( this.hTrackingTarget ( ) )
z = 20 + radius + speed * 0.5
if vy < 0 then
y = y + vy * 0.7
elseif vy > 0 then
y = y + vy
end
object.translateTo ( application.getCurrentUserActiveCamera ( ), x + vx, y, z, object.kGlobalSpace, dt * this.nTrackingSpeed ( ))
--object.rotateTo ( application.getCurrentUserActiveCamera ( ), 0, 0, 0, object.kGlobalSpace, dt * this.nTrackingSpeed ( ) )
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------