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

How do I rotate with a CFrame?

Asked by 6 years ago

I'm using a script to summon a wall. The wall is offset because it's a union, so it can't just spawn in with 0, 0, 0 orientation. I've been trying to set it to spawn with the orientation of "Vector3.new(54.71, sok, -30.81)" but it doesn't work.

wallsource = script.Brick:Clone()
wallsource.Parent = character
wallp = script.IceWall:Clone()
wallp.Parent = character
wallsource.CanCollide = false   
wallsource.CFrame = character.HumanoidRootPart.CFrame - Vector3.new(0, 2, 0)
sok = character.Brick.Orientation.Y + 70    
print(wallsource.CFrame.lookVector)
wallp.CFrame = wallsource.CFrame
wallp.CFrame = CFrame.new(wallsource.Position, Vector3.new(54.71, sok, -30.81))

wallsource puts a brick in that's facing the same direction as the torso but on the ground, it sets the general location that the wallp should be at.

However, wallp seems to just want to be whatever rotation it deems fit. It needs to be 54.71, sok, -30.81 otherwise it gets weird. The 54.71 and -30.81 make sure that it's sitting flat on the ground and the sok is what makes it face forwards relative to your character.

1 answer

Log in to vote
0
Answered by 6 years ago

using the following syntax: CFrame.new(Vector3, Vector3) makes a cframe where the first vector3 is the position and the second is another position that defines what position the cframe looks at

try this instead:

CFrame.new(wallsource.Position)*CFrame.FromEulerAnglesXYZ(math.rad(54.71), math.rad(sok), math.rad(-30.81)

the reason all axis are within a math.rad is because CFrame.FromEulerAnglesXYZ is in radians, and i assume that you were using degrees

0
Sorry for the late response, ended up fixing it myself then getting lost in working on the project! Thanks for the reply anyways Storm_Cloud 20 — 6y
Ad

Answer this question