3D object rotating, want it to pause on tap, and resume on next tap.
How can I achieve this. I am using the setting attached to automate my rotation of the object. I have it set to rotate when Lens is initiated, but I want to make it pause, and then resume on tap events. I was told I more than likely need to create a custom script for this. Could someone help me figure this out? my JS skills are rudimentary at best, and 'm really stumbling along through the code. lol
-
Hi Topher,
You can achieve what you're describing with the following script.
// ToggleTweenPlayback.js
// tweenObject [SceneObject]: The SceneObject with the Tween Scripts
//@input SceneObject tweenObject
// tweenName [string]: The name of the tween to pause/resume on tap
//@input string tweenName
script.createEvent("TapEvent").bind(onTap);
function onTap(e){
if(global.tweenManager.isPaused(script.tweenObject, script.tweenName)){
// Resume the tween if it is paused
global.tweenManager.resumeTween(script.tweenObject, script.tweenName);
}
else if(global.tweenManager.isPlaying(script.tweenObject, script.tweenName)){
// Pause the tween if it is playing
global.tweenManager.pauseTween(script.tweenObject, script.tweenName);
}
}It will look like this when added to a Scene Object:
Set Tween Object to the SceneObject that has a Tween script on it.
Set Tween Name to the name of the tween you want to toggle.
Let me know if you have any other questions!
Best,
Peter
Comment actions -
Hi Peter! Thanks so much for taking the time to reply. I put this script on my SceneObject "Jersey" and it changes the SceneObject from the green icon, to a script icon. (not sure if this is supposed to). Also, after that, I tried to put the Tween Object as the jersey mesh (blue icon), but the only Tween I have defined is TweensJersey, which is setting it to rotate... is that the Tween Name I should be setting?
Comment actions -
Just figured this out... after reading through the error log, I realized I needed to have the SceneObject as TweensJersey, not the actual mesh. The tween is located inside the TweensJersey Scene Object.
Thanks!
Comment actions
Please sign in to leave a comment.
Have a comment?