I am building a system to allow characters to lift crates/boxes and put them down. I am having issues with the releasing part of the problem.
I currently have it raycast downwards from the player to determine the raycast result position & normal to align the crate with. See this sample image for an example:
However, I want this only to occur on the X & Z axis. For the Y axis, that should be aligned with the character’s lookvector so that it looks like the box has been put down in front/facing him.
This is the current Raycast code:
local v3 = raycastResult.Position
local rX, _, rZ = CFrame.new(v3, v3 + raycastResult.Normal):ToEulerAnglesXYZ()
box:SetPrimaryPartCFrame(CFrame.new(v3) * CFrame.Angles(rX, 0, rZ))
Can’t seem to figure out that problem though. I tried:
local _, rY, _ = CFrame.new(v3, root.Position):ToEulerAnglesXYZ()
though that had incredibly weird & incorrect results.
Appreciate any support.
-G