Jump to content

[Script] Animated analog clock


Recommended Posts

I like to extend the conversion started in the Conversion into NIF (Clock) thread a pose a question for our scripting gurus. Suppose we could make an animated analog clock having animated sequences playidle_01, playidle_02, ...playidle_12 which represent the 12 hours on an analog clock. How would one tie these animated sequences to actual game time via a script? In other words looking to explore the idea of having a working analog clock in the game.

 

Thinking of using the techniques presented here to make the clock.

Link to comment
Share on other sites

While I don't fully know a solution I think

"GetCurrentGameTime()" and "StartTimerGameTime()" might prove useful.

For a digital clock the solution would be relatively easy, especially if minute and hour digit were independent.

An analogue clock however seems to be harder to do.

Link to comment
Share on other sites

Just need to make a ready-made clock, and get people who are well versed in scripts to experiment with these clocks. One person cannot master everything in the world. Otherwise, he will somehow understand everything, but he will not understand anything well.
Link to comment
Share on other sites

Does it even require an animation?

 

I don't know whats possible from a script but, some thoughts:

What about separate meshes (nifs) you can rotate into position in-game? I could point the arrows at 12/00. Then you could rotate it by 3 degrees for each minute from script? and the same for the hour arrow.

The swing could still be a continues animation.

 

as this would make it difficult to make it a buildable object (with 3 or 4 different parts/nifs) What about a SCOL, would that still work?

Or are there any other ways to combine them into 1 workshop asset while still manipulating each part?

 

The hour & minutes could be independent scripts, each affecting one arrow (?)

Link to comment
Share on other sites

Does it even require an animation?

 

I don't know whats possible from a script but, some thoughts:

What about separate meshes (nifs) you can rotate into position in-game? I could point the arrows at 12/00. Then you could rotate it by 3 degrees for each minute from script? and the same for the hour arrow.

The swing could still be a continues animation.

 

as this would make it difficult to make it a buildable object (with 3 or 4 different parts/nifs) What about a SCOL, would that still work?

Or are there any other ways to combine them into 1 workshop asset while still manipulating each part?

 

The hour & minutes could be independent scripts, each affecting one arrow (?)

Yes, the pendulum can be animated separately, as a separate nif. Nif's can be assembled by ref_attach_node, or even hung on bs connect point. But there is no problem to animate the pendulum at once in one nif. Just animate one swing left-right, select the pendulum mesh, hold shift, move-copy keys, select all keys again, hold shift, copy. Thousands of frames will take about five minutes.

The clock itself does not make sense to cut into separate nif's. Nif can have any number of sequences for all arrow positions, and these sequences can be run from a script. Such mods have already been done many times by people. But for an approximate playing time, you only need 12 sequences. I don't know why the game needs a very precise time. It's just an advanced decor element.

Edited by South8028
Link to comment
Share on other sites

PlayGamebryoAnimation() and OnTimerGameTime(), if the animation is in the .nif. For templates, see SecurityBarBase01.nif and securityBarScript.

 

The script also has to detect the current game time OnInit() to call the proper number of animation sequences as the clock's hour hand needs match the current time (e.g., if the current game time is 3pm, then play 3 sequences). To get the current game time, you can use this function or a GameHour global check (FormID: 00000038).

 

 

Forgot to mention that if the clock's hour hand is placed on the clock face by a script (could be an ObjectReference script attached to the clock's base form), then you can use TranslateTo or TranslateToRef so the hour hand rotates constantly. In this case, PlayGamebryoAnimation() is not necessary.

Edited by LarannKiar
Link to comment
Share on other sites

PlayGamebryoAnimation() and OnTimerGameTime(), if the animation is in the .nif. For templates, see SecurityBarBase01.nif and securityBarScript.

 

The script also has to detect the current game time OnInit() to call the proper number of animation sequences as the clock's hour hand needs match the current time (e.g., if the current game time is 3pm, then play 3 sequences). To get the current game time, you can use this function or a GameHour global check (FormID: 00000038).

 

 

Forgot to mention that if the clock's hour hand is placed on the clock face by a script (could be an ObjectReference script attached to the clock's base form), then you can use TranslateTo or TranslateToRef so the hour hand rotates constantly. In this case, PlayGamebryoAnimation() is not necessary.

That last part is what I was thinking about. That way you can accurately represent the current game time, minute by minute without the need for animations. Theoretically you could turn any combination of objects into a clock that way.

Link to comment
Share on other sites

Good input all. I have been able to rough out a clock with an animation using the tutorial referenced above. Trying to determine a mathematical relationship between the pendulum (second hand), and the hour hand. One swing of the pendulum equates to one second ; however, the pendulum does rotate 360. As the pendulum does not rotate 360 degrees around the center point, I would think angular limits also have to be considered. Maybe over thinking it...been known to do that.

Link to comment
Share on other sites

I divided the mesh so it should be easy to move everything around. I set the time (9:42) using rotation. (-90 & -108) set it to 0 to point them up straight. Then rotate 6 degrees per minute. 30 for each hour.

The pendulum can be rotated around the same center.

 

the collision only involves the base.

The rest doesn't have one.

 

Its still one nif, so separate if you need to.

Edited by RoNin1971
Link to comment
Share on other sites

Good input all. I have been able to rough out a clock with an animation using the tutorial referenced above. Trying to determine a mathematical relationship between the pendulum (second hand), and the hour hand. One swing of the pendulum equates to one second ; however, the pendulum does rotate 360. As the pendulum does not rotate 360 degrees around the center point, I would think angular limits also have to be considered. Maybe over thinking it...been known to do that.

Forget about synchronizing the pendulum. it would swing like crazy since seconds go by, what ... 20 times faster :)

I would just make it swing back and forth in "real time".

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...