How can I add an angle to the current LookVector to make it more downwards? I have a slash attack that goes forward(direction, LookVector) from the HumanoidRootPart, but when I jump, I want it to go downwards. But, I don’t know how to add on to a LookVector, so I need help.
I have tried multiplying the LookVector with CFrame.Angles() but it is not working and it says I need a Vector3. I tried to do Orientation but I just don’t know anymore. If there is any solutions to this or alternative solutions I just need to know.
if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
local downdirection = CFrame.Angles(0,math.rad(90),0)
end
local rainbowslash = game.ServerStorage.rainbowslash:Clone()
print("rainbowslash clone")
rainbowslash.Parent = player.Character.Head
rainbowslash.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(math.random(-1,1),math.random(-1,1),-1)
rainbowslash.Orientation = rainbowslash.Orientation + Vector3.new(180,0,math.random(-100,100))
local vel = Instance.new("BodyVelocity", rainbowslash) --velocity
vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
print(player.Character.HumanoidRootPart.CFrame.LookVector)
vel.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * speed -- I don't know how to add an angle to this, I want to make it more downwards (I want to add on downdirection variable to this but it just wont work, it has errors)
print(vel.Velocity)
game.Debris:AddItem(rainbowslash,lifetime)
It turns the LookVector into a CFrame which allows you to multiply by CFrame.Angles to effectively rotate the angle of the velocity in object space. The ANGLE value is how much you rotate by in degrees in object space relative to the LookVector of the HumanoidRootPart.
(I put the 45 on the first slot in CFrame.Angles because that’d pitch the CFrame forward to make it face down if it were facing forward before, instead of yawing it, making it turn right/left as that CFrame.Angles in your code would.)
(Edit: That is, CFrame.Angles’s axes are X, Y and Z, whereas Orientation’s angles are Y, X, Z. So CFrame.Angles(math.rad(90), 0, 0) is (almost) the same as CFrame.fromOrientation(0, math.rad(90), 0)
It’s in parentheses because it is calling the math.rad function. It’s the same as why this is in parentheses. print("test")
CFrames use radians, and math.rad turns degrees into radians.