How to move object with script

Harry Banda
Harry Banda Posts: 8
edited June 2022 in Programming #1

When I try to move an object using a script I get the following error:

19:47:42 [Tween/TweenManager.js:506] Tween Manager: Tween, move_bunny, is not found. Ensure that move_bunny is on "Lens Turn On" and that Tween Manager is at the top of the Objects Panel.

Screenshots:
https://imgur.com/a/aj5iKZa

Comments

  • Max
    Max Posts: 26 🔥

    The TweenTransform script is set to 'Tapped' in your screenshot.
    Set it to 'Lens Turned On' so the TweenManager can find it! Then playing it from code will work.

    Here's some example code that would play this Tween on tapped, though I think you already have this set up in your project :)

    //@input SceneObject objectWithTweenScript
    
    function onTapped(){
        global.tweenManager.startTween(script.objectWithTweenScript, "move_bunny");
    }
    var tappedEvent = script.createEvent("TapEvent");
    tappedEvent.bind(onTapped);
    

    Hope this helps!