Untitled
unknown
plain_text
2 years ago
8.7 kB
3
Indexable
//@input Component.AnimationMixer sneakyAnim //@input SceneObject sneakySceneObject //@input Component.Camera cam //@input Component.ScreenTransform firstScreenPos //@input SceneObject secondPos //@input SceneObject frontHint //@input Component.ScreenTransform thirdScreenPos //@input Component.ScreenTransform fourthScreenPos //@input SceneObject[] tweenObjects //@input Component.LookAtComponent sneakyLookAt //@input SceneObject resetTween //@input SceneObject sneakyTweenedObject //@input Component.ScriptComponent textFade //@input SceneObject[] test //@input SceneObject layerToCopyNorm //@input SceneObject layerToCopyCc // @input Component.ScriptComponent instanceSoundScript // @input Asset.AudioTrackAsset sneakyAudio // @input Asset.AudioTrackAsset sneakyAudio2 //@input Component.ScreenTransform topScreenPos //@input SceneObject hintPos //@input Component.ScreenTransform shoulderScreenPos //@input SceneObject headBinding //@input Asset.Material sneakyMaterial //@input Component.ScreenTransform sneakyTapHintPos //@input SceneObject hintLayer //@input SceneObject sneakyArm //@input Component.AnimationMixer sneakyArmAnim //@input SceneObject findFaceHint script.sneakyArm.enabled = false var order = ['shoulder', 'top', 'hintTap', 'bottom'] //var order = ["hintTap"] var currentIndex = -1 var skipAfterFirst = ['hintTap'] setLayerCC() // ########## // TIMINGS // ########## var delayTapAnimOnSecond = 1 var delaySpinAfterTapStartedOnSecond = 2 var secondRan = false var sneakyLockedToShoulder = false var audioVolume = 0.2 // A class controlling sneaky function SneakyClass() { var _this = this _this.setWorldPos = function (pos) { script.sneakySceneObject.getTransform().setWorldPosition(pos) } } var sneaky = null sneaky = new SneakyClass() var initialized = false function init() { if (initialized) return initialized = true // runFirst() // runThird() // runNext() resetSneaky(function(){ runNext(true) }) } //init() // function resetSneaky(cb) { global.tweenManager.startTween(script.tweenObjects[4], 'reset') global.tweenManager.startTween(script.resetTween, 'reset', cb) script.sneakyMaterial.mainPass.enable_opacity = false } function runShoulder() { print('run shoulder') setLayerCC() script.sneakyMaterial.mainPass.enable_opacity = true script.sneakyLookAt.enabled = false global.tweenManager.startTween(script.tweenObjects[0], 'init') var dlySet = script.createEvent('DelayedCallbackEvent') dlySet.bind(function () { // var headPos = script.headBinding.getTransform().getWorldPosition() // var shoulderPos = script.shoulderPos.getTransform().getWorldPosition() // sneaky.setWorldPos(shoulderPos.add(new vec3(0,0,-40))) var screenPos = script.shoulderScreenPos.anchors.getCenter() // move sneaky slightly right screenPos.x += 0.1 var worldPos = screenToWorld(screenPos) sneaky.setWorldPos(worldPos) sneakyLockedToShoulder = true }) dlySet.reset(0.1) script.sneakyAnim.startWithCallback('Bottom', 0, 1, function () { sneakyLockedToShoulder = false runNext() }) var dly = script.createEvent('DelayedCallbackEvent') dly.bind(function () {}) dly.reset(delayTapAnimOnSecond) } function runTop() { print('run top') // setLayerCC() global.tweenManager.startTween(script.tweenObjects[1], 'init') script.sneakyAnim.startWithCallback('Top', 0, 1, function () { runNext() }) var dly = script.createEvent('DelayedCallbackEvent') dly.bind(function () { var screenPos = script.topScreenPos.anchors.getCenter() var worldPos = screenToWorld(screenPos) sneaky.setWorldPos(worldPos) }) dly.reset(0.1) } function runBottom() { print('run bottom') setLayerCC() global.tweenManager.startTween(script.tweenObjects[3], 'init') script.sneakyAnim.startWithCallback('Bottom', 0, 1, function () { runNext() }) var dly = script.createEvent('DelayedCallbackEvent') dly.bind(function () { var screenPos = script.topScreenPos.anchors.getCenter() var worldPos = screenToWorld(screenPos) sneaky.setWorldPos(worldPos) }) dly.reset(0.1) } function runHintTap() { print('hint tap') setLayerHint() var dlySpin = script.createEvent('DelayedCallbackEvent') dlySpin.bind(function() { global.tweenManager.startTween(script.frontHint, "rotate_180", function() { global.tweenManager.startTween(script.frontHint, "rotate_180") }) }) dlySpin.reset(delaySpinAfterTapStartedOnSecond) var dly = script.createEvent('DelayedCallbackEvent') dly.bind(function () { global.tweenManager.startTween(script.tweenObjects[4], 'in') var screenPos = script.sneakyTapHintPos.anchors.getCenter() var worldPos = screenToWorld(screenPos) script.sneakyArm.getTransform().setWorldPosition(worldPos) script.sneakyArm.enabled = true script.sneakyArmAnim.startWithCallback('Layer0', 0, 1, function () { global.tweenManager.startTween( script.tweenObjects[4], 'out', function () { script.sneakyArm.enabled = false runNext() } ) }) }) dly.reset(0.1) if (global.cameraSide == 'front') { script.instanceSoundScript.api.play(script.sneakyAudio2, audioVolume) } } var updateEvent = script.createEvent('UpdateEvent') updateEvent.bind(function () { if (sneakyLockedToShoulder) { var screenPos = script.shoulderScreenPos.anchors.getCenter() // move sneaky slightly right screenPos.x += 0.1 var worldPos = screenToWorld(screenPos) sneaky.setWorldPos(worldPos) } }) function setLayerHint() { script.test.forEach(function (o) { o.setRenderLayer(script.hintLayer.getRenderLayer()) }) } function setLayerCC() { script.test.forEach(function (o) { o.setRenderLayer(script.layerToCopyCc.getRenderLayer()) }) } function setLayerNorm() { script.test.forEach(function (o) { o.setRenderLayer(script.layerToCopyNorm.getRenderLayer()) }) } var camFront = script.createEvent('CameraFrontEvent') camFront.bind(function () { // init() }) function firstPassDone() { skipAfterFirst.forEach(function (s) { var ind = order.indexOf(s) if (ind > 0) { order.splice(ind, 1) print(order) } }) } function runNext(isFirst) { function afterReset() { print('here') currentIndex++ if (currentIndex > order.length - 1) { firstPassDone() currentIndex = 0 } switch (order[currentIndex]) { case 'shoulder': runShoulder() break case 'top': runTop() break case 'hintTap': runHintTap() break case 'bottom': runBottom() break } } resetSneaky(function () { var dlyNext = script.createEvent('DelayedCallbackEvent') dlyNext.bind(function () { afterReset() }) if(isFirst){ dlyNext.reset(0) } else{ dlyNext.reset(1.5) } }) } var faceFound = script.createEvent("FaceFoundEvent") faceFound.bind(function(){ if(global.cameraSide == 'front'){ init() global.tweenManager.startTween(script.findFaceHint, "out") } }) // ########## // HELPERS // ########## function screenToWorld(screenPos) { screenPos = new vec2( convertRange(screenPos.x, [-1, 1], [0, 1]), convertRange(screenPos.y, [1, -1], [0, 1]) ) return script.cam.screenSpaceToWorldSpace(screenPos, 40) } function convertRange(value, r1, r2) { return ((value - r1[0]) * (r2[1] - r2[0])) / (r1[1] - r1[0]) + r2[0] } /* Can we have Sneaky shows up on the right side of the screen, waving (frames 241-481). Then behind 3D Flip camera, tap animation (frames 482-722). 3D text rotate (can we speed up the animation so he is a bit more energic?) Then bottom left (behind native UI) idle (frames 0-240) Then repeat different appear/disappear (behind CC or in front of it like crossing the 4th wall, behind other shoulder). At one point, appears behind the logo and tap (not as energic as the previous tap) Logo will flicker (waiting assets from Apple for the logo) I set up a rough path for Red because it wasn't part of the storyboard. It starts on the left side of the screen, cross over in front of the user then rotate behind (maybe we need a portrait segmentation) and land on the user's shoulder. The world hints for Red, Car and Donatello are in this build as well as Ring counter and Steering wheel. PS: SFX to come */ //var upd = script.createEvent('UpdateEvent') //upd.bind(function(){ // var rot = script.test.getTransform().getWorldRotation() // print(rot) //})
Editor is loading...