lua - Roblox Studio:铰链旋转而不是门
问题描述
我正在尝试在 Roblox Studio 中制作动画开/关门。该脚本有效,但它正在旋转铰链而不是门。请告诉我我做错了什么,我将如何解决这个问题?
local tween = game:GetService("TweenService")
local Center = script.Parent.Center
local Door = "Closed"
local CF = Instance.new("CFrameValue")
CF.Value = Center.CFrame
CF.Changed:Connect(function()
Center.CFrame = CF.Value
end)
script.Parent.Door.ClickDetector.MouseClick:Connect(function()
if Door == "closed" then
tween:Create(CF, TweenInfo.new(1), {Value = Center .CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))}):play()
Door = "open"
else
tween:Create(CF, TweenInfo.new(1), {Value = Center .CFrame * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))}):play()
Door = "closed"
end
end)
解决方案
推荐阅读
- html - 对齐按钮图像内的文本和图像
- mysql - MySQL 在安装 MySQL 时询问用户名和密码
- java-8 - 如何使用 Jackson 解析对象遵循 json 类型?
- ruby-on-rails - YADCF Bootstrap Datetimepicker 从容器溢出
- apache - .htaccess 将所有路由重定向到 .html
- microsoft-teams - Azure 机器人服务中的团队频道不起作用
- swiftui - 任何人都可以使用 SwiftUI SignInWithAppleButton 在 tvOS 上工作
- r - R quosure 问题中的用户函数
- javascript - nodejs 调试 - 保存脚本的状态(包含所有对象和 var 值)并在下次运行时使用它
- javascript - 如何检测用户何时关闭浏览器?