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

How would I get a body gyro to get another face of a part to ... face you?

Asked by 7 years ago

It sounds weird-- but I'm trying to get a part to face my character, and this part has a cylinder mesh in it-- because the body gyro would only make the front face of a part face me, and because the mesh doesn't face the front--

local Gyro = Instance.new("BodyGyro", Part)
    Gyro.CFrame = CFrame.new(Part.Position, TorsoPos)
    Gyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
    Gyro.P = 999999

I was wondering if there is a way get it to have the left or right face of a part face me instead, so it looks right because I cant come up with the math to rotate it properly myself. =w=;

AND UH IF YOUR ANSWER USES MATH could you please explain what it is you're doing in case I don't understand it?

1 answer

Log in to vote
0
Answered by
CodeNil 30
7 years ago

You need to rotate the cframe with CFrame.Angles()

local Gyro = Instance.new("BodyGyro", Part)
Gyro.CFrame = CFrame.new(Part.Position, TorsoPos) * CFrame.Angles(0, 0, math.rad(-90))
Gyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
Gyro.P = 999999

the math.rad() will turn an angle in degrees, into one in radians, because CFrame.Angles accepts radians. Just fiddle with that, not sure which way it would need to be rotation, so try moving the math.rad() around between the 3 spots, and changing it between -90 or 90, you'll figure it out with a bit of experimentation

CFrame.Angles(math.rad(-90) , 0, 0)
CFrame.Angles(math.rad(90), 0, 0)
CFrame.Angles(0, math.rad(-90) ,0)
CFrame.Angles(0, math.rad(90), 0)
CFrame.Angles(0, 0, math.rad(-90))
CFrame.Angles(0, 0, math.rad(90))
0
-u- boy do I feel stupid. Thank you Petrovolt 89 — 7y
Ad

Answer this question