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

how to set CFrame orientation to object orientation correctly?

ive been trying to make a a way for a character to do a leap,(like in mario odyssey) and ive got most fo the code nailed down, but im having trouble with this one part. for context, the way in doing this is by creating a ball with the velocity i need for the leap, and then i have an attachment that will go to the ball, and face the same direction as the player, then move the player to the attatchment. The problem is with the direction, when using the code below for the attachment, the attachment will face the direction of the player, but it will also turn a bit to the orientation of 0,0,0. Im not sure what to do.

code:


attachment.CFrame = CFrame.new(ball.CFrame.p + Vector3.new(0,-1.1,0))  * (player.Character.HumanoidRootPart.CFrame - player.Character.HumanoidRootPart.CFrame.p)

gif of whats happening

1 answer

Try doing this: By using Cframe, Angles we can affect the rotation matrix of the CFrame. Comment, if this isnt what you wanted.

Code:

attachment.CFrame = CFrame.new(ball.CFrame.p + Vector3.new(0,-1.1,0))  * (player.Character.HumanoidRootPart.CFrame - player.Character.HumanoidRootPart.CFrame.p) * CFrame.Angles(0,0,0)

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