I’ve been busting my head trying to understand for several days now, but I can’t. If anyone could help me understand, thank you
I just know the synthax :
CFrame.new(Position, lookVector)
Hi, so, CFrame is a Coordinate Frame
there’s a lot of posts about this.
CFrame has a lot of Vector3,
Position,UpVector,RightVector,LookVector, and can be rotated.
There’s a lot of functions and properties, you can check out here`
Also;
CFrame.new(Position,lookVector) is deprecated!
use CFrame.lookAt()
Yes but still, i understand nothing
I know very well that it is a Coordinate Frame
but like, if you tell to make a part that will follow the player’s back from 5 mt, i wont be able to make it
i know the synthax but now how to apply it
well, you can do this!
local Part = workspace.Part
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
game:GetService("RunService").Heartbeat:Connect(function()
local Y = Character.HumanoidRootPart.CFrame.LookVector -- LookVector Is where it's facing!
local X = CFrame.new(Character.HumanoidRootPart.Position + (Y * -10)) -- Creates the position, and puts the position BACK according to the LookVector, Multiplying negative to put it in the back!
Part.CFrame = X
end)
Hmmm, yes i see im gonna train it thank
You can also use arithmetic operators on CFrames.
Adding a Vector3 to a CFrame will translate the CFrame’s position in world space.
Multiplying a CFrame by another CFrame will translate transform it in object space, and this can be done for rotation as well.
Building on @varjoy’s example:
local Part = workspace.Part
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
game:GetService("RunService").Stepped:Connect(function()
-- 5 studs behind the HRP
Part.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 5)
end)
You should use the developer.roblox.com website to check the basics of CFrame. You can even use YouTube to search for tutorials.
The * is used for multiply but why use it in this case?
Part.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 5)
You guys should continue this in DMs if you wanna learn/teach more.
I hope that can be helpful for you.
CFrames have a position component and an orientation component represented by a 3x3 matrix. Using the *
operator on CFrames performs a matrix composition. (That’s because the CFrame data type has a metatable where the __mul method is implemented, but that’s not important here.)
That code will create a new CFrame that has the same orientation as HumanoidRootPart, but offset by 5 studs in the positive Z direction, which in Roblox’s coordinates is backwards relative to the part.
CFrame means basically changing every properties that uses Vector3
Not quite. It is just a single data type that contains data on both a position and an orientation, sort of analogous to the ‘Transform’ object in Unity.
Every BasePart has a CFrame property, but the CFrame object is not specific to just BaseParts.
You can read about it in the links that @Dev_Vegas posted.
Vector3 is for position, while orientation is rotation.
I know.
CFrame can change these things (position, orientation) whereas vector3 change only position
Vector3 can also apply for orientation. For instance:
part.Orientation = Vector3.new(math.rad(60),0,0)
Correct me if I’m wrong about the radians.
Oh i didnt know that i tought only cframe was able to change orientation
CFrame has more complex stuffs and more powerful compare to Vector3.
The reason you multiply it is because you can’t add 2 CFrames together.