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

how to set CFrame orientation to object orientation correctly?

Asked by 4 years ago

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

Log in to vote
0
Answered by
Farsalis 369 Moderation Voter
4 years ago
Edited 4 years ago

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)
Ad

Answer this question