Hello Developers,
I am currently working on similar game like Tower Battles and Tower Defence Simulator. I am having trouble with Towers meaning characters that shoot in direction of the enemy. But they move out of their spots during rotation that is made through BodyGyro, CFrame properties. How I could make my Towers keep their position without affecting their BodyGyro movements? Since Welding will break their rotation.
Here is my BodyGyro setting that keeps rotating an tower in enemy direction.
function lookAtTarget(Target)
if Target then
--Torso.CFrame = CFrame.new(Torso.Position, Vector3.new(Target["Torso"].Position.X, Torso.Position.Y, Target["Torso"].Position.Z))
if Torso:FindFirstChild("BodyGyro") then
else
local BodyGyro = Instance.new("BodyGyro")
BodyGyro.Parent = Torso
BodyGyro.CFrame = Torso.CFrame
BodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
end
Torso:WaitForChild("BodyGyro").MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
Torso:WaitForChild("BodyGyro").P = 10000
Torso:WaitForChild("BodyGyro").D = 1
Torso:WaitForChild("BodyGyro").CFrame = CFrame.new(Torso.Position, Vector3.new(Target["Torso"].Position.X, Torso.Position.Y, Target["Torso"].Position.Z))
end
end
Any ideas how I could prevent
towerfrom moving from it’s spot without affecting theirBodyGyrorotation?