一个简单的距离控制心跳功能,当离目标物体越近,心跳的Tween动画播放速度就会越快。
代码如下:
wait(1) local player = Players:GetLocalPlayer() local ui1 = script.Parent local ui2 = player.Avatar:WaitForChild("Chest"):WaitForChild("BillBoardGUI"):WaitForChild("UiImage") local part = WorkSpace:WaitForChild("零件") local tweenService=GetService("TweenService") --获取动画服务 local function abc() local dist = player:DistanceFromAvatar(part.Position) --获取玩家角色到零件2的距离 local a = dist*20 local tweenInfo = { duration = a,--时长/msds repeatCount = 1,--重复次数,-1是无限 easing = "inSine",--动画播放类型 yoyo = true,--动画循环类型 } local action = { LocalScale = Vector3.New(1,1,1) } local tween = tweenService:CreateTween(ui1, tweenInfo,action) --创建动画对象 local tween2 = tweenService:CreateTween(ui2, tweenInfo,action) --创建动画对象 tween:Play() --播放动画 tween2:Play() tween2:OnComplete(abc) end abc()
这个只有动画效果,没有心跳的音效,蹲一个大神给我加上,或者有其他想法的可以写在评论区里。
附上地图包:
请登录后评论~