Move objects in the scene

  • #1, by OcasoThursday, 11. December 2014, 00:31 10 years ago
    Hello, I want to move a object or a animation to one point to another. I want to make a bird fliying from one side to the screen to the other side. How can i do it?

    Can i made that animation appears on the scene randomly?

    Thanks

    Newbie

    14 Posts


  • #2, by afrlmeThursday, 11. December 2014, 02:19 10 years ago
    Actually yes. I recommend checking out this tutorial & .ved example I created @ here.

    Actually it seems I've not yet gotten round to writing up the tutorial part but maybe you can figure it out from the .ved? It's pretty complex though if you don't have any scripting knowledge.

    The example shows how to create dynamic clouds that are randomly placed on scene start & on each loop the speed, y position & scale of the animation is randomly generated.

    Making animations move is as simple as 1 line of code though.
    startObjectTween( ActiveAnimations["animation_name"], VAnimationCurrentPosition, ActiveAnimations["animation_name"].AnimationCurrentPosition, {x = 300, y = 500}, 3000, easeLinearOut) -- move animation_name to 300.500 over 3s with easing easeLinearOut.
    


    I recommend using my little workflow function instead of having to type out full startObjectTween functions each time though.

    add code as definition script to script section. check the example for how to call the function.
    -- example: moveAnim("animation_name", 300, 500, 3000, easeQuintOut) -- move animation_name to 300.500 over 3s with smooth ease out.
    
    function moveAnim(anim, x, y, delay, easing)
     startObjectTween( ActiveAnimations[anim], VAnimationCurrentPosition, ActiveAnimations[anim].AnimationCurrentPosition, {x = x, y = y}, delay, easing)
    end
    

    Imperator

    7278 Posts

  • #3, by NovelThursday, 11. December 2014, 22:38 10 years ago
    I have some kind of tutorial here (without LUA).
    http://www.visionaire-studio.net/forum/thread/objekte-einfac...

    Only German but google-translator should help.

    It's a bit outdated (I think vis4 has another way to move objects) but getting the logics behind still make sense, I think.

    Newbie

    100 Posts

  • #4, by afrlmeThursday, 11. December 2014, 22:58 10 years ago
    Yes it's possible to move animations without lua script but it involves using if queries & values to check/update the position as well as creating a loop with the jump to x action part.

    In 4.0 there's the move object by action part which allows you to actually offset the object & object polygon itself. In the upcoming build there is a new action part which allows you to send an object to specific coordinates. Both action parts allow you to specify the amount of time it should take for the object to move from current position to the target coordinates/offset value.

    It can be done with a single line of Lua now too so I guess there's plenty of methods available to choose from. smile

    P.S: I've already sent him back the .ved he sent me with it moving the animation. It randomly positions the bird animation on scene start & randomly sets animation scale between a min & max value & uses a randomly generated delay value for each time the bird flies across the screen to make it more dynamic.

    Imperator

    7278 Posts

  • #5, by nelsoncMonday, 26. January 2015, 03:08 10 years ago
    When will the next build be available ? I was looking at using such feature to display ending credits. Thanks !!!

    Newbie

    43 Posts

  • #6, by nelsoncMonday, 26. January 2015, 03:40 10 years ago
    In the meanwhile, is it possible to get the line of code to move an object from its current position to a defined point (knowing its name) ? Google is not helping very much :-/ Thank you very much !!

    Newbie

    43 Posts

  • #7, by nelsoncMonday, 26. January 2015, 04:28 10 years ago
    using function found in wiki :

    function moveObj(obj, x, y, delay, easing)
    obj = getObject("Game.GameCurrentScene.SceneObjects[" .. obj .. "]")
    startObjectTween(obj, VObjectOffset, obj:getPoint(VObjectOffset), {x = x, y = y}, delay, easing)
    end

    To summarize the script :
    - pause 1 ms
    - execute script moveObj("Obj_Credits", 0, 0, 0, easeQuintOut)
    - move object Obj_Credits in 15000 ms

    Couldn't use twice moveObj("Obj_Credits", 0, 0, 0, easeQuintOut) because couldn't find easing enum in documentation (I was looking for linear easing).
    Using directly startObjectTween did not work properly (first time ok but not second time). Had to use moveObj function.

    Newbie

    43 Posts

  • #8, by afrlmeMonday, 26. January 2015, 14:36 10 years ago
    I moving animations instead of objects (if possible). Currently move object action part & moveObj() function work based off of offset value, so whatever position it is currently placed on scene is classed as 0,0 instead of whatever the actual coordinates are.

    To use an animation:

    1. add the animation to a scene object & set as infinite in the properties tab.

    2. drag the animation position to below the scene background.

    3. create an at begin of scene action & then create begin cutscene action inside of this & then add an execute a script action part containing...

    local anim = ActiveAnimations["animation_name"] -- replace animation_name with name of animation you want to move (case sensitive)
    anim:to(time, { CurrentPosition = {x = anim.CurrentPosition.x, y = - 1000} }, easeQuintOut) -- replace y value with negative animation height value, replace time with time (in ms) the animation should take to move from current coordinates to target coordinates
    


    4.Then add a pause action part containing the same amount of time as the time you set in the script above.

    5. Finally add an end cutscene action part. The cutscene will allow people to skip the credits with ESC key.

    6. Add other action parts after this (as needed).

    Hope this helps, somewhat...

    Imperator

    7278 Posts

  • #9, by nelsoncMonday, 26. January 2015, 16:21 10 years ago
    Is it possible to use another easing than easeQuintOut?
    I would like a linear easing for ending credits.

    And yes, your posts helped, thanks :-)

    Newbie

    43 Posts

  • #10, by afrlmeMonday, 26. January 2015, 16:32 10 years ago
    Sure you can use whatever easing you like.

    easeLinearInOut, easeLinearIn, easeLinearOut, easeSineInOut, easeCircInOut, easeQuintInOut, etc... all of them have InOut, In or Out versions. There's even more available than that too.

    http://easings.net/ -- most of these work, but the names are written differently (see examples above).

    Imperator

    7278 Posts