该脚本是用,固定时间去变换天空盒,利用动画去变化光源亮度。
在服务器逻辑创建一个服务器脚本,把下面代码放进去。
脚本代码如下:
local a = 0 local environment = WorkSpace.Environment local function tkbh() if a == 0 then a = 3 local tweenInfo = --定义一个tween动画 { duration = 100000,--时长/ms repeatCount = 1,--重复次数,-1是无限 easing = "inSine",--动画播放类型 yoyo = false,--动画循环类型 } local action = { LightIntensity = 0.6 } local tween = TweenServiceJS:CreateTween(environment, tweenInfo,action) tween:OnComplete(function() a = 4 environment.FrontTexture = "rwid://T1NadTB5DT1RCxfErK" --天空盒前图片 environment.BackTexture = "rwid://T1aadTB5DT1RCxfErK" --天空盒后图片 environment.LeftTexture = "rwid://T1aydTB5DT1RCxfErK" --天空盒左图片 environment.RightTexture = "rwid://T1JydTB5DT1RCxfErK" --天空盒右图片 environment.UpTexture = "rwid://T1JtdTB5DT1RCxfErK" --天空盒顶图片 environment.DownTexture = "rwid://T10adTB5DT1RCxfErK" --天空盒底图片 end) tween:Play() --播放tween动画 elseif a == 4 then a = 3 local tweenInfo = --定义一个tween动画 { duration = 100000,--时长/ms repeatCount = 1,--重复次数,-1是无限 easing = "inSine",--动画播放类型 yoyo = false,--动画循环类型 } local action = { LightIntensity = 0.3 } local tween = TweenServiceJS:CreateTween(environment, tweenInfo,action) tween:OnComplete(function() a = 1 environment.FrontTexture = "rwid://T16RYTB_bv1RCvBVdK" --天空盒前图片 environment.BackTexture = "rwid://T1PRdTBjCv1RCvBVdK" --天空盒后图片 environment.LeftTexture = "rwid://T1ERYTBvbv1RCvBVdK" --天空盒左图片 environment.RightTexture = "rwid://T1uyYTBvEv1RCvBVdK" --天空盒右图片 environment.UpTexture = "rwid://T14ydTByb_1RCvBVdK" --天空盒顶图片 environment.DownTexture = "rwid://T1rRYTBQhv1RCvBVdK" --天空盒底图片 end) tween:Play() --播放tween动画 elseif a == 1 then a = 3 local tweenInfo = --定义一个tween动画 { duration = 60000,--时长/ms repeatCount = 1,--重复次数,-1是无限 easing = "inSine",--动画播放类型 yoyo = false,--动画循环类型 } local action = { LightIntensity = 0 } local tween = TweenServiceJS:CreateTween(environment, tweenInfo,action) tween:OnComplete(function() a = 2 end) tween:Play() --播放tween动画 elseif a == 2 then a = 3 local tweenInfo = --定义一个tween动画 { duration = 60000,--时长/ms repeatCount = 1,--重复次数,-1是无限 easing = "inSine",--动画播放类型 yoyo = false,--动画循环类型 } local action = { LightIntensity = 0.5 } local tween = TweenServiceJS:CreateTween(environment, tweenInfo,action) tween:OnComplete(function() a = 5 environment.FrontTexture = "rwid://T2OtCTBgdT1RCvBVdK" --天空盒前图片 environment.BackTexture = "rwid://T2RaYTB7Lv1RCvBVdK" --天空盒后图片 environment.LeftTexture = "rwid://T25yCTBKJT1RCvBVdK" --天空盒左图片 environment.RightTexture = "rwid://T2kaCTBgdT1RCvBVdK" --天空盒右图片 environment.UpTexture = "rwid://T26tYTB7Lv1RCvBVdK" --天空盒顶图片 environment.DownTexture = "rwid://T2gRCTBKxT1RCvBVdK" --天空盒底图片 end) tween:Play() --播放tween动画 elseif a == 5 then a = 3 local tweenInfo = --定义一个tween动画 { duration = 100000,--时长/ms repeatCount = 1,--重复次数,-1是无限 easing = "inSine",--动画播放类型 yoyo = false,--动画循环类型 } local action = { LightIntensity = 1.5 } local tween = TweenServiceJS:CreateTween(environment, tweenInfo,action) tween:OnComplete(function() a = 0 end) tween:Play() --播放tween动画 end end local tkbhhs = RWTimer:Create(tkbh, 1, -1) tkbhhs:Start()
请登录后评论~