I’m currently working on a project in Roblox where I want to smoothly move a part and have it interact with other parts it touches along the way. However, I’ve encountered an issue when using tween animations and anchoring the part during the animation process.
The reason for anchoring the part is to achieve smoother animations. Without anchoring, there seems to be some jittering caused by gravity, even when using massless or setting the density to 0.
The problem I’m facing is that when the part is anchored, it no longer generates touch events with other parts. Once I remove the anchor, the part can touch other parts again, but the touch results are quite strange. The part shouldn’t be colliding with the spawn location, yet it seems to behave unexpectedly.
I have created a video to demonstrate the issue. Please take a look:
here is my server script in my part:
local part = script.Parent
local ts = game:GetService("TweenService")
ts:Create(part, TweenInfo.new(15), {
CFrame = part.CFrame - Vector3.new(100, 0 ,0)
}):Play()
part.Touched:Connect(function(op)
print(op)
end)
Has anyone else encountered a similar problem while using tween animations and anchoring a part? If so, I would appreciate any insights or suggestions on how to resolve this issue.
For the jittering, set the part’s Network Owner to nil (server).
Tweens are forced to ignore physics and will tween straight to the destination. To have it collide, I suggest using AlignPositionAlignPosition | Documentation - Roblox Creator Hub.
Hope this helped!
A part needs to have physics to generate .Touched events, as those are handled by the physics engine, so Anchored parts don’t generate .Touched events.
As other people said, you need to use an AlignPosition to use the physics engine to move parts in order to use .Touched. This comes with the added benefit of any players standing on top of the part moving along with it.
Thank you so much for helping me find the key sentence in the Roblox documentation. I never knew about it before. (The documentation is too long for me to read, and my English isn’t very good.)