HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Animation Timing

06-24-2006, 10:03 PM#1
Hemlock
I executed a animation of a mountain king like this.

Trigger:
Custom script: call SetUnitAnimationByIndex (udg_SuperHero, 12)

After that I putted in wait command like you can see underneath here

Trigger:
Custom script: call TriggerSleepAction( 0.15 )

Right after this wait, I froze the units animation, but it seems like the unit freezes differently everytime I run trigger. (sometimes it freezes earlier than other times)

is there something that I can do about this, cause I need the animation to freeze at a nearly exact point of his animation time.
06-24-2006, 10:25 PM#2
Anitarf
That will be hard to pull off. First of all, waits and game-time waits are terribly inaccurate when it comes to short-time waits. You would have to use timers to achieve precise timing.

However, based on my experiments with the Cinematic System I think you can't achieve perfect precision either way; either the animation playing or the animation speed change functions aren't as precise as we would like, so you can get slightly different results, especialy on different hardware.

The wc3c cinematic contest entry that used the cinematic system, 2-P's Friends, had this issue, It played almost the same every time I watched it, but one super-slow motion part was all wrong, a special effect appeared long before the two blades clashed, so I asked iNfraNe for a screenshot of that scene and on his computer, the two blades were clashed together.
06-24-2006, 10:33 PM#3
The)TideHunter(
TriggerSleepAction isent as accurate, if it says 0.15, it wont be exact, it might be less it might be more.
Instead, use a timer and handle vars, which is alot better.

Collapse JASS:
function GC takes nothing returns gamecache
    if(udg_GC == null) then
        call FlushGameCache(InitGameCache("GC"))
        set udg_GC = InitGameCache("GC")
    endif
    return udg_GC
endfunction

function H2I takes handle H returns integer
    return H
    return 0
endfunction

function I2Unit takes integer I returns unit
    return I
    return 0
endfunction

function SetUnitAnimationByIndexTimed_Revert takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit TheUnit = I2Unit(GetStoredInteger(GC(), "SetUnitAnimationByIndexTimed_Unit", I2S(H2I(t))))
    // Freeze your units animation here.
    call DestroyTimer(t)
    set t = null
endfunction

function SetUnitAnimationByIndexTimed takes unit whichUnit, integer Index, real duration returns nothing
    local timer t = CreateTimer()
    call SetUnitAnimationByIndex(whichUnit, Index)
    call StoreInteger(GC(), "SetUnitAnimationByIndexTimed_Unit", I2S(H2I(t)), H2I(whichUnit))
    call TimerStart(t, duration, false, function SetUnitAnimationByIndexTimed_Revert)
endfunction

Excuse me if that dosent work, i dident use a editor, i just typed it up.
That should work though, and to use it, just type:

Collapse JASS:
call SetUnitAnimationByIndexTimed(udg_SuperHero, 12, 0.15)

EDIT: Or you could go with Anitarf, he knows what hes talking about.
06-24-2006, 10:42 PM#4
Hemlock
"The)TideHunter(": correct me if I am wrong but that jass code you wrote, I need to insert that in "custom script code" area right, if so it gives an error

Anitarf: yes, I saw that problem in friends too, but not only in friends.
I myself make cinematics since summer 2004 and shortly encountered the problem as well as I was working with animations more and more, it seems I am not the only troubled one here :/
06-24-2006, 10:44 PM#5
aquilla
Since he already uses a global var I using it would be enough..

in map script ->
Collapse JASS:
function PauseSuperHeroAnim takes nothing returns nothing
    call SetUnitTimeScale(udg_SuperHero, 0)
    call DestroyTimer(GetExpiredTimer())
endfunction
and in the event:
Trigger:
Actions
Custom script: call SetUnitAnimationByIndex(udg_SuperHero, 12)
Custom script: call TimerStart(CreateTimer(), 0.15, false, function PauseSuperHeroAnim)
06-24-2006, 11:00 PM#6
Hemlock
That seemed to work =D, can I also slow down the animation from that moment on?
06-24-2006, 11:14 PM#7
Hemlock
It seems I found an even easier way myself, it goes like this...

Trigger:
Custom script: call SetUnitAnimationByIndex (udg_SuperHero, 12)
Countdown Timer - Start Animation_timer as a One-shot timer that will expire in 0.15 seconds

Trigger:
Untitled Trigger 001
Collapse Events
Time - Animation_timer expires
Conditions
Collapse Actions
Animation - Change SuperHero's animation speed to 4.00% of its original speed
06-24-2006, 11:18 PM#8
iNfraNe
thats not easier. Thats just lazier.
06-24-2006, 11:19 PM#9
aquilla
yep, that's sort of the GUI-version of my code, forgot about that event though :)
06-25-2006, 12:10 AM#10
The)TideHunter(
Quote:
Originally Posted by Warnicro
"The)TideHunter(": correct me if I am wrong but that jass code you wrote, I need to insert that in "custom script code" area right, if so it gives an error

It gave an error, because i forgot to mention you need a global gamecache called GC, (or in Jass udg_GC), which return bug normally uses in conflict with handle vars.
What error does it say? if it says Expected a name, then its because you need to make the cache.
If not, please post :)

EDIT: Only problem is, in your trigger, because your using a global, if you try to do that twice in the same 0.15 seconds, then 1 will never change back.
Thats why i used locals and made the functions in the first place
06-25-2006, 01:11 AM#11
Hemlock
Yeah I understand its lazier, but I am not really that good with jass, and as long its a sollution and works proper, I can live with that, no hard feelings against the jass(ers) around, I am too, a effware that jass is way better an.decient that GUI