aliens

Author Topic: Better Explosion Timing  (Read 13972 times)

Offline mercy

  • Colonel
  • ****
  • Posts: 341
    • View Profile
Better Explosion Timing
« on: May 21, 2013, 10:17:52 am »
Noticed in 0.9 that explosions go too fast. When the camera centers on Explosion_Position the game has played most explosions frames already so the player usually sees only the end of the explosion animation.

Possible solution:    in sequence

Missile shot or grenade thrown

If timer reaches 0 or missile hits  schedule camera movement among other game events to explosion position. So the game knows it should sometime move the camera to explosion position

Camera is CENTERED on explosion

Explosion frames play out

Display sprite Frame 1 and KEEP IT ON SCREEN  don't let it disappear

wait a few ticks = on correct computer speed or framerate if you calculate it for users CPU strength

Display sprite Frame 2 and KEEP IT ON SCREEN  don't let it disappear

wait a few ticks = on correct computer speed or framerate if you calculate it for users CPU strength

Display sprite Frame 3 and KEEP IT ON SCREEN  don't let it disappear

Measure the time of EXPLOSION_SOUND_EFFECT_DURATION and keep the explosion sprite frames ON SCREEN so that LAST_FRAME_OF_EXPLOSION_SPRITE is KEPT ON SCREEN right until explosion sound effect play ends.

This requires skillful timing of showing every explosion frames for the correct duration.
In the original game explosions play out very skillfully timed, please observe.

In OpenXCOM explosions play out too fast when the camera gets centered on it the frames are usually GONE or only the last 1-2 frames play then I can see only smoke.

I did special effects for two of our commercial games so I noticed this.

Examples: using the explosion sprite MOD

Basic anim 0.2 sec pause between frames

8 FRAMES (default number of sprites)


Double-frame using
FRAME_1 ....
FRAME_2 50% opacity Dissolve layer mode in Photoshop
FRAME_2 100% opacity Dissolve = Normal at 100% opacity layer mode in Photoshop
FRAME_3 50% opacity Dissolve layer mode in Photoshop
FRAME_3 100% opacity Dissolve layer mode in Photoshop
etc..   

16 FRAMES


Same animation sped up: 0.05sec delay between frames simulating FiRE SPEED 5 or 6 in OpenXCOM   

16 FRAMES


0.02 sec delayed animation per frame  to simulate  OpenXCOM FiRE SPEED 5 or 6 using above frame doubling technique: 

16 FRAMES


« Last Edit: May 22, 2013, 04:47:46 pm by mercy »

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: Better Explosion Timing
« Reply #1 on: May 21, 2013, 10:51:47 pm »
In openxcom battlescape animations, including explosions, play at 10 FPS. so 0.1 sec per frame, or on 100msec timer. No matter your firespeed. So I'm not sure where you get that 0.02 number?

I also have no idea what the original animation speed is, because in my dosbox it runs a lot faster, more like the last explosion. So the 10FPS looks very natural to me.

I checked specially for you :) The xcom normal explosion sound is 0.5sec long + 0.5sec of reverb. The explosion animation is 8 frames. So at 10FPS the animation is 0.8 sec long, which is perfect ;)
« Last Edit: May 21, 2013, 11:00:50 pm by Daiky »

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Better Explosion Timing
« Reply #2 on: May 21, 2013, 11:02:07 pm »
call me crazy... but maybe that should be 8 frames per second? (just going with gut instinct here, because most animated objects seem to follow a rule of 8. i have nothing substantial to back up my claim.)

Offline mercy

  • Colonel
  • ****
  • Posts: 341
    • View Profile
Re: Better Explosion Timing
« Reply #3 on: May 22, 2013, 08:51:20 am »
In openxcom battlescape animations, including explosions, play at 10 FPS. so 0.1 sec per frame, or on 100msec timer. No matter your firespeed. So I'm not sure where you get that 0.02 number?

It's the delay I set between GIF frames.

I also have no idea what the original animation speed is, because in my dosbox it runs a lot faster, more like the last explosion. So the 10FPS looks very natural to me.
Yes, in DosBox and in UFO DEFENSE the animations are play out much "slower".

I checked specially for you :) The xcom normal explosion sound is 0.5sec long + 0.5sec of reverb. The explosion animation is 8 frames. So at 10FPS the animation is 0.8 sec long, which is perfect ;)

It happens during fights that the camera somehow fails to hurry where the explosion is happening and by then the camera gets there the explosion frames are already "played out" and only smoke or maybe explosion anim frames 7-8 are seen. Also the explosion sound seems to be cut short or a shorter version is played? There are two explosion sound effects, large and small. During fights somehow there are occasions when the explosion is cut short and no explosion sprites are displayed.

Or if the explosion area is partly covered by Fog of War, maybe the explosion sprites aren't displayed, they should display over the whole explosion area.

Would it be possible to check somehow with fail-safe code, when an explosion happens - before the explosion sound sample starts to play, the camera should be already centered on the explosion. Play the sound then start displaying the anim frames. 

Test maybe to display the frames like this:

Explosion sound effect playing 00:0.1 (=0.1sec)  show anim frame 1
sound effect playing 00:0.2  show anim frame 1
sound effect playing 00:0.3  anim frame 2
sound effect playing 00:0.4  anim frame 2
sound effect playing 00:0.5  anim frame 3
sound effect playing 00:0.6  anim frame 3
sound effect playing 00:0.7  anim frame 4
sound effect playing 00:0.8  anim frame 4
Time after sound effect played 00:0.9  anim frame 5
Time after sound effect played 00:1.0  anim frame 5
Time after sound effect played 00:1.1  anim frame 6
Time after sound effect played 00:1.2  anim frame 6
Time after sound effect played 00:1.3  anim frame 7
Time after sound effect played 00:1.4  anim frame 7
Time after sound effect played 00:1.5  anim frame 8
Time after sound effect played 00:1.6  anim frame 8

Let the graphics delay a bit by keeping frames longer on screen

So begin play the explosion sound effect, display the anim frames, but delay the graphics so it is shown a little bit slower, keeping the frames on-screen to play out a little after the sound ended.

Volutar

  • Guest
Re: Better Explosion Timing
« Reply #4 on: May 22, 2013, 10:37:57 am »
It doesn't matter really. 0.2s delay or 0.1s delay.

Offline mercy

  • Colonel
  • ****
  • Posts: 341
    • View Profile
Re: Better Explosion Timing
« Reply #5 on: May 22, 2013, 04:38:53 pm »
It doesn't matter really. 0.2s delay or 0.1s delay.

The code sometimes doesn't play out the full explosion animation from frame 1 to 8 before player eyes = camera.

It will be hard to debug, because sometimes it works, but during heavy battles with lots of animations on-map, increasing level of destruction, many soldiers and aliens on map, like on terror missions the openXCOM code starts to fail showing/playing explosion frames 1-8.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Better Explosion Timing
« Reply #6 on: May 22, 2013, 07:43:58 pm »
btw I recently added speed toggle in debug mode (F8), it can be useful when you testing animations.