Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to offset CFrame rotation and position?

So my question is this: How can I use values to offset a CFrames rotation AND position? (Preferably with Vector3s)

Here's some example code

local V_Offset =V_Model.Offset.Value
local V_Rotation =V_Model.Rotation.Value

V_Model:SetPrimaryPartCFrame(CFrame.new(PL_Head.CFrame.Position,Dynamic_MousePose.Value)*CFrame.new(V_Offset,V_Rotation))

('V_Offset' and 'V_Rotation' are both Vector3 Values)

This is a demo of what I've tried, the results are the 'V_Model' being positioned correctly, but rotated 180 degrees regardless of the value of 'V_Rotation'.

Some notes: It must be offset form the position of the CFrame! not a new position in world space. (V_Model will be moving around the world at all times) The values 'V_Offset' and 'V_Rotation' will be changed in-game for different rotations and positions. Also, This code will be running constantly, so I need as much optimization as possible!

Hopefully this isn't to confusing, I apologize if it is. Thanks.

1 comment

0

https://developer.roblox.com/en-us/articles/Understanding-CFrame All you need to do is get a certain Vector3 value and add it in the CFrame position/rotation.

1 answer

Nvm, I figured it out...

Thanks to kevinsoaresv for the link, It didn't completely solve the problem bit it was (and definitely will be) very helpful!

This discussion is preserved as it was. New answers, comments, and votes are closed.