Random Object Movement & Animation

  • #1, z hella-Tuesday, 04. January 2022, 10:11 hodinky 2 years ago
    Hey everyone.
    I am a beginner with Visionaire and Lua and I hope you can help me figure smth out. I was wondering if it is possible to create a setup to have an object move around randomly on the scene and have an animation played at the same time.

    So for example I have a snail as an object on my scene and I would like it to move around randomly and have an animation played.
    In addition, I am also wondering if you can also randomly rotate an animated object.

    Bažant

    7 Posts


  • #2, z afrlmeTuesday, 04. January 2022, 14:20 hodinky 2 years ago
    When you say move around, do you mean have it walk from point A to point B? or do you mean you want it to seemingly magically teleport around to different locations in the scene? if it's the latter then why not setup the snail as a character? You could then setup a called by other action block & a create a value & then inside of the called by other action block you would do a set random value on the value you created & then do something like this...
    if value "example" is 1

    send character "snail" to position 100, 100

    elseif value "example" is 2

    send character "snail" to position 100, 50

    elseif...

    etc

    end if

    wait until character "snail" stops

    jump to action part #1



    Then all you would need to do is call the called by other action block inside of an "at begin of scene" action, so that it starts as soon as the scene is shown.

    You would also need to make sure you manually quit/stop the called by other block before changing scenes as it's a looping action block due to the jump to x action part.

    As for randomly rotate, what do you mean by that?

    Imperátor

    7285 Posts

  • #3, z hella-Tuesday, 04. January 2022, 15:01 hodinky 2 years ago
    Yes I want the object to "walk". From point A to a random new point B. Maybe the picture attached will help.
    So the scene is a page on which the snail would be free to crawl around in any direction.
    So I would like to give it a random movement. But then it would make sense to have the snail rotate in the direction that it crawls.

    for now I kept the snail as an object as you can also pick it up and use it as an item, too.

    Bažant

    7 Posts

  • #4, z afrlmeTuesday, 04. January 2022, 16:06 hodinky 2 years ago
    It being a character shouldn't matter. You can also assign multiple directions to characters & it should orientate itself based on which direction it's walking. If you want something that looks more natural & the snail isn't supposed to move very fast/far around the scene, then it being an animation assigned to a scene object & controlled by a curve might be a better idea - though it will be a lot more complicated.

    Curves (aka bezier curves) let you create complex pathing patterns, which can also control rotation, scale, etc. A good example of where a curve would work really well, is let's say you want to have a bird swoop in from outside of the scene edge down near to the ground & then swoop back up & maybe do a loop the loop or something just for the fun of it. With curves that would be possible & it wouldn't just be moving from point A to point B in a rigid line, it would appear to gradually rotate & move with the curve lines you have drawn.

    By the way, I would recommend joining our discord server if you aren't already on there. I've not been very well the past week, so unfortunately I'm not really up to providing any examples right now, but there's plenty of helpful people always online on the discord server that might be able to provide you with a solution. wink

    https://discord.gg/g5zFejW

    Imperátor

    7285 Posts