i am trying to make it so as a player moves the front face of a part will constantly be facing the player, i tried changing the cframe of the bodygyro by doing:
however this holds little to no effect, i am currently testing it on the regular base sized part if that holds any importance. Am i doing this wrong if so how do i fix this.
High torque will make the any external force very hard to counteract the gyro. Power is the aggressiveness of the turning, and dampening slows the gyro down before it reaches its destination.
It’s a matter of experimenting. Torque is what you need to change if the brick isn’t moving very much. Power and dampening are more for visual preference.
its beginning to work now, however this is still a large problem. This is all for a follow system towards the player and if the player walks straight through the brick it now treats the back surface as the front surface is this something to do with the gyro or something completely unrelated?
This might be when the lookAt CFrame constructor tries to look straight upward or downward. There are ways around this, but it will take a little bit more complicated approach.
Does it permanently break it after the player leaves the brick?
nothing gets permanently broken all that happens is the surface that looks at the player changes, the brick does not have the capacity to do a 180 turn instead it just decides to change the surface in which follows the player. It can be fixed if the player goes over the brick making the front surface the main surface. This does not happen if the player does a wide turn only if the player is trying to force a quick 180 turn by walking through the brick.
Can you verify that the surface is actually changing? Or if instead it is the same surface but quickly flipped before turning 180 degrees back toward the player again.
I made an example of this, a look bot that looks at humanoids.
--settings
local Dampening = 600 --Decays the motion. Little to none means springy shakey, a lot makes motion subdued and lazy.
local MaxTorque = 10000 --Maximum force to rotate. Super high might screw with the hinge constraint.
local P = 8000 --Willingness to use that force. Raising it will make a faster head turning.
--body
script.Parent.Anchored = false --physically simulate the hinge head
script.Parent.Anchor.Transparency = 1 -- hide the anchor on runTime
script.Parent.BodyGyro.D = Dampening
script.Parent.BodyGyro.MaxTorque = Vector3.new(MaxTorque,MaxTorque,MaxTorque)
script.Parent.BodyGyro.P = P
local function lookAtNearest()
--get nearest head in model that contains a humanoid
local nearest
local distanceOfNearest = math.huge
for index,child in ipairs(workspace:GetChildren()) do
if child.className == "Model" and child:FindFirstChild("Humanoid") and child:FindFirstChild("Head") then
local candidateDistance = (script.Parent.Position - child.Head.Position).Magnitude
if candidateDistance < distanceOfNearest then
distanceOfNearest = candidateDistance
nearest = child
end
end
end
--look at it if it exists
if nearest then
local dir = (nearest.Head.Position - script.Parent.Position).unit
local spawnPos = script.Parent.Position
local pos = spawnPos + (dir * 1)
script.Parent:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos + dir)
end
end
--checkLoop
while true do
wait()
lookAtNearest()
end
This code just shows a part of the system. Full thing below.