Not logged inOpenClonk Forum
Up Topic General / Help and Questions / Trying to synchronize animation with y-axis movement
- - By Andriel Date 2013-04-21 07:30 Edited 2013-04-22 11:48
So I was trying to animate the elevator winches, like this (in the case script):
effect.animation_id = elevator -> PlayAnimation(anim, 5, GetWinchSpinAnimationPosition(anim), Anim_Linear(0, 0, 1000, 5, ANIM_Remove));     (inside an fx$effect$start)
and
func GetWinchSpinAnimationPosition(string anim, int pos)
{
  var dir = -1;
  if(GetComDir() == COMD_Down) dir = +1;
  return Anim_Y(pos, 0, GetAnimationLength(anim), 50*dir);
}

Pretty much copied from the Clonk's scaling animation, however, the winches won't turn. It works with PlayAnimation("winchSpin", 5, Anim_Linear(0,0, GetAnimationLength("winchSpin"), 10, ANIM_Loop), Anim_Const(1000)), and I checked all the functions were called, so what's the problem here?
Reply
Parent - - By Zapper [de] Date 2013-04-22 09:05
Mh, you want to animate the base building using the Y position of the case, right?
I am not sure whether that works. Anim_Y itself is pretty context insensitive.
You could try moving the elevator base up and down with the mouse - if the winches start spinning, you are using the elevator bulding's position instead of the case's.

ck, does that work somehow?
Parent - By Clonk-Karl [de] Date 2013-04-22 14:47
It should work the way Andriel has it. Anim_Y takes the Y position of the calling object, not the Y position of the object whose mesh is being animated.
Reply
Parent - - By Clonk-Karl [de] Date 2013-04-22 14:45
Why are you using Anim_Linear(0, 0, 1000, 5, ANIM_Remove) instead of Anim_Const(1000) (as you have it in the working version) for the animation weight? This will remove the animation after only 5 frames.
Reply
Parent - - By Andriel Date 2013-04-24 16:52
I took it from the Clonk's scaling animation.
Even if the animation was played for just 5 frames, you would see the 5 frames. But it doesn't even start the animation.
Reply
Parent - - By Clonk-Karl [de] Date 2013-04-24 17:22
Can you send to me the modified elevator? I'll have a look.

The difference to the Clonk is that the Clonk is making a transition from another animation (walking/hangling/or whatever it was doing before climbing), and that transition takes 5 frames. After those 5 frames the previous animation is removed.
Reply
Parent - - By Andriel Date 2013-04-24 17:31
Here you are.
Attachment: Elevator.ocd.zip (1038k)
Reply
Parent - - By Clonk-Karl [de] Date 2013-05-02 12:32
Looks like I was wrong and Zapper was right after all -- it takes the Y position of the elevator, and not that of the elevator case. I thought it was different. In any case this should be easy to change... I'll do that
Reply
Parent - - By Pyrit Date 2013-05-02 18:40
Does Anim_Y really take the y-position of an object for animation? It didn't work for me when I was moving a clonk in y-direction with SetPosition(). Only when I added SetYDir() it got animated.
Parent - By Clonk-Karl [de] Date 2013-05-02 20:02
Yes, it uses ydir to decide how much to advance the animation.
Reply
Up Topic General / Help and Questions / Trying to synchronize animation with y-axis movement

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill