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

How to offset CFrame rotation and position?

Asked by 4 years ago
Edited 4 years ago

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.

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. kevinsoaresv 47 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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!

Ad

Answer this question