Timing multiple animations
3 posters
Page 1 of 1
Timing multiple animations
Hi Guys
I have a gantry crane running on rails. Its got a spreader slung underneath which is able to move along the cranes beams along its x-asis and rise and lower to simulate dropping off, picking up a load.
So ive got 3 animations
1. Move the entire crane along its rails over the z axis
2. move the spreader left to right (or vice versa) on the x axis
3. move the spreader up and down on the y axis.
Edit. Nevermind my previous question, which was based on a rather silly assumption I made.
I've got the spreader moving its load up, and to the right across the gantry beam whenever a train is withing 150m. trackdistance. The gantry crane 'waits' a few seconds before then moving itself plust the spreader and its load across the z axis (moving everything forward).
And it works. However!
When the animations have finished, i'd like to perform other movements in opposite directions. So the crane should wait a few seconds, move its spreader to the left again, move it up again and finally the entire thing should be moving towards you again.
But the changing values for additional functions to achieve that will of course also meet the conditions set in the first animation. So they'll clash. Is there a way to get around that?
I have a gantry crane running on rails. Its got a spreader slung underneath which is able to move along the cranes beams along its x-asis and rise and lower to simulate dropping off, picking up a load.
So ive got 3 animations
1. Move the entire crane along its rails over the z axis
2. move the spreader left to right (or vice versa) on the x axis
3. move the spreader up and down on the y axis.
Edit. Nevermind my previous question, which was based on a rather silly assumption I made.
I've got the spreader moving its load up, and to the right across the gantry beam whenever a train is withing 150m. trackdistance. The gantry crane 'waits' a few seconds before then moving itself plust the spreader and its load across the z axis (moving everything forward).
- Code:
[Object]
Position = 0,0,0
States = ..\Misc\kuenz.b3d
TranslateZFunction = if[trackDistance<200, if[value<100, if[value+0.001>0.2, value+0.25, value+0.001], 100], 0]
[Object]
Position = -12,-5,0
States = ..\Misc\spreader.b3d
TranslateZFunction = if[trackDistance<200, if[value<100, if[value+0.001>0.2, value+0.25, value+0.001], 100], 0]
TranslateXFunction = if[trackDistance<200, if[value<24, value+0.075, 24], 0]
TranslateYFunction = if[trackDistance<200, if[value<10, value+0.100, 10], 0]
[Object]
Position = -12,-5,6.5
States = ..\Misc\spreader.b3d
TranslateZFunction = if[trackDistance<200, if[value<100, if[value+0.001>0.2, value+0.25, value+0.001], 100], 0]
TranslateXFunction = if[trackDistance<200, if[value<24, value+0.075, 24], 0]
TranslateYFunction = if[trackDistance<200, if[value<10, value+0.100, 10], 0]
[Object]
Position = -12,0.5,-0.5
States = ..\Containers\RuStock\Load~ISOC~9653_0000.B3D
TranslateZFunction = if[trackDistance<200, if[value<100, if[value+0.001>0.2, value+0.25, value+0.001], 100], 0]
TranslateXFunction = if[trackDistance<200, if[value<24, value+0.075, 24], 0]
TranslateYFunction = if[trackDistance<200, if[value<10, value+0.100, 10], 0]
And it works. However!
When the animations have finished, i'd like to perform other movements in opposite directions. So the crane should wait a few seconds, move its spreader to the left again, move it up again and finally the entire thing should be moving towards you again.
But the changing values for additional functions to achieve that will of course also meet the conditions set in the first animation. So they'll clash. Is there a way to get around that?
ebennekom- Posts : 53
Join date : 2017-12-14
Location : Alicante, Spain
Re: Timing multiple animations
You're mis-understanding the time variable
From the documentation:
This means your crane will start moving at either of these two points:
1. If you start your game at midnight, with the crane in view, it will start moving at +5s.
2. Otherwise, if it comes into view at any time after midnight +5s, it will immediately start moving.
From the documentation again:
Delta, running at 60fps will give you a value of 0.016 or there abouts.
Your current formulae will therefore (in all likelyhood) move the crane 0.3m every frame regardless, which as you've figured isn't the most helpful of animations
Anyhows:
The short answer is that this will be a pain in the neck to animate correctly, as there's no way to access the results of other formulae.
A single move and drop / raise is probably easy(er) than a cycle, but exactly how much I'm not sure yet :S
I haven't got any brilliant ideas just at the moment, just some basic suggestions and a fudged bit of logic:
Your up/ down formula wants to be something like this:
If the time elapsed is less than 10s, do nothing. If the time elapsed is greater than 10s and less than 25s AND the distance down is not yet complete, lower (Tie this to the delta variable). If the time elapsed is greater than 25s and less than 35s, do nothing. If the time elapsed is greater than 35s and less than 50s AND the distance up is not yet complete, raise. If the time elapsed is greater than 50s and less than 60s, do nothing.
Combine this with a modulo (%) operator, so that it only operates every second or third minute.
From the documentation:
time The current in-game time measured in seconds since midnight of the first day.
This means your crane will start moving at either of these two points:
1. If you start your game at midnight, with the crane in view, it will start moving at +5s.
2. Otherwise, if it comes into view at any time after midnight +5s, it will immediately start moving.
From the documentation again:
delta The time difference since the last evaluation of the function in seconds. Please note that there is no guaranteed time that elapses between successive function calls.
Delta, running at 60fps will give you a value of 0.016 or there abouts.
Your current formulae will therefore (in all likelyhood) move the crane 0.3m every frame regardless, which as you've figured isn't the most helpful of animations
Anyhows:
The short answer is that this will be a pain in the neck to animate correctly, as there's no way to access the results of other formulae.
A single move and drop / raise is probably easy(er) than a cycle, but exactly how much I'm not sure yet :S
I haven't got any brilliant ideas just at the moment, just some basic suggestions and a fudged bit of logic:
- First work out the L-R cycle animation. This *needs* to be absolutely fixed regardless of framerate, so we know where our crane is at any one time, so really wants to be tied to something like the time variable.
- Ensure that the L-R animation has long pauses at either end, preferably considerably longer than the raise / drop one, as otherwise it'll inevitably move off at the wrong point.
Your up/ down formula wants to be something like this:
If the time elapsed is less than 10s, do nothing. If the time elapsed is greater than 10s and less than 25s AND the distance down is not yet complete, lower (Tie this to the delta variable). If the time elapsed is greater than 25s and less than 35s, do nothing. If the time elapsed is greater than 35s and less than 50s AND the distance up is not yet complete, raise. If the time elapsed is greater than 50s and less than 60s, do nothing.
Combine this with a modulo (%) operator, so that it only operates every second or third minute.
Re: Timing multiple animations
Hi Leezer, Thanks for your response. Some serious food for thought there.
It raises some questions though. But first things first (trying to take baby steps here)
So, if time is the number of seconds since midnight, gametime today is it true the number it returns depends on the starttime I defined for the startingpoint (initial station) of my route?
IE, .sta StartingStation;;12.0005;;0;0;ATS;;30;50;sounds\departure.wav
Here we start 5 secs after noon, so (12*60*60)+5 = 43205secs, is that the actual value time returns right after gamestart?
Orrrrrrrr, is the game simply taking the users system time and calculates the difference in seconds between that and midnight that day?
It raises some questions though. But first things first (trying to take baby steps here)
So, if time is the number of seconds since midnight, gametime today is it true the number it returns depends on the starttime I defined for the startingpoint (initial station) of my route?
IE, .sta StartingStation;;12.0005;;0;0;ATS;;30;50;sounds\departure.wav
Here we start 5 secs after noon, so (12*60*60)+5 = 43205secs, is that the actual value time returns right after gamestart?
Orrrrrrrr, is the game simply taking the users system time and calculates the difference in seconds between that and midnight that day?
ebennekom- Posts : 53
Join date : 2017-12-14
Location : Alicante, Spain
Re: Timing multiple animations
In-sim time. You use that variable for clocks and such.
Quork- Posts : 1438
Join date : 2012-05-05
Age : 33
Location : Hofheim a.T., Hessen (Hesse), European Union
Re: Timing multiple animations
ebennekom wrote:Here we start 5 secs after noon, so (12*60*60)+5 = 43205secs, is that the actual value time returns right after gamestart?
Orrrrrrrr, is the game simply taking the users system time and calculates the difference in seconds between that and midnight that day?
As Quork notes, it's the first of the two options
Adding system time as a variable is actually a quite interesting idea though; I'm sure someone could find a use for that.
Re: Timing multiple animations
Sooner or later, sure... Though I think that's also a topic for the new formats. Considering all the problems arising around animated objects etc., I think we'll end up with basic scripting; conditions and variables to be passed between functions both inside an object and between objects within a route file. Would also allow for increased realism in many cases, like the german Zufahrtsicherungssignal (lit. signal securing the entry: A signal showing "danger" until the train approaching it is confirmed to be in ETCS cab signaling mode, thus ensuring no trains without ETCS get onto the route).
Quork- Posts : 1438
Join date : 2012-05-05
Age : 33
Location : Hofheim a.T., Hessen (Hesse), European Union
Re: Timing multiple animations
Whilst this is wandering rather O/T, the current implementation makes it essentially impossible to link between component [Object] sections within an .animated file.
TLDR:
Each [Object] section is parsed into it's own internal container, with no reference to the other objects within the .animated file.
Access to the result of any other functions within the object should just be a case of adding a small amount of code, but this isn't necessarily a good idea, as IIRC various stuff depends heavily on the order in which functions are called and the results from that.
TLDR:
Each [Object] section is parsed into it's own internal container, with no reference to the other objects within the .animated file.
Access to the result of any other functions within the object should just be a case of adding a small amount of code, but this isn't necessarily a good idea, as IIRC various stuff depends heavily on the order in which functions are called and the results from that.
Re: Timing multiple animations
Okay, that's all been very helpful. Thanks guys!
So to summarize, it's not possible to programmatically have different moving 'parts' within an animated object to access each-others function outcomes. However, timing can be applied to mimic a kind of 'waiting for each-other to finish' effect.
I'll definitely be tinkering with that over the weekend, see what happens.
On the other hand, I'm still very new at all this stuff so may have to resort to more simplistic animations.
Either way, I'm glad I bothered to register here and just ask
So to summarize, it's not possible to programmatically have different moving 'parts' within an animated object to access each-others function outcomes. However, timing can be applied to mimic a kind of 'waiting for each-other to finish' effect.
I'll definitely be tinkering with that over the weekend, see what happens.
On the other hand, I'm still very new at all this stuff so may have to resort to more simplistic animations.
Either way, I'm glad I bothered to register here and just ask
ebennekom- Posts : 53
Join date : 2017-12-14
Location : Alicante, Spain
Re: Timing multiple animations
Correct.
Each individual [Object] section is entirely independent within the games internals from any other.
Applying timing to mimic this is the only way to do it, not ideal I know.
Each individual [Object] section is entirely independent within the games internals from any other.
Applying timing to mimic this is the only way to do it, not ideal I know.
Similar topics
» Toggling of animations and shadows
» Changing Destination of train multiple times along route
» Multiple Ambiant Lightings in Routes
» How to cycle through multiple object one at a time using a key?
» New Feature: Multiple Interior Views
» Changing Destination of train multiple times along route
» Multiple Ambiant Lightings in Routes
» How to cycle through multiple object one at a time using a key?
» New Feature: Multiple Interior Views
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum