Scene tracking & camera management script
Generally a games will contain many diffrent "scenes" such as "start screen" scene, cut scene, gameplay scene, transition scene with score gain sumery ... Each scene will probably need different dynamic adjustment so we need a way to track which scene our current frame belongs to. The "scene" script below will help us with this task.
function Start()
scene = -1
sceneChanged = false
end
function Update()
_scene = 0
end
function UpdateS()
if _scene < shape.CData[7] then
_scene = shape.CData[7]
end
end
function LateUpdate()
if scene ~= _scene then
sceneChanged = true
scene = _scene
else
sceneChanged = false
end
end
For each scene determine a pattern which only appears on it and give it a "scene" tag and assign a scene id number to its CData0. That way the variable "scene" will alway refer to the current scene.
function Start()
camRot = Camera.Rot
oldRot, oldRot1 = {x=0, y = 0}, {x=-65,y = 0}
end
function LateUpdate()
if sceneChanged then
Setting.TopDownCam = scene == 1
if scene == 0 then
camRot.x = oldRot.x
camRot.y = oldRot.y
else
camRot.x = oldRot1.x
camRot.y = oldRot1.y
end
else if scene == 0 then
oldRot.x = camRot.x
oldRot.y = camRot.y
else
oldRot1.x = camRot.x
oldRot1.y = camRot.y
end
end
end
function Save()
PData[0] = oldRot.x
PData[1] = oldRot.y
PData[2] = Camera.Distance
PData[3] = oldRot1.x
PData[4] = oldRot1.y
end
function Load()
oldRot.x = PData[0]
oldRot.y = PData[1]
Camera.Distance = PData[2]
oldRot1.x = PData[3]
oldRot1.y = PData[4]
end