[Solved] Why does "loop = true" not keep animations running?
[Solved] Why does "loop = true" not keep animations running?
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?
Last edited by MrChoke on Tue Oct 27, 2015 10:43 pm, edited 1 time in total.
[Solved] Re: Why does "loop = true" not keep animations runn
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.
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.
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,
}
Re: [Solved] Why does "loop = true" not keep animations runn
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.
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
Oh. Thanks Petri! I will update the wiki with this.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.
Re: [Solved] Why does "loop = true" not keep animations runn
Do crystals without the crystal component affect ironman/single save modes?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.
Re: [Solved] Why does "loop = true" not keep animations runn
If it doesn't have a CrystalComponent, it's not a crystal, and it won't save the game.Isaac wrote:Do crystals without the crystal component affect ironman/single save modes?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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: [Solved] Why does "loop = true" not keep animations runn
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.
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.