.animated sound (StateChangeSound)
4 posters
Page 1 of 1
.animated sound (StateChangeSound)
I am trying to make a platform announcement (Train arrival), where it would be played if the train is 425m behind the object. (The object is placed in the end of the station)
My following code is:
What I am expecting to happen: If the train is 425m behind the object, change the state to 1.
When the state got changed to 1, play the Arrival sound. Since the train is less than 425m, it should always return 1 from now on. And it should only play the sound once as the state only got changed once.
What happens instead: The sound will repeatedly play every few seconds when trackDistance is smaller than 425m.
Is this intentional? If yes, what is the correct way of doing it? Thanks
My following code is:
- Code:
[Object]
States = 1.csv, 2.csv
Position = -8.2, 0.2, 0
StateFunction = If[trackDistance[0]<425, 1, 0]
[StateChangeSound]
FileNames = , ARR.wav
Position = 0, 0, 0
Volume=0.8
Radius = 200
What I am expecting to happen: If the train is 425m behind the object, change the state to 1.
When the state got changed to 1, play the Arrival sound. Since the train is less than 425m, it should always return 1 from now on. And it should only play the sound once as the state only got changed once.
What happens instead: The sound will repeatedly play every few seconds when trackDistance is smaller than 425m.
Is this intentional? If yes, what is the correct way of doing it? Thanks
Last edited by LXQt on Sun Apr 25, 2021 5:20 pm; edited 1 time in total (Reason for editing : Further explanation)
Re: .animated sound (StateChangeSound)
Still can't make it to only play once
A workaround is to check If[trackDistance[0]>400 & trackDistance[0]<425, 1, 0] (Check if the train is between 400 and 425m from the object)
Then apply an 8 second RefreshRate, so there must be at least an 8 second interval before it loops again. (Which the train has PROBABLY passed at this point)
The problem is
1. It will loop again if the player decided to have the train go slower.
2. Sometimes I end up missing the announcement due to timing (Going 25m requires less than 8 seconds at around 45-60km/h, the object could passed the 400m mark before it refreshes and change the state)
A workaround is to check If[trackDistance[0]>400 & trackDistance[0]<425, 1, 0] (Check if the train is between 400 and 425m from the object)
Then apply an 8 second RefreshRate, so there must be at least an 8 second interval before it loops again. (Which the train has PROBABLY passed at this point)
The problem is
1. It will loop again if the player decided to have the train go slower.
2. Sometimes I end up missing the announcement due to timing (Going 25m requires less than 8 seconds at around 45-60km/h, the object could passed the 400m mark before it refreshes and change the state)
Re: .animated sound (StateChangeSound)
Probably it's a good idea to add a flag (boolean true/false) to the sound sections that determines if it's played once or looped
Delsin- Posts : 313
Join date : 2016-08-20
LXQt likes this post
Re: .animated sound (StateChangeSound)
That would be nice, but I am still not sure is this a bug or not...
The documentation (and the name "StateChangeSound" itself) suggest that it will only get played once when a state got changed.
So if nothing got changed after the train distance is closer than 425m, what could possibly triggers the StateChangeSound?
(It also does not wait for the sound to finish playing before playing another one, at an 1-2 second interval)
Older versions just straight up not work at all with the StateChangeSound
It may also be worth noting that on the example above, it is assumed that 1.csv and 2.csv is empty. I don't actually need to change states
Which means I can just use 2 null.csv and achieve the same effect.
The documentation (and the name "StateChangeSound" itself) suggest that it will only get played once when a state got changed.
So if nothing got changed after the train distance is closer than 425m, what could possibly triggers the StateChangeSound?
(It also does not wait for the sound to finish playing before playing another one, at an 1-2 second interval)
Older versions just straight up not work at all with the StateChangeSound
It may also be worth noting that on the example above, it is assumed that 1.csv and 2.csv is empty. I don't actually need to change states
Which means I can just use 2 null.csv and achieve the same effect.
Re: .animated sound (StateChangeSound)
You miss this.
I forget which case it should be shown up. In case something still wrong, swap the value.
I have so much object with this exact feature and all worked with this key
- Code:
PlayonShow=1
PlayonHide=0
I forget which case it should be shown up. In case something still wrong, swap the value.
I have so much object with this exact feature and all worked with this key
Re: .animated sound (StateChangeSound)
This is for a single state. The same thing happens even if I switch to single state with PlayOnShow/PlayOnHide.
It seems that the if statement will change the state everytime the original value changes. So even the same value can triggers multiple sound.
(Let just say trackDistance updates every one second, if the condition is true, it will set the same state every one second)
It also seems StateChangeSound detects when the state got set (instead of only changed).
It seems that the if statement will change the state everytime the original value changes. So even the same value can triggers multiple sound.
(Let just say trackDistance updates every one second, if the condition is true, it will set the same state every one second)
It also seems StateChangeSound detects when the state got set (instead of only changed).
Re: .animated sound (StateChangeSound)
I tried it, but only works, if I put the object in the scenery. But if I put it in a train, it won't show, and no sound.
Peti817172M- Posts : 4
Join date : 2023-12-26
Similar topics
» .animated sound
» Animated objects with sound
» .animated sound limitations?
» Animated sound not rotating with object
» Animated Objects: Following The Track- Now with SOUND!
» Animated objects with sound
» .animated sound limitations?
» Animated sound not rotating with object
» Animated Objects: Following The Track- Now with SOUND!
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum