Jump to content

Problems with tree growth animation

Recommended Posts

Today I just got into Spriter to start making a custom growth animation for my marble seed.
The problem is.. weird things started happening when I tested the animation in game.
Approach 1:

Frame 0: Planted seed normal sizeFrame 200: Planted seed shrunk to oblivion.Frame 201: Remove planted seed, add very, very small tree.Frame 1000: Tree enlarges to its regular size.

Which gives as a result a nice animation, except for something:


(Tree on the right).

The seed never disappears (regrows while the anim plays) and stays there until the tree is mined at least once.


Approach 2:

Frame 0: Planted seed as normal.Frame 200: Seed shrunk to oblivion.Frame 201: Seed image is replaced by very small tree image (hold right mouse button, select image).Frame 1000: Tree is enlarged to its full size.

Which gives as result, well...



... Anyways, this is the part that handles the animation (inside my marble seed prefab):

local function growtree(inst)    inst.growtask = nil    inst.growtime = nil    inst.issapling:set(false)    local treenum = 1--math.random(1,4) --One tree at a time	local tree = SpawnPrefab("marbletree_"..treenum)    if tree then 	tree.Transform:SetPosition(inst.Transform:GetWorldPosition() )         tree.AnimState:SetBank("marble_trees")        tree.AnimState:SetBuild("marbleseed")        tree.AnimState:PlayAnimation("growing_"..treenum)        --tree:growfromseed()        inst:Remove()	endend

Doing this for both approaches.


Any ideas why this is happening?


Attaching the scml of the second approach in case someone wants to give it a look.





Edited by Ryuushu
Link to comment
Share on other sites

@Ryuushu, I'm not that familiar with Spriter (only done really basic stuff in it), but I'd guess the root is getting messed up in the second approach somehow.


Although I think there should be a way to fix the seed showing on the first approach... Are you using the same code for handling the animation on the first approach? Presumably the seed is another object in the Spriter project, and you may be able to hide/show it independently of the larger tree (the way the game hides the idle arm on the character vs the carrying arm, or hair when a hat is on).

Link to comment
Share on other sites

Yup, I was using the same code. Uh, I did not manage to do that, well, rather, I didn't need to do it. After I looked at Wilson's stategraph I saw the part you mentioned, so I went back to Spriter and I noticed that little return arrow called "Repeat Playback"... Turns out (not surprisingly) that enabling it on animations that are only supposed to run once will mess them up (and disabling it on "static" animations, like dropped items, will make them invisible <<; ).

The approach I'm using now is basically the first with a little modification:

Frame 0: Planted seed normal sizeFrame 200: Planted seed shrunk to oblivion.Frame 201: Remove planted seed, add very, very small tree.Frame 950: Tree enlarges to its regular size.Frame 1000: Tree stays in its regular size.

Without those 50 frames the tree will grow up a tiny little bit when mined once. Which looks kinda weird.

Here's how it looks now:


And yup, second approach messes up the root, even now.


Like always, thank you very much!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...