As the title says, I’m trying to make a part face the direction that the HRP is facing (so they’re looking in the same direction).
I believe I need to use the lookVector for the HRP but other than that I have no idea what to do.
As the title says, I’m trying to make a part face the direction that the HRP is facing (so they’re looking in the same direction).
I believe I need to use the lookVector for the HRP but other than that I have no idea what to do.
There is no need to use the look vector because you can just set bodyGyro.CFrame
to the humanoid root part’s CFrame. The translational component of the CFrame is ignored so the body gyro’s rotation will be equivalent to that of the humanoid root part.
Won’t that make the part look towards the HRP?
The bodyGyro
’s rotation is defined by its CFrame
property. In other words, the rotation of bodyGyro.CFrame
is the target rotation that the gyro is attempting to keep its parent in. So if we take the CFrame
of the humanoid root part (which contains its rotation) and assign it to the body gyro’s CFrame, the target orientation of the gyro will be that of the humanoid root part.
Let me go test. When I’ve done this before I’m pretty sure it faces the HRP instead of facing the direction.
You’re probably correct though.
How would I go about making it face the HRP then? (Wanna know in case of future uses)
You can use the CFrame.new(pos , lookAt)
constructor. pos
is the position of the CFrame (which in this case is irrelevant) and lookAt
is a vector representing the position to look towards. In order to get a rotation facing the humanoid root part, you can do CFrame.new(Vector3.new(0 , 0 , 0) , hrp.Position)
.
Hey guys, is there a way I could use BodyGyro and make the part face a directional vector? lookAt takes a positional vector to face to. I want to use a directional vector in a bodygyro. Any solutions to this?
CFrame.lookAt(Vector3.new(), directionVector).Rotation + someVector3Position