Page 1 of 1

[Solved] Why does "loop = true" not keep animations running?

Posted: Tue Oct 27, 2015 7:51 pm
by MrChoke
Maybe I do not understand what loop = true means for animations. It doesn't do anything when defined in the object or set with animation:setLoop(true). I am doing a custom healing crystal. One without the "Crystal" component. But I am using everything else from it, including the "spin" animation. However, I cannot keep it spinning. Am I missing something?

[Solved] Re: Why does "loop = true" not keep animations runn

Posted: Tue Oct 27, 2015 10:42 pm
by MrChoke
I still don't know what loop = true does but I solved my problem in another way. I want the spin to keep going. It was easy with my first animationEvent. I use normalizedTime = 1 to do the event at the end of the spin and then I restart it. Very neat.

Code: Select all

...
  {
            class = "Animation",
            animations = {
                spin = "assets/animations/env/healing_crystal_spin.fbx",
            },
            onAnimationEvent = 
                function(self, event)
                    print("in onAnimationEvent", event)
                    if event == "spinEnd" then
                        self:stop()
                        self:play("spin")
                    end
                end,
           },
...

defineAnimationEvent{
    animation = "assets/animations/env/healing_crystal_spin.fbx",
    event = "spinEnd",
    normalizedTime = 1,
}
UPDATE: Answered my own question. "playOnInit" is required for "loop = true" to work. I wanted the crystal to start out disabled and not spinning. Then I click something to activate it and start the spin. Doing it like this does not keep it spinning. You have to do the animationEvent above in order to keep it going.

Re: [Solved] Why does "loop = true" not keep animations runn

Posted: Tue Oct 27, 2015 10:49 pm
by petri
AnimationComponent:play() has an optional second argument 'loop' (default false) which you can use to play a looping animation. This should work: play("anim", true)

playOnInit and loop properties are just shortcuts so that a script is not needed for simple cases.

Re: [Solved] Why does "loop = true" not keep animations runn

Posted: Wed Oct 28, 2015 12:30 am
by MrChoke
petri wrote:AnimationComponent:play() has an optional second argument 'loop' (default false) which you can use to play a looping animation. This should work: play("anim", true)

playOnInit and loop properties are just shortcuts so that a script is not needed for simple cases.
Oh. Thanks Petri! I will update the wiki with this.

Re: [Solved] Why does "loop = true" not keep animations runn

Posted: Wed Oct 28, 2015 12:33 am
by Isaac
petri wrote:AnimationComponent:play() has an optional second argument 'loop' (default false) which you can use to play a looping animation. This should work: play("anim", true)

playOnInit and loop properties are just shortcuts so that a script is not needed for simple cases.
Do crystals without the crystal component affect ironman/single save modes?

Re: [Solved] Why does "loop = true" not keep animations runn

Posted: Wed Oct 28, 2015 2:59 am
by minmay
Isaac wrote:
petri wrote:AnimationComponent:play() has an optional second argument 'loop' (default false) which you can use to play a looping animation. This should work: play("anim", true)

playOnInit and loop properties are just shortcuts so that a script is not needed for simple cases.
Do crystals without the crystal component affect ironman/single save modes?
If it doesn't have a CrystalComponent, it's not a crystal, and it won't save the game.

Re: [Solved] Why does "loop = true" not keep animations runn

Posted: Wed Oct 28, 2015 4:48 am
by MrChoke
I have completed my plans with crystals in my dungeon with the help you guys. Basically I have a crystal that uses the "Crystal" component. I changed only the activate and deactivate textures. This means it has a built-in party heal and auto-save. And with that "reload" code from minmay, I have the correct material reloading upon a game load.

Then I have eight other crystals that I will use more like power sources and not as healing crystals. This do not have a crystal component. I re-use the model, the animation, the sound, but with my own colored textures for activated and deactivated. And because there is no crystal component, there is no auto-save and no party heal. Also, because there is no crystal component I can use setMaterialOverrides() instead of setMaterial() to change the textures. setMaterialOverrides() does not need special processing for a reload. The game handles it automatically.