使用绳索约束连接网格
2016-8-25 13:3:10
收藏:0
阅读:122
评论:1
我正在尝试使用ROBLOX的新绳索约束和一组零件做出一种“布料模拟”。
目前,我已经制作了一个10x10的一组.4x.4x.4块,并且现在我想用绳索约束将每个块连接起来。
我根据它们的行和列用它们的名字和字符串操作来命名网格中的每个部分(例如:网格中的第一个部分为1 1,最后一个为10 10)
然后我在每个部件中插入4个连接点和4个绳索约束。 以下是代码(ab代表上面,be代表下面,等等):
for i2 = 1,#gParts do
local ab = tostring (tonumber(gParts[i2].Name:match(“^(%S +)”))-5)..' '..tostring (tonumber(string.sub(gParts[i2].Name,-1))-1)
local be = tostring (tonumber(gParts[i2].Name:match(“^(%S +)”))+5)..' '..tostring(tonumber(string.sub(gParts[i2].Name,-1))+1)
local le = tostring (tonumber(gParts[i2].Name:match(“^(%S +)”))-1)..' '..tostring (tonumber(string.sub(gParts[i2].Name,-1)))
local ri = tostring (tonumber(gParts[i2].Name:match(“^(%S +)”))+1)..' '..tostring(tonumber(string.sub(gParts[i2].Name,-1)))
for i3 = 1,4 do
local atchm = Instance.new(“Attachment”,gParts[i2])
local ropeconst = Instance.new(“RopeConstraint”,gParts[i2])
end
end
绳索约束有两个我需要使用的主要属性:连接点1和连接点2。
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

我从来没有真正尝试过新的约束,但我相信这应该可行。
请记住,约束是Roblox中的一个新实例,它们很可能仍然是实验性的。
X = 10; Y = 10; spread = 4; --Spread是约束的长度。你可能需要增加这个长度,特别是如果它很僵硬。 function createAttachments() --这是在假定gParts是填充了Part实例的表的情况下进行的 for i,v in pairs(gParts) do local atch = Instance.new("Attachment",v); end; end; function connectConstraints(part,x,y) if x ~= X then connectRight = x+1.." "..y; end; if y ~= Y then connectDown = x.." "..y+1; end; if connectRight ~= nil then local ropeconst = Instance.new("RopeConstraint",part); ropeconst.Length = spread; ropeconst.Attachment0 = part.Attachment; ropeconst.Attachment1 = connectRight.Attachment; end; if connectLeft ~= nil then local ropeconst = Instance.new("RopeConstraint",part); ropeconst.Length = spread; ropeconst.Attachment0 = part.Attachment; ropeconst.Attachment1 = connectLeft.Attachment; end; end; createAttachments(); connectConstraints();如果这对你不起作用,请告诉我。如果需要,我可以从网站本身联系你。