LookVector not working properly

I’m trying to set the force of a VectorForce to the LookVector of a part. But it appears to only work when the part is facing the Z vector.
Facing Z vector
image
Facing other vector
image

The part has these children
image

script.Parent.VectorForce.Force = script.Parent.CFrame.LookVector*20

Any help?

An objects LookVector will change when it’s Rotation has changed, giving you the direction it’s front face is currently facing.
You would either have to apply the force relative to the BasePart or apply an updated LookVector.

Thanks for replying but the pictures I took were after I changed their orientation and then clicked the run test button in studio. Even with a loop to update the LookVector and the Force, the same thing happens.

So you are trying to set the force of a VectorForce to the LookVector of a part. However, the issue may arise because the LookVector is a unit vector pointing in the forward direction of the part’s CFrame, which might not align with the axis you expect.

-- Assuming your script is a child of the part you want to apply force to
local part = script.Parent
local vectorForce = part.VectorForce

-- Set the force based on the part's CFrame
vectorForce.Force = part.CFrame.LookVector * 20

If your part is rotated such that its local forward direction (the direction it faces by default) is not aligned with the global Z-axis, then using LookVector directly may not give you the desired results. In such cases, using the part’s CFrame can help you ensure that the force is applied in the correct direction relative to the part’s local coordinate system.

Hi, I’m thankful for your reply but as I was testing your code I found the issue I had was that I set the RelativeTo property to Attachment0 instead of World. Thanks for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.