roblox - 罗布乐思; 使损坏的部分重新出现
问题描述
我制作了一个游戏,您可以在其中踩到特定的瓷砖,这部分会被破坏。我想让这个被破坏的方块在一定时间后重新出现,现在你可能想知道为什么我不让这个部分不可见并让它失去它的玩家碰撞。我没有这样做,因为我不知道如何在零件透明度 1 之上制作纹理。
解决方案
您可以制作零件的副本,然后进行销毁,并在几秒钟后将副本放回原处:
function onTouched(hit)
-- see if it was a player that touched the part
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if (plr == nil) then return end
-- make backup of the part and its parent
local part = workspace.Part
local backup = part:Clone()
local backupParent = part.Parent
part:Destroy() -- do some cool effect for the destruction of it...
spawn(function()
wait(5)
-- put part back in place
backup.Parent = backupParent
backup.Touched:Connect(onTouched)
end)
end
workspace.Part.Touched:Connect(onTouched)
如果你只是想让它消失,你也可以通过将它的 Parent 设置为 nil 来临时将它从对象树中删除:
function onTouched(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if (plr == nil) then return end
local part = workspace.Part
local backupParent = part.Parent
part.Parent = nil
spawn(function()
wait(5)
part.Parent = backupParent
end)
end
推荐阅读
- azure - 使用 PowerShell ARM Cmdlet 授予 AKS 对 ACR 的访问权限
- php - 在原始查询 laravel 中使用 php 变量
- postgresql - postgresql - 内部联接无法正常工作
- oracle - Oracle 查询性能改进
- c# - 计算机图形学中的固定旋转
- c - 填充动态 char 数组会导致覆盖
- c# - 我的百分比值是在 c# 的文本框中打印“0”
- dialogflow-es - 使用 Google Assistant SDK 定制内置意图
- mysql - MySQL 存储过程案例语句语法错误 - 续 2
- java - JavaFX WebView 不加载页面