I’m trying to raycast 2 studs infront of the HumanoidRootParts based on its current rotation. I thought it’d be simple but what I have currently doesn’t work at all, it just gets random results.
WorkspaceService:Raycast(UnverifiedPosition, Vector3.new(UnverifiedPosition.X, 0, UnverifiedPosition.Z) * 2, RaycastParams)
CFrame enables you to get a position relative to a direction. (CFrames are quaternions which store both positional and rotational data)
Vectors only store positional data.
Try this out:
local LENGTH = 2
--//LookVector is the forward component of the CFrame, so it'll be the looking direction, hence the name
local rayDirection = humanoidRootPart.CFrame.LookVector.Unit*LENGTH
I’m always lost when it comes to CFrame, lol. I should look into getting familiar with it.
Thanks for this.