Jump to content

[Lua] lower waterheight smoothly


dennis
 Share

Recommended Posts

Heya all,

 

I wrote this little piece of code:

 i = 1000
 repeat
  world:SetWaterHeight(i)
  i = i - 0.1
 until i < 0.80
 if i <= 0.90 then
  self.enabled = false
  self.lowerstate = false
 end

 

I wanted it to lower smoothly, so you can actually see it come down. I placed this code inside

Script:UpdateWorld()

but my screen then stuck and the water is at the preferred height

 

cheers

Link to comment
Share on other sites

you are looping inside a loop already, so your entire loop will be done in every frame,

do something like this instead (not tested) :

 

in Start()

i=1000

 

in UpdateWorld()

if (i > 0.9)
then
  world:SetWaterHeight(i)
  i=i-.1*Time:GetSpeed() --use getspeed to be fps independant.
end

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...