Hoping someone can help me figure out a strange problem I'm having.
In wet weather conditions (i.e. rain, storm, etc.), I want there to be puddles that slowly rise from the ground for a mod I'm working on. And when the weather is dry/rain stops, I want the puddles to slowly disappear.
I'm a total noob when it comes to programming in general and especially Papyrus, but Cipscis has been super helpful in getting me started with a script, which I will include below. So far, it is working out good, where rainy weather causes the puddle to rise (Z position increases) up to a certain point, then when the weather is dry the puddle goes down (Z position decreases) and stops just below the ground (hidden). I also have the ability to control the frequency at which the updates occur, as well as add an extra effect (puddle splashes object) on top of the puddle object, which moves with the puddle.
The one problem I'm having and hoping someone can help us figure out is that every time the update occurs, the puddle object "flashes", meaning that it disappears and then reappears before it changes Z position. This happens every single update, regardless if the update frequency is every 10 seconds, every 1 second, or whatever I set it to. The "flash" happens quickly, like in milliseconds, but it's definitely noticeable.
I want the puddle to transition smoothly up or down, but not disappear/reappear. Here is the script that is assigned to the puddle object in the CK. Any ideas on how to prevent that?
Spoiler ScriptName Puddle2 extends ObjectReferenceFloat Property UpdateDelay = 10.0 Auto{ Time between each update.Configurable; Default: 10.0 seconds }ObjectReference Property MyEffect Auto{ The ripple effect associated with this puddle.Whether this object is enabled or disabled is handled elsewhere via an enable parent. }Float ZOffsetFloat Property MaxIncrease = 21.0 Auto{ Maximum increase in height.Configurable; Default: 21.0 units (around 1' or 30cm) }Float ZMinFloat ZMaxFloat ZPosBool Enabled_val = trueBool Property Enabled Bool Function get() Return Enabled_val EndFunction Function set(Bool abValue) If (abValue) Enable() Else Disable() EndIf Enabled_val = abValue EndFunctionEndPropertyFloat Property PleasantChange = -1.0 Auto{ Height change per tick (default: 10 seconds) in pleasant weather.Configurable; Default: -1.0 units (around 0.6' or 1.4cm) }Float Property CloudyChange = -0.5 Auto{ Height change per tick (default: 10 seconds) in cloudy weather.Configurable; Default: -0.5 units (around 0.3' or 0.7cm) }Float Property RainingChange = 1.0 Auto{ Height change per tick (default: 10 seconds) in raining weather.Configurable; Default: +1.0 units (around 0.6' or 1.4cm) }Float Property SnowingChange = 0.0 Auto{ Height change per tick (default: 10 seconds) in snowing weather.Configurable; Default: +0.0 units }Float Property UnclassifiedChange = 0.0 Auto{ Height change per tick (default: 10 seconds) in unclassified weather.Configurable; Default: +0.0 units }Auto State Inactive Event OnInit() MoveToMyEditorLocation() ZPos = GetPositionZ() ZMin = ZPos ZMax = ZMin + MaxIncrease ZOffset = MyEffect.GetPositionZ() - ZPos RegisterForSingleUpdate(UpdateDelay) EndEvent Event OnUpdate() If (IsNearPlayer()) GoToState("Active") EndIf RegisterForSingleUpdate(UpdateDelay) EndEventEndStateState Active Event OnUpdate() If (!IsNearPlayer()) GoToState("Inactive") EndIf Weather CurrentWeather = Weather.GetCurrentWeather() Int WeatherType = CurrentWeather.GetClassification() Float ZPosNew If (WeatherType == 0) ; Pleasant ZPosNew = ZPos + PleasantChange ElseIf (WeatherType == 1) ; Cloudy ZPosNew = ZPos + CloudyChange ElseIf (WeatherType == 2) ; Raining ZPosNew = ZPos + RainingChange ElseIf (WeatherType == 3) ; Snowing ZPosNew = ZPos + SnowingChange Else ; No classification ZPosNew = ZPos + UnclassifiedChange EndIf If (ZPosNew < ZMin) ZPosNew = ZMin If (Enabled) Enabled = false EndIf Else If (!Enabled) Enabled = true EndIf If (ZPosNew > ZMax) ZPosNew = ZMax EndIf EndIf If (ZPosNew != ZPos) SetPositionZ(ZPosNew) ZPos = ZPosNew EndIf RegisterForSingleUpdate(UpdateDelay) EndEventEndStateFunction SetPositionZ(Float afValue) SetPosition(GetPositionX(), GetPositionY(), afValue)EndFunctionEvent OnInit() ; Even though this version of the event will never run, as this script will never be in the empty state, it must be defined for the empty state in order for the script to compile.EndEvent