We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Play animation through runCode function

Home Forums General Questions Play animation through runCode function

Tagged: 

  • This topic has 3 replies, 2 voices, and was last updated 2 years ago by kdv.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #56583
    sazzrro
    Participant

    Hello, I’m wondering what method I should be using in order to play an animation of an object with code. After learning about the runCode function, I’ve been able to do other things to objects like change their position, material, and switch cameras; however, I haven’t yet found the right method to use in order to play an animation this way. My resource for seeing what methods/properties are available is found here:
    Resource

    I noticed that the doc says to not change the .animate method unless you know what you’re doing so I don’t think that’s the one I’m looking for, but I could be wrong

    #56586
    kdv
    Participant
    function runCode(app) {
      const action = v3d.SceneUtils.getAnimationActionByName(app, 'farmer_mesh');
      action.play();
    }

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #56587
    sazzrro
    Participant

    Thanks, I got it to work with that code. I had to use the reset method before using the play method to have it run

    #56589
    kdv
    Participant

    you can stop all actions before running the chosen one
    app.mixer.stopAllAction();

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.