Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you tween a part while UNanchored?

Asked by 6 years ago
Edited 6 years ago

I'm trying to make my AI shooter face the enemy target in a smoother rotational transition; though it won't tween since it's not anchored and I need it anchored in order for the tween to work. I tried doing unanchored torso and anchored torso repeatedly, but it's really inefficient.

So is there a way to tween a part without it being anchored?

If impossible, then is there something else other than tweening?

0
You can't use TweenService when a part must face to your direction. Only if you want a part faces to your direction but never moves so it faces to your direction. cherrythetree 130 — 6y

2 answers

Log in to vote
2
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

BodyMovers allow for the smooth movement and rotation of unanchored parts. They use Roblox physics and include various properties that influence how they move. If you wanted to make an object/model face a specific point, I would recommend BodyGyro. When you set the CFrame property of this BodyMover, it will rotate its parent to adopt the orientation of the CFrame given.

For example, if you wanted to make a humanoid model rotate to constantly face a part called FacePart in workspace, you could do something like this in a script inside the model:

local Model = script.Parent
local Target = workspace.FacePart
local BG = Instance.new("BodyGyro")
BG.MaxTorque = Vector3.new(0,math.huge,0)
BG.Parent = Model.HumanoidRootPart

game:GetService("RunService").Stepped:Connect(function()
    local DesiredCFrame = CFrame.new(Model.HumanoidRootPart.Position, Target.Position)
    BG.CFrame = DesiredCFrame
end)

The MaxTorque of BodyGyros controls which axes the gyro can apply force to. Since in the script it is only set on the Y-axis, it will only control the "swivelling" of the model.

Hope this helps!

0
i like it User#19524 175 — 6y
0
thx fusionFSJAL 33 — 6y
Ad
Log in to vote
1
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago

This looks like a job for BodyGyro!

It will allow you to apply a rotational force to an object to keep it oriented in a specific manner.

Hope this helps! :)

0
i like it User#19524 175 — 6y
0
<3 chomboghai 2044 — 6y

Answer this question