Animation loop problem
2 posters
Page 1 of 1
Animation loop problem
Hello,
I want an animation that cycles through a list of objects but does not loop.
This is the code I'm using: StateFunction = mod[quotient[time,1],10]
This is the result:
The problem is, like I said before, it loops. I tried to use min instead of mod with the code but the animation does not cycle through the objects at all.
Any help is appreciated
I want an animation that cycles through a list of objects but does not loop.
This is the code I'm using: StateFunction = mod[quotient[time,1],10]
This is the result:
The problem is, like I said before, it loops. I tried to use min instead of mod with the code but the animation does not cycle through the objects at all.
Any help is appreciated
Re: Animation loop problem
Can you clarify what you're trying to do (and how you're planning to trigger it)?
You probably want an if clause that runs the animation when the current state is below 10, but as far as I can see at the minute, your current code will trigger at the start of the sim.
You probably want an if clause that runs the animation when the current state is below 10, but as far as I can see at the minute, your current code will trigger at the start of the sim.
Re: Animation loop problem
I'm trying to make a dirt animation that makes the train get dirtier when the time passes. When you load the train it should be clean, but after some time the dirt will start to appear.
There are 10 dirt states. I want the animation to stop at the 10th state, ie the dirtiest state.
There are 10 dirt states. I want the animation to stop at the 10th state, ie the dirtiest state.
Re: Animation loop problem
Hmm...
To make what you've got work, I think you want the following:
Minor addition however:
I'm not sure this will ever work especially well though.
To make what you've got work, I think you want the following:
- Code:
if[currentState > 9, mod[quotient[time,1],10], currentState]
Minor addition however:
- Code:
if[speedometer < 10, currentState, if[currentState > 9, mod[quotient[time,1],10], currentState]]
I'm not sure this will ever work especially well though.
Rakago likes this post
Re: Animation loop problem
Tested both codes, tried several settings but the train always starts dirty and not clean, and the animation does not cycle thourgh the dirt states...
Re: Animation loop problem
Hello!
I very slightly tweaked your code, and it works perfectly, only in Object Viewer!
In-game it just loads the last object (dirtiest state), it does not cycle through the rest at all.
Why does this happen?
I very slightly tweaked your code, and it works perfectly, only in Object Viewer!
- Code:
StateFunction = if[currentState < 9, mod[quotient[time,1],10], currentState]
In-game it just loads the last object (dirtiest state), it does not cycle through the rest at all.
Why does this happen?
Re: Animation loop problem
Fiddle, too much stuff floating around plus a typo :/
I didn't really bother to read your maths mind, which is terminally broken.
The issue in the main game will be with the time, but please read the whole explanation and go away and read up a little on some basic math.
First, you've got to remember that in OpenBVE terms, time is expressed in terms of an absolute number of seconds from midnight.
Object Viewer has no concept of time, and it's time counter starts from zero.
On the other hand, let's assume that your routefile has a first station time at an arbritary 9am.
Our in-game time counter at this point will therefore be 32400
If you look at your current code, the interesting part at 9am is therefore as follows:
mod[quotient[32400,1],10]
Decompose this a little further:
quotient[32400,1] ==> This will always evaluate to 32400 (32400 / 1 = 32400!)
Therefore, our code now looks like this:
mod[32400,10]
Decomposing this gives us the following calculation:
32400 - 10 * Floor(32400/10) ==> This evaluates to 104943600
Why then does it display the final state?
This is a 'feature' of the way the game works. Everything is loaded at midnight, and the game is then run in fast-forward mode to the start. Thus, it'll run through all the states before the first frame is loaded, and sticks at the final state.
TLDR:
Math is complex.
I would suspect that the odometer is probably a better source of the trigger number than time, which might work reasonably with your current code.
I didn't really bother to read your maths mind, which is terminally broken.
The issue in the main game will be with the time, but please read the whole explanation and go away and read up a little on some basic math.
First, you've got to remember that in OpenBVE terms, time is expressed in terms of an absolute number of seconds from midnight.
Object Viewer has no concept of time, and it's time counter starts from zero.
On the other hand, let's assume that your routefile has a first station time at an arbritary 9am.
Our in-game time counter at this point will therefore be 32400
If you look at your current code, the interesting part at 9am is therefore as follows:
mod[quotient[32400,1],10]
Decompose this a little further:
quotient[32400,1] ==> This will always evaluate to 32400 (32400 / 1 = 32400!)
Therefore, our code now looks like this:
mod[32400,10]
Decomposing this gives us the following calculation:
32400 - 10 * Floor(32400/10) ==> This evaluates to 104943600
Why then does it display the final state?
This is a 'feature' of the way the game works. Everything is loaded at midnight, and the game is then run in fast-forward mode to the start. Thus, it'll run through all the states before the first frame is loaded, and sticks at the final state.
TLDR:
Math is complex.
I would suspect that the odometer is probably a better source of the trigger number than time, which might work reasonably with your current code.
Re: Animation loop problem
Thanks for the reply, I really suck at maths lol What would be the correct code to make this work in-game?
Similar topics
» Animation formula brainpicking...
» Animation code - assistance needed
» Help with animation
» Problem With Add-ons
» problem of textureshiftyfunction
» Animation code - assistance needed
» Help with animation
» Problem With Add-ons
» problem of textureshiftyfunction
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum