[SOLVED]AnimationList: only plays first animation?

edited September 2010 in Help request
Surely I can't be that thick :)

Hi iarwain and all,

I have devoured the 04_Anim over and over and also the good thread here: https://forum.orx-project.org/discussion/123

...but I cannot work out animation sets.

I have two animations defined. I can create the object onscreen and set the orxObject_SetTargetAnim to my first animation and it plays.

Set it to the second one and it plays the first one only.

Set it to something illegal, and it still plays the first one.

Here's the minimal code to illustrate:


INI
---
[AnimatedObject]
Graphic			= t01 ;as a default	
Scale			= 2.0
Position  		= (0, 0, 0)
AnimationSet 	= UtilitiesAnimSet

[UtilitiesAnimSet]
AnimationList	= ElevatorAnim#DoorAnim
LinkList	= ElevatorLoop#DoorLoop

[ElevatorAnim]
DefaultKeyDuration  = 1.0; <= This defines the duration for all our frames unless locally specified differently
KeyData1            = t01; elevator open
KeyData2            = t02; elevator closed

[DoorAnim]
DefaultKeyDuration  = 1.0; <= This defines the duration for all our frames unless locally specified differently
KeyData1            = t03; door open
KeyData2            = t04; door closed


[ElevatorLoop]
Source		= ElevatorAnim
Destination = ElevatorAnim

[DoorLoop]
Source		= DoorAnim
Destination = DoorAnim


[Tiles]
Texture     = ../../data/scenery/tiles.png
TextureSize = (32, 48, 0)
Pivot		= top left

[t01@Tiles]
TextureCorner = (0, 0, 0)

[t02@Tiles]
TextureCorner = (32, 0, 0)

[t03@Tiles]
TextureCorner = (64, 0, 0)

[t04@Tiles]
TextureCorner = (96, 0, 0)

Code
----
orxOBJECT *tile;
tile = orxObject_CreateFromConfig("AnimatedObject");

orxObject_SetTargetAnim(tile, "ElevatorLoop");


The above code plays my ElevatorAnim in a loop nicely.

Changing the last line to: orxObject_SetTargetAnim(tile, "DoorLoop"); plays the ElevatorAnim in a loop.

Changing the last line to: orxObject_SetTargetAnim(tile, "asdkjhacxv xlcjvh"); plays the ElevatorAnim in a loop.

I know I'm missing something completely obvious. Tested on both windows and linux builds, and also tried orxObject_SetCurrentAnim instead of orxObject_SetTargetAnim calls.

ps. iarwain, hope the move went well and wasn't too stressful.

Comments

  • edited September 2010
    Hello,

    My guess is that you haven't set up the animation transitions properly.
    They are the ones you set up in the LinkList property of the animation set.

    So you need something like this:
    [Elevator2Door]
    Source = ElevatorAnim
    Destination = DoorAnim
    

    and vice versa, if you wan't the reverse transition aswell. Then add those to the LinkList:
    LinkList = ElevatorLoop#DoorLoop#Elevator2Door#Door2Elevator
    

    The orxObject_SetTargetAnim should then find the path to the animation.

    Edit: I just read that not even SetCurrentAnim works, so maybe it's not the transitions after all...
  • edited September 2010
    Thanks for that, gives me things to try.

    I think what I might do first is make a copy of 04_Anim and deconstruct it slowly to match my code and see at what point it behaves like my code. I'll change "target" to "current" first and remove all 04_Anim links.

    Hopefully that might turn up the basic rule I'm missing.
  • edited September 2010
    Hi!

    Well, as usual Ekerik wrote it all. :) You're indeed missing a transition to go from one animation to the other.

    Using SetCurrent will help with this issue but actually bypass the whole graph logic. The purpose of the animation graph is for orx to find the correct animation to chain depending on the final animation you want.

    Such as SetTarget("Run"), will trigger different animations depending if your character is sitting or standing (and if you have a stand up animation to go from sitting to standing).

    The system itself is very powerful but its description in a .ini file is extremely annoying. I couldn't find a more elegant way to define all the links so I'm hoping to see a (community-created?) editor to do the dirty work for the developer in the future! :)

    PS: The move went well and I just arrived to the hotel near San Francisco about 30 mins ago, thanks for asking! Time to catch some sleep now! :D
  • edited September 2010
    Thanks for that. I certainly will need the graph system for the main sprites in the game. The utility stuff like elevators certainly need to be bypassing the graph.

    I just finished cutting back a copy of 04_Anim to see what happens. The results are interesting:



    1. Remove Update Clock and Animation handler, add orxObject_SetTargetAnim(pstSoldier, "WalkRight") after the created object in Init().

    Result: WalkRight animation plays and loops

    2. Change to orxObject_SetTargetAnim(pstSoldier, "WalkLeft");

    Result: WalkLeft animation plays and loops

    3. Reduce the AnimSet LinkList to: LinkList = WalkRightLoop#WalkLeftLoop and AnimationList = WalkRight#WalkLeft

    Result: No animation plays. Only Still frame. (I now understand that this is because of the broken links in the animation graph)

    4. Change orxObject_SetTargetAnim(pstSoldier, "WalkLeft"); to orxObject_SetCurrentAnim(pstSoldier, "WalkLeft");

    Result: WalkLeft animation plays and loops

    5. Delete [IdleRightLoop], [IdleRight2Left] & [IdleRight2WalkRight] declarations from the ini.

    Result: WalkLeft animation plays and loops

    6. Delete [WalkRight2IdleRight], [IdleLeftLoop], [IdleLeft2Right] & [IdleLeft2WalkLeft] declarations from the ini.

    Result: WalkLeft animation plays and loops

    7 Delete [WalkLeft2IdleLeft], [IdleRight] & [IdleLeft] declarations from the ini.

    Result: WalkLeft animation plays and loops



    The aim of the above is to just have two animations, WalkRight and WalkLeft defined and in the link list, no transitions, and to get it to play the second animation which is to play WalkLeft by bypassing the graph. It is successful.

    My own example however is not able to play the second anim. So I've proved the system works as it should, but what is in my code/config that upsets things...

    I'll continue cutting pieces away until I work out what element causes my issue.
  • edited September 2010
    SOLVED!

    It appears with all my dancing around different settings I never had two crucial things set at the same time:

    orxObject_SetCurrentAnim

    used instead of...

    orxObject_SetTargetAnim


    But at the same time... I should have been calling the animation definitions (ie DoorAnim), not the source/target loop definitions (ie DoorLoop).

    Can't believe it as that simple and I never hit on that combination with everything I tried.

    Anyway all good, thanks for the tips, guys. Onto the next part.
  • edited September 2010
    I'm glad you found the issue! =)

    I'd be happy to hear about any ideas on how to improve the animation/graph declaration as it's rather annoying in its current state.
  • edited September 2010
    I really think for the power the graph system gives you, and the amount of code you avoid with it, I'm surprised to hear that is considered annoying by some (from what I read).

    The only thing that could be considered annoying is the sheer amount of sections to write and hook up. A small editor would certainly be nice if someone writes one (like a node editor to connect up the animations and output a config).

    But without it, I think the system is great as it is. I'm planning to write a small tutorial on it based on my findings to make it easier for others coming in.
  • edited September 2010
    sausage wrote:
    I really think for the power the graph system gives you, and the amount of code you avoid with it, I'm surprised to hear that is considered annoying by some (from what I read).

    I have to admit than when you get 10+ animations for a character, writing all the links become a tedious task.
    The only thing that could be considered annoying is the sheer amount of sections to write and hook up. A small editor would certainly be nice if someone writes one (like a node editor to connect up the animations and output a config).

    An editor would be great and would prevent most of the mistakes that can be made when writing the links. Also it'd allow to preview the animations chaining visually, and that would be a great feature.
    But without it, I think the system is great as it is. I'm planning to write a small tutorial on it based on my findings to make it easier for others coming in.

    Good as I don't see any editor coming anytime soon.
    Eyecreate's Pey editor was a first step in this direction but I don't think there has been much progress on it lately.

    I, for sure, won't write such an editor due to serious lack of time and the fact I hate writing UI code. :D

    A tutorial might be very helpful though, I'm looking forward to seeing it! :)
Sign In or Register to comment.