Throwing TNT - combining vectors

I’m looking to get my character to throw TNT in the direction of the X,Z direction of the HumanoidRootPart, but the YAngle of the camera. I’ve already calculated both of these things fine.

I’m having trouble creating a unit vector which has the Y Angle of camera, and the X and Z direction of the humanoid root part. An explanation of how to do this would be perfect.

1 Like

Assuming this is being done from the client side:

local playerLook = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector
local cameraLook = workspace.CurrentCamera.CFrame.LookVector
local throwVector = ((playerLook * Vector3.new(1, 0, 1)) + (cameraLook * Vector3.new(0, 1, 0))).Unit

Edit: forgot to convert throwVector into a unit, also make sure to do the obvious stuff like checking that the player character isn’t nil, etc.

2 Likes