解决角色模型MoveTo传送时,密闭空间会发生位置偏移的解决方法

大家应该都知道,角色在使用MoveTo的时候,会因为坐标位置存在着模型等等,从而导致角色被传送到模型的上方,这导致在较为密闭空间的传送时,角色会被传送出场景外。所以我写了一个能够精准传送到某点位置的方法。
说明:
角色模型:player.Character
传送坐标:pos
原理:将角色传送至该坐标后,如果坐标位置有模型存在,就会被偏移到模型上方,此时将偏移量计算出来,再将角色偏移回pos坐标点。

local pos = Vector3.new(0,0,0)
player.Character:MoveTo(pos)
player.Character:TranslateBy(Vector3.new(0,pos.Y-player.Character.PrimaryPart.Position.Y,0))
2 个赞

感谢分享~~~~~

1 个赞
关于我们    加入我们    条款    隐私政策
©2021 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。
粤ICP备20013629号