Explosion Animation

edited June 2013 in Help request
I am trying to animate ammo explosion and for some reason nothing happens.
I use 04_Anim tutorial as an example.

I am a bit confused mostly because I want a single time animation.

In my ammo object I do something like this. I tried increasing lifetime of the Ammo object, but it had no impact.
orxBOOL Ammo::OnCollide(ScrollObject *collider, const orxCHAR *partName, const orxVECTOR &position, const orxVECTOR &normal)
{
    /* just die */
    SetLifeTime(orxFLOAT_0);
    SetAnim("ExplosionAnimSet"); // trigger animation
    return orxTRUE;
}

And here is my config setup. I don't get how LinkList should work in this case.
[ExplostionAnimSet]
AnimationList = ExplosionAnim
LinkList = ExplosionLink

[ExplosionLink]
Source = ExplosionAnim
Destination = ExplosionAnim

[ExplosionAnim]
DefaultKeyDuration = 0.1
KeyData1 = Explosion0
KeyData2 = Explosion1
KeyData3 = Explosion2

[Explosion]

[Explosion0@Explosion]
Texture = explosion0.png

[Explosion1@Explosion]
Texture = explosion1.png

[Explosion2@Explosion]
Texture = explosion2.png

Comments

  • edited June 2013
    Some quick observations:

    - If you delete your object at the same time you set an anim on it, you won't be able to see it. ;)
    - You have a typo in ExplostionAnimSet, did you do the same when referencing it from your object?
    - You should add a second animation, Idle, which would just be one frame and would loop on itself, this way you can have a real anim graph: idle->idle, idle->explosion, explosion->idle.
    - You can do your SetLifeTime(0) when handling the new animation (explosion->idle) or by adding a custom event somewhere in your animation and using OnNewAnim()/OnAnimEvent: this way, even if the length of your anim changes, your Ammo object will always be deleted at the right time.
  • edited June 2013
    I got it working. My ammo or bullet did not have AnimationSet property defined. I thought it was not necessary, because I was setting animation at runtime.

    Here is how I understand it. The AnimationSet has to be defined before the actual animation can be used. So, in my case I have only 2 states: idle and explosion, but 3 transitions: idle-to-idle, idle-to-explosion and explosion-to-idle. I have to define the AnimationSet with animations and valid transitions (links) between animations. The 1st animation in the set is the default one.

    What is the difference between orxObject_SetTargetAnim and orxObject_SetCurrentAnim?
    I think that one changes abruptly and the other uses links to change animation from one to another thus it should result in a smooth animation transition from one state to another.


    Unfortunately I am now getting an error on application exit. If I comment out the line:

    AnimationSet = ExplosionAnimSet

    the error on exit does not occur.

    I really don't do much with bullets. I create bullets, react on collision with the bullet and that's it. My object's method on collision takes the hit damage and and the bullet simply goes away. I obviously need to start using events to dispose of the bullet instead of SetLifeTime(3.), but I don't think it is what causes the error listed below.

    Error:
    [15:38:27] [ASSERT] [orxStructure.c:orxStructure_Delete():519] [ASSERT] : <((orxSTRUCTURE *)_pStructure)->u64OwnerGUID == orxU64_UNDEFINED>
    
    #0	0x000000010007c495 in _orxDebug_Break at src/debug/orxDebug.c:306
    #1	0x000000010012d63b in orxStructure_Delete at src/object/orxStructure.c:519
    #2	0x0000000100055699 in orxAnimSet_Delete at src/anim/orxAnimSet.c:1657
    #3	0x00000001000512aa in orxAnimPointer_Delete at src/anim/orxAnimPointer.c:634
    #4	0x00000001000c06d2 in orxObject_UnlinkStructure at src/object/orxObject.c:3385
    #5	0x00000001000c0085 in orxObject_Delete at src/object/orxObject.c:2531
    #6	0x000000010000e830 in ScrollObjectBinder<Ammo>::DeleteObject(ScrollObject*) at Scroll/ScrollBase.inl:2104
    #7	0x00000001000023ca in ScrollBase::DeleteObject(ScrollObject*) at Scroll/ScrollBase.inl:241
    #8	0x0000000100004d0f in ScrollBase::BaseExit() at Scroll/ScrollBase.inl:1295
    #9	0x0000000100001caa in ScrollBase::StaticExit() at Scroll/ScrollBase.inl:1483
    

    I like that orx is capable of detecting that higher level code made a mistake. It caught me a few times already. I think this is another case of object reference being kept after the object was destroyed by orx.

    My code:
    orxBOOL Ammo::OnCollide(ScrollObject *collider, const orxCHAR *partName, const orxVECTOR &position, const orxVECTOR &normal)
    {
        /* just die */
        SetLifeTime(3.);
        SetAnim("ExplosionAnim", orxTRUE);
        return orxTRUE;
    }
    

    Config file:
    
    [AmmoT]
    Graphic = @
    Texture = pixel
    Position = (0, 0, 0)
    Scale = (6, 3, 0)
    Body = AmmoBox
    AnimationSet = ExplosionAnimSet
    
    [ExplosionAnimSet]
    AnimationList = ExplosionIdleAnim # ExplosionAnim
    LinkList = ExplosionAnim_Idle_to_Idle # ExplosionAnim_Idle_to_Expl # ExplosionAnim_Expl_to_Idle
    
    [ExplosionAnim_Idle_to_Idle]
    Source = ExplosionIdleAnim
    Destination = ExplosionIdleAnim
    
    [ExplosionAnim_Idle_to_Expl]
    Source = ExplosionIdleAnim
    Destination = ExplosionAnim
    
    [ExplosionAnim_Expl_to_Idle]
    Source = ExplosionAnim
    Destination = ExplosionIdleAnim
    
    [ExplosionAnim]
    DefaultKeyDuration = 0.1
    KeyData1 = Explosion0
    KeyData2 = Explosion1
    KeyData3 = Explosion2
    
    [ExplosionIdleAnim]
    DefaultKeyDuration = 0.1
    KeyData1 = AmmoT
    
    [Explosion]
    Pivot = center
    
    [ExplosionIdle@Explosion]
    Texture = pixel
    
  • edited June 2013
    Out of curiosity, are you using the latest from the hg repo?

    And yes, you're correct for SetTargetAnim/SetCurrentAnim: the target will set a "destination" on the graph and try to follow the links that will bring us there, raising all the encountered events in the process, whereas the current version will just "teleport" us to that node of the graph, no matter if it was reachable or not in the first place.
  • edited June 2013
    I try to keep up with orx. So, I am on current:
    https://bitbucket.org/orx/orx
    https://bitbucket.org/orx/scroll
    

    I am running "turns".

    At the moment the explosion animation has 16 images and thus it should take 1.6 seconds, but it may get paused and I've seen it paused in the middle. May this be an issue?
  • edited June 2013
    Always make sure the folder /include/Scroll/orx uses the latest version from /orx/include as I don't update the repo of Scroll as often as orx gets modified. :)

    I only see 3 frames in your config for the explosion, so I guess it's not the same version?

    When did you notice the animation get paused? If you pause the game, that should happen (there's a config property Pausable if you want some objects not being affected by Scroll::Pause()).
    Otherwise it might be an issue somewhere either in your game or on orx's side.
    If you share your project with me, I can have a look if you want, that should be easier than doing it with snippets over the forum. :)
  • edited June 2013
    I don't want to waste your time on my issues. I will do my best on my side and share the project offline if I can't find the problem.

    Yes, I saw Scroll had its own copy of includes. I did not consume that.
  • edited June 2013
    I have decided to create a simpler test project and to my surprise I was able to reproduce my issue almost immediately.

    All I have to do is start application, it displays a dot. Animation is not even getting triggered on the visual side. Quit application (I use Cmd-Q) and I get the reported error.

    The bitbucket public project that demonstrates the issue is here:

    https://bitbucket.org/Kulak/testanimationinscroll
  • edited June 2013
    Thanks, I'll try it tonight or tomorrow. However your project is currently private, I can't access it.
  • edited June 2013
    oops. I meant to make it public.

    I have changed the project to public and allowed forks.
  • edited June 2013
    I reference original scroll project, but I have renamed orx include folder to be "no orx". This way I made sure I don't consume old version of orx include files.
  • edited June 2013
    I've just tried your test project on Windows7/VS2008 with the latest Scroll&orx from the hg repositories and couldn't repro your issue.

    What I did is simply launch, see there's a dot being displayed and quit by pressing the 'X' button in both debug & release.

    I'll have to try it on OS X this week end, but I'd be surprised if it were a platform dependent issue given the callstack.

    Just in case, could you double check your libraries (both compile time and runtime) are in sync with your headers?
  • edited June 2013
    I had to rebuild my orx copy for unrelated reason.

    However, after I have rebuilt orx and scroll copies I no longer have an issue in the test project.

    I guess my original project configuration was messed up somehow.
  • edited June 2013
    Happy to hear that, less work for me. ;)
Sign In or Register to comment.